📄 elf-bfd.h
字号:
unsigned plt_alignment : 4; unsigned can_gc_sections : 1; unsigned want_dynbss : 1;};/* Information stored for each BFD section in an ELF file. This structure is allocated by elf_new_section_hook. */struct bfd_elf_section_data{ /* The ELF header for this section. */ Elf_Internal_Shdr this_hdr; /* The ELF header for the reloc section associated with this section, if any. */ Elf_Internal_Shdr rel_hdr; /* If there is a second reloc section associated with this section, as can happen on Irix 6, this field points to the header. */ Elf_Internal_Shdr *rel_hdr2; /* The number of relocations currently assigned to REL_HDR. */ unsigned int rel_count; /* The number of relocations currently assigned to REL_HDR2. */ unsigned int rel_count2; /* The ELF section number of this section. Only used for an output file. */ int this_idx; /* The ELF section number of the reloc section indicated by REL_HDR if any. Only used for an output file. */ int rel_idx; /* The ELF section number of the reloc section indicated by REL_HDR2 if any. Only used for an output file. */ int rel_idx2; /* Used by the backend linker to store the symbol hash table entries associated with relocs against global symbols. */ struct elf_link_hash_entry **rel_hashes; /* A pointer to the swapped relocs. If the section uses REL relocs, rather than RELA, all the r_addend fields will be zero. This pointer may be NULL. It is used by the backend linker. */ Elf_Internal_Rela *relocs; /* Used by the backend linker when generating a shared library to record the dynamic symbol index for a section symbol corresponding to this section. A value of 0 means that there is no dynamic symbol for this section. */ long dynindx; /* A pointer used for .stab linking optimizations. */ PTR stab_info; /* A pointer available for the processor specific ELF backend. */ PTR tdata; /* Nonzero if this section uses RELA relocations, rather than REL. */ unsigned int use_rela_p:1;};#define elf_section_data(sec) ((struct bfd_elf_section_data*)sec->used_by_bfd)#define get_elf_backend_data(abfd) \ ((struct elf_backend_data *) (abfd)->xvec->backend_data)/* Enumeration to specify the special section. */typedef enum elf_linker_section_enum{ LINKER_SECTION_UNKNOWN, /* not used */ LINKER_SECTION_GOT, /* .got section for global offset pointers */ LINKER_SECTION_PLT, /* .plt section for generated procedure stubs */ LINKER_SECTION_SDATA, /* .sdata/.sbss section for PowerPC */ LINKER_SECTION_SDATA2, /* .sdata2/.sbss2 section for PowerPC */ LINKER_SECTION_MAX /* # of linker sections */} elf_linker_section_enum_t;/* Sections created by the linker. */typedef struct elf_linker_section{ char *name; /* name of the section */ char *rel_name; /* name of the associated .rel{,a}. section */ char *bss_name; /* name of a related .bss section */ char *sym_name; /* name of symbol to reference this section */ asection *section; /* pointer to the section */ asection *bss_section; /* pointer to the bss section associated with this */ asection *rel_section; /* pointer to the relocations needed for this section */ struct elf_link_hash_entry *sym_hash; /* pointer to the created symbol hash value */ bfd_vma initial_size; /* initial size before any linker generated allocations */ bfd_vma sym_offset; /* offset of symbol from beginning of section */ bfd_vma hole_size; /* size of reserved address hole in allocation */ bfd_vma hole_offset; /* current offset for the hole */ bfd_vma max_hole_offset; /* maximum offset for the hole */ elf_linker_section_enum_t which; /* which section this is */ boolean hole_written_p; /* whether the hole has been initialized */ unsigned int alignment; /* alignment for the section */ flagword flags; /* flags to use to create the section */} elf_linker_section_t;/* Linked list of allocated pointer entries. This hangs off of the symbol lists, and provides allows us to return different pointers, based on different addend's. */typedef struct elf_linker_section_pointers{ struct elf_linker_section_pointers *next; /* next allocated pointer for this symbol */ bfd_vma offset; /* offset of pointer from beginning of section */ bfd_signed_vma addend; /* addend used */ elf_linker_section_enum_t which; /* which linker section this is */ boolean written_address_p; /* whether address was written yet */} elf_linker_section_pointers_t;/* Some private data is stashed away for future use using the tdata pointer in the bfd structure. */struct elf_obj_tdata{ Elf_Internal_Ehdr elf_header[1]; /* Actual data, but ref like ptr */ Elf_Internal_Shdr **elf_sect_ptr; Elf_Internal_Phdr *phdr; struct elf_segment_map *segment_map; struct bfd_strtab_hash *strtab_ptr; int num_locals; int num_globals; asymbol **section_syms; /* STT_SECTION symbols for each section */ Elf_Internal_Shdr symtab_hdr; Elf_Internal_Shdr shstrtab_hdr; Elf_Internal_Shdr strtab_hdr; Elf_Internal_Shdr dynsymtab_hdr; Elf_Internal_Shdr dynstrtab_hdr; Elf_Internal_Shdr dynversym_hdr; Elf_Internal_Shdr dynverref_hdr; Elf_Internal_Shdr dynverdef_hdr; unsigned int symtab_section, shstrtab_section; unsigned int strtab_section, dynsymtab_section; unsigned int dynversym_section, dynverdef_section, dynverref_section; file_ptr next_file_pos;#if 0 /* we don't need these inside bfd anymore, and I think these weren't used outside bfd. */ void *prstatus; /* The raw /proc prstatus structure */ void *prpsinfo; /* The raw /proc prpsinfo structure */#endif bfd_vma gp; /* The gp value (MIPS only, for now) */ unsigned int gp_size; /* The gp size (MIPS only, for now) */ /* Information grabbed from an elf core file. */ int core_signal; int core_pid; int core_lwpid; char* core_program; char* core_command; /* This is set to true if the object was created by the backend linker. */ boolean linker; /* A mapping from external symbols to entries in the linker hash table, used when linking. This is indexed by the symbol index minus the sh_info field of the symbol table header. */ struct elf_link_hash_entry **sym_hashes; /* A mapping from local symbols to offsets into the global offset table, used when linking. This is indexed by the symbol index. Like for the globals, we use a union and two names primarily to document the intent of any particular piece of code. The field should be used as a count until size_dynamic_sections, at which point the contents of the .got is fixed. Afterward, if an entry is -1, then the symbol does not require a global offset table entry. */ union { bfd_signed_vma *refcounts; bfd_vma *offsets; } local_got; /* A mapping from local symbols to offsets into the various linker sections added. This is index by the symbol index. */ elf_linker_section_pointers_t **linker_section_pointers; /* The linker ELF emulation code needs to let the backend ELF linker know what filename should be used for a dynamic object if the dynamic object is found using a search. The emulation code then sometimes needs to know what name was actually used. Until the file has been added to the linker symbol table, this field holds the name the linker wants. After it has been added, it holds the name actually used, which will be the DT_SONAME entry if there is one. */ const char *dt_name; /* When a reference in a regular object is resolved by a shared object is loaded into via the DT_NEEDED entries by the linker ELF emulation code, we need to add the shared object to the DT_NEEDED list of the resulting binary to indicate the dependency as if the -l option is passed to the linker. This field holds the name of the loaded shared object. */ const char *dt_soname; /* Irix 5 often screws up the symbol table, sorting local symbols after global symbols. This flag is set if the symbol table in this BFD appears to be screwed up. If it is, we ignore the sh_info field in the symbol table header, and always read all the symbols. */ boolean bad_symtab; /* Records the result of `get_program_header_size'. */ bfd_size_type program_header_size; /* Used by find_nearest_line entry point. */ PTR line_info; /* Used by MIPS ELF find_nearest_line entry point. The structure could be included directly in this one, but there's no point to wasting the memory just for the infrequently called find_nearest_line. */ struct mips_elf_find_line *find_line_info; /* A place to stash dwarf1 info for this bfd. */ struct dwarf1_debug *dwarf1_find_line_info; /* A place to stash dwarf2 info for this bfd. */ PTR dwarf2_find_line_info; /* An array of stub sections indexed by symbol number, used by the MIPS ELF linker. FIXME: We should figure out some way to only include this field for a MIPS ELF target. */ asection **local_stubs; /* Used to determine if the e_flags field has been initialized */ boolean flags_init; /* Number of symbol version definitions we are about to emit. */ unsigned int cverdefs; /* Number of symbol version references we are about to emit. */ unsigned int cverrefs; /* Symbol version definitions in external objects. */ Elf_Internal_Verdef *verdef; /* Symbol version references to external objects. */ Elf_Internal_Verneed *verref; /* Linker sections that we are interested in. */ struct elf_linker_section *linker_section[ (int)LINKER_SECTION_MAX ]; /* The Irix 5 support uses two virtual sections, which represent text/data symbols defined in dynamic objects. */ asymbol *elf_data_symbol; asymbol *elf_text_symbol; asection *elf_data_section; asection *elf_text_section;};#define elf_tdata(bfd) ((bfd) -> tdata.elf_obj_data)#define elf_elfheader(bfd) (elf_tdata(bfd) -> elf_header)#define elf_elfsections(bfd) (elf_tdata(bfd) -> elf_sect_ptr)#define elf_shstrtab(bfd) (elf_tdata(bfd) -> strtab_ptr)#define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section)#define elf_dynsymtab(bfd) (elf_tdata(bfd) -> dynsymtab_section)#define elf_dynversym(bfd) (elf_tdata(bfd) -> dynversym_section)#define elf_dynverdef(bfd) (elf_tdata(bfd) -> dynverdef_section)#define elf_dynverref(bfd) (elf_tdata(bfd) -> dynverref_section)#define elf_num_locals(bfd) (elf_tdata(bfd) -> num_locals)#define elf_num_globals(bfd) (elf_tdata(bfd) -> num_globals)#define elf_section_syms(bfd) (elf_tdata(bfd) -> section_syms)#define core_prpsinfo(bfd) (elf_tdata(bfd) -> prpsinfo)#define core_prstatus(bfd) (elf_tdata(bfd) -> prstatus)#define elf_gp(bfd) (elf_tdata(bfd) -> gp)#define elf_gp_size(bfd) (elf_tdata(bfd) -> gp_size)#define elf_sym_hashes(bfd) (elf_tdata(bfd) -> sym_hashes)#define elf_local_got_refcounts(bfd) (elf_tdata(bfd) -> local_got.refcounts)#define elf_local_got_offsets(bfd) (elf_tdata(bfd) -> local_got.offsets)#define elf_local_ptr_offsets(bfd) (elf_tdata(bfd) -> linker_section_pointers)#define elf_dt_name(bfd) (elf_tdata(bfd) -> dt_name)#define elf_dt_soname(bfd) (elf_tdata(bfd) -> dt_soname)#define elf_bad_symtab(bfd) (elf_tdata(bfd) -> bad_symtab)#define elf_flags_init(bfd) (elf_tdata(bfd) -> flags_init)#define elf_linker_section(bfd,n) (elf_tdata(bfd) -> linker_section[(int)n])extern void _bfd_elf_swap_verdef_in PARAMS ((bfd *, const Elf_External_Verdef *, Elf_Internal_Verdef *));extern void _bfd_elf_swap_verdef_out PARAMS ((bfd *, const Elf_Internal_Verdef *, Elf_External_Verdef *));extern void _bfd_elf_swap_verdaux_in PARAMS ((bfd *, const Elf_External_Verdaux *, Elf_Internal_Verdaux *));extern void _bfd_elf_swap_verdaux_out PARAMS ((bfd *, const Elf_Internal_Verdaux *, Elf_External_Verdaux *));extern void _bfd_elf_swap_verneed_in PARAMS ((bfd *, const Elf_External_Verneed *, Elf_Internal_Verneed *));extern void _bfd_elf_swap_verneed_out PARAMS ((bfd *, const Elf_Internal_Verneed *, Elf_External_Verneed *));extern void _bfd_elf_swap_vernaux_in PARAMS ((bfd *, const Elf_External_Vernaux *, Elf_Internal_Vernaux *));extern void _bfd_elf_swap_vernaux_out PARAMS ((bfd *, const Elf_Internal_Vernaux *, Elf_External_Vernaux *));extern void _bfd_elf_swap_versym_in PARAMS ((bfd *, const Elf_External_Versym *, Elf_Internal_Versym *));extern void _bfd_elf_swap_versym_out PARAMS ((bfd *, const Elf_Internal_Versym *, Elf_External_Versym *));extern int _bfd_elf_section_from_bfd_section PARAMS ((bfd *, asection *));extern char *bfd_elf_string_from_elf_section PARAMS ((bfd *, unsigned, unsigned));extern char *bfd_elf_get_str_section PARAMS ((bfd *, unsigned));extern boolean _bfd_elf_print_private_bfd_data PARAMS ((bfd *, PTR));extern void bfd_elf_print_symbol PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));#define elf_string_from_elf_strtab(abfd,strindex) \ bfd_elf_string_from_elf_section(abfd,elf_elfheader(abfd)->e_shstrndx,strindex)#define bfd_elf32_print_symbol bfd_elf_print_symbol#define bfd_elf64_print_symbol bfd_elf_print_symbolextern unsigned long bfd_elf_hash PARAMS ((const char *));extern bfd_reloc_status_type bfd_elf_generic_reloc PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));extern boolean bfd_elf_mkobject PARAMS ((bfd *));extern boolean bfd_elf_mkcorefile PARAMS ((bfd *));extern Elf_Internal_Shdr *bfd_elf_find_section PARAMS ((bfd *, char *));extern boolean _bfd_elf_make_section_from_shdr PARAMS ((bfd *abfd, Elf_Internal_Shdr *hdr, const char *name));extern boolean _bfd_elf_make_section_from_phdr PARAMS ((bfd *abfd, Elf_Internal_Phdr *hdr, int index, const char *typename));extern struct bfd_hash_entry *_bfd_elf_link_hash_newfunc PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));extern struct bfd_link_hash_table *_bfd_elf_link_hash_table_create PARAMS ((bfd *));extern void _bfd_elf_link_hash_copy_indirect PARAMS ((struct elf_link_hash_entry *, struct elf_link_hash_entry *));extern void _bfd_elf_link_hash_hide_symbol PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));extern boolean _bfd_elf_link_hash_table_init PARAMS ((struct elf_link_hash_table *, bfd *, struct bfd_hash_entry *(*) (struct bfd_hash_entry *, struct bfd_hash_table *, const char *)));extern boolean _bfd_elf_slurp_version_tables PARAMS ((bfd *));extern boolean _bfd_elf_copy_private_symbol_data PARAMS ((bfd *, asymbol *, bfd *, asymbol *));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -