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