Ulrich Drepper | ce0bdb6 | 2007-02-05 07:13:52 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2007 Red Hat, Inc. |
| 2 | Written by Ulrich Drepper <drepper@redhat.com>, 2007. |
| 3 | |
| 4 | Red Hat elfutils is free software; you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License as published by the |
| 6 | Free Software Foundation; version 2 of the License. |
| 7 | |
| 8 | Red Hat elfutils is distributed in the hope that it will be useful, but |
| 9 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License along |
| 14 | with Red Hat elfutils; if not, write to the Free Software Foundation, |
| 15 | Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. |
| 16 | |
| 17 | Red Hat elfutils is an included package of the Open Invention Network. |
| 18 | An included package of the Open Invention Network is a package for which |
| 19 | Open Invention Network licensees cross-license their patents. No patent |
| 20 | license is granted, either expressly or impliedly, by designation as an |
| 21 | included package. Should you wish to participate in the Open Invention |
| 22 | Network licensing program, please visit www.openinventionnetwork.com |
| 23 | <http://www.openinventionnetwork.com>. */ |
| 24 | |
| 25 | #ifndef _ARLIB_H |
| 26 | #define _ARLIB_H 1 |
| 27 | |
| 28 | #include <ar.h> |
| 29 | #include <byteswap.h> |
| 30 | #include <endian.h> |
| 31 | #include <libelf.h> |
| 32 | #include <obstack.h> |
| 33 | #include <stddef.h> |
| 34 | #include <stdint.h> |
| 35 | #include <sys/types.h> |
| 36 | |
| 37 | |
Ulrich Drepper | b597dfa | 2007-10-16 05:21:27 +0000 | [diff] [blame] | 38 | /* Maximum length of a file name that fits directly into the ar header. |
| 39 | We cannot use the final byte since a / goes there. */ |
| 40 | #define MAX_AR_NAME_LEN (sizeof (((struct ar_hdr *) NULL)->ar_name) - 1) |
Ulrich Drepper | ce0bdb6 | 2007-02-05 07:13:52 +0000 | [diff] [blame] | 41 | |
| 42 | |
| 43 | /* Words matching in size to archive header. */ |
| 44 | #define AR_HDR_WORDS (sizeof (struct ar_hdr) / sizeof (uint32_t)) |
| 45 | |
| 46 | |
| 47 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
| 48 | # define le_bswap_32(val) bswap_32 (val) |
| 49 | #else |
| 50 | # define le_bswap_32(val) (val) |
| 51 | #endif |
| 52 | |
| 53 | |
| 54 | /* Symbol table type. */ |
| 55 | struct arlib_symtab |
| 56 | { |
| 57 | /* Symbol table handling. */ |
| 58 | struct obstack symsoffob; |
| 59 | struct obstack symsnameob; |
| 60 | size_t symsofflen; |
| 61 | uint32_t *symsoff; |
| 62 | size_t symsnamelen; |
| 63 | char *symsname; |
| 64 | |
| 65 | /* Long filename handling. */ |
| 66 | struct obstack longnamesob; |
| 67 | size_t longnameslen; |
| 68 | char *longnames; |
| 69 | }; |
| 70 | |
| 71 | |
Ulrich Drepper | 0fe6353 | 2007-02-05 21:05:51 +0000 | [diff] [blame] | 72 | /* Global variable with symbol table. */ |
| 73 | extern struct arlib_symtab symtab; |
Ulrich Drepper | ce0bdb6 | 2007-02-05 07:13:52 +0000 | [diff] [blame] | 74 | |
| 75 | |
Ulrich Drepper | 0fe6353 | 2007-02-05 21:05:51 +0000 | [diff] [blame] | 76 | /* Initialize ARLIB_SYMTAB structure. */ |
| 77 | extern void arlib_init (void); |
| 78 | |
Ulrich Drepper | ce0bdb6 | 2007-02-05 07:13:52 +0000 | [diff] [blame] | 79 | /* Finalize ARLIB_SYMTAB content. */ |
Ulrich Drepper | 0fe6353 | 2007-02-05 21:05:51 +0000 | [diff] [blame] | 80 | extern void arlib_finalize (void); |
Ulrich Drepper | ce0bdb6 | 2007-02-05 07:13:52 +0000 | [diff] [blame] | 81 | |
| 82 | /* Free resources for ARLIB_SYMTAB. */ |
Ulrich Drepper | 0fe6353 | 2007-02-05 21:05:51 +0000 | [diff] [blame] | 83 | extern void arlib_fini (void); |
Ulrich Drepper | ce0bdb6 | 2007-02-05 07:13:52 +0000 | [diff] [blame] | 84 | |
| 85 | /* Add symbols from ELF with value OFFSET to the symbol table SYMTAB. */ |
| 86 | extern void arlib_add_symbols (Elf *elf, const char *arfname, |
Ulrich Drepper | 0fe6353 | 2007-02-05 21:05:51 +0000 | [diff] [blame] | 87 | const char *membername, off_t off); |
Ulrich Drepper | ce0bdb6 | 2007-02-05 07:13:52 +0000 | [diff] [blame] | 88 | |
| 89 | /* Add name a file offset of a symbol. */ |
Ulrich Drepper | 0fe6353 | 2007-02-05 21:05:51 +0000 | [diff] [blame] | 90 | extern void arlib_add_symref (const char *symname, off_t symoff); |
Ulrich Drepper | ce0bdb6 | 2007-02-05 07:13:52 +0000 | [diff] [blame] | 91 | |
| 92 | /* Add long file name FILENAME of length FILENAMELEN to the symbol table |
| 93 | SYMTAB. Return the offset into the long file name table. */ |
Ulrich Drepper | 0fe6353 | 2007-02-05 21:05:51 +0000 | [diff] [blame] | 94 | extern long int arlib_add_long_name (const char *filename, size_t filenamelen); |
Ulrich Drepper | ce0bdb6 | 2007-02-05 07:13:52 +0000 | [diff] [blame] | 95 | |
| 96 | #endif /* arlib.h */ |