00001 /* 00002 * Copyright 2003, 2004, 2005, 2006 PathScale, Inc. All Rights Reserved. 00003 */ 00004 00005 /* ELF support for BFD. 00006 Copyright 1991, 1992, 1993, 1994, 1995, 1997, 1998, 2000, 2001, 2002, 00007 2003 Free Software Foundation, Inc. 00008 00009 Written by Fred Fish @ Cygnus Support, from information published 00010 in "UNIX System V Release 4, Programmers Guide: ANSI C and 00011 Programming Support Tools". 00012 00013 This file is part of BFD, the Binary File Descriptor library. 00014 00015 This program is free software; you can redistribute it and/or modify 00016 it under the terms of the GNU General Public License as published by 00017 the Free Software Foundation; either version 2 of the License, or 00018 (at your option) any later version. 00019 00020 This program is distributed in the hope that it will be useful, 00021 but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 GNU General Public License for more details. 00024 00025 You should have received a copy of the GNU General Public License 00026 along with this program; if not, write to the Free Software 00027 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 00028 00029 00030 /* This file is part of ELF support for BFD, and contains the portions 00031 that describe how ELF is represented internally in the BFD library. 00032 I.E. it describes the in-memory representation of ELF. It requires 00033 the elf-common.h file which contains the portions that are common to 00034 both the internal and external representations. */ 00035 00036 00037 /* NOTE that these structures are not kept in the same order as they appear 00038 in the object file. In some cases they've been reordered for more optimal 00039 packing under various circumstances. */ 00040 00041 #ifndef _ELF_INTERNAL_H 00042 #define _ELF_INTERNAL_H 00043 00044 /* ELF Header */ 00045 00046 #define EI_NIDENT 16 /* Size of e_ident[] */ 00047 00048 typedef struct elf_internal_ehdr { 00049 unsigned char e_ident[EI_NIDENT]; /* ELF "magic number" */ 00050 bfd_vma e_entry; /* Entry point virtual address */ 00051 bfd_size_type e_phoff; /* Program header table file offset */ 00052 bfd_size_type e_shoff; /* Section header table file offset */ 00053 unsigned long e_version; /* Identifies object file version */ 00054 unsigned long e_flags; /* Processor-specific flags */ 00055 unsigned short e_type; /* Identifies object file type */ 00056 unsigned short e_machine; /* Specifies required architecture */ 00057 unsigned int e_ehsize; /* ELF header size in bytes */ 00058 unsigned int e_phentsize; /* Program header table entry size */ 00059 unsigned int e_phnum; /* Program header table entry count */ 00060 unsigned int e_shentsize; /* Section header table entry size */ 00061 unsigned int e_shnum; /* Section header table entry count */ 00062 unsigned int e_shstrndx; /* Section header string table index */ 00063 } Elf_Internal_Ehdr; 00064 00065 /* Program header */ 00066 00067 struct elf_internal_phdr { 00068 unsigned long p_type; /* Identifies program segment type */ 00069 unsigned long p_flags; /* Segment flags */ 00070 bfd_vma p_offset; /* Segment file offset */ 00071 bfd_vma p_vaddr; /* Segment virtual address */ 00072 bfd_vma p_paddr; /* Segment physical address */ 00073 bfd_vma p_filesz; /* Segment size in file */ 00074 bfd_vma p_memsz; /* Segment size in memory */ 00075 bfd_vma p_align; /* Segment alignment, file & memory */ 00076 }; 00077 00078 typedef struct elf_internal_phdr Elf_Internal_Phdr; 00079 00080 /* Section header */ 00081 00082 typedef struct elf_internal_shdr { 00083 unsigned int sh_name; /* Section name, index in string tbl */ 00084 unsigned int sh_type; /* Type of section */ 00085 bfd_vma sh_flags; /* Miscellaneous section attributes */ 00086 bfd_vma sh_addr; /* Section virtual addr at execution */ 00087 bfd_size_type sh_size; /* Size of section in bytes */ 00088 bfd_size_type sh_entsize; /* Entry size if section holds table */ 00089 unsigned long sh_link; /* Index of another section */ 00090 unsigned long sh_info; /* Additional section information */ 00091 file_ptr sh_offset; /* Section file offset */ 00092 unsigned int sh_addralign; /* Section alignment */ 00093 00094 /* The internal rep also has some cached info associated with it. */ 00095 asection * bfd_section; /* Associated BFD section. */ 00096 unsigned char *contents; /* Section contents. */ 00097 } Elf_Internal_Shdr; 00098 00099 /* Symbol table entry */ 00100 00101 struct elf_internal_sym { 00102 bfd_vma st_value; /* Value of the symbol */ 00103 bfd_vma st_size; /* Associated symbol size */ 00104 unsigned long st_name; /* Symbol name, index in string tbl */ 00105 unsigned char st_info; /* Type and binding attributes */ 00106 unsigned char st_other; /* Visibilty, and target specific */ 00107 unsigned int st_shndx; /* Associated section index */ 00108 }; 00109 00110 typedef struct elf_internal_sym Elf_Internal_Sym; 00111 00112 /* Note segments */ 00113 00114 typedef struct elf_internal_note { 00115 unsigned long namesz; /* Size of entry's owner string */ 00116 unsigned long descsz; /* Size of the note descriptor */ 00117 unsigned long type; /* Interpretation of the descriptor */ 00118 char * namedata; /* Start of the name+desc data */ 00119 char * descdata; /* Start of the desc data */ 00120 bfd_vma descpos; /* File offset of the descdata */ 00121 } Elf_Internal_Note; 00122 00123 /* Relocation Entries */ 00124 00125 typedef struct elf_internal_rela { 00126 bfd_vma r_offset; /* Location at which to apply the action */ 00127 bfd_vma r_info; /* Index and Type of relocation */ 00128 bfd_vma r_addend; /* Constant addend used to compute value */ 00129 } Elf_Internal_Rela; 00130 00131 /* dynamic section structure */ 00132 00133 typedef struct elf_internal_dyn { 00134 /* This needs to support 64-bit values in elf64. */ 00135 bfd_vma d_tag; /* entry tag value */ 00136 union { 00137 /* This needs to support 64-bit values in elf64. */ 00138 bfd_vma d_val; 00139 bfd_vma d_ptr; 00140 } d_un; 00141 } Elf_Internal_Dyn; 00142 00143 /* This structure appears in a SHT_GNU_verdef section. */ 00144 00145 typedef struct elf_internal_verdef { 00146 unsigned short vd_version; /* Version number of structure. */ 00147 unsigned short vd_flags; /* Flags (VER_FLG_*). */ 00148 unsigned short vd_ndx; /* Version index. */ 00149 unsigned short vd_cnt; /* Number of verdaux entries. */ 00150 unsigned long vd_hash; /* Hash of name. */ 00151 unsigned long vd_aux; /* Offset to verdaux entries. */ 00152 unsigned long vd_next; /* Offset to next verdef. */ 00153 00154 /* These fields are set up when BFD reads in the structure. FIXME: 00155 It would be cleaner to store these in a different structure. */ 00156 bfd *vd_bfd; /* BFD. */ 00157 const char *vd_nodename; /* Version name. */ 00158 struct elf_internal_verdef *vd_nextdef; /* vd_next as pointer. */ 00159 struct elf_internal_verdaux *vd_auxptr; /* vd_aux as pointer. */ 00160 unsigned int vd_exp_refno; /* Used by the linker. */ 00161 } Elf_Internal_Verdef; 00162 00163 /* This structure appears in a SHT_GNU_verdef section. */ 00164 00165 typedef struct elf_internal_verdaux { 00166 unsigned long vda_name; /* String table offset of name. */ 00167 unsigned long vda_next; /* Offset to next verdaux. */ 00168 00169 /* These fields are set up when BFD reads in the structure. FIXME: 00170 It would be cleaner to store these in a different structure. */ 00171 const char *vda_nodename; /* vda_name as pointer. */ 00172 struct elf_internal_verdaux *vda_nextptr; /* vda_next as pointer. */ 00173 } Elf_Internal_Verdaux; 00174 00175 /* This structure appears in a SHT_GNU_verneed section. */ 00176 00177 typedef struct elf_internal_verneed { 00178 unsigned short vn_version; /* Version number of structure. */ 00179 unsigned short vn_cnt; /* Number of vernaux entries. */ 00180 unsigned long vn_file; /* String table offset of library name. */ 00181 unsigned long vn_aux; /* Offset to vernaux entries. */ 00182 unsigned long vn_next; /* Offset to next verneed. */ 00183 00184 /* These fields are set up when BFD reads in the structure. FIXME: 00185 It would be cleaner to store these in a different structure. */ 00186 bfd *vn_bfd; /* BFD. */ 00187 const char *vn_filename; /* vn_file as pointer. */ 00188 struct elf_internal_vernaux *vn_auxptr; /* vn_aux as pointer. */ 00189 struct elf_internal_verneed *vn_nextref; /* vn_nextref as pointer. */ 00190 } Elf_Internal_Verneed; 00191 00192 /* This structure appears in a SHT_GNU_verneed section. */ 00193 00194 typedef struct elf_internal_vernaux { 00195 unsigned long vna_hash; /* Hash of dependency name. */ 00196 unsigned short vna_flags; /* Flags (VER_FLG_*). */ 00197 unsigned short vna_other; /* Unused. */ 00198 unsigned long vna_name; /* String table offset to version name. */ 00199 unsigned long vna_next; /* Offset to next vernaux. */ 00200 00201 /* These fields are set up when BFD reads in the structure. FIXME: 00202 It would be cleaner to store these in a different structure. */ 00203 const char *vna_nodename; /* vna_name as pointer. */ 00204 struct elf_internal_vernaux *vna_nextptr; /* vna_next as pointer. */ 00205 } Elf_Internal_Vernaux; 00206 00207 /* This structure appears in a SHT_GNU_versym section. This is not a 00208 standard ELF structure; ELF just uses Elf32_Half. */ 00209 00210 typedef struct elf_internal_versym { 00211 unsigned short vs_vers; 00212 } Elf_Internal_Versym; 00213 00214 /* Structure for syminfo section. */ 00215 typedef struct 00216 { 00217 unsigned short int si_boundto; 00218 unsigned short int si_flags; 00219 } Elf_Internal_Syminfo; 00220 00221 /* This structure appears on the stack and in NT_AUXV core file notes. */ 00222 typedef struct 00223 { 00224 bfd_vma a_type; 00225 bfd_vma a_val; 00226 } Elf_Internal_Auxv; 00227 00228 00229 /* This structure is used to describe how sections should be assigned 00230 to program segments. */ 00231 00232 struct elf_segment_map 00233 { 00234 /* Next program segment. */ 00235 struct elf_segment_map *next; 00236 /* Program segment type. */ 00237 unsigned long p_type; 00238 /* Program segment flags. */ 00239 unsigned long p_flags; 00240 /* Program segment physical address. */ 00241 bfd_vma p_paddr; 00242 /* Whether the p_flags field is valid; if not, the flags are based 00243 on the section flags. */ 00244 unsigned int p_flags_valid : 1; 00245 /* Whether the p_paddr field is valid; if not, the physical address 00246 is based on the section lma values. */ 00247 unsigned int p_paddr_valid : 1; 00248 /* Whether this segment includes the file header. */ 00249 unsigned int includes_filehdr : 1; 00250 /* Whether this segment includes the program headers. */ 00251 unsigned int includes_phdrs : 1; 00252 /* Number of sections (may be 0). */ 00253 unsigned int count; 00254 /* Sections. Actual number of elements is in count field. */ 00255 asection *sections[1]; 00256 }; 00257 00258 #endif /* _ELF_INTERNAL_H */
1.5.6