]>
Commit | Line | Data |
---|---|---|
3284fe0c L |
1 | /* elfcomm.h -- include file of common code for ELF format file. |
2 | Copyright 2010 | |
3 | Free Software Foundation, Inc. | |
4 | ||
5 | Originally developed by Eric Youngdale <[email protected]> | |
6 | Modifications by Nick Clifton <[email protected]> | |
7 | ||
8 | This file is part of GNU Binutils. | |
9 | ||
10 | This program is free software; you can redistribute it and/or modify | |
11 | it under the terms of the GNU General Public License as published by | |
12 | the Free Software Foundation; either version 3 of the License, or | |
13 | (at your option) any later version. | |
14 | ||
15 | This program is distributed in the hope that it will be useful, | |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | GNU General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU General Public License | |
21 | along with this program; if not, write to the Free Software | |
22 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA | |
23 | 02110-1301, USA. */ | |
24 | \f | |
25 | #ifndef _ELFCOMM_H | |
26 | #define _ELFCOMM_H | |
27 | ||
28 | #include "aout/ar.h" | |
29 | ||
30 | void error (const char *, ...) ATTRIBUTE_PRINTF_1; | |
31 | void warn (const char *, ...) ATTRIBUTE_PRINTF_1; | |
32 | ||
33 | #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) | |
34 | /* We can't use any bfd types here since readelf may define BFD64 and | |
35 | objdump may not. */ | |
36 | #define HOST_WIDEST_INT long long | |
37 | #else | |
38 | #define HOST_WIDEST_INT long | |
39 | #endif | |
40 | typedef unsigned HOST_WIDEST_INT elf_vma; | |
41 | ||
42 | extern void (*byte_put) (unsigned char *, elf_vma, int); | |
43 | extern void byte_put_little_endian (unsigned char *, elf_vma, int); | |
44 | extern void byte_put_big_endian (unsigned char *, elf_vma, int); | |
45 | ||
46 | extern elf_vma (*byte_get) (unsigned char *, int); | |
47 | extern elf_vma byte_get_signed (unsigned char *, int); | |
48 | extern elf_vma byte_get_little_endian (unsigned char *, int); | |
49 | extern elf_vma byte_get_big_endian (unsigned char *, int); | |
74bc6052 | 50 | extern void byte_get_64 (unsigned char *, elf_vma *, elf_vma *); |
3284fe0c L |
51 | |
52 | #define BYTE_PUT(field, val) byte_put (field, val, sizeof (field)) | |
53 | #define BYTE_GET(field) byte_get (field, sizeof (field)) | |
54 | #define BYTE_GET_SIGNED(field) byte_get_signed (field, sizeof (field)) | |
55 | ||
56 | /* This is just a bit of syntatic sugar. */ | |
57 | #define streq(a,b) (strcmp ((a), (b)) == 0) | |
58 | #define strneq(a,b,n) (strncmp ((a), (b), (n)) == 0) | |
59 | #define const_strneq(a,b) (strncmp ((a), (b), sizeof (b) - 1) == 0) | |
60 | ||
61 | /* Structure to hold information about an archive file. */ | |
62 | ||
63 | struct archive_info | |
64 | { | |
65 | char * file_name; /* Archive file name. */ | |
66 | FILE * file; /* Open file descriptor. */ | |
c2a7d3f5 NC |
67 | elf_vma index_num; /* Number of symbols in table. */ |
68 | elf_vma * index_array; /* The array of member offsets. */ | |
3284fe0c L |
69 | char * sym_table; /* The symbol table. */ |
70 | unsigned long sym_size; /* Size of the symbol table. */ | |
71 | char * longnames; /* The long file names table. */ | |
72 | unsigned long longnames_size; /* Size of the long file names table. */ | |
73 | unsigned long nested_member_origin; /* Origin in the nested archive of the current member. */ | |
74 | unsigned long next_arhdr_offset; /* Offset of the next archive header. */ | |
75 | bfd_boolean is_thin_archive; /* TRUE if this is a thin archive. */ | |
c2a7d3f5 | 76 | bfd_boolean uses_64bit_indicies; /* TRUE if the index table uses 64bit entries. */ |
3284fe0c L |
77 | struct ar_hdr arhdr; /* Current archive header. */ |
78 | }; | |
79 | ||
80 | /* Return the path name for a proxy entry in a thin archive. */ | |
81 | extern char *adjust_relative_path (const char *, const char *, int); | |
82 | ||
83 | /* Read the symbol table and long-name table from an archive. */ | |
84 | extern int setup_archive (struct archive_info *, const char *, FILE *, | |
85 | bfd_boolean, bfd_boolean); | |
86 | ||
87 | /* Open and setup a nested archive, if not already open. */ | |
88 | extern int setup_nested_archive (struct archive_info *, const char *); | |
89 | ||
90 | /* Release the memory used for the archive information. */ | |
91 | extern void release_archive (struct archive_info *); | |
92 | ||
93 | /* Get the name of an archive member from the current archive header. */ | |
94 | ||
95 | extern char *get_archive_member_name (struct archive_info *, | |
96 | struct archive_info *); | |
97 | ||
98 | /* Get the name of an archive member at a given offset within an | |
99 | archive. */ | |
100 | ||
101 | extern char *get_archive_member_name_at (struct archive_info *, | |
102 | unsigned long, | |
103 | struct archive_info *); | |
104 | ||
105 | /* Construct a string showing the name of the archive member, qualified | |
106 | with the name of the containing archive file. */ | |
107 | ||
108 | extern char *make_qualified_name (struct archive_info *, | |
109 | struct archive_info *, | |
110 | const char *); | |
111 | ||
112 | #endif /* _ELFCOMM_H */ |