| 1 | /* BFD back-end data structures for ELF files.
|
|---|
| 2 | Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
|---|
| 3 | Free Software Foundation, Inc.
|
|---|
| 4 | Written by Cygnus Support.
|
|---|
| 5 |
|
|---|
| 6 | This file is part of BFD, the Binary File Descriptor library.
|
|---|
| 7 |
|
|---|
| 8 | This program is free software; you can redistribute it and/or modify
|
|---|
| 9 | it under the terms of the GNU General Public License as published by
|
|---|
| 10 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 11 | (at your option) any later version.
|
|---|
| 12 |
|
|---|
| 13 | This program is distributed in the hope that it will be useful,
|
|---|
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 16 | GNU General Public License for more details.
|
|---|
| 17 |
|
|---|
| 18 | You should have received a copy of the GNU General Public License
|
|---|
| 19 | along with this program; if not, write to the Free Software
|
|---|
| 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|---|
| 21 |
|
|---|
| 22 | #ifndef _LIBELF_H_
|
|---|
| 23 | #define _LIBELF_H_ 1
|
|---|
| 24 |
|
|---|
| 25 | #include "elf/common.h"
|
|---|
| 26 | #include "elf/internal.h"
|
|---|
| 27 | #include "elf/external.h"
|
|---|
| 28 | #include "bfdlink.h"
|
|---|
| 29 |
|
|---|
| 30 | /* The number of entries in a section is its size divided by the size
|
|---|
| 31 | of a single entry. This is normally only applicaable to reloc and
|
|---|
| 32 | symbol table sections. */
|
|---|
| 33 | #define NUM_SHDR_ENTRIES(shdr) ((shdr)->sh_size / (shdr)->sh_entsize)
|
|---|
| 34 |
|
|---|
| 35 | /* If size isn't specified as 64 or 32, NAME macro should fail. */
|
|---|
| 36 | #ifndef NAME
|
|---|
| 37 | #if ARCH_SIZE==64
|
|---|
| 38 | #define NAME(x,y) CAT4(x,64,_,y)
|
|---|
| 39 | #endif
|
|---|
| 40 | #if ARCH_SIZE==32
|
|---|
| 41 | #define NAME(x,y) CAT4(x,32,_,y)
|
|---|
| 42 | #endif
|
|---|
| 43 | #endif
|
|---|
| 44 |
|
|---|
| 45 | #ifndef NAME
|
|---|
| 46 | #define NAME(x,y) CAT4(x,NOSIZE,_,y)
|
|---|
| 47 | #endif
|
|---|
| 48 |
|
|---|
| 49 | #define ElfNAME(X) NAME(Elf,X)
|
|---|
| 50 | #define elfNAME(X) NAME(elf,X)
|
|---|
| 51 |
|
|---|
| 52 | /* Information held for an ELF symbol. The first field is the
|
|---|
| 53 | corresponding asymbol. Every symbol is an ELF file is actually a
|
|---|
| 54 | pointer to this structure, although it is often handled as a
|
|---|
| 55 | pointer to an asymbol. */
|
|---|
| 56 |
|
|---|
| 57 | typedef struct
|
|---|
| 58 | {
|
|---|
| 59 | /* The BFD symbol. */
|
|---|
| 60 | asymbol symbol;
|
|---|
| 61 | /* ELF symbol information. */
|
|---|
| 62 | Elf_Internal_Sym internal_elf_sym;
|
|---|
| 63 | /* Backend specific information. */
|
|---|
| 64 | union
|
|---|
| 65 | {
|
|---|
| 66 | unsigned int hppa_arg_reloc;
|
|---|
| 67 | PTR mips_extr;
|
|---|
| 68 | PTR any;
|
|---|
| 69 | }
|
|---|
| 70 | tc_data;
|
|---|
| 71 |
|
|---|
| 72 | /* Version information. This is from an Elf_Internal_Versym
|
|---|
| 73 | structure in a SHT_GNU_versym section. It is zero if there is no
|
|---|
| 74 | version information. */
|
|---|
| 75 | unsigned short version;
|
|---|
| 76 |
|
|---|
| 77 | } elf_symbol_type;
|
|---|
| 78 | |
|---|
| 79 |
|
|---|
| 80 | /* ELF linker hash table entries. */
|
|---|
| 81 |
|
|---|
| 82 | struct elf_link_hash_entry
|
|---|
| 83 | {
|
|---|
| 84 | struct bfd_link_hash_entry root;
|
|---|
| 85 |
|
|---|
| 86 | /* Symbol index in output file. This is initialized to -1. It is
|
|---|
| 87 | set to -2 if the symbol is used by a reloc. */
|
|---|
| 88 | long indx;
|
|---|
| 89 |
|
|---|
| 90 | /* Symbol size. */
|
|---|
| 91 | bfd_size_type size;
|
|---|
| 92 |
|
|---|
| 93 | /* Symbol index as a dynamic symbol. Initialized to -1, and remains
|
|---|
| 94 | -1 if this is not a dynamic symbol. */
|
|---|
| 95 | /* ??? Note that this is consistently used as a synonym for tests
|
|---|
| 96 | against whether we can perform various simplifying transformations
|
|---|
| 97 | to the code. (E.g. changing a pc-relative jump to a PLT entry
|
|---|
| 98 | into a pc-relative jump to the target function.) That test, which
|
|---|
| 99 | is often relatively complex, and someplaces wrong or incomplete,
|
|---|
| 100 | should really be replaced by a predicate in elflink.c.
|
|---|
| 101 |
|
|---|
| 102 | End result: this field -1 does not indicate that the symbol is
|
|---|
| 103 | not in the dynamic symbol table, but rather that the symbol is
|
|---|
| 104 | not visible outside this DSO. */
|
|---|
| 105 | long dynindx;
|
|---|
| 106 |
|
|---|
| 107 | /* String table index in .dynstr if this is a dynamic symbol. */
|
|---|
| 108 | unsigned long dynstr_index;
|
|---|
| 109 |
|
|---|
| 110 | /* If this is a weak defined symbol from a dynamic object, this
|
|---|
| 111 | field points to a defined symbol with the same value, if there is
|
|---|
| 112 | one. Otherwise it is NULL. */
|
|---|
| 113 | struct elf_link_hash_entry *weakdef;
|
|---|
| 114 |
|
|---|
| 115 | /* If this symbol requires an entry in the global offset table, the
|
|---|
| 116 | processor specific backend uses this field to track usage and
|
|---|
| 117 | final offset. We use a union and two names primarily to document
|
|---|
| 118 | the intent of any particular piece of code. The field should be
|
|---|
| 119 | used as a count until size_dynamic_sections, at which point the
|
|---|
| 120 | contents of the .got is fixed. Afterward, if this field is -1,
|
|---|
| 121 | then the symbol does not require a global offset table entry. */
|
|---|
| 122 | union
|
|---|
| 123 | {
|
|---|
| 124 | bfd_signed_vma refcount;
|
|---|
| 125 | bfd_vma offset;
|
|---|
| 126 | } got;
|
|---|
| 127 |
|
|---|
| 128 | /* Same, but tracks a procedure linkage table entry. */
|
|---|
| 129 | union
|
|---|
| 130 | {
|
|---|
| 131 | bfd_signed_vma refcount;
|
|---|
| 132 | bfd_vma offset;
|
|---|
| 133 | } plt;
|
|---|
| 134 |
|
|---|
| 135 | /* If this symbol is used in the linker created sections, the processor
|
|---|
| 136 | specific backend uses this field to map the field into the offset
|
|---|
| 137 | from the beginning of the section. */
|
|---|
| 138 | struct elf_linker_section_pointers *linker_section_pointer;
|
|---|
| 139 |
|
|---|
| 140 | /* Version information. */
|
|---|
| 141 | union
|
|---|
| 142 | {
|
|---|
| 143 | /* This field is used for a symbol which is not defined in a
|
|---|
| 144 | regular object. It points to the version information read in
|
|---|
| 145 | from the dynamic object. */
|
|---|
| 146 | Elf_Internal_Verdef *verdef;
|
|---|
| 147 | /* This field is used for a symbol which is defined in a regular
|
|---|
| 148 | object. It is set up in size_dynamic_sections. It points to
|
|---|
| 149 | the version information we should write out for this symbol. */
|
|---|
| 150 | struct bfd_elf_version_tree *vertree;
|
|---|
| 151 | } verinfo;
|
|---|
| 152 |
|
|---|
| 153 | /* Virtual table entry use information. This array is nominally of size
|
|---|
| 154 | size/sizeof(target_void_pointer), though we have to be able to assume
|
|---|
| 155 | and track a size while the symbol is still undefined. It is indexed
|
|---|
| 156 | via offset/sizeof(target_void_pointer). */
|
|---|
| 157 | size_t vtable_entries_size;
|
|---|
| 158 | boolean *vtable_entries_used;
|
|---|
| 159 |
|
|---|
| 160 | /* Virtual table derivation info. */
|
|---|
| 161 | struct elf_link_hash_entry *vtable_parent;
|
|---|
| 162 |
|
|---|
| 163 | /* Symbol type (STT_NOTYPE, STT_OBJECT, etc.). */
|
|---|
| 164 | char type;
|
|---|
| 165 |
|
|---|
| 166 | /* Symbol st_other value, symbol visibility. */
|
|---|
| 167 | unsigned char other;
|
|---|
| 168 |
|
|---|
| 169 | /* Hash value of the name computed using the ELF hash function. */
|
|---|
| 170 | unsigned long elf_hash_value;
|
|---|
| 171 |
|
|---|
| 172 | /* Some flags; legal values follow. */
|
|---|
| 173 | unsigned short elf_link_hash_flags;
|
|---|
| 174 | /* Symbol is referenced by a non-shared object. */
|
|---|
| 175 | #define ELF_LINK_HASH_REF_REGULAR 01
|
|---|
| 176 | /* Symbol is defined by a non-shared object. */
|
|---|
| 177 | #define ELF_LINK_HASH_DEF_REGULAR 02
|
|---|
| 178 | /* Symbol is referenced by a shared object. */
|
|---|
| 179 | #define ELF_LINK_HASH_REF_DYNAMIC 04
|
|---|
| 180 | /* Symbol is defined by a shared object. */
|
|---|
| 181 | #define ELF_LINK_HASH_DEF_DYNAMIC 010
|
|---|
| 182 | /* Symbol has a non-weak reference from a non-shared object. */
|
|---|
| 183 | #define ELF_LINK_HASH_REF_REGULAR_NONWEAK 020
|
|---|
| 184 | /* Dynamic symbol has been adjustd. */
|
|---|
| 185 | #define ELF_LINK_HASH_DYNAMIC_ADJUSTED 040
|
|---|
| 186 | /* Symbol needs a copy reloc. */
|
|---|
| 187 | #define ELF_LINK_HASH_NEEDS_COPY 0100
|
|---|
| 188 | /* Symbol needs a procedure linkage table entry. */
|
|---|
| 189 | #define ELF_LINK_HASH_NEEDS_PLT 0200
|
|---|
| 190 | /* Symbol appears in a non-ELF input file. */
|
|---|
| 191 | #define ELF_LINK_NON_ELF 0400
|
|---|
| 192 | /* Symbol should be marked as hidden in the version information. */
|
|---|
| 193 | #define ELF_LINK_HIDDEN 01000
|
|---|
| 194 | /* Symbol was forced to local scope due to a version script file. */
|
|---|
| 195 | #define ELF_LINK_FORCED_LOCAL 02000
|
|---|
| 196 | /* Symbol was marked during garbage collection. */
|
|---|
| 197 | #define ELF_LINK_HASH_MARK 04000
|
|---|
| 198 | /* Symbol is referenced by a non-GOT/non-PLT relocation. This is
|
|---|
| 199 | not currently set by all the backends. */
|
|---|
| 200 | #define ELF_LINK_NON_GOT_REF 010000
|
|---|
| 201 | };
|
|---|
| 202 |
|
|---|
| 203 | /* Records local symbols to be emitted in the dynamic symbol table. */
|
|---|
| 204 |
|
|---|
| 205 | struct elf_link_local_dynamic_entry
|
|---|
| 206 | {
|
|---|
| 207 | struct elf_link_local_dynamic_entry *next;
|
|---|
| 208 |
|
|---|
| 209 | /* The input bfd this symbol came from. */
|
|---|
| 210 | bfd *input_bfd;
|
|---|
| 211 |
|
|---|
| 212 | /* The index of the local symbol being copied. */
|
|---|
| 213 | long input_indx;
|
|---|
| 214 |
|
|---|
| 215 | /* The index in the outgoing dynamic symbol table. */
|
|---|
| 216 | long dynindx;
|
|---|
| 217 |
|
|---|
| 218 | /* A copy of the input symbol. */
|
|---|
| 219 | Elf_Internal_Sym isym;
|
|---|
| 220 | };
|
|---|
| 221 |
|
|---|
| 222 | /* ELF linker hash table. */
|
|---|
| 223 |
|
|---|
| 224 | struct elf_link_hash_table
|
|---|
| 225 | {
|
|---|
| 226 | struct bfd_link_hash_table root;
|
|---|
| 227 | /* Whether we have created the special dynamic sections required
|
|---|
| 228 | when linking against or generating a shared object. */
|
|---|
| 229 | boolean dynamic_sections_created;
|
|---|
| 230 | /* The BFD used to hold special sections created by the linker.
|
|---|
| 231 | This will be the first BFD found which requires these sections to
|
|---|
| 232 | be created. */
|
|---|
| 233 | bfd *dynobj;
|
|---|
| 234 | /* The number of symbols found in the link which must be put into
|
|---|
| 235 | the .dynsym section. */
|
|---|
| 236 | bfd_size_type dynsymcount;
|
|---|
| 237 | /* The string table of dynamic symbols, which becomes the .dynstr
|
|---|
| 238 | section. */
|
|---|
| 239 | struct bfd_strtab_hash *dynstr;
|
|---|
| 240 | /* The number of buckets in the hash table in the .hash section.
|
|---|
| 241 | This is based on the number of dynamic symbols. */
|
|---|
| 242 | bfd_size_type bucketcount;
|
|---|
| 243 | /* A linked list of DT_NEEDED names found in dynamic objects
|
|---|
| 244 | included in the link. */
|
|---|
| 245 | struct bfd_link_needed_list *needed;
|
|---|
| 246 | /* The _GLOBAL_OFFSET_TABLE_ symbol. */
|
|---|
| 247 | struct elf_link_hash_entry *hgot;
|
|---|
| 248 | /* A pointer to information used to link stabs in sections. */
|
|---|
| 249 | PTR stab_info;
|
|---|
| 250 | /* A linked list of local symbols to be added to .dynsym. */
|
|---|
| 251 | struct elf_link_local_dynamic_entry *dynlocal;
|
|---|
| 252 | /* A linked list of DT_RPATH/DT_RUNPATH names found in dynamic
|
|---|
| 253 | objects included in the link. */
|
|---|
| 254 | struct bfd_link_needed_list *runpath;
|
|---|
| 255 | };
|
|---|
| 256 |
|
|---|
| 257 | /* Look up an entry in an ELF linker hash table. */
|
|---|
| 258 |
|
|---|
| 259 | #define elf_link_hash_lookup(table, string, create, copy, follow) \
|
|---|
| 260 | ((struct elf_link_hash_entry *) \
|
|---|
| 261 | bfd_link_hash_lookup (&(table)->root, (string), (create), \
|
|---|
| 262 | (copy), (follow)))
|
|---|
| 263 |
|
|---|
| 264 | /* Traverse an ELF linker hash table. */
|
|---|
| 265 |
|
|---|
| 266 | #define elf_link_hash_traverse(table, func, info) \
|
|---|
| 267 | (bfd_link_hash_traverse \
|
|---|
| 268 | (&(table)->root, \
|
|---|
| 269 | (boolean (*) PARAMS ((struct bfd_link_hash_entry *, PTR))) (func), \
|
|---|
| 270 | (info)))
|
|---|
| 271 |
|
|---|
| 272 | /* Get the ELF linker hash table from a link_info structure. */
|
|---|
| 273 |
|
|---|
| 274 | #define elf_hash_table(p) ((struct elf_link_hash_table *) ((p)->hash))
|
|---|
| 275 | |
|---|
| 276 |
|
|---|
| 277 | /* Constant information held for an ELF backend. */
|
|---|
| 278 |
|
|---|
| 279 | struct elf_size_info {
|
|---|
| 280 | unsigned char sizeof_ehdr, sizeof_phdr, sizeof_shdr;
|
|---|
| 281 | unsigned char sizeof_rel, sizeof_rela, sizeof_sym, sizeof_dyn, sizeof_note;
|
|---|
| 282 |
|
|---|
| 283 | /* The size of entries in the .hash section. */
|
|---|
| 284 | unsigned char sizeof_hash_entry;
|
|---|
| 285 |
|
|---|
| 286 | /* The number of internal relocations to allocate per external
|
|---|
| 287 | relocation entry. */
|
|---|
| 288 | unsigned char int_rels_per_ext_rel;
|
|---|
| 289 |
|
|---|
| 290 | unsigned char arch_size, file_align;
|
|---|
| 291 | unsigned char elfclass, ev_current;
|
|---|
| 292 | int (*write_out_phdrs) PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
|
|---|
| 293 | boolean (*write_shdrs_and_ehdr) PARAMS ((bfd *));
|
|---|
| 294 | void (*write_relocs) PARAMS ((bfd *, asection *, PTR));
|
|---|
| 295 | void (*swap_symbol_out) PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
|
|---|
| 296 | boolean (*slurp_reloc_table)
|
|---|
| 297 | PARAMS ((bfd *, asection *, asymbol **, boolean));
|
|---|
| 298 | long (*slurp_symbol_table) PARAMS ((bfd *, asymbol **, boolean));
|
|---|
| 299 | void (*swap_dyn_in) PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
|
|---|
| 300 | void (*swap_dyn_out) PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
|
|---|
| 301 |
|
|---|
| 302 | /* This function, if defined, is called to swap in a REL
|
|---|
| 303 | relocation. If an external relocation corresponds to more than
|
|---|
| 304 | one internal relocation, then all relocations are swapped in at
|
|---|
| 305 | once. */
|
|---|
| 306 | void (*swap_reloc_in)
|
|---|
| 307 | PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rel *));
|
|---|
| 308 |
|
|---|
| 309 | /* This function, if defined, is called to swap out a REL
|
|---|
| 310 | relocation. */
|
|---|
| 311 | void (*swap_reloc_out)
|
|---|
| 312 | PARAMS ((bfd *, const Elf_Internal_Rel *, bfd_byte *));
|
|---|
| 313 |
|
|---|
| 314 | /* This function, if defined, is called to swap in a RELA
|
|---|
| 315 | relocation. If an external relocation corresponds to more than
|
|---|
| 316 | one internal relocation, then all relocations are swapped in at
|
|---|
| 317 | once. */
|
|---|
| 318 | void (*swap_reloca_in)
|
|---|
| 319 | PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *));
|
|---|
| 320 |
|
|---|
| 321 | /* This function, if defined, is called to swap out a RELA
|
|---|
| 322 | relocation. */
|
|---|
| 323 | void (*swap_reloca_out)
|
|---|
| 324 | PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *));
|
|---|
| 325 |
|
|---|
| 326 | };
|
|---|
| 327 |
|
|---|
| 328 | #define elf_symbol_from(ABFD,S) \
|
|---|
| 329 | (((S)->the_bfd->xvec->flavour == bfd_target_elf_flavour \
|
|---|
| 330 | && (S)->the_bfd->tdata.elf_obj_data != 0) \
|
|---|
| 331 | ? (elf_symbol_type *) (S) \
|
|---|
| 332 | : 0)
|
|---|
| 333 |
|
|---|
| 334 | struct elf_backend_data
|
|---|
| 335 | {
|
|---|
| 336 | /* The architecture for this backend. */
|
|---|
| 337 | enum bfd_architecture arch;
|
|---|
| 338 |
|
|---|
| 339 | /* The ELF machine code (EM_xxxx) for this backend. */
|
|---|
| 340 | int elf_machine_code;
|
|---|
| 341 |
|
|---|
| 342 | /* The maximum page size for this backend. */
|
|---|
| 343 | bfd_vma maxpagesize;
|
|---|
| 344 |
|
|---|
| 345 | /* A function to translate an ELF RELA relocation to a BFD arelent
|
|---|
| 346 | structure. */
|
|---|
| 347 | void (*elf_info_to_howto) PARAMS ((bfd *, arelent *,
|
|---|
| 348 | Elf_Internal_Rela *));
|
|---|
| 349 |
|
|---|
| 350 | /* A function to translate an ELF REL relocation to a BFD arelent
|
|---|
| 351 | structure. */
|
|---|
| 352 | void (*elf_info_to_howto_rel) PARAMS ((bfd *, arelent *,
|
|---|
| 353 | Elf_Internal_Rel *));
|
|---|
| 354 |
|
|---|
| 355 | /* A function to determine whether a symbol is global when
|
|---|
| 356 | partitioning the symbol table into local and global symbols.
|
|---|
| 357 | This should be NULL for most targets, in which case the correct
|
|---|
| 358 | thing will be done. MIPS ELF, at least on the Irix 5, has
|
|---|
| 359 | special requirements. */
|
|---|
| 360 | boolean (*elf_backend_sym_is_global) PARAMS ((bfd *, asymbol *));
|
|---|
| 361 |
|
|---|
| 362 | /* The remaining functions are hooks which are called only if they
|
|---|
| 363 | are not NULL. */
|
|---|
| 364 |
|
|---|
| 365 | /* A function to permit a backend specific check on whether a
|
|---|
| 366 | particular BFD format is relevant for an object file, and to
|
|---|
| 367 | permit the backend to set any global information it wishes. When
|
|---|
| 368 | this is called elf_elfheader is set, but anything else should be
|
|---|
| 369 | used with caution. If this returns false, the check_format
|
|---|
| 370 | routine will return a bfd_error_wrong_format error. */
|
|---|
| 371 | boolean (*elf_backend_object_p) PARAMS ((bfd *));
|
|---|
| 372 |
|
|---|
| 373 | /* A function to do additional symbol processing when reading the
|
|---|
| 374 | ELF symbol table. This is where any processor-specific special
|
|---|
| 375 | section indices are handled. */
|
|---|
| 376 | void (*elf_backend_symbol_processing) PARAMS ((bfd *, asymbol *));
|
|---|
| 377 |
|
|---|
| 378 | /* A function to do additional symbol processing after reading the
|
|---|
| 379 | entire ELF symbol table. */
|
|---|
| 380 | boolean (*elf_backend_symbol_table_processing) PARAMS ((bfd *,
|
|---|
| 381 | elf_symbol_type *,
|
|---|
| 382 | unsigned int));
|
|---|
| 383 |
|
|---|
| 384 | /* A function to set the type of the info field. Processor-specific
|
|---|
| 385 | types should be handled here. */
|
|---|
| 386 | int (*elf_backend_get_symbol_type) PARAMS (( Elf_Internal_Sym *, int));
|
|---|
| 387 |
|
|---|
| 388 | /* A function to do additional processing on the ELF section header
|
|---|
| 389 | just before writing it out. This is used to set the flags and
|
|---|
| 390 | type fields for some sections, or to actually write out data for
|
|---|
| 391 | unusual sections. */
|
|---|
| 392 | boolean (*elf_backend_section_processing) PARAMS ((bfd *,
|
|---|
| 393 | Elf32_Internal_Shdr *));
|
|---|
| 394 |
|
|---|
| 395 | /* A function to handle unusual section types when creating BFD
|
|---|
| 396 | sections from ELF sections. */
|
|---|
| 397 | boolean (*elf_backend_section_from_shdr) PARAMS ((bfd *,
|
|---|
| 398 | Elf32_Internal_Shdr *,
|
|---|
| 399 | char *));
|
|---|
| 400 |
|
|---|
| 401 | /* A function to convert machine dependent section header flags to
|
|---|
| 402 | BFD internal section header flags. */
|
|---|
| 403 | boolean (*elf_backend_section_flags) PARAMS ((flagword *,
|
|---|
| 404 | Elf32_Internal_Shdr *));
|
|---|
| 405 |
|
|---|
| 406 | /* A function to handle unusual program segment types when creating BFD
|
|---|
| 407 | sections from ELF program segments. */
|
|---|
| 408 | boolean (*elf_backend_section_from_phdr) PARAMS ((bfd *,
|
|---|
| 409 | Elf32_Internal_Phdr *,
|
|---|
| 410 | int));
|
|---|
| 411 |
|
|---|
| 412 | /* A function to set up the ELF section header for a BFD section in
|
|---|
| 413 | preparation for writing it out. This is where the flags and type
|
|---|
| 414 | fields are set for unusual sections. */
|
|---|
| 415 | boolean (*elf_backend_fake_sections) PARAMS ((bfd *, Elf32_Internal_Shdr *,
|
|---|
| 416 | asection *));
|
|---|
| 417 |
|
|---|
| 418 | /* A function to get the ELF section index for a BFD section. If
|
|---|
| 419 | this returns true, the section was found. If it is a normal ELF
|
|---|
| 420 | section, *RETVAL should be left unchanged. If it is not a normal
|
|---|
| 421 | ELF section *RETVAL should be set to the SHN_xxxx index. */
|
|---|
| 422 | boolean (*elf_backend_section_from_bfd_section)
|
|---|
| 423 | PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *retval));
|
|---|
| 424 |
|
|---|
| 425 | /* If this field is not NULL, it is called by the add_symbols phase
|
|---|
| 426 | of a link just before adding a symbol to the global linker hash
|
|---|
| 427 | table. It may modify any of the fields as it wishes. If *NAME
|
|---|
| 428 | is set to NULL, the symbol will be skipped rather than being
|
|---|
| 429 | added to the hash table. This function is responsible for
|
|---|
| 430 | handling all processor dependent symbol bindings and section
|
|---|
| 431 | indices, and must set at least *FLAGS and *SEC for each processor
|
|---|
| 432 | dependent case; failure to do so will cause a link error. */
|
|---|
| 433 | boolean (*elf_add_symbol_hook)
|
|---|
| 434 | PARAMS ((bfd *abfd, struct bfd_link_info *info,
|
|---|
| 435 | const Elf_Internal_Sym *, const char **name,
|
|---|
| 436 | flagword *flags, asection **sec, bfd_vma *value));
|
|---|
| 437 |
|
|---|
| 438 | /* If this field is not NULL, it is called by the elf_link_output_sym
|
|---|
| 439 | phase of a link for each symbol which will appear in the object file. */
|
|---|
| 440 | boolean (*elf_backend_link_output_symbol_hook)
|
|---|
| 441 | PARAMS ((bfd *, struct bfd_link_info *info, const char *,
|
|---|
| 442 | Elf_Internal_Sym *, asection *));
|
|---|
| 443 |
|
|---|
| 444 | /* The CREATE_DYNAMIC_SECTIONS function is called by the ELF backend
|
|---|
| 445 | linker the first time it encounters a dynamic object in the link.
|
|---|
| 446 | This function must create any sections required for dynamic
|
|---|
| 447 | linking. The ABFD argument is a dynamic object. The .interp,
|
|---|
| 448 | .dynamic, .dynsym, .dynstr, and .hash functions have already been
|
|---|
| 449 | created, and this function may modify the section flags if
|
|---|
| 450 | desired. This function will normally create the .got and .plt
|
|---|
| 451 | sections, but different backends have different requirements. */
|
|---|
| 452 | boolean (*elf_backend_create_dynamic_sections)
|
|---|
| 453 | PARAMS ((bfd *abfd, struct bfd_link_info *info));
|
|---|
| 454 |
|
|---|
| 455 | /* The CHECK_RELOCS function is called by the add_symbols phase of
|
|---|
| 456 | the ELF backend linker. It is called once for each section with
|
|---|
| 457 | relocs of an object file, just after the symbols for the object
|
|---|
| 458 | file have been added to the global linker hash table. The
|
|---|
| 459 | function must look through the relocs and do any special handling
|
|---|
| 460 | required. This generally means allocating space in the global
|
|---|
| 461 | offset table, and perhaps allocating space for a reloc. The
|
|---|
| 462 | relocs are always passed as Rela structures; if the section
|
|---|
| 463 | actually uses Rel structures, the r_addend field will always be
|
|---|
| 464 | zero. */
|
|---|
| 465 | boolean (*check_relocs)
|
|---|
| 466 | PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
|
|---|
| 467 | const Elf_Internal_Rela *relocs));
|
|---|
| 468 |
|
|---|
| 469 | /* The ADJUST_DYNAMIC_SYMBOL function is called by the ELF backend
|
|---|
| 470 | linker for every symbol which is defined by a dynamic object and
|
|---|
| 471 | referenced by a regular object. This is called after all the
|
|---|
| 472 | input files have been seen, but before the SIZE_DYNAMIC_SECTIONS
|
|---|
| 473 | function has been called. The hash table entry should be
|
|---|
| 474 | bfd_link_hash_defined ore bfd_link_hash_defweak, and it should be
|
|---|
| 475 | defined in a section from a dynamic object. Dynamic object
|
|---|
| 476 | sections are not included in the final link, and this function is
|
|---|
| 477 | responsible for changing the value to something which the rest of
|
|---|
| 478 | the link can deal with. This will normally involve adding an
|
|---|
| 479 | entry to the .plt or .got or some such section, and setting the
|
|---|
| 480 | symbol to point to that. */
|
|---|
| 481 | boolean (*elf_backend_adjust_dynamic_symbol)
|
|---|
| 482 | PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *h));
|
|---|
| 483 |
|
|---|
| 484 | /* The ALWAYS_SIZE_SECTIONS function is called by the backend linker
|
|---|
| 485 | after all the linker input files have been seen but before the
|
|---|
| 486 | section sizes have been set. This is called after
|
|---|
| 487 | ADJUST_DYNAMIC_SYMBOL, but before SIZE_DYNAMIC_SECTIONS. */
|
|---|
| 488 | boolean (*elf_backend_always_size_sections)
|
|---|
| 489 | PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
|
|---|
| 490 |
|
|---|
| 491 | /* The SIZE_DYNAMIC_SECTIONS function is called by the ELF backend
|
|---|
| 492 | linker after all the linker input files have been seen but before
|
|---|
| 493 | the sections sizes have been set. This is called after
|
|---|
| 494 | ADJUST_DYNAMIC_SYMBOL has been called on all appropriate symbols.
|
|---|
| 495 | It is only called when linking against a dynamic object. It must
|
|---|
| 496 | set the sizes of the dynamic sections, and may fill in their
|
|---|
| 497 | contents as well. The generic ELF linker can handle the .dynsym,
|
|---|
| 498 | .dynstr and .hash sections. This function must handle the
|
|---|
| 499 | .interp section and any sections created by the
|
|---|
| 500 | CREATE_DYNAMIC_SECTIONS entry point. */
|
|---|
| 501 | boolean (*elf_backend_size_dynamic_sections)
|
|---|
| 502 | PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
|
|---|
| 503 |
|
|---|
| 504 | /* The RELOCATE_SECTION function is called by the ELF backend linker
|
|---|
| 505 | to handle the relocations for a section.
|
|---|
| 506 |
|
|---|
| 507 | The relocs are always passed as Rela structures; if the section
|
|---|
| 508 | actually uses Rel structures, the r_addend field will always be
|
|---|
| 509 | zero.
|
|---|
| 510 |
|
|---|
| 511 | This function is responsible for adjust the section contents as
|
|---|
| 512 | necessary, and (if using Rela relocs and generating a
|
|---|
| 513 | relocateable output file) adjusting the reloc addend as
|
|---|
| 514 | necessary.
|
|---|
| 515 |
|
|---|
| 516 | This function does not have to worry about setting the reloc
|
|---|
| 517 | address or the reloc symbol index.
|
|---|
| 518 |
|
|---|
| 519 | LOCAL_SYMS is a pointer to the swapped in local symbols.
|
|---|
| 520 |
|
|---|
| 521 | LOCAL_SECTIONS is an array giving the section in the input file
|
|---|
| 522 | corresponding to the st_shndx field of each local symbol.
|
|---|
| 523 |
|
|---|
| 524 | The global hash table entry for the global symbols can be found
|
|---|
| 525 | via elf_sym_hashes (input_bfd).
|
|---|
| 526 |
|
|---|
| 527 | When generating relocateable output, this function must handle
|
|---|
| 528 | STB_LOCAL/STT_SECTION symbols specially. The output symbol is
|
|---|
| 529 | going to be the section symbol corresponding to the output
|
|---|
| 530 | section, which means that the addend must be adjusted
|
|---|
| 531 | accordingly. */
|
|---|
| 532 | boolean (*elf_backend_relocate_section)
|
|---|
| 533 | PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
|
|---|
| 534 | bfd *input_bfd, asection *input_section, bfd_byte *contents,
|
|---|
| 535 | Elf_Internal_Rela *relocs, Elf_Internal_Sym *local_syms,
|
|---|
| 536 | asection **local_sections));
|
|---|
| 537 |
|
|---|
| 538 | /* The FINISH_DYNAMIC_SYMBOL function is called by the ELF backend
|
|---|
| 539 | linker just before it writes a symbol out to the .dynsym section.
|
|---|
| 540 | The processor backend may make any required adjustment to the
|
|---|
| 541 | symbol. It may also take the opportunity to set contents of the
|
|---|
| 542 | dynamic sections. Note that FINISH_DYNAMIC_SYMBOL is called on
|
|---|
| 543 | all .dynsym symbols, while ADJUST_DYNAMIC_SYMBOL is only called
|
|---|
| 544 | on those symbols which are defined by a dynamic object. */
|
|---|
| 545 | boolean (*elf_backend_finish_dynamic_symbol)
|
|---|
| 546 | PARAMS ((bfd *output_bfd, struct bfd_link_info *info,
|
|---|
| 547 | struct elf_link_hash_entry *h, Elf_Internal_Sym *sym));
|
|---|
| 548 |
|
|---|
| 549 | /* The FINISH_DYNAMIC_SECTIONS function is called by the ELF backend
|
|---|
| 550 | linker just before it writes all the dynamic sections out to the
|
|---|
| 551 | output file. The FINISH_DYNAMIC_SYMBOL will have been called on
|
|---|
| 552 | all dynamic symbols. */
|
|---|
| 553 | boolean (*elf_backend_finish_dynamic_sections)
|
|---|
| 554 | PARAMS ((bfd *output_bfd, struct bfd_link_info *info));
|
|---|
| 555 |
|
|---|
| 556 | /* A function to do any beginning processing needed for the ELF file
|
|---|
| 557 | before building the ELF headers and computing file positions. */
|
|---|
| 558 | void (*elf_backend_begin_write_processing)
|
|---|
| 559 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 560 |
|
|---|
| 561 | /* A function to do any final processing needed for the ELF file
|
|---|
| 562 | before writing it out. The LINKER argument is true if this BFD
|
|---|
| 563 | was created by the ELF backend linker. */
|
|---|
| 564 | void (*elf_backend_final_write_processing)
|
|---|
| 565 | PARAMS ((bfd *, boolean linker));
|
|---|
| 566 |
|
|---|
| 567 | /* This function is called by get_program_header_size. It should
|
|---|
| 568 | return the number of additional program segments which this BFD
|
|---|
| 569 | will need. It should return -1 on error. */
|
|---|
| 570 | int (*elf_backend_additional_program_headers) PARAMS ((bfd *));
|
|---|
| 571 |
|
|---|
| 572 | /* This function is called to modify an existing segment map in a
|
|---|
| 573 | backend specific fashion. */
|
|---|
| 574 | boolean (*elf_backend_modify_segment_map) PARAMS ((bfd *));
|
|---|
| 575 |
|
|---|
| 576 | /* This function is called during section gc to discover the section a
|
|---|
| 577 | particular relocation refers to. It need not be defined for hosts
|
|---|
| 578 | that have no queer relocation types. */
|
|---|
| 579 | asection * (*gc_mark_hook)
|
|---|
| 580 | PARAMS ((bfd *abfd, struct bfd_link_info *, Elf_Internal_Rela *,
|
|---|
| 581 | struct elf_link_hash_entry *h, Elf_Internal_Sym *));
|
|---|
| 582 |
|
|---|
| 583 | /* This function, if defined, is called during the sweep phase of gc
|
|---|
| 584 | in order that a backend might update any data structures it might
|
|---|
| 585 | be maintaining. */
|
|---|
| 586 | boolean (*gc_sweep_hook)
|
|---|
| 587 | PARAMS ((bfd *abfd, struct bfd_link_info *info, asection *o,
|
|---|
| 588 | const Elf_Internal_Rela *relocs));
|
|---|
| 589 |
|
|---|
| 590 | /* This function, if defined, is called after the ELF headers have
|
|---|
| 591 | been created. This allows for things like the OS and ABI versions
|
|---|
| 592 | to be changed. */
|
|---|
| 593 | void (*elf_backend_post_process_headers)
|
|---|
| 594 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 595 |
|
|---|
| 596 | /* This function, if defined, prints a symbol to file and returns the
|
|---|
| 597 | name of the symbol to be printed. It should return NULL to fall
|
|---|
| 598 | back to default symbol printing. */
|
|---|
| 599 | const char *(*elf_backend_print_symbol_all)
|
|---|
| 600 | PARAMS ((bfd *, PTR, asymbol *));
|
|---|
| 601 |
|
|---|
| 602 | /* This function, if defined, is called after all local symbols and
|
|---|
| 603 | global symbols converted to locals are emited into the symtab
|
|---|
| 604 | section. It allows the backend to emit special global symbols
|
|---|
| 605 | not handled in the hash table. */
|
|---|
| 606 | boolean (*elf_backend_output_arch_syms)
|
|---|
| 607 | PARAMS ((bfd *, struct bfd_link_info *, PTR,
|
|---|
| 608 | boolean (*) PARAMS ((PTR, const char *,
|
|---|
| 609 | Elf_Internal_Sym *, asection *))));
|
|---|
| 610 |
|
|---|
| 611 | /* Copy any information related to dynamic linking from a pre-existing
|
|---|
| 612 | symbol IND to a newly created symbol DIR. */
|
|---|
| 613 | void (*elf_backend_copy_indirect_symbol)
|
|---|
| 614 | PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
|
|---|
| 615 |
|
|---|
| 616 | /* Modify any information related to dynamic linking such that the
|
|---|
| 617 | symbol is not exported. */
|
|---|
| 618 | void (*elf_backend_hide_symbol)
|
|---|
| 619 | PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
|
|---|
| 620 |
|
|---|
| 621 | /* The swapping table to use when dealing with ECOFF information.
|
|---|
| 622 | Used for the MIPS ELF .mdebug section. */
|
|---|
| 623 | const struct ecoff_debug_swap *elf_backend_ecoff_debug_swap;
|
|---|
| 624 |
|
|---|
| 625 | /* Alternate EM_xxxx machine codes for this backend. */
|
|---|
| 626 | int elf_machine_alt1;
|
|---|
| 627 | int elf_machine_alt2;
|
|---|
| 628 |
|
|---|
| 629 | const struct elf_size_info *s;
|
|---|
| 630 |
|
|---|
| 631 | /* offset of the _GLOBAL_OFFSET_TABLE_ symbol from the start of the
|
|---|
| 632 | .got section */
|
|---|
| 633 | bfd_vma got_symbol_offset;
|
|---|
| 634 |
|
|---|
| 635 | /* The size in bytes of the headers for the GOT and PLT. This includes
|
|---|
| 636 | the so-called reserved entries on some systems. */
|
|---|
| 637 | bfd_vma got_header_size;
|
|---|
| 638 | bfd_vma plt_header_size;
|
|---|
| 639 |
|
|---|
| 640 | /* This is true if the linker should act like collect and gather
|
|---|
| 641 | global constructors and destructors by name. This is true for
|
|---|
| 642 | MIPS ELF because the Irix 5 tools can not handle the .init
|
|---|
| 643 | section. */
|
|---|
| 644 | unsigned collect : 1;
|
|---|
| 645 |
|
|---|
| 646 | /* This is true if the linker should ignore changes to the type of a
|
|---|
| 647 | symbol. This is true for MIPS ELF because some Irix 5 objects
|
|---|
| 648 | record undefined functions as STT_OBJECT although the definitions
|
|---|
| 649 | are STT_FUNC. */
|
|---|
| 650 | unsigned type_change_ok : 1;
|
|---|
| 651 |
|
|---|
| 652 | /* Whether the backend may use REL relocations. (Some backends use
|
|---|
| 653 | both REL and RELA relocations, and this flag is set for those
|
|---|
| 654 | backends.) */
|
|---|
| 655 | unsigned may_use_rel_p : 1;
|
|---|
| 656 |
|
|---|
| 657 | /* Whether the backend may use RELA relocations. (Some backends use
|
|---|
| 658 | both REL and RELA relocations, and this flag is set for those
|
|---|
| 659 | backends.) */
|
|---|
| 660 | unsigned may_use_rela_p : 1;
|
|---|
| 661 |
|
|---|
| 662 | /* Whether the default relocation type is RELA. If a backend with
|
|---|
| 663 | this flag set wants REL relocations for a particular section,
|
|---|
| 664 | it must note that explicitly. Similarly, if this flag is clear,
|
|---|
| 665 | and the backend wants RELA relocations for a particular
|
|---|
| 666 | section. */
|
|---|
| 667 | unsigned default_use_rela_p : 1;
|
|---|
| 668 |
|
|---|
| 669 | /* True if addresses "naturally" sign extend. This is used when
|
|---|
| 670 | swapping in from Elf32 when BFD64. */
|
|---|
| 671 | unsigned sign_extend_vma : 1;
|
|---|
| 672 |
|
|---|
| 673 | unsigned want_got_plt : 1;
|
|---|
| 674 | unsigned plt_readonly : 1;
|
|---|
| 675 | unsigned want_plt_sym : 1;
|
|---|
| 676 | unsigned plt_not_loaded : 1;
|
|---|
| 677 | unsigned plt_alignment : 4;
|
|---|
| 678 | unsigned can_gc_sections : 1;
|
|---|
| 679 | unsigned want_dynbss : 1;
|
|---|
| 680 | };
|
|---|
| 681 |
|
|---|
| 682 | /* Information stored for each BFD section in an ELF file. This
|
|---|
| 683 | structure is allocated by elf_new_section_hook. */
|
|---|
| 684 |
|
|---|
| 685 | struct bfd_elf_section_data
|
|---|
| 686 | {
|
|---|
| 687 | /* The ELF header for this section. */
|
|---|
| 688 | Elf_Internal_Shdr this_hdr;
|
|---|
| 689 | /* The ELF header for the reloc section associated with this
|
|---|
| 690 | section, if any. */
|
|---|
| 691 | Elf_Internal_Shdr rel_hdr;
|
|---|
| 692 | /* If there is a second reloc section associated with this section,
|
|---|
| 693 | as can happen on Irix 6, this field points to the header. */
|
|---|
| 694 | Elf_Internal_Shdr *rel_hdr2;
|
|---|
| 695 | /* The number of relocations currently assigned to REL_HDR. */
|
|---|
| 696 | unsigned int rel_count;
|
|---|
| 697 | /* The number of relocations currently assigned to REL_HDR2. */
|
|---|
| 698 | unsigned int rel_count2;
|
|---|
| 699 | /* The ELF section number of this section. Only used for an output
|
|---|
| 700 | file. */
|
|---|
| 701 | int this_idx;
|
|---|
| 702 | /* The ELF section number of the reloc section indicated by
|
|---|
| 703 | REL_HDR if any. Only used for an output file. */
|
|---|
| 704 | int rel_idx;
|
|---|
| 705 | /* The ELF section number of the reloc section indicated by
|
|---|
| 706 | REL_HDR2 if any. Only used for an output file. */
|
|---|
| 707 | int rel_idx2;
|
|---|
| 708 | /* Used by the backend linker to store the symbol hash table entries
|
|---|
| 709 | associated with relocs against global symbols. */
|
|---|
| 710 | struct elf_link_hash_entry **rel_hashes;
|
|---|
| 711 | /* A pointer to the swapped relocs. If the section uses REL relocs,
|
|---|
| 712 | rather than RELA, all the r_addend fields will be zero. This
|
|---|
| 713 | pointer may be NULL. It is used by the backend linker. */
|
|---|
| 714 | Elf_Internal_Rela *relocs;
|
|---|
| 715 | /* Used by the backend linker when generating a shared library to
|
|---|
| 716 | record the dynamic symbol index for a section symbol
|
|---|
| 717 | corresponding to this section. A value of 0 means that there is
|
|---|
| 718 | no dynamic symbol for this section. */
|
|---|
| 719 | long dynindx;
|
|---|
| 720 | /* A pointer used for .stab linking optimizations. */
|
|---|
| 721 | PTR stab_info;
|
|---|
| 722 | /* A pointer available for the processor specific ELF backend. */
|
|---|
| 723 | PTR tdata;
|
|---|
| 724 | /* Nonzero if this section uses RELA relocations, rather than REL. */
|
|---|
| 725 | unsigned int use_rela_p:1;
|
|---|
| 726 | };
|
|---|
| 727 |
|
|---|
| 728 | #define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)
|
|---|
| 729 |
|
|---|
| 730 | #define get_elf_backend_data(abfd) \
|
|---|
| 731 | ((struct elf_backend_data *) (abfd)->xvec->backend_data)
|
|---|
| 732 |
|
|---|
| 733 | /* Enumeration to specify the special section. */
|
|---|
| 734 | typedef enum elf_linker_section_enum
|
|---|
| 735 | {
|
|---|
| 736 | LINKER_SECTION_UNKNOWN, /* not used */
|
|---|
| 737 | LINKER_SECTION_GOT, /* .got section for global offset pointers */
|
|---|
| 738 | LINKER_SECTION_PLT, /* .plt section for generated procedure stubs */
|
|---|
| 739 | LINKER_SECTION_SDATA, /* .sdata/.sbss section for PowerPC */
|
|---|
| 740 | LINKER_SECTION_SDATA2, /* .sdata2/.sbss2 section for PowerPC */
|
|---|
| 741 | LINKER_SECTION_MAX /* # of linker sections */
|
|---|
| 742 | } elf_linker_section_enum_t;
|
|---|
| 743 |
|
|---|
| 744 | /* Sections created by the linker. */
|
|---|
| 745 |
|
|---|
| 746 | typedef struct elf_linker_section
|
|---|
| 747 | {
|
|---|
| 748 | char *name; /* name of the section */
|
|---|
| 749 | char *rel_name; /* name of the associated .rel{,a}. section */
|
|---|
| 750 | char *bss_name; /* name of a related .bss section */
|
|---|
| 751 | char *sym_name; /* name of symbol to reference this section */
|
|---|
| 752 | asection *section; /* pointer to the section */
|
|---|
| 753 | asection *bss_section; /* pointer to the bss section associated with this */
|
|---|
| 754 | asection *rel_section; /* pointer to the relocations needed for this section */
|
|---|
| 755 | struct elf_link_hash_entry *sym_hash; /* pointer to the created symbol hash value */
|
|---|
| 756 | bfd_vma initial_size; /* initial size before any linker generated allocations */
|
|---|
| 757 | bfd_vma sym_offset; /* offset of symbol from beginning of section */
|
|---|
| 758 | bfd_vma hole_size; /* size of reserved address hole in allocation */
|
|---|
| 759 | bfd_vma hole_offset; /* current offset for the hole */
|
|---|
| 760 | bfd_vma max_hole_offset; /* maximum offset for the hole */
|
|---|
| 761 | elf_linker_section_enum_t which; /* which section this is */
|
|---|
| 762 | boolean hole_written_p; /* whether the hole has been initialized */
|
|---|
| 763 | unsigned int alignment; /* alignment for the section */
|
|---|
| 764 | flagword flags; /* flags to use to create the section */
|
|---|
| 765 | } elf_linker_section_t;
|
|---|
| 766 |
|
|---|
| 767 | /* Linked list of allocated pointer entries. This hangs off of the symbol lists, and
|
|---|
| 768 | provides allows us to return different pointers, based on different addend's. */
|
|---|
| 769 |
|
|---|
| 770 | typedef struct elf_linker_section_pointers
|
|---|
| 771 | {
|
|---|
| 772 | struct elf_linker_section_pointers *next; /* next allocated pointer for this symbol */
|
|---|
| 773 | bfd_vma offset; /* offset of pointer from beginning of section */
|
|---|
| 774 | bfd_signed_vma addend; /* addend used */
|
|---|
| 775 | elf_linker_section_enum_t which; /* which linker section this is */
|
|---|
| 776 | boolean written_address_p; /* whether address was written yet */
|
|---|
| 777 | } elf_linker_section_pointers_t;
|
|---|
| 778 |
|
|---|
| 779 | /* Some private data is stashed away for future use using the tdata pointer
|
|---|
| 780 | in the bfd structure. */
|
|---|
| 781 |
|
|---|
| 782 | struct elf_obj_tdata
|
|---|
| 783 | {
|
|---|
| 784 | Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */
|
|---|
| 785 | Elf_Internal_Shdr **elf_sect_ptr;
|
|---|
| 786 | Elf_Internal_Phdr *phdr;
|
|---|
| 787 | struct elf_segment_map *segment_map;
|
|---|
| 788 | struct bfd_strtab_hash *strtab_ptr;
|
|---|
| 789 | int num_locals;
|
|---|
| 790 | int num_globals;
|
|---|
| 791 | asymbol **section_syms; /* STT_SECTION symbols for each section */
|
|---|
| 792 | Elf_Internal_Shdr symtab_hdr;
|
|---|
| 793 | Elf_Internal_Shdr shstrtab_hdr;
|
|---|
| 794 | Elf_Internal_Shdr strtab_hdr;
|
|---|
| 795 | Elf_Internal_Shdr dynsymtab_hdr;
|
|---|
| 796 | Elf_Internal_Shdr dynstrtab_hdr;
|
|---|
| 797 | Elf_Internal_Shdr dynversym_hdr;
|
|---|
| 798 | Elf_Internal_Shdr dynverref_hdr;
|
|---|
| 799 | Elf_Internal_Shdr dynverdef_hdr;
|
|---|
| 800 | unsigned int symtab_section, shstrtab_section;
|
|---|
| 801 | unsigned int strtab_section, dynsymtab_section;
|
|---|
| 802 | unsigned int dynversym_section, dynverdef_section, dynverref_section;
|
|---|
| 803 | file_ptr next_file_pos;
|
|---|
| 804 | #if 0
|
|---|
| 805 | /* we don't need these inside bfd anymore, and I think
|
|---|
| 806 | these weren't used outside bfd. */
|
|---|
| 807 | void *prstatus; /* The raw /proc prstatus structure */
|
|---|
| 808 | void *prpsinfo; /* The raw /proc prpsinfo structure */
|
|---|
| 809 | #endif
|
|---|
| 810 | bfd_vma gp; /* The gp value (MIPS only, for now) */
|
|---|
| 811 | unsigned int gp_size; /* The gp size (MIPS only, for now) */
|
|---|
| 812 |
|
|---|
| 813 | /* Information grabbed from an elf core file. */
|
|---|
| 814 | int core_signal;
|
|---|
| 815 | int core_pid;
|
|---|
| 816 | int core_lwpid;
|
|---|
| 817 | char* core_program;
|
|---|
| 818 | char* core_command;
|
|---|
| 819 |
|
|---|
| 820 | /* This is set to true if the object was created by the backend
|
|---|
| 821 | linker. */
|
|---|
| 822 | boolean linker;
|
|---|
| 823 |
|
|---|
| 824 | /* A mapping from external symbols to entries in the linker hash
|
|---|
| 825 | table, used when linking. This is indexed by the symbol index
|
|---|
| 826 | minus the sh_info field of the symbol table header. */
|
|---|
| 827 | struct elf_link_hash_entry **sym_hashes;
|
|---|
| 828 |
|
|---|
| 829 | /* A mapping from local symbols to offsets into the global offset
|
|---|
| 830 | table, used when linking. This is indexed by the symbol index.
|
|---|
| 831 | Like for the globals, we use a union and two names primarily to
|
|---|
| 832 | document the intent of any particular piece of code. The field
|
|---|
| 833 | should be used as a count until size_dynamic_sections, at which
|
|---|
| 834 | point the contents of the .got is fixed. Afterward, if an entry
|
|---|
| 835 | is -1, then the symbol does not require a global offset table entry. */
|
|---|
| 836 | union
|
|---|
| 837 | {
|
|---|
| 838 | bfd_signed_vma *refcounts;
|
|---|
| 839 | bfd_vma *offsets;
|
|---|
| 840 | } local_got;
|
|---|
| 841 |
|
|---|
| 842 | /* A mapping from local symbols to offsets into the various linker
|
|---|
| 843 | sections added. This is index by the symbol index. */
|
|---|
| 844 | elf_linker_section_pointers_t **linker_section_pointers;
|
|---|
| 845 |
|
|---|
| 846 | /* The linker ELF emulation code needs to let the backend ELF linker
|
|---|
| 847 | know what filename should be used for a dynamic object if the
|
|---|
| 848 | dynamic object is found using a search. The emulation code then
|
|---|
| 849 | sometimes needs to know what name was actually used. Until the
|
|---|
| 850 | file has been added to the linker symbol table, this field holds
|
|---|
| 851 | the name the linker wants. After it has been added, it holds the
|
|---|
| 852 | name actually used, which will be the DT_SONAME entry if there is
|
|---|
| 853 | one. */
|
|---|
| 854 | const char *dt_name;
|
|---|
| 855 |
|
|---|
| 856 | /* When a reference in a regular object is resolved by a shared
|
|---|
| 857 | object is loaded into via the DT_NEEDED entries by the linker
|
|---|
| 858 | ELF emulation code, we need to add the shared object to the
|
|---|
| 859 | DT_NEEDED list of the resulting binary to indicate the dependency
|
|---|
| 860 | as if the -l option is passed to the linker. This field holds the
|
|---|
| 861 | name of the loaded shared object. */
|
|---|
| 862 | const char *dt_soname;
|
|---|
| 863 |
|
|---|
| 864 | /* Irix 5 often screws up the symbol table, sorting local symbols
|
|---|
| 865 | after global symbols. This flag is set if the symbol table in
|
|---|
| 866 | this BFD appears to be screwed up. If it is, we ignore the
|
|---|
| 867 | sh_info field in the symbol table header, and always read all the
|
|---|
| 868 | symbols. */
|
|---|
| 869 | boolean bad_symtab;
|
|---|
| 870 |
|
|---|
| 871 | /* Records the result of `get_program_header_size'. */
|
|---|
| 872 | bfd_size_type program_header_size;
|
|---|
| 873 |
|
|---|
| 874 | /* Used by find_nearest_line entry point. */
|
|---|
| 875 | PTR line_info;
|
|---|
| 876 |
|
|---|
| 877 | /* Used by MIPS ELF find_nearest_line entry point. The structure
|
|---|
| 878 | could be included directly in this one, but there's no point to
|
|---|
| 879 | wasting the memory just for the infrequently called
|
|---|
| 880 | find_nearest_line. */
|
|---|
| 881 | struct mips_elf_find_line *find_line_info;
|
|---|
| 882 |
|
|---|
| 883 | /* A place to stash dwarf1 info for this bfd. */
|
|---|
| 884 | struct dwarf1_debug *dwarf1_find_line_info;
|
|---|
| 885 |
|
|---|
| 886 | /* A place to stash dwarf2 info for this bfd. */
|
|---|
| 887 | PTR dwarf2_find_line_info;
|
|---|
| 888 |
|
|---|
| 889 | /* An array of stub sections indexed by symbol number, used by the
|
|---|
| 890 | MIPS ELF linker. FIXME: We should figure out some way to only
|
|---|
| 891 | include this field for a MIPS ELF target. */
|
|---|
| 892 | asection **local_stubs;
|
|---|
| 893 |
|
|---|
| 894 | /* Used to determine if the e_flags field has been initialized */
|
|---|
| 895 | boolean flags_init;
|
|---|
| 896 |
|
|---|
| 897 | /* Number of symbol version definitions we are about to emit. */
|
|---|
| 898 | unsigned int cverdefs;
|
|---|
| 899 |
|
|---|
| 900 | /* Number of symbol version references we are about to emit. */
|
|---|
| 901 | unsigned int cverrefs;
|
|---|
| 902 |
|
|---|
| 903 | /* Symbol version definitions in external objects. */
|
|---|
| 904 | Elf_Internal_Verdef *verdef;
|
|---|
| 905 |
|
|---|
| 906 | /* Symbol version references to external objects. */
|
|---|
| 907 | Elf_Internal_Verneed *verref;
|
|---|
| 908 |
|
|---|
| 909 | /* Linker sections that we are interested in. */
|
|---|
| 910 | struct elf_linker_section *linker_section[ (int)LINKER_SECTION_MAX ];
|
|---|
| 911 |
|
|---|
| 912 | /* The Irix 5 support uses two virtual sections, which represent
|
|---|
| 913 | text/data symbols defined in dynamic objects. */
|
|---|
| 914 | asymbol *elf_data_symbol;
|
|---|
| 915 | asymbol *elf_text_symbol;
|
|---|
| 916 | asection *elf_data_section;
|
|---|
| 917 | asection *elf_text_section;
|
|---|
| 918 | };
|
|---|
| 919 |
|
|---|
| 920 | #define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)
|
|---|
| 921 | #define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)
|
|---|
| 922 | #define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)
|
|---|
| 923 | #define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)
|
|---|
| 924 | #define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)
|
|---|
| 925 | #define elf_dynsymtab(bfd) (elf_tdata(bfd) -> dynsymtab_section)
|
|---|
| 926 | #define elf_dynversym(bfd) (elf_tdata(bfd) -> dynversym_section)
|
|---|
| 927 | #define elf_dynverdef(bfd) (elf_tdata(bfd) -> dynverdef_section)
|
|---|
| 928 | #define elf_dynverref(bfd) (elf_tdata(bfd) -> dynverref_section)
|
|---|
| 929 | #define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)
|
|---|
| 930 | #define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)
|
|---|
| 931 | #define elf_section_syms(bfd) (elf_tdata(bfd) -> section_syms)
|
|---|
| 932 | #define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)
|
|---|
| 933 | #define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)
|
|---|
| 934 | #define elf_gp(bfd) (elf_tdata(bfd) -> gp)
|
|---|
| 935 | #define elf_gp_size(bfd) (elf_tdata(bfd) -> gp_size)
|
|---|
| 936 | #define elf_sym_hashes(bfd) (elf_tdata(bfd) -> sym_hashes)
|
|---|
| 937 | #define elf_local_got_refcounts(bfd) (elf_tdata(bfd) -> local_got.refcounts)
|
|---|
| 938 | #define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got.offsets)
|
|---|
| 939 | #define elf_local_ptr_offsets(bfd) (elf_tdata(bfd) -> linker_section_pointers)
|
|---|
| 940 | #define elf_dt_name(bfd) (elf_tdata(bfd) -> dt_name)
|
|---|
| 941 | #define elf_dt_soname(bfd) (elf_tdata(bfd) -> dt_soname)
|
|---|
| 942 | #define elf_bad_symtab(bfd) (elf_tdata(bfd) -> bad_symtab)
|
|---|
| 943 | #define elf_flags_init(bfd) (elf_tdata(bfd) -> flags_init)
|
|---|
| 944 | #define elf_linker_section(bfd,n) (elf_tdata(bfd) -> linker_section[(int)n])
|
|---|
| 945 | |
|---|
| 946 |
|
|---|
| 947 | extern void _bfd_elf_swap_verdef_in
|
|---|
| 948 | PARAMS ((bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *));
|
|---|
| 949 | extern void _bfd_elf_swap_verdef_out
|
|---|
| 950 | PARAMS ((bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *));
|
|---|
| 951 | extern void _bfd_elf_swap_verdaux_in
|
|---|
| 952 | PARAMS ((bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *));
|
|---|
| 953 | extern void _bfd_elf_swap_verdaux_out
|
|---|
| 954 | PARAMS ((bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *));
|
|---|
| 955 | extern void _bfd_elf_swap_verneed_in
|
|---|
| 956 | PARAMS ((bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *));
|
|---|
| 957 | extern void _bfd_elf_swap_verneed_out
|
|---|
| 958 | PARAMS ((bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *));
|
|---|
| 959 | extern void _bfd_elf_swap_vernaux_in
|
|---|
| 960 | PARAMS ((bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *));
|
|---|
| 961 | extern void _bfd_elf_swap_vernaux_out
|
|---|
| 962 | PARAMS ((bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *));
|
|---|
| 963 | extern void _bfd_elf_swap_versym_in
|
|---|
| 964 | PARAMS ((bfd *, const Elf_External_Versym *, Elf_Internal_Versym *));
|
|---|
| 965 | extern void _bfd_elf_swap_versym_out
|
|---|
| 966 | PARAMS ((bfd *, const Elf_Internal_Versym *, Elf_External_Versym *));
|
|---|
| 967 |
|
|---|
| 968 | extern int _bfd_elf_section_from_bfd_section PARAMS ((bfd *, asection *));
|
|---|
| 969 | extern char *bfd_elf_string_from_elf_section
|
|---|
| 970 | PARAMS ((bfd *, unsigned, unsigned));
|
|---|
| 971 | extern char *bfd_elf_get_str_section PARAMS ((bfd *, unsigned));
|
|---|
| 972 |
|
|---|
| 973 | extern boolean _bfd_elf_print_private_bfd_data PARAMS ((bfd *, PTR));
|
|---|
| 974 | extern void bfd_elf_print_symbol PARAMS ((bfd *, PTR, asymbol *,
|
|---|
| 975 | bfd_print_symbol_type));
|
|---|
| 976 | #define elf_string_from_elf_strtab(abfd,strindex) \
|
|---|
| 977 | bfd_elf_string_from_elf_section(abfd,elf_elfheader(abfd)->e_shstrndx,strindex)
|
|---|
| 978 |
|
|---|
| 979 | #define bfd_elf32_print_symbol bfd_elf_print_symbol
|
|---|
| 980 | #define bfd_elf64_print_symbol bfd_elf_print_symbol
|
|---|
| 981 |
|
|---|
| 982 | extern unsigned long bfd_elf_hash PARAMS ((const char *));
|
|---|
| 983 |
|
|---|
| 984 | extern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *,
|
|---|
| 985 | arelent *,
|
|---|
| 986 | asymbol *,
|
|---|
| 987 | PTR,
|
|---|
| 988 | asection *,
|
|---|
| 989 | bfd *,
|
|---|
| 990 | char **));
|
|---|
| 991 | extern boolean bfd_elf_mkobject PARAMS ((bfd *));
|
|---|
| 992 | extern boolean bfd_elf_mkcorefile PARAMS ((bfd *));
|
|---|
| 993 | extern Elf_Internal_Shdr *bfd_elf_find_section PARAMS ((bfd *, char *));
|
|---|
| 994 | extern boolean _bfd_elf_make_section_from_shdr
|
|---|
| 995 | PARAMS ((bfd *abfd, Elf_Internal_Shdr *hdr, const char *name));
|
|---|
| 996 | extern boolean _bfd_elf_make_section_from_phdr
|
|---|
| 997 | PARAMS ((bfd *abfd, Elf_Internal_Phdr *hdr, int index, const char *typename));
|
|---|
| 998 | extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc
|
|---|
| 999 | PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
|
|---|
| 1000 | extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create
|
|---|
| 1001 | PARAMS ((bfd *));
|
|---|
| 1002 | extern void _bfd_elf_link_hash_copy_indirect
|
|---|
| 1003 | PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));
|
|---|
| 1004 | extern void _bfd_elf_link_hash_hide_symbol
|
|---|
| 1005 | PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
|
|---|
| 1006 | extern boolean _bfd_elf_link_hash_table_init
|
|---|
| 1007 | PARAMS ((struct elf_link_hash_table *, bfd *,
|
|---|
| 1008 | struct bfd_hash_entry *(*) (struct bfd_hash_entry *,
|
|---|
| 1009 | struct bfd_hash_table *,
|
|---|
| 1010 | const char *)));
|
|---|
| 1011 | extern boolean _bfd_elf_slurp_version_tables PARAMS ((bfd *));
|
|---|
| 1012 |
|
|---|
| 1013 | extern boolean _bfd_elf_copy_private_symbol_data
|
|---|
| 1014 | PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
|
|---|
| 1015 | extern boolean _bfd_elf_copy_private_section_data
|
|---|
| 1016 | PARAMS ((bfd *, asection *, bfd *, asection *));
|
|---|
| 1017 | extern boolean _bfd_elf_write_object_contents PARAMS ((bfd *));
|
|---|
| 1018 | extern boolean _bfd_elf_write_corefile_contents PARAMS ((bfd *));
|
|---|
| 1019 | extern boolean _bfd_elf_set_section_contents PARAMS ((bfd *, sec_ptr, PTR,
|
|---|
| 1020 | file_ptr,
|
|---|
| 1021 | bfd_size_type));
|
|---|
| 1022 | extern long _bfd_elf_get_symtab_upper_bound PARAMS ((bfd *));
|
|---|
| 1023 | extern long _bfd_elf_get_symtab PARAMS ((bfd *, asymbol **));
|
|---|
| 1024 | extern long _bfd_elf_get_dynamic_symtab_upper_bound PARAMS ((bfd *));
|
|---|
| 1025 | extern long _bfd_elf_canonicalize_dynamic_symtab PARAMS ((bfd *, asymbol **));
|
|---|
| 1026 | extern long _bfd_elf_get_reloc_upper_bound PARAMS ((bfd *, sec_ptr));
|
|---|
| 1027 | extern long _bfd_elf_canonicalize_reloc PARAMS ((bfd *, sec_ptr,
|
|---|
| 1028 | arelent **, asymbol **));
|
|---|
| 1029 | extern long _bfd_elf_get_dynamic_reloc_upper_bound PARAMS ((bfd *));
|
|---|
| 1030 | extern long _bfd_elf_canonicalize_dynamic_reloc PARAMS ((bfd *, arelent **,
|
|---|
| 1031 | asymbol **));
|
|---|
| 1032 | extern asymbol *_bfd_elf_make_empty_symbol PARAMS ((bfd *));
|
|---|
| 1033 | extern void _bfd_elf_get_symbol_info PARAMS ((bfd *, asymbol *,
|
|---|
| 1034 | symbol_info *));
|
|---|
| 1035 | extern boolean _bfd_elf_is_local_label_name PARAMS ((bfd *, const char *));
|
|---|
| 1036 | extern alent *_bfd_elf_get_lineno PARAMS ((bfd *, asymbol *));
|
|---|
| 1037 | extern boolean _bfd_elf_set_arch_mach PARAMS ((bfd *, enum bfd_architecture,
|
|---|
| 1038 | unsigned long));
|
|---|
| 1039 | extern boolean _bfd_elf_find_nearest_line PARAMS ((bfd *, asection *,
|
|---|
| 1040 | asymbol **,
|
|---|
| 1041 | bfd_vma, const char **,
|
|---|
| 1042 | const char **,
|
|---|
| 1043 | unsigned int *));
|
|---|
| 1044 | #define _bfd_elf_read_minisymbols _bfd_generic_read_minisymbols
|
|---|
| 1045 | #define _bfd_elf_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
|
|---|
| 1046 | extern int _bfd_elf_sizeof_headers PARAMS ((bfd *, boolean));
|
|---|
| 1047 | extern boolean _bfd_elf_new_section_hook PARAMS ((bfd *, asection *));
|
|---|
| 1048 | extern boolean _bfd_elf_init_reloc_shdr
|
|---|
| 1049 | PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, boolean));
|
|---|
| 1050 |
|
|---|
| 1051 | /* If the target doesn't have reloc handling written yet: */
|
|---|
| 1052 | extern void _bfd_elf_no_info_to_howto PARAMS ((bfd *, arelent *,
|
|---|
| 1053 | Elf_Internal_Rela *));
|
|---|
| 1054 |
|
|---|
| 1055 | extern boolean bfd_section_from_shdr PARAMS ((bfd *, unsigned int shindex));
|
|---|
| 1056 | extern boolean bfd_section_from_phdr PARAMS ((bfd *, Elf_Internal_Phdr *, int));
|
|---|
| 1057 |
|
|---|
| 1058 | extern int _bfd_elf_symbol_from_bfd_symbol PARAMS ((bfd *, asymbol **));
|
|---|
| 1059 |
|
|---|
| 1060 | asection *bfd_section_from_elf_index PARAMS ((bfd *, unsigned int));
|
|---|
| 1061 | boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
|
|---|
| 1062 | struct bfd_link_info *));
|
|---|
| 1063 | struct bfd_strtab_hash *_bfd_elf_stringtab_init PARAMS ((void));
|
|---|
| 1064 | boolean
|
|---|
| 1065 | _bfd_elf_link_record_dynamic_symbol PARAMS ((struct bfd_link_info *,
|
|---|
| 1066 | struct elf_link_hash_entry *));
|
|---|
| 1067 | long
|
|---|
| 1068 | _bfd_elf_link_lookup_local_dynindx PARAMS ((struct bfd_link_info *,
|
|---|
| 1069 | bfd *, long));
|
|---|
| 1070 | boolean
|
|---|
| 1071 | _bfd_elf_compute_section_file_positions PARAMS ((bfd *,
|
|---|
| 1072 | struct bfd_link_info *));
|
|---|
| 1073 | void _bfd_elf_assign_file_positions_for_relocs PARAMS ((bfd *));
|
|---|
| 1074 | file_ptr _bfd_elf_assign_file_position_for_section PARAMS ((Elf_Internal_Shdr *,
|
|---|
| 1075 | file_ptr,
|
|---|
| 1076 | boolean));
|
|---|
| 1077 |
|
|---|
| 1078 | extern boolean _bfd_elf_validate_reloc PARAMS ((bfd *, arelent *));
|
|---|
| 1079 |
|
|---|
| 1080 | boolean _bfd_elf_create_dynamic_sections PARAMS ((bfd *,
|
|---|
| 1081 | struct bfd_link_info *));
|
|---|
| 1082 | boolean _bfd_elf_create_got_section PARAMS ((bfd *,
|
|---|
| 1083 | struct bfd_link_info *));
|
|---|
| 1084 | unsigned long _bfd_elf_link_renumber_dynsyms PARAMS ((bfd *,
|
|---|
| 1085 | struct bfd_link_info *));
|
|---|
| 1086 |
|
|---|
| 1087 | elf_linker_section_t *_bfd_elf_create_linker_section
|
|---|
| 1088 | PARAMS ((bfd *abfd,
|
|---|
| 1089 | struct bfd_link_info *info,
|
|---|
| 1090 | enum elf_linker_section_enum,
|
|---|
| 1091 | elf_linker_section_t *defaults));
|
|---|
| 1092 |
|
|---|
| 1093 | elf_linker_section_pointers_t *_bfd_elf_find_pointer_linker_section
|
|---|
| 1094 | PARAMS ((elf_linker_section_pointers_t *linker_pointers,
|
|---|
| 1095 | bfd_signed_vma addend,
|
|---|
| 1096 | elf_linker_section_enum_t which));
|
|---|
| 1097 |
|
|---|
| 1098 | boolean bfd_elf32_create_pointer_linker_section
|
|---|
| 1099 | PARAMS ((bfd *abfd,
|
|---|
| 1100 | struct bfd_link_info *info,
|
|---|
| 1101 | elf_linker_section_t *lsect,
|
|---|
| 1102 | struct elf_link_hash_entry *h,
|
|---|
| 1103 | const Elf32_Internal_Rela *rel));
|
|---|
| 1104 |
|
|---|
| 1105 | bfd_vma bfd_elf32_finish_pointer_linker_section
|
|---|
| 1106 | PARAMS ((bfd *output_abfd,
|
|---|
| 1107 | bfd *input_bfd,
|
|---|
| 1108 | struct bfd_link_info *info,
|
|---|
| 1109 | elf_linker_section_t *lsect,
|
|---|
| 1110 | struct elf_link_hash_entry *h,
|
|---|
| 1111 | bfd_vma relocation,
|
|---|
| 1112 | const Elf32_Internal_Rela *rel,
|
|---|
| 1113 | int relative_reloc));
|
|---|
| 1114 |
|
|---|
| 1115 | boolean bfd_elf64_create_pointer_linker_section
|
|---|
| 1116 | PARAMS ((bfd *abfd,
|
|---|
| 1117 | struct bfd_link_info *info,
|
|---|
| 1118 | elf_linker_section_t *lsect,
|
|---|
| 1119 | struct elf_link_hash_entry *h,
|
|---|
| 1120 | const Elf64_Internal_Rela *rel));
|
|---|
| 1121 |
|
|---|
| 1122 | bfd_vma bfd_elf64_finish_pointer_linker_section
|
|---|
| 1123 | PARAMS ((bfd *output_abfd,
|
|---|
| 1124 | bfd *input_bfd,
|
|---|
| 1125 | struct bfd_link_info *info,
|
|---|
| 1126 | elf_linker_section_t *lsect,
|
|---|
| 1127 | struct elf_link_hash_entry *h,
|
|---|
| 1128 | bfd_vma relocation,
|
|---|
| 1129 | const Elf64_Internal_Rela *rel,
|
|---|
| 1130 | int relative_reloc));
|
|---|
| 1131 |
|
|---|
| 1132 | boolean _bfd_elf_make_linker_section_rela
|
|---|
| 1133 | PARAMS ((bfd *dynobj,
|
|---|
| 1134 | elf_linker_section_t *lsect,
|
|---|
| 1135 | int alignment));
|
|---|
| 1136 |
|
|---|
| 1137 | boolean _bfd_elfcore_section_from_phdr
|
|---|
| 1138 | PARAMS ((bfd *, Elf_Internal_Phdr *, int));
|
|---|
| 1139 |
|
|---|
| 1140 | extern const bfd_target *bfd_elf32_object_p PARAMS ((bfd *));
|
|---|
| 1141 | extern const bfd_target *bfd_elf32_core_file_p PARAMS ((bfd *));
|
|---|
| 1142 | extern char *bfd_elf32_core_file_failing_command PARAMS ((bfd *));
|
|---|
| 1143 | extern int bfd_elf32_core_file_failing_signal PARAMS ((bfd *));
|
|---|
| 1144 | extern boolean bfd_elf32_core_file_matches_executable_p PARAMS ((bfd *,
|
|---|
| 1145 | bfd *));
|
|---|
| 1146 |
|
|---|
| 1147 | extern boolean bfd_elf32_bfd_link_add_symbols
|
|---|
| 1148 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 1149 | extern boolean bfd_elf32_bfd_final_link
|
|---|
| 1150 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 1151 |
|
|---|
| 1152 | extern void bfd_elf32_swap_symbol_in
|
|---|
| 1153 | PARAMS ((bfd *, const Elf32_External_Sym *, Elf_Internal_Sym *));
|
|---|
| 1154 | extern void bfd_elf32_swap_symbol_out
|
|---|
| 1155 | PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
|
|---|
| 1156 | extern void bfd_elf32_swap_reloc_in
|
|---|
| 1157 | PARAMS ((bfd *, const Elf32_External_Rel *, Elf_Internal_Rel *));
|
|---|
| 1158 | extern void bfd_elf32_swap_reloc_out
|
|---|
| 1159 | PARAMS ((bfd *, const Elf_Internal_Rel *, Elf32_External_Rel *));
|
|---|
| 1160 | extern void bfd_elf32_swap_reloca_in
|
|---|
| 1161 | PARAMS ((bfd *, const Elf32_External_Rela *, Elf_Internal_Rela *));
|
|---|
| 1162 | extern void bfd_elf32_swap_reloca_out
|
|---|
| 1163 | PARAMS ((bfd *, const Elf_Internal_Rela *, Elf32_External_Rela *));
|
|---|
| 1164 | extern void bfd_elf32_swap_phdr_in
|
|---|
| 1165 | PARAMS ((bfd *, const Elf32_External_Phdr *, Elf_Internal_Phdr *));
|
|---|
| 1166 | extern void bfd_elf32_swap_phdr_out
|
|---|
| 1167 | PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf32_External_Phdr *));
|
|---|
| 1168 | extern void bfd_elf32_swap_dyn_in
|
|---|
| 1169 | PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
|
|---|
| 1170 | extern void bfd_elf32_swap_dyn_out
|
|---|
| 1171 | PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
|
|---|
| 1172 | extern long bfd_elf32_slurp_symbol_table
|
|---|
| 1173 | PARAMS ((bfd *, asymbol **, boolean));
|
|---|
| 1174 | extern boolean bfd_elf32_write_shdrs_and_ehdr PARAMS ((bfd *));
|
|---|
| 1175 | extern int bfd_elf32_write_out_phdrs
|
|---|
| 1176 | PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
|
|---|
| 1177 | extern void bfd_elf32_write_relocs
|
|---|
| 1178 | PARAMS ((bfd *, asection *, PTR));
|
|---|
| 1179 | extern boolean bfd_elf32_slurp_reloc_table
|
|---|
| 1180 | PARAMS ((bfd *, asection *, asymbol **, boolean));
|
|---|
| 1181 | extern boolean bfd_elf32_add_dynamic_entry
|
|---|
| 1182 | PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
|
|---|
| 1183 | extern boolean bfd_elf32_link_create_dynamic_sections
|
|---|
| 1184 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 1185 | extern Elf_Internal_Rela *_bfd_elf32_link_read_relocs
|
|---|
| 1186 | PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean));
|
|---|
| 1187 |
|
|---|
| 1188 | extern const bfd_target *bfd_elf64_object_p PARAMS ((bfd *));
|
|---|
| 1189 | extern const bfd_target *bfd_elf64_core_file_p PARAMS ((bfd *));
|
|---|
| 1190 | extern char *bfd_elf64_core_file_failing_command PARAMS ((bfd *));
|
|---|
| 1191 | extern int bfd_elf64_core_file_failing_signal PARAMS ((bfd *));
|
|---|
| 1192 | extern boolean bfd_elf64_core_file_matches_executable_p PARAMS ((bfd *,
|
|---|
| 1193 | bfd *));
|
|---|
| 1194 | extern boolean bfd_elf64_bfd_link_add_symbols
|
|---|
| 1195 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 1196 | extern boolean bfd_elf64_bfd_final_link
|
|---|
| 1197 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 1198 |
|
|---|
| 1199 | extern void bfd_elf64_swap_symbol_in
|
|---|
| 1200 | PARAMS ((bfd *, const Elf64_External_Sym *, Elf_Internal_Sym *));
|
|---|
| 1201 | extern void bfd_elf64_swap_symbol_out
|
|---|
| 1202 | PARAMS ((bfd *, const Elf_Internal_Sym *, PTR));
|
|---|
| 1203 | extern void bfd_elf64_swap_reloc_in
|
|---|
| 1204 | PARAMS ((bfd *, const Elf64_External_Rel *, Elf_Internal_Rel *));
|
|---|
| 1205 | extern void bfd_elf64_swap_reloc_out
|
|---|
| 1206 | PARAMS ((bfd *, const Elf_Internal_Rel *, Elf64_External_Rel *));
|
|---|
| 1207 | extern void bfd_elf64_swap_reloca_in
|
|---|
| 1208 | PARAMS ((bfd *, const Elf64_External_Rela *, Elf_Internal_Rela *));
|
|---|
| 1209 | extern void bfd_elf64_swap_reloca_out
|
|---|
| 1210 | PARAMS ((bfd *, const Elf_Internal_Rela *, Elf64_External_Rela *));
|
|---|
| 1211 | extern void bfd_elf64_swap_phdr_in
|
|---|
| 1212 | PARAMS ((bfd *, const Elf64_External_Phdr *, Elf_Internal_Phdr *));
|
|---|
| 1213 | extern void bfd_elf64_swap_phdr_out
|
|---|
| 1214 | PARAMS ((bfd *, const Elf_Internal_Phdr *, Elf64_External_Phdr *));
|
|---|
| 1215 | extern void bfd_elf64_swap_dyn_in
|
|---|
| 1216 | PARAMS ((bfd *, const PTR, Elf_Internal_Dyn *));
|
|---|
| 1217 | extern void bfd_elf64_swap_dyn_out
|
|---|
| 1218 | PARAMS ((bfd *, const Elf_Internal_Dyn *, PTR));
|
|---|
| 1219 | extern long bfd_elf64_slurp_symbol_table
|
|---|
| 1220 | PARAMS ((bfd *, asymbol **, boolean));
|
|---|
| 1221 | extern boolean bfd_elf64_write_shdrs_and_ehdr PARAMS ((bfd *));
|
|---|
| 1222 | extern int bfd_elf64_write_out_phdrs
|
|---|
| 1223 | PARAMS ((bfd *, const Elf_Internal_Phdr *, int));
|
|---|
| 1224 | extern void bfd_elf64_write_relocs
|
|---|
| 1225 | PARAMS ((bfd *, asection *, PTR));
|
|---|
| 1226 | extern boolean bfd_elf64_slurp_reloc_table
|
|---|
| 1227 | PARAMS ((bfd *, asection *, asymbol **, boolean));
|
|---|
| 1228 | extern boolean bfd_elf64_add_dynamic_entry
|
|---|
| 1229 | PARAMS ((struct bfd_link_info *, bfd_vma, bfd_vma));
|
|---|
| 1230 | extern boolean bfd_elf64_link_create_dynamic_sections
|
|---|
| 1231 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 1232 | extern Elf_Internal_Rela *_bfd_elf64_link_read_relocs
|
|---|
| 1233 | PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean));
|
|---|
| 1234 |
|
|---|
| 1235 | #define bfd_elf32_link_record_dynamic_symbol \
|
|---|
| 1236 | _bfd_elf_link_record_dynamic_symbol
|
|---|
| 1237 | #define bfd_elf64_link_record_dynamic_symbol \
|
|---|
| 1238 | _bfd_elf_link_record_dynamic_symbol
|
|---|
| 1239 |
|
|---|
| 1240 | boolean _bfd_elf32_link_record_local_dynamic_symbol
|
|---|
| 1241 | PARAMS ((struct bfd_link_info *, bfd *, long));
|
|---|
| 1242 | boolean _bfd_elf64_link_record_local_dynamic_symbol
|
|---|
| 1243 | PARAMS ((struct bfd_link_info *, bfd *, long));
|
|---|
| 1244 |
|
|---|
| 1245 | extern boolean _bfd_elf_close_and_cleanup PARAMS ((bfd *));
|
|---|
| 1246 | extern bfd_reloc_status_type _bfd_elf_rel_vtable_reloc_fn
|
|---|
| 1247 | PARAMS ((bfd *, arelent *, struct symbol_cache_entry *, PTR,
|
|---|
| 1248 | asection *, bfd *, char **));
|
|---|
| 1249 |
|
|---|
| 1250 | boolean _bfd_elf32_gc_sections
|
|---|
| 1251 | PARAMS ((bfd *abfd, struct bfd_link_info *info));
|
|---|
| 1252 | boolean _bfd_elf32_gc_common_finalize_got_offsets
|
|---|
| 1253 | PARAMS ((bfd *abfd, struct bfd_link_info *info));
|
|---|
| 1254 | boolean _bfd_elf32_gc_common_final_link
|
|---|
| 1255 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 1256 | boolean _bfd_elf32_gc_record_vtinherit
|
|---|
| 1257 | PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
|
|---|
| 1258 | boolean _bfd_elf32_gc_record_vtentry
|
|---|
| 1259 | PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
|
|---|
| 1260 |
|
|---|
| 1261 | boolean _bfd_elf64_gc_sections
|
|---|
| 1262 | PARAMS ((bfd *abfd, struct bfd_link_info *info));
|
|---|
| 1263 | boolean _bfd_elf64_gc_common_finalize_got_offsets
|
|---|
| 1264 | PARAMS ((bfd *abfd, struct bfd_link_info *info));
|
|---|
| 1265 | boolean _bfd_elf64_gc_common_final_link
|
|---|
| 1266 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 1267 | boolean _bfd_elf64_gc_record_vtinherit
|
|---|
| 1268 | PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
|
|---|
| 1269 | boolean _bfd_elf64_gc_record_vtentry
|
|---|
| 1270 | PARAMS ((bfd *, asection *, struct elf_link_hash_entry *, bfd_vma));
|
|---|
| 1271 |
|
|---|
| 1272 | /* MIPS ELF specific routines. */
|
|---|
| 1273 |
|
|---|
| 1274 | extern boolean _bfd_mips_elf_object_p PARAMS ((bfd *));
|
|---|
| 1275 | extern boolean _bfd_mips_elf_section_from_shdr
|
|---|
| 1276 | PARAMS ((bfd *, Elf_Internal_Shdr *, char *));
|
|---|
| 1277 | extern boolean _bfd_mips_elf_fake_sections
|
|---|
| 1278 | PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
|
|---|
| 1279 | extern boolean _bfd_mips_elf_section_from_bfd_section
|
|---|
| 1280 | PARAMS ((bfd *, Elf_Internal_Shdr *, asection *, int *));
|
|---|
| 1281 | extern boolean _bfd_mips_elf_section_processing
|
|---|
| 1282 | PARAMS ((bfd *, Elf_Internal_Shdr *));
|
|---|
| 1283 | extern void _bfd_mips_elf_symbol_processing PARAMS ((bfd *, asymbol *));
|
|---|
| 1284 | extern boolean _bfd_mips_elf_read_ecoff_info
|
|---|
| 1285 | PARAMS ((bfd *, asection *, struct ecoff_debug_info *));
|
|---|
| 1286 | extern void _bfd_mips_elf_final_write_processing PARAMS ((bfd *, boolean));
|
|---|
| 1287 | extern bfd_reloc_status_type _bfd_mips_elf_hi16_reloc
|
|---|
| 1288 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
|---|
| 1289 | extern bfd_reloc_status_type _bfd_mips_elf_lo16_reloc
|
|---|
| 1290 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
|---|
| 1291 | extern bfd_reloc_status_type _bfd_mips_elf_gprel16_reloc
|
|---|
| 1292 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
|---|
| 1293 | extern bfd_reloc_status_type _bfd_mips_elf_got16_reloc
|
|---|
| 1294 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
|---|
| 1295 | extern bfd_reloc_status_type _bfd_mips_elf_gprel32_reloc
|
|---|
| 1296 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
|---|
| 1297 | extern boolean _bfd_mips_elf_set_private_flags PARAMS ((bfd *, flagword));
|
|---|
| 1298 | extern boolean _bfd_mips_elf_copy_private_bfd_data PARAMS ((bfd *, bfd *));
|
|---|
| 1299 | extern boolean _bfd_mips_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *));
|
|---|
| 1300 | extern boolean _bfd_mips_elf_find_nearest_line
|
|---|
| 1301 | PARAMS ((bfd *, asection *, asymbol **, bfd_vma, const char **,
|
|---|
| 1302 | const char **, unsigned int *));
|
|---|
| 1303 | extern boolean _bfd_mips_elf_set_section_contents
|
|---|
| 1304 | PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
|
|---|
| 1305 | extern boolean _bfd_mips_elf_create_dynamic_sections
|
|---|
| 1306 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 1307 | extern boolean _bfd_mips_elf_add_symbol_hook
|
|---|
| 1308 | PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
|
|---|
| 1309 | const char **, flagword *, asection **, bfd_vma *));
|
|---|
| 1310 | extern boolean _bfd_mips_elf_adjust_dynamic_symbol
|
|---|
| 1311 | PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));
|
|---|
| 1312 | extern boolean _bfd_mips_elf_finish_dynamic_symbol
|
|---|
| 1313 | PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
|
|---|
| 1314 | Elf_Internal_Sym *));
|
|---|
| 1315 | extern boolean _bfd_mips_elf_finish_dynamic_sections
|
|---|
| 1316 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 1317 | extern asection * _bfd_mips_elf_gc_mark_hook
|
|---|
| 1318 | PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *,
|
|---|
| 1319 | struct elf_link_hash_entry *, Elf_Internal_Sym *));
|
|---|
| 1320 | extern boolean _bfd_mips_elf_gc_sweep_hook
|
|---|
| 1321 | PARAMS ((bfd *, struct bfd_link_info *, asection *,
|
|---|
| 1322 | const Elf_Internal_Rela *));
|
|---|
| 1323 | extern boolean _bfd_mips_elf_always_size_sections
|
|---|
| 1324 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 1325 | extern boolean _bfd_mips_elf_size_dynamic_sections
|
|---|
| 1326 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 1327 | extern boolean _bfd_mips_elf_check_relocs
|
|---|
| 1328 | PARAMS ((bfd *, struct bfd_link_info *, asection *,
|
|---|
| 1329 | const Elf_Internal_Rela *));
|
|---|
| 1330 | extern struct bfd_link_hash_table *_bfd_mips_elf_link_hash_table_create
|
|---|
| 1331 | PARAMS ((bfd *));
|
|---|
| 1332 | extern boolean _bfd_mips_elf_print_private_bfd_data
|
|---|
| 1333 | PARAMS ((bfd *, PTR));
|
|---|
| 1334 | extern boolean _bfd_mips_elf_link_output_symbol_hook
|
|---|
| 1335 | PARAMS ((bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *,
|
|---|
| 1336 | asection *));
|
|---|
| 1337 | extern boolean _bfd_mips_elf_final_link
|
|---|
| 1338 | PARAMS ((bfd *, struct bfd_link_info *));
|
|---|
| 1339 | extern int _bfd_mips_elf_additional_program_headers PARAMS ((bfd *));
|
|---|
| 1340 | extern boolean _bfd_mips_elf_modify_segment_map PARAMS ((bfd *));
|
|---|
| 1341 | extern boolean _bfd_mips_elf_relocate_section
|
|---|
| 1342 | PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
|---|
| 1343 | Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
|
|---|
| 1344 |
|
|---|
| 1345 | /* SH ELF specific routine. */
|
|---|
| 1346 |
|
|---|
| 1347 | extern boolean _sh_elf_set_mach_from_flags PARAMS ((bfd *));
|
|---|
| 1348 |
|
|---|
| 1349 | #endif /* _LIBELF_H_ */
|
|---|