blob: e117166e47aa2a8c0f13ad819ea199f4bf665b58 [file] [log] [blame]
Ben Cheng25b3c042013-11-20 14:45:36 -08001/* Copyright (C) 2007-2012 Red Hat, Inc.
Elliott Hughes03333822015-02-18 22:19:45 -08002 This file is part of elfutils.
Ben Cheng25b3c042013-11-20 14:45:36 -08003 Written by Ulrich Drepper <drepper@redhat.com>, 2007.
4
Elliott Hughes03333822015-02-18 22:19:45 -08005 This file is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
Ben Cheng25b3c042013-11-20 14:45:36 -08009
Elliott Hughes03333822015-02-18 22:19:45 -080010 elfutils is distributed in the hope that it will be useful, but
Ben Cheng25b3c042013-11-20 14:45:36 -080011 WITHOUT ANY WARRANTY; without even the implied warranty of
Elliott Hughes03333822015-02-18 22:19:45 -080012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
Ben Cheng25b3c042013-11-20 14:45:36 -080014
Elliott Hughes03333822015-02-18 22:19:45 -080015 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
Ben Cheng25b3c042013-11-20 14:45:36 -080017
18#ifndef _ARLIB_H
19#define _ARLIB_H 1
20
21#include <ar.h>
22#include <argp.h>
23#include <byteswap.h>
24#include <endian.h>
25#include <libelf.h>
26#include <obstack.h>
27#include <stdbool.h>
28#include <stddef.h>
29#include <stdint.h>
30#include <sys/types.h>
31
32
33/* State of -D/-U flags. */
34extern bool arlib_deterministic_output;
35
36/* For options common to ar and ranlib. */
37extern const struct argp_child arlib_argp_children[];
38
39
40/* Maximum length of a file name that fits directly into the ar header.
41 We cannot use the final byte since a / goes there. */
42#define MAX_AR_NAME_LEN (sizeof (((struct ar_hdr *) NULL)->ar_name) - 1)
43
44
45/* Words matching in size to archive header. */
46#define AR_HDR_WORDS (sizeof (struct ar_hdr) / sizeof (uint32_t))
47
48
49#if __BYTE_ORDER == __LITTLE_ENDIAN
50# define le_bswap_32(val) bswap_32 (val)
51#else
52# define le_bswap_32(val) (val)
53#endif
54
55
56/* Symbol table type. */
57struct arlib_symtab
58{
59 /* Symbol table handling. */
60 struct obstack symsoffob;
61 struct obstack symsnameob;
62 size_t symsofflen;
63 uint32_t *symsoff;
64 size_t symsnamelen;
65 char *symsname;
66
67 /* Long filename handling. */
68 struct obstack longnamesob;
69 size_t longnameslen;
70 char *longnames;
71};
72
73
74/* Global variable with symbol table. */
75extern struct arlib_symtab symtab;
76
77
78/* Initialize ARLIB_SYMTAB structure. */
79extern void arlib_init (void);
80
81/* Finalize ARLIB_SYMTAB content. */
82extern void arlib_finalize (void);
83
84/* Free resources for ARLIB_SYMTAB. */
85extern void arlib_fini (void);
86
87/* Add symbols from ELF with value OFFSET to the symbol table SYMTAB. */
88extern void arlib_add_symbols (Elf *elf, const char *arfname,
89 const char *membername, off_t off);
90
91/* Add name a file offset of a symbol. */
92extern void arlib_add_symref (const char *symname, off_t symoff);
93
94/* Add long file name FILENAME of length FILENAMELEN to the symbol table
95 SYMTAB. Return the offset into the long file name table. */
96extern long int arlib_add_long_name (const char *filename, size_t filenamelen);
97
98#endif /* arlib.h */