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