]>
Commit | Line | Data |
---|---|---|
db232882 KR |
1 | /* BFD back-end data structures for ELF files. |
2 | Copyright (C) 1992, 1993 Free Software Foundation, Inc. | |
3 | Written by Cygnus Support. | |
4 | ||
5 | This file is part of BFD, the Binary File Descriptor library. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
20 | ||
21 | #ifndef _LIBELF_H_ | |
22 | #define _LIBELF_H_ 1 | |
23 | ||
81187b54 KR |
24 | #include "elf/common.h" |
25 | #include "elf/internal.h" | |
26 | #include "elf/external.h" | |
6ec3bb6a | 27 | #include "bfdlink.h" |
81187b54 | 28 | |
998ce1e0 | 29 | /* If size isn't specified as 64 or 32, NAME macro should fail. */ |
9942e684 | 30 | #ifndef NAME |
7050286d | 31 | #if ARCH_SIZE==64 |
638616ca | 32 | #define NAME(x,y) CAT4(x,64,_,y) |
998ce1e0 KR |
33 | #endif |
34 | #if ARCH_SIZE==32 | |
638616ca | 35 | #define NAME(x,y) CAT4(x,32,_,y) |
9942e684 KR |
36 | #endif |
37 | #endif | |
38 | ||
153cb9ad KR |
39 | #ifndef NAME |
40 | #define NAME(x,y) CAT4(x,NOSIZE,_,y) | |
41 | #endif | |
42 | ||
638616ca KR |
43 | #define ElfNAME(X) NAME(Elf,X) |
44 | #define elfNAME(X) NAME(elf,X) | |
45 | ||
95469b02 ILT |
46 | /* Information held for an ELF symbol. The first field is the |
47 | corresponding asymbol. Every symbol is an ELF file is actually a | |
48 | pointer to this structure, although it is often handled as a | |
49 | pointer to an asymbol. */ | |
50 | ||
db232882 KR |
51 | typedef struct |
52 | { | |
95469b02 | 53 | /* The BFD symbol. */ |
db232882 | 54 | asymbol symbol; |
95469b02 | 55 | /* ELF symbol information. */ |
268f94ac | 56 | Elf_Internal_Sym internal_elf_sym; |
95469b02 | 57 | /* Backend specific information. */ |
7050286d KR |
58 | union |
59 | { | |
60 | unsigned int hppa_arg_reloc; | |
cf286547 | 61 | PTR mips_extr; |
7050286d KR |
62 | PTR any; |
63 | } | |
64 | tc_data; | |
ee8cb548 | 65 | } elf_symbol_type; |
013dec1a ILT |
66 | \f |
67 | /* ELF linker hash table entries. */ | |
68 | ||
69 | struct elf_link_hash_entry | |
70 | { | |
71 | struct bfd_link_hash_entry root; | |
72 | ||
73 | /* Symbol index in output file. This is initialized to -1. It is | |
74 | set to -2 if the symbol is used by a reloc. */ | |
75 | long indx; | |
76 | ||
77 | /* Symbol size. */ | |
78 | bfd_size_type size; | |
79 | ||
013dec1a ILT |
80 | /* Symbol index as a dynamic symbol. Initialized to -1, and remains |
81 | -1 if this is not a dynamic symbol. */ | |
82 | long dynindx; | |
83 | ||
84 | /* String table index in .dynstr if this is a dynamic symbol. */ | |
85 | unsigned long dynstr_index; | |
86 | ||
87 | /* If this is a weak defined symbol from a dynamic object, this | |
88 | field points to a defined symbol with the same value, if there is | |
89 | one. Otherwise it is NULL. */ | |
90 | struct elf_link_hash_entry *weakdef; | |
91 | ||
7c6da9ca ILT |
92 | /* If we need to generate a COPY reloc, the processor specific |
93 | backend uses this to hold the offset into the reloc section. */ | |
94 | bfd_vma copy_offset; | |
95 | ||
013dec1a ILT |
96 | /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.). */ |
97 | char type; | |
98 | ||
99 | /* Some flags; legal values follow. */ | |
100 | unsigned char elf_link_hash_flags; | |
101 | /* Symbol is referenced by a non-shared object. */ | |
102 | #define ELF_LINK_HASH_REF_REGULAR 01 | |
103 | /* Symbol is defined by a non-shared object. */ | |
104 | #define ELF_LINK_HASH_DEF_REGULAR 02 | |
105 | /* Symbol is referenced by a shared object. */ | |
106 | #define ELF_LINK_HASH_REF_DYNAMIC 04 | |
107 | /* Symbol is defined by a shared object. */ | |
108 | #define ELF_LINK_HASH_DEF_DYNAMIC 010 | |
109 | /* Symbol is referenced by two or more shared objects. */ | |
110 | #define ELF_LINK_HASH_REF_DYNAMIC_MULTIPLE 020 | |
111 | /* Symbol is defined by two or more shared objects. */ | |
112 | #define ELF_LINK_HASH_DEF_DYNAMIC_MULTIPLE 040 | |
113 | /* Dynamic symbol has been adjustd. */ | |
114 | #define ELF_LINK_HASH_DYNAMIC_ADJUSTED 0100 | |
bf73e4f3 ILT |
115 | /* Symbol is defined as weak. */ |
116 | #define ELF_LINK_HASH_DEFINED_WEAK 0200 | |
013dec1a ILT |
117 | }; |
118 | ||
119 | /* ELF linker hash table. */ | |
7050286d | 120 | |
013dec1a ILT |
121 | struct elf_link_hash_table |
122 | { | |
123 | struct bfd_link_hash_table root; | |
124 | /* The first dynamic object found during a link. We create several | |
125 | special input sections when linking against dynamic objects, and | |
126 | we simply attach them to the first one found. */ | |
127 | bfd *dynobj; | |
128 | /* The number of symbols found in the link which must be put into | |
129 | the .dynsym section. */ | |
130 | size_t dynsymcount; | |
131 | /* The string table of dynamic symbols, which becomes the .dynstr | |
132 | section. */ | |
133 | struct strtab *dynstr; | |
134 | /* The number of buckets in the hash table in the .hash section. | |
135 | This is based on the number of dynamic symbols. */ | |
136 | size_t bucketcount; | |
137 | }; | |
138 | ||
139 | /* Look up an entry in an ELF linker hash table. */ | |
140 | ||
141 | #define elf_link_hash_lookup(table, string, create, copy, follow) \ | |
142 | ((struct elf_link_hash_entry *) \ | |
143 | bfd_link_hash_lookup (&(table)->root, (string), (create), \ | |
144 | (copy), (follow))) | |
145 | ||
146 | /* Traverse an ELF linker hash table. */ | |
147 | ||
148 | #define elf_link_hash_traverse(table, func, info) \ | |
149 | (bfd_link_hash_traverse \ | |
150 | (&(table)->root, \ | |
151 | (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \ | |
152 | (info))) | |
153 | ||
154 | /* Get the ELF linker hash table from a link_info structure. */ | |
155 | ||
156 | #define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash)) | |
157 | \f | |
95469b02 ILT |
158 | /* Constant information held for an ELF backend. */ |
159 | ||
268f94ac | 160 | struct elf_backend_data |
7050286d | 161 | { |
95469b02 ILT |
162 | /* Whether the backend uses REL or RELA relocations. FIXME: some |
163 | ELF backends use both. When we need to support one, this whole | |
164 | approach will need to be changed. */ | |
7050286d | 165 | int use_rela_p; |
95469b02 ILT |
166 | |
167 | /* Whether this backend is 64 bits or not. FIXME: Who cares? */ | |
7050286d | 168 | int elf_64_p; |
95469b02 ILT |
169 | |
170 | /* The architecture for this backend. */ | |
81187b54 | 171 | enum bfd_architecture arch; |
95469b02 | 172 | |
a5ccdad1 ILT |
173 | /* The ELF machine code (EM_xxxx) for this backend. */ |
174 | int elf_machine_code; | |
175 | ||
95469b02 ILT |
176 | /* The maximum page size for this backend. */ |
177 | bfd_vma maxpagesize; | |
178 | ||
6ec3bb6a ILT |
179 | /* This is true if the linker should act like collect and gather |
180 | global constructors and destructors by name. This is true for | |
181 | MIPS ELF because the Irix 5 tools can not handle the .init | |
182 | section. */ | |
183 | boolean collect; | |
184 | ||
95469b02 ILT |
185 | /* A function to translate an ELF RELA relocation to a BFD arelent |
186 | structure. */ | |
7050286d | 187 | void (*elf_info_to_howto) PARAMS ((bfd *, arelent *, |
268f94ac | 188 | Elf_Internal_Rela *)); |
95469b02 ILT |
189 | |
190 | /* A function to translate an ELF REL relocation to a BFD arelent | |
191 | structure. */ | |
7050286d | 192 | void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *, |
268f94ac | 193 | Elf_Internal_Rel *)); |
db232882 | 194 | |
643e9fc7 ILT |
195 | /* A function to determine whether a symbol is global when |
196 | partitioning the symbol table into local and global symbols. | |
197 | This should be NULL for most targets, in which case the correct | |
198 | thing will be done. MIPS ELF, at least on the Irix 5, has | |
199 | special requirements. */ | |
200 | boolean (*elf_backend_sym_is_global) PARAMS ((bfd *, asymbol *)); | |
201 | ||
95469b02 ILT |
202 | /* The remaining functions are hooks which are called only if they |
203 | are not NULL. */ | |
204 | ||
a5ccdad1 ILT |
205 | /* A function to permit a backend specific check on whether a |
206 | particular BFD format is relevant for an object file, and to | |
207 | permit the backend to set any global information it wishes. When | |
208 | this is called elf_elfheader is set, but anything else should be | |
209 | used with caution. If this returns false, the check_format | |
d1ad85a6 | 210 | routine will return a bfd_error_wrong_format error. */ |
a5ccdad1 ILT |
211 | boolean (*elf_backend_object_p) PARAMS ((bfd *)); |
212 | ||
95469b02 ILT |
213 | /* A function to do additional symbol processing when reading the |
214 | ELF symbol table. This is where any processor-specific special | |
215 | section indices are handled. */ | |
e2a422b8 | 216 | void (*elf_backend_symbol_processing) PARAMS ((bfd *, asymbol *)); |
95469b02 ILT |
217 | |
218 | /* A function to do additional symbol processing after reading the | |
219 | entire ELF symbol table. */ | |
220 | boolean (*elf_backend_symbol_table_processing) PARAMS ((bfd *, | |
221 | elf_symbol_type *, | |
222 | int)); | |
223 | ||
224 | /* A function to do additional processing on the ELF section header | |
225 | just before writing it out. This is used to set the flags and | |
226 | type fields for some sections, or to actually write out data for | |
227 | unusual sections. */ | |
228 | boolean (*elf_backend_section_processing) PARAMS ((bfd *, | |
229 | Elf32_Internal_Shdr *)); | |
230 | ||
231 | /* A function to handle unusual section types when creating BFD | |
232 | sections from ELF sections. */ | |
233 | boolean (*elf_backend_section_from_shdr) PARAMS ((bfd *, | |
234 | Elf32_Internal_Shdr *, | |
235 | char *)); | |
236 | ||
237 | /* A function to set up the ELF section header for a BFD section in | |
238 | preparation for writing it out. This is where the flags and type | |
239 | fields are set for unusual sections. */ | |
240 | boolean (*elf_backend_fake_sections) PARAMS ((bfd *, Elf32_Internal_Shdr *, | |
241 | asection *)); | |
242 | ||
243 | /* A function to get the ELF section index for a BFD section. If | |
244 | this returns true, the section was found. If it is a normal ELF | |
245 | section, *RETVAL should be left unchanged. If it is not a normal | |
246 | ELF section *RETVAL should be set to the SHN_xxxx index. */ | |
247 | boolean (*elf_backend_section_from_bfd_section) | |
248 | PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *retval)); | |
249 | ||
6ec3bb6a ILT |
250 | /* If this field is not NULL, it is called by the add_symbols phase |
251 | of a link just before adding a symbol to the global linker hash | |
252 | table. It may modify any of the fields as it wishes. If *NAME | |
253 | is set to NULL, the symbol will be skipped rather than being | |
254 | added to the hash table. This function is responsible for | |
255 | handling all processor dependent symbol bindings and section | |
256 | indices, and must set at least *FLAGS and *SEC for each processor | |
257 | dependent case; failure to do so will cause a link error. */ | |
258 | boolean (*elf_add_symbol_hook) | |
259 | PARAMS ((bfd *abfd, struct bfd_link_info *info, | |
260 | const Elf_Internal_Sym *, const char **name, | |
261 | flagword *flags, asection **sec, bfd_vma *value)); | |
262 | ||
ff5a090f JL |
263 | /* If this field is not NULL, it is called by the elf_link_output_sym |
264 | phase of a link for each symbol which will appear in the object file. */ | |
265 | boolean (*elf_backend_link_output_symbol_hook) | |
266 | PARAMS ((bfd *, struct bfd_link_info *info, const char *, | |
267 | Elf_Internal_Sym *, asection *)); | |
268 | ||
013dec1a ILT |
269 | /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend |
270 | linker the first time it encounters a dynamic object in the link. | |
271 | This function must create any sections required for dynamic | |
272 | linking. The ABFD argument is a dynamic object. The .interp, | |
273 | .dynamic, .dynsym, .dynstr, and .hash functions have already been | |
274 | created, and this function may modify the section flags if | |
275 | desired. This function will normally create the .got and .plt | |
276 | sections, but different backends have different requirements. */ | |
277 | boolean (*elf_backend_create_dynamic_sections) | |
278 | PARAMS ((bfd *abfd, struct bfd_link_info *info)); | |
279 | ||
280 | /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend | |
281 | linker for every symbol which is defined by a dynamic object and | |
282 | referenced by a regular object. This is called after all the | |
283 | input files have been seen, but before the SIZE_DYNAMIC_SECTIONS | |
284 | function has been called. The hash table entry should be | |
285 | bfd_link_hash_defined, and it should be defined in a section from | |
286 | a dynamic object. Dynamic object sections are not included in | |
287 | the final link, and this function is responsible for changing the | |
288 | value to something which the rest of the link can deal with. | |
289 | This will normally involve adding an entry to the .plt or .got or | |
290 | some such section, and setting the symbol to point to that. */ | |
291 | boolean (*elf_backend_adjust_dynamic_symbol) | |
292 | PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h)); | |
293 | ||
294 | /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend | |
295 | linker after all the linker input files have been seen but before | |
296 | the sections sizes have been set. This is called after | |
297 | ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols. | |
298 | It is only called when linking against a dynamic object. It must | |
299 | set the sizes of the dynamic sections, and may fill in their | |
300 | contents as well. The generic ELF linker can handle the .dynsym, | |
301 | .dynstr and .hash sections. This function must handle the | |
302 | .interp section and any sections created by the | |
303 | CREATE_DYNAMIC_SECTIONS entry point. */ | |
304 | boolean (*elf_backend_size_dynamic_sections) | |
305 | PARAMS ((bfd *output_bfd, struct bfd_link_info *info)); | |
306 | ||
6ec3bb6a ILT |
307 | /* The RELOCATE_SECTION function is called by the ELF backend linker |
308 | to handle the relocations for a section. | |
309 | ||
310 | The relocs are always passed as Rela structures; if the section | |
311 | actually uses Rel structures, the r_addend field will always be | |
312 | zero. | |
313 | ||
314 | This function is responsible for adjust the section contents as | |
315 | necessary, and (if using Rela relocs and generating a | |
316 | relocateable output file) adjusting the reloc addend as | |
317 | necessary. | |
318 | ||
319 | This function does not have to worry about setting the reloc | |
320 | address or the reloc symbol index. | |
321 | ||
322 | LOCAL_SYMS is a pointer to the swapped in local symbols. | |
323 | ||
324 | LOCAL_SECTIONS is an array giving the section in the input file | |
325 | corresponding to the st_shndx field of each local symbol. | |
326 | ||
327 | The global hash table entry for the global symbols can be found | |
328 | via elf_sym_hashes (input_bfd). | |
329 | ||
330 | When generating relocateable output, this function must handle | |
331 | STB_LOCAL/STT_SECTION symbols specially. The output symbol is | |
332 | going to be the section symbol corresponding to the output | |
333 | section, which means that the addend must be adjusted | |
334 | accordingly. */ | |
335 | boolean (*elf_backend_relocate_section) | |
336 | PARAMS ((bfd *output_bfd, struct bfd_link_info *info, | |
337 | bfd *input_bfd, asection *input_section, bfd_byte *contents, | |
338 | Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms, | |
6dde66d5 | 339 | asection **local_sections, char *output_names)); |
6ec3bb6a | 340 | |
013dec1a ILT |
341 | /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend |
342 | linker just before it writes a symbol out to the .dynsym section. | |
343 | The processor backend may make any required adjustment to the | |
344 | symbol. It may also take the opportunity to set contents of the | |
345 | dynamic sections. Note that FINISH_DYNAMIC_SYMBOL is called on | |
346 | all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called | |
347 | on those symbols which are defined by a dynamic object. */ | |
348 | boolean (*elf_backend_finish_dynamic_symbol) | |
349 | PARAMS ((bfd *output_bfd, struct bfd_link_info *info, | |
350 | struct elf_link_hash_entry *h, Elf_Internal_Sym *sym)); | |
351 | ||
352 | /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend | |
353 | linker just before it writes all the dynamic sections out to the | |
354 | output file. The FINISH_DYNAMIC_SYMBOL will have been called on | |
355 | all dynamic symbols. */ | |
356 | boolean (*elf_backend_finish_dynamic_sections) | |
357 | PARAMS ((bfd *output_bfd, struct bfd_link_info *info)); | |
358 | ||
99a6c761 JL |
359 | /* A function to do any beginning processing needed for the ELF file |
360 | before building the ELF headers and computing file positions. */ | |
ff5a090f JL |
361 | void (*elf_backend_begin_write_processing) |
362 | PARAMS ((bfd *, struct bfd_link_info *)); | |
99a6c761 | 363 | |
643e9fc7 ILT |
364 | /* A function to do any final processing needed for the ELF file |
365 | before writing it out. */ | |
ff5a090f JL |
366 | void (*elf_backend_final_write_processing) |
367 | PARAMS ((bfd *, struct bfd_link_info *)); | |
643e9fc7 | 368 | |
95469b02 ILT |
369 | /* The swapping table to use when dealing with ECOFF information. |
370 | Used for the MIPS ELF .mdebug section. */ | |
371 | const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap; | |
81187b54 KR |
372 | }; |
373 | ||
d24928c0 KR |
374 | struct elf_sym_extra |
375 | { | |
376 | int elf_sym_num; /* sym# after locals/globals are reordered */ | |
377 | }; | |
378 | ||
379 | typedef struct elf_sym_extra Elf_Sym_Extra; | |
380 | ||
ea617174 ILT |
381 | /* Information stored for each BFD section in an ELF file. This |
382 | structure is allocated by elf_new_section_hook. */ | |
383 | ||
32090b8e | 384 | struct bfd_elf_section_data { |
ea617174 | 385 | /* The ELF header for this section. */ |
32090b8e | 386 | Elf_Internal_Shdr this_hdr; |
ea617174 ILT |
387 | /* The ELF header for the reloc section associated with this |
388 | section, if any. */ | |
32090b8e | 389 | Elf_Internal_Shdr rel_hdr; |
ea617174 ILT |
390 | /* The ELF section number of this section. Only used for an output |
391 | file. */ | |
392 | int this_idx; | |
393 | /* The ELF section number of the reloc section associated with this | |
394 | section, if any. Only used for an output file. */ | |
395 | int rel_idx; | |
396 | /* Used by the backend linker to store the symbol hash table entries | |
397 | associated with relocs against global symbols. */ | |
6ec3bb6a | 398 | struct elf_link_hash_entry **rel_hashes; |
ea617174 ILT |
399 | /* A pointer to the unswapped external relocs; this may be NULL. */ |
400 | PTR relocs; | |
32090b8e | 401 | }; |
ea617174 | 402 | |
32090b8e | 403 | #define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd) |
32090b8e KR |
404 | |
405 | #define get_elf_backend_data(abfd) \ | |
406 | ((struct elf_backend_data *) (abfd)->xvec->backend_data) | |
407 | ||
408 | struct strtab | |
409 | { | |
410 | char *tab; | |
411 | int nentries; | |
412 | int length; | |
413 | }; | |
414 | ||
415 | /* Some private data is stashed away for future use using the tdata pointer | |
416 | in the bfd structure. */ | |
417 | ||
418 | struct elf_obj_tdata | |
419 | { | |
420 | Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */ | |
421 | Elf_Internal_Shdr **elf_sect_ptr; | |
d79ab07c | 422 | Elf_Internal_Phdr *phdr; |
32090b8e KR |
423 | struct strtab *strtab_ptr; |
424 | int num_locals; | |
425 | int num_globals; | |
d24928c0 KR |
426 | Elf_Sym_Extra *sym_extra; |
427 | asymbol **section_syms; /* STT_SECTION symbols for each section */ | |
428 | int num_section_syms; /* number of section_syms allocated */ | |
32090b8e KR |
429 | Elf_Internal_Shdr symtab_hdr; |
430 | Elf_Internal_Shdr shstrtab_hdr; | |
431 | Elf_Internal_Shdr strtab_hdr; | |
cb71adf1 PS |
432 | Elf_Internal_Shdr dynsymtab_hdr; |
433 | Elf_Internal_Shdr dynstrtab_hdr; | |
434 | int symtab_section, shstrtab_section, strtab_section, dynsymtab_section; | |
32090b8e KR |
435 | file_ptr next_file_pos; |
436 | void *prstatus; /* The raw /proc prstatus structure */ | |
437 | void *prpsinfo; /* The raw /proc prpsinfo structure */ | |
d5a30a08 ILT |
438 | bfd_vma gp; /* The gp value (MIPS only, for now) */ |
439 | int gp_size; /* The gp size (MIPS only, for now) */ | |
6ec3bb6a ILT |
440 | |
441 | /* A mapping from external symbols to entries in the linker hash | |
442 | table, used when linking. This is indexed by the symbol index | |
443 | minus the sh_info field of the symbol table header. */ | |
444 | struct elf_link_hash_entry **sym_hashes; | |
5315c428 | 445 | |
c1f84521 ILT |
446 | /* The linker ELF emulation code needs to let the backend ELF linker |
447 | know what filename should be used for a dynamic object if the | |
448 | dynamic object is found using a search. This field is used to | |
449 | hold that information. */ | |
450 | const char *dt_needed_name; | |
451 | ||
5315c428 ILT |
452 | /* Irix 5 often screws up the symbol table, sorting local symbols |
453 | after global symbols. This flag is set if the symbol table in | |
454 | this BFD appears to be screwed up. If it is, we ignore the | |
455 | sh_info field in the symbol table header, and always read all the | |
456 | symbols. */ | |
457 | boolean bad_symtab; | |
32090b8e KR |
458 | }; |
459 | ||
460 | #define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data) | |
461 | #define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header) | |
462 | #define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr) | |
463 | #define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr) | |
464 | #define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section) | |
cb71adf1 | 465 | #define elf_dynsymtab(bfd) (elf_tdata(bfd) -> dynsymtab_section) |
32090b8e KR |
466 | #define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals) |
467 | #define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals) | |
d24928c0 KR |
468 | #define elf_sym_extra(bfd) (elf_tdata(bfd) -> sym_extra) |
469 | #define elf_section_syms(bfd) (elf_tdata(bfd) -> section_syms) | |
470 | #define elf_num_section_syms(bfd) (elf_tdata(bfd) -> num_section_syms) | |
32090b8e KR |
471 | #define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo) |
472 | #define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus) | |
d5a30a08 ILT |
473 | #define elf_gp(bfd) (elf_tdata(bfd) -> gp) |
474 | #define elf_gp_size(bfd) (elf_tdata(bfd) -> gp_size) | |
6ec3bb6a | 475 | #define elf_sym_hashes(bfd) (elf_tdata(bfd) -> sym_hashes) |
c1f84521 | 476 | #define elf_dt_needed_name(bfd) (elf_tdata(bfd) -> dt_needed_name) |
5315c428 | 477 | #define elf_bad_symtab(bfd) (elf_tdata(bfd) -> bad_symtab) |
6ec3bb6a | 478 | \f |
32090b8e KR |
479 | extern char * elf_string_from_elf_section PARAMS ((bfd *, unsigned, unsigned)); |
480 | extern char * elf_get_str_section PARAMS ((bfd *, unsigned)); | |
481 | ||
482 | #define bfd_elf32_mkobject bfd_elf_mkobject | |
483 | #define bfd_elf64_mkobject bfd_elf_mkobject | |
484 | #define elf_mkobject bfd_elf_mkobject | |
485 | ||
153cb9ad | 486 | extern unsigned long bfd_elf_hash PARAMS ((CONST unsigned char *)); |
7e37f9ff | 487 | |
32090b8e KR |
488 | extern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *, |
489 | arelent *, | |
490 | asymbol *, | |
491 | PTR, | |
492 | asection *, | |
4c3721d5 ILT |
493 | bfd *, |
494 | char **)); | |
998ce1e0 | 495 | extern boolean bfd_elf_mkobject PARAMS ((bfd *)); |
e2a422b8 | 496 | extern Elf_Internal_Shdr *bfd_elf_find_section PARAMS ((bfd *, char *)); |
497c5434 ILT |
497 | extern boolean _bfd_elf_make_section_from_shdr |
498 | PARAMS ((bfd *abfd, Elf_Internal_Shdr *hdr, const char *name)); | |
5315c428 ILT |
499 | extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc |
500 | PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); | |
6ec3bb6a ILT |
501 | extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create |
502 | PARAMS ((bfd *)); | |
5315c428 ILT |
503 | extern boolean _bfd_elf_link_hash_table_init |
504 | PARAMS ((struct elf_link_hash_table *, bfd *, | |
505 | struct bfd_hash_entry *(*) (struct bfd_hash_entry *, | |
506 | struct bfd_hash_table *, | |
507 | const char *))); | |
6ec3bb6a | 508 | |
9942e684 | 509 | extern boolean bfd_elf32_write_object_contents PARAMS ((bfd *)); |
32090b8e KR |
510 | extern boolean bfd_elf64_write_object_contents PARAMS ((bfd *)); |
511 | ||
2f3508ad ILT |
512 | extern const bfd_target *bfd_elf32_object_p PARAMS ((bfd *)); |
513 | extern const bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *)); | |
9942e684 KR |
514 | extern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *)); |
515 | extern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *)); | |
516 | extern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *, | |
517 | bfd *)); | |
518 | extern boolean bfd_elf32_set_section_contents PARAMS ((bfd *, sec_ptr, PTR, | |
519 | file_ptr, | |
520 | bfd_size_type)); | |
7050286d | 521 | |
326e32d7 ILT |
522 | extern long bfd_elf32_get_symtab_upper_bound PARAMS ((bfd *)); |
523 | extern long bfd_elf32_get_symtab PARAMS ((bfd *, asymbol **)); | |
cb71adf1 PS |
524 | extern long bfd_elf32_get_dynamic_symtab_upper_bound PARAMS ((bfd *)); |
525 | extern long bfd_elf32_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **)); | |
326e32d7 ILT |
526 | extern long bfd_elf32_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); |
527 | extern long bfd_elf32_canonicalize_reloc PARAMS ((bfd *, sec_ptr, | |
528 | arelent **, asymbol **)); | |
9942e684 KR |
529 | extern asymbol *bfd_elf32_make_empty_symbol PARAMS ((bfd *)); |
530 | extern void bfd_elf32_print_symbol PARAMS ((bfd *, PTR, asymbol *, | |
531 | bfd_print_symbol_type)); | |
532 | extern void bfd_elf32_get_symbol_info PARAMS ((bfd *, asymbol *, | |
7050286d | 533 | symbol_info *)); |
9942e684 KR |
534 | extern alent *bfd_elf32_get_lineno PARAMS ((bfd *, asymbol *)); |
535 | extern boolean bfd_elf32_set_arch_mach PARAMS ((bfd *, enum bfd_architecture, | |
536 | unsigned long)); | |
537 | extern boolean bfd_elf32_find_nearest_line PARAMS ((bfd *, asection *, | |
538 | asymbol **, | |
539 | bfd_vma, CONST char **, | |
540 | CONST char **, | |
541 | unsigned int *)); | |
542 | extern int bfd_elf32_sizeof_headers PARAMS ((bfd *, boolean)); | |
32090b8e | 543 | extern void bfd_elf32__write_relocs PARAMS ((bfd *, asection *, PTR)); |
e6858d1b | 544 | extern boolean bfd_elf32_new_section_hook PARAMS ((bfd *, asection *)); |
6ec3bb6a ILT |
545 | extern boolean bfd_elf32_bfd_link_add_symbols |
546 | PARAMS ((bfd *, struct bfd_link_info *)); | |
547 | extern boolean bfd_elf32_bfd_final_link | |
548 | PARAMS ((bfd *, struct bfd_link_info *)); | |
81187b54 | 549 | |
840846da ILT |
550 | extern void bfd_elf32_swap_symbol_in |
551 | PARAMS ((bfd *, Elf32_External_Sym *, Elf_Internal_Sym *)); | |
552 | extern void bfd_elf32_swap_symbol_out | |
553 | PARAMS ((bfd *, Elf_Internal_Sym *, Elf32_External_Sym *)); | |
013dec1a ILT |
554 | extern void bfd_elf32_swap_reloc_in |
555 | PARAMS ((bfd *, Elf32_External_Rel *, Elf_Internal_Rel *)); | |
556 | extern void bfd_elf32_swap_reloc_out | |
557 | PARAMS ((bfd *, Elf_Internal_Rel *, Elf32_External_Rel *)); | |
558 | extern void bfd_elf32_swap_reloca_in | |
559 | PARAMS ((bfd *, Elf32_External_Rela *, Elf_Internal_Rela *)); | |
560 | extern void bfd_elf32_swap_reloca_out | |
561 | PARAMS ((bfd *, Elf_Internal_Rela *, Elf32_External_Rela *)); | |
562 | extern void bfd_elf32_swap_dyn_in | |
563 | PARAMS ((bfd *, const Elf32_External_Dyn *, Elf_Internal_Dyn *)); | |
564 | extern void bfd_elf32_swap_dyn_out | |
565 | PARAMS ((bfd *, const Elf_Internal_Dyn *, Elf32_External_Dyn *)); | |
566 | extern boolean bfd_elf32_add_dynamic_entry | |
567 | PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma)); | |
568 | ||
81187b54 | 569 | /* If the target doesn't have reloc handling written yet: */ |
9942e684 KR |
570 | extern void bfd_elf32_no_info_to_howto PARAMS ((bfd *, arelent *, |
571 | Elf32_Internal_Rela *)); | |
db232882 | 572 | |
2f3508ad ILT |
573 | extern const bfd_target *bfd_elf64_object_p PARAMS ((bfd *)); |
574 | extern const bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *)); | |
7d9bb6da KR |
575 | extern char *bfd_elf64_core_file_failing_command PARAMS ((bfd *)); |
576 | extern int bfd_elf64_core_file_failing_signal PARAMS ((bfd *)); | |
577 | extern boolean bfd_elf64_core_file_matches_executable_p PARAMS ((bfd *, | |
578 | bfd *)); | |
579 | extern boolean bfd_elf64_set_section_contents PARAMS ((bfd *, sec_ptr, PTR, | |
580 | file_ptr, | |
581 | bfd_size_type)); | |
582 | ||
326e32d7 ILT |
583 | extern long bfd_elf64_get_symtab_upper_bound PARAMS ((bfd *)); |
584 | extern long bfd_elf64_get_symtab PARAMS ((bfd *, asymbol **)); | |
cb71adf1 PS |
585 | extern long bfd_elf64_get_dynamic_symtab_upper_bound PARAMS ((bfd *)); |
586 | extern long bfd_elf64_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **)); | |
326e32d7 ILT |
587 | extern long bfd_elf64_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr)); |
588 | extern long bfd_elf64_canonicalize_reloc PARAMS ((bfd *, sec_ptr, | |
589 | arelent **, asymbol **)); | |
7d9bb6da KR |
590 | extern asymbol *bfd_elf64_make_empty_symbol PARAMS ((bfd *)); |
591 | extern void bfd_elf64_print_symbol PARAMS ((bfd *, PTR, asymbol *, | |
592 | bfd_print_symbol_type)); | |
593 | extern void bfd_elf64_get_symbol_info PARAMS ((bfd *, asymbol *, | |
594 | symbol_info *)); | |
595 | extern alent *bfd_elf64_get_lineno PARAMS ((bfd *, asymbol *)); | |
596 | extern boolean bfd_elf64_set_arch_mach PARAMS ((bfd *, enum bfd_architecture, | |
597 | unsigned long)); | |
598 | extern boolean bfd_elf64_find_nearest_line PARAMS ((bfd *, asection *, | |
599 | asymbol **, | |
600 | bfd_vma, CONST char **, | |
601 | CONST char **, | |
602 | unsigned int *)); | |
603 | extern int bfd_elf64_sizeof_headers PARAMS ((bfd *, boolean)); | |
32090b8e | 604 | extern void bfd_elf64__write_relocs PARAMS ((bfd *, asection *, PTR)); |
7d9bb6da | 605 | extern boolean bfd_elf64_new_section_hook PARAMS ((bfd *, asection *)); |
6ec3bb6a ILT |
606 | extern boolean bfd_elf64_bfd_link_add_symbols |
607 | PARAMS ((bfd *, struct bfd_link_info *)); | |
608 | extern boolean bfd_elf64_bfd_final_link | |
609 | PARAMS ((bfd *, struct bfd_link_info *)); | |
7d9bb6da | 610 | |
840846da ILT |
611 | extern void bfd_elf64_swap_symbol_in |
612 | PARAMS ((bfd *, Elf64_External_Sym *, Elf_Internal_Sym *)); | |
613 | extern void bfd_elf64_swap_symbol_out | |
614 | PARAMS ((bfd *, Elf_Internal_Sym *, Elf64_External_Sym *)); | |
013dec1a ILT |
615 | extern void bfd_elf64_swap_reloc_in |
616 | PARAMS ((bfd *, Elf64_External_Rel *, Elf_Internal_Rel *)); | |
617 | extern void bfd_elf64_swap_reloc_out | |
618 | PARAMS ((bfd *, Elf_Internal_Rel *, Elf64_External_Rel *)); | |
619 | extern void bfd_elf64_swap_reloca_in | |
620 | PARAMS ((bfd *, Elf64_External_Rela *, Elf_Internal_Rela *)); | |
621 | extern void bfd_elf64_swap_reloca_out | |
622 | PARAMS ((bfd *, Elf_Internal_Rela *, Elf64_External_Rela *)); | |
623 | extern void bfd_elf64_swap_dyn_in | |
624 | PARAMS ((bfd *, const Elf64_External_Dyn *, Elf_Internal_Dyn *)); | |
625 | extern void bfd_elf64_swap_dyn_out | |
626 | PARAMS ((bfd *, const Elf_Internal_Dyn *, Elf64_External_Dyn *)); | |
627 | extern boolean bfd_elf64_add_dynamic_entry | |
628 | PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma)); | |
629 | ||
7d9bb6da KR |
630 | /* If the target doesn't have reloc handling written yet: */ |
631 | extern void bfd_elf64_no_info_to_howto PARAMS ((bfd *, arelent *, | |
632 | Elf64_Internal_Rela *)); | |
633 | ||
db232882 | 634 | #endif /* _LIBELF_H_ */ |