| #ifndef ELF_H |
| #define ELF_H |
| |
| #define EI_NIDENT 16 /* Size of e_ident array. */ |
| |
| /* Values for e_type. */ |
| #define ET_NONE 0 /* No file type */ |
| #define ET_REL 1 /* Relocatable file */ |
| #define ET_EXEC 2 /* Executable file */ |
| #define ET_DYN 3 /* Shared object file */ |
| #define ET_CORE 4 /* Core file */ |
| |
| /* Values for e_machine (architecute). */ |
| #define EM_NONE 0 /* No machine */ |
| #define EM_M32 1 /* AT&T WE 32100 */ |
| #define EM_SPARC 2 /* SUN SPARC */ |
| #define EM_386 3 /* Intel 80386+ */ |
| #define EM_68K 4 /* Motorola m68k family */ |
| #define EM_88K 5 /* Motorola m88k family */ |
| #define EM_486 6 /* Perhaps disused */ |
| #define EM_860 7 /* Intel 80860 */ |
| #define EM_MIPS 8 /* MIPS R3000 big-endian */ |
| #define EM_S370 9 /* IBM System/370 */ |
| #define EM_MIPS_RS3_LE 10 /* MIPS R3000 little-endian */ |
| |
| #define EM_PARISC 15 /* HPPA */ |
| #define EM_VPP500 17 /* Fujitsu VPP500 */ |
| #define EM_SPARC32PLUS 18 /* Sun's "v8plus" */ |
| #define EM_960 19 /* Intel 80960 */ |
| #define EM_PPC 20 /* PowerPC */ |
| #define EM_PPC64 21 /* PowerPC 64-bit */ |
| #define EM_S390 22 /* IBM S390 */ |
| |
| #define EM_V800 36 /* NEC V800 series */ |
| #define EM_FR20 37 /* Fujitsu FR20 */ |
| #define EM_RH32 38 /* TRW RH-32 */ |
| #define EM_RCE 39 /* Motorola RCE */ |
| #define EM_ARM 40 /* ARM */ |
| #define EM_FAKE_ALPHA 41 /* Digital Alpha */ |
| #define EM_SH 42 /* Hitachi SH */ |
| #define EM_SPARCV9 43 /* SPARC v9 64-bit */ |
| #define EM_TRICORE 44 /* Siemens Tricore */ |
| #define EM_ARC 45 /* Argonaut RISC Core */ |
| #define EM_H8_300 46 /* Hitachi H8/300 */ |
| #define EM_H8_300H 47 /* Hitachi H8/300H */ |
| #define EM_H8S 48 /* Hitachi H8S */ |
| #define EM_H8_500 49 /* Hitachi H8/500 */ |
| #define EM_IA_64 50 /* Intel Merced */ |
| #define EM_MIPS_X 51 /* Stanford MIPS-X */ |
| #define EM_COLDFIRE 52 /* Motorola Coldfire */ |
| #define EM_68HC12 53 /* Motorola M68HC12 */ |
| #define EM_MMA 54 /* Fujitsu MMA Multimedia Accelerator*/ |
| #define EM_PCP 55 /* Siemens PCP */ |
| #define EM_NCPU 56 /* Sony nCPU embeeded RISC */ |
| #define EM_NDR1 57 /* Denso NDR1 microprocessor */ |
| #define EM_STARCORE 58 /* Motorola Start*Core processor */ |
| #define EM_ME16 59 /* Toyota ME16 processor */ |
| #define EM_ST100 60 /* STMicroelectronic ST100 processor */ |
| #define EM_TINYJ 61 /* Advanced Logic Corp. Tinyj emb.fam*/ |
| #define EM_X86_64 62 /* AMD x86-64 architecture */ |
| #define EM_PDSP 63 /* Sony DSP Processor */ |
| |
| #define EM_FX66 66 /* Siemens FX66 microcontroller */ |
| #define EM_ST9PLUS 67 /* STMicroelectronics ST9+ 8/16 mc */ |
| #define EM_ST7 68 /* STmicroelectronics ST7 8 bit mc */ |
| #define EM_68HC16 69 /* Motorola MC68HC16 microcontroller */ |
| #define EM_68HC11 70 /* Motorola MC68HC11 microcontroller */ |
| #define EM_68HC08 71 /* Motorola MC68HC08 microcontroller */ |
| #define EM_68HC05 72 /* Motorola MC68HC05 microcontroller */ |
| #define EM_SVX 73 /* Silicon Graphics SVx */ |
| #define EM_AT19 74 /* STMicroelectronics ST19 8 bit mc */ |
| #define EM_VAX 75 /* Digital VAX */ |
| #define EM_CRIS 76 /* Axis Communications 32-bit embedded processor */ |
| #define EM_JAVELIN 77 /* Infineon Technologies 32-bit embedded processor */ |
| #define EM_FIREPATH 78 /* Element 14 64-bit DSP Processor */ |
| #define EM_ZSP 79 /* LSI Logic 16-bit DSP Processor */ |
| #define EM_MMIX 80 /* Donald Knuth's educational 64-bit processor */ |
| #define EM_HUANY 81 /* Harvard University machine-independent object files */ |
| #define EM_PRISM 82 /* SiTera Prism */ |
| #define EM_AVR 83 /* Atmel AVR 8-bit microcontroller */ |
| #define EM_FR30 84 /* Fujitsu FR30 */ |
| #define EM_D10V 85 /* Mitsubishi D10V */ |
| #define EM_D30V 86 /* Mitsubishi D30V */ |
| #define EM_V850 87 /* NEC v850 */ |
| #define EM_M32R 88 /* Mitsubishi M32R */ |
| #define EM_MN10300 89 /* Matsushita MN10300 */ |
| #define EM_MN10200 90 /* Matsushita MN10200 */ |
| #define EM_PJ 91 /* picoJava */ |
| #define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ |
| #define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ |
| #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ |
| #define EM_NUM 95 |
| |
| /* Values for p_type. */ |
| #define PT_NULL 0 /* Unused entry. */ |
| #define PT_LOAD 1 /* Loadable segment. */ |
| #define PT_DYNAMIC 2 /* Dynamic linking information segment. */ |
| #define PT_INTERP 3 /* Pathname of interpreter. */ |
| #define PT_NOTE 4 /* Auxiliary information. */ |
| #define PT_SHLIB 5 /* Reserved (not used). */ |
| #define PT_PHDR 6 /* Location of program header itself. */ |
| |
| /* Values for p_flags. */ |
| #define PF_X 0x1 /* Executable. */ |
| #define PF_W 0x2 /* Writable. */ |
| #define PF_R 0x4 /* Readable. */ |
| |
| |
| #define ELF_PROGRAM_RETURNS_BIT 0x8000000 /* e_flags bit 31 */ |
| |
| #define EI_MAG0 0 |
| #define ELFMAG0 0x7f |
| |
| #define EI_MAG1 1 |
| #define ELFMAG1 'E' |
| |
| #define EI_MAG2 2 |
| #define ELFMAG2 'L' |
| |
| #define EI_MAG3 3 |
| #define ELFMAG3 'F' |
| |
| #define ELFMAG "\177ELF" |
| |
| #define EI_CLASS 4 /* File class byte index */ |
| #define ELFCLASSNONE 0 /* Invalid class */ |
| #define ELFCLASS32 1 /* 32-bit objects */ |
| #define ELFCLASS64 2 /* 64-bit objects */ |
| |
| #define EI_DATA 5 /* Data encodeing byte index */ |
| #define ELFDATANONE 0 /* Invalid data encoding */ |
| #define ELFDATA2LSB 1 /* 2's complement little endian */ |
| #define ELFDATA2MSB 2 /* 2's complement big endian */ |
| |
| #define EI_VERSION 6 /* File version byte index */ |
| /* Value must be EV_CURRENT */ |
| |
| #define EV_NONE 0 /* Invalid ELF Version */ |
| #define EV_CURRENT 1 /* Current version */ |
| |
| #define ELF32_PHDR_SIZE (8*4) /* Size of an elf program header */ |
| |
| #ifndef ASSEMBLY |
| |
| #include "stdint.h" |
| |
| /* |
| * ELF definitions common to all 32-bit architectures. |
| */ |
| |
| typedef uint32_t Elf32_Addr; |
| typedef uint16_t Elf32_Half; |
| typedef uint32_t Elf32_Off; |
| typedef uint16_t Elf32_Section; |
| typedef int32_t Elf32_Sword; |
| typedef uint32_t Elf32_Word; |
| typedef uint32_t Elf32_Size; |
| |
| typedef uint64_t Elf64_Addr; |
| typedef uint16_t Elf64_Half; |
| typedef uint64_t Elf64_Off; |
| typedef uint16_t Elf64_Section; |
| typedef int32_t Elf64_Sword; |
| typedef uint32_t Elf64_Word; |
| typedef uint64_t Elf64_Size; |
| typedef uint64_t Elf64_Xword; |
| typedef int64_t Elf64_Sxword; |
| |
| /* |
| * ELF header. |
| */ |
| typedef struct { |
| unsigned char e_ident[EI_NIDENT]; /* File identification. */ |
| Elf32_Half e_type; /* File type. */ |
| Elf32_Half e_machine; /* Machine architecture. */ |
| Elf32_Word e_version; /* ELF format version. */ |
| Elf32_Addr e_entry; /* Entry point. */ |
| Elf32_Off e_phoff; /* Program header file offset. */ |
| Elf32_Off e_shoff; /* Section header file offset. */ |
| Elf32_Word e_flags; /* Architecture-specific flags. */ |
| Elf32_Half e_ehsize; /* Size of ELF header in bytes. */ |
| Elf32_Half e_phentsize; /* Size of program header entry. */ |
| Elf32_Half e_phnum; /* Number of program header entries. */ |
| Elf32_Half e_shentsize; /* Size of section header entry. */ |
| Elf32_Half e_shnum; /* Number of section header entries. */ |
| Elf32_Half e_shstrndx; /* Section name strings section. */ |
| } Elf32_Ehdr; |
| |
| typedef struct { |
| unsigned char e_ident[EI_NIDENT]; /* File identification. */ |
| Elf64_Half e_type; /* File type. */ |
| Elf64_Half e_machine; /* Machine architecture. */ |
| Elf64_Word e_version; /* ELF format version. */ |
| Elf64_Addr e_entry; /* Entry point. */ |
| Elf64_Off e_phoff; /* Program header file offset. */ |
| Elf64_Off e_shoff; /* Section header file offset. */ |
| Elf64_Word e_flags; /* Architecture-specific flags. */ |
| Elf64_Half e_ehsize; /* Size of ELF header in bytes. */ |
| Elf64_Half e_phentsize; /* Size of program header entry. */ |
| Elf64_Half e_phnum; /* Number of program header entries. */ |
| Elf64_Half e_shentsize; /* Size of section header entry. */ |
| Elf64_Half e_shnum; /* Number of section header entries. */ |
| Elf64_Half e_shstrndx; /* Section name strings section. */ |
| } Elf64_Ehdr; |
| |
| /* |
| * Program header. |
| */ |
| typedef struct { |
| Elf32_Word p_type; /* Entry type. */ |
| Elf32_Off p_offset; /* File offset of contents. */ |
| Elf32_Addr p_vaddr; /* Virtual address (not used). */ |
| Elf32_Addr p_paddr; /* Physical address. */ |
| Elf32_Size p_filesz; /* Size of contents in file. */ |
| Elf32_Size p_memsz; /* Size of contents in memory. */ |
| Elf32_Word p_flags; /* Access permission flags. */ |
| Elf32_Size p_align; /* Alignment in memory and file. */ |
| } Elf32_Phdr; |
| |
| typedef struct { |
| Elf64_Word p_type; /* Entry type. */ |
| Elf64_Word p_flags; /* Access permission flags. */ |
| Elf64_Off p_offset; /* File offset of contents. */ |
| Elf64_Addr p_vaddr; /* Virtual address (not used). */ |
| Elf64_Addr p_paddr; /* Physical address. */ |
| Elf64_Size p_filesz; /* Size of contents in file. */ |
| Elf64_Size p_memsz; /* Size of contents in memory. */ |
| Elf64_Size p_align; /* Alignment in memory and file. */ |
| } Elf64_Phdr; |
| |
| |
| /* Dynamic section entry. */ |
| |
| typedef struct |
| { |
| Elf32_Sword d_tag; /* Dynamic entry type */ |
| union |
| { |
| Elf32_Word d_val; /* Integer value */ |
| Elf32_Addr d_ptr; /* Address value */ |
| } d_un; |
| } Elf32_Dyn; |
| |
| typedef struct |
| { |
| Elf64_Sxword d_tag; /* Dynamic entry type */ |
| union |
| { |
| Elf64_Xword d_val; /* Integer value */ |
| Elf64_Addr d_ptr; /* Address value */ |
| } d_un; |
| } Elf64_Dyn; |
| |
| /* Legal values for d_tag (dynamic entry type). */ |
| |
| #define DT_NULL 0 /* Marks end of dynamic section */ |
| #define DT_NEEDED 1 /* Name of needed library */ |
| #define DT_PLTRELSZ 2 /* Size in bytes of PLT relocs */ |
| #define DT_PLTGOT 3 /* Processor defined value */ |
| #define DT_HASH 4 /* Address of symbol hash table */ |
| #define DT_STRTAB 5 /* Address of string table */ |
| #define DT_SYMTAB 6 /* Address of symbol table */ |
| #define DT_RELA 7 /* Address of Rela relocs */ |
| #define DT_RELASZ 8 /* Total size of Rela relocs */ |
| #define DT_RELAENT 9 /* Size of one Rela reloc */ |
| #define DT_STRSZ 10 /* Size of string table */ |
| #define DT_SYMENT 11 /* Size of one symbol table entry */ |
| #define DT_INIT 12 /* Address of init function */ |
| #define DT_FINI 13 /* Address of termination function */ |
| #define DT_SONAME 14 /* Name of shared object */ |
| #define DT_RPATH 15 /* Library search path (deprecated) */ |
| #define DT_SYMBOLIC 16 /* Start symbol search here */ |
| #define DT_REL 17 /* Address of Rel relocs */ |
| #define DT_RELSZ 18 /* Total size of Rel relocs */ |
| #define DT_RELENT 19 /* Size of one Rel reloc */ |
| #define DT_PLTREL 20 /* Type of reloc in PLT */ |
| #define DT_DEBUG 21 /* For debugging; unspecified */ |
| #define DT_TEXTREL 22 /* Reloc might modify .text */ |
| #define DT_JMPREL 23 /* Address of PLT relocs */ |
| #define DT_BIND_NOW 24 /* Process relocations of object */ |
| #define DT_INIT_ARRAY 25 /* Array with addresses of init fct */ |
| #define DT_FINI_ARRAY 26 /* Array with addresses of fini fct */ |
| #define DT_INIT_ARRAYSZ 27 /* Size in bytes of DT_INIT_ARRAY */ |
| #define DT_FINI_ARRAYSZ 28 /* Size in bytes of DT_FINI_ARRAY */ |
| #define DT_RUNPATH 29 /* Library search path */ |
| #define DT_FLAGS 30 /* Flags for the object being loaded */ |
| #define DT_ENCODING 32 /* Start of encoded range */ |
| #define DT_PREINIT_ARRAY 32 /* Array with addresses of preinit fct*/ |
| #define DT_PREINIT_ARRAYSZ 33 /* size in bytes of DT_PREINIT_ARRAY */ |
| #define DT_NUM 34 /* Number used */ |
| #define DT_LOOS 0x6000000d /* Start of OS-specific */ |
| #define DT_HIOS 0x6ffff000 /* End of OS-specific */ |
| #define DT_LOPROC 0x70000000 /* Start of processor-specific */ |
| #define DT_HIPROC 0x7fffffff /* End of processor-specific */ |
| #define DT_PROCNUM 0x32 /* Most used by any processor */ |
| |
| /* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the |
| Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's |
| approach. */ |
| #define DT_VALRNGLO 0x6ffffd00 |
| #define DT_GNU_PRELINKED 0x6ffffdf5 /* Prelinking timestamp */ |
| #define DT_GNU_CONFLICTSZ 0x6ffffdf6 /* Size of conflict section */ |
| #define DT_GNU_LIBLISTSZ 0x6ffffdf7 /* Size of library list */ |
| #define DT_CHECKSUM 0x6ffffdf8 |
| #define DT_PLTPADSZ 0x6ffffdf9 |
| #define DT_MOVEENT 0x6ffffdfa |
| #define DT_MOVESZ 0x6ffffdfb |
| #define DT_FEATURE_1 0x6ffffdfc /* Feature selection (DTF_*). */ |
| #define DT_POSFLAG_1 0x6ffffdfd /* Flags for DT_* entries, effecting |
| the following DT_* entry. */ |
| #define DT_SYMINSZ 0x6ffffdfe /* Size of syminfo table (in bytes) */ |
| #define DT_SYMINENT 0x6ffffdff /* Entry size of syminfo */ |
| #define DT_VALRNGHI 0x6ffffdff |
| #define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag)) /* Reverse order! */ |
| #define DT_VALNUM 12 |
| |
| /* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the |
| Dyn.d_un.d_ptr field of the Elf*_Dyn structure. |
| |
| If any adjustment is made to the ELF object after it has been |
| built these entries will need to be adjusted. */ |
| #define DT_ADDRRNGLO 0x6ffffe00 |
| #define DT_GNU_CONFLICT 0x6ffffef8 /* Start of conflict section */ |
| #define DT_GNU_LIBLIST 0x6ffffef9 /* Library list */ |
| #define DT_CONFIG 0x6ffffefa /* Configuration information. */ |
| #define DT_DEPAUDIT 0x6ffffefb /* Dependency auditing. */ |
| #define DT_AUDIT 0x6ffffefc /* Object auditing. */ |
| #define DT_PLTPAD 0x6ffffefd /* PLT padding. */ |
| #define DT_MOVETAB 0x6ffffefe /* Move table. */ |
| #define DT_SYMINFO 0x6ffffeff /* Syminfo table. */ |
| #define DT_ADDRRNGHI 0x6ffffeff |
| #define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag)) /* Reverse order! */ |
| #define DT_ADDRNUM 10 |
| |
| /* The versioning entry types. The next are defined as part of the |
| GNU extension. */ |
| #define DT_VERSYM 0x6ffffff0 |
| |
| #define DT_RELACOUNT 0x6ffffff9 |
| #define DT_RELCOUNT 0x6ffffffa |
| |
| /* These were chosen by Sun. */ |
| #define DT_FLAGS_1 0x6ffffffb /* State flags, see DF_1_* below. */ |
| #define DT_VERDEF 0x6ffffffc /* Address of version definition |
| table */ |
| #define DT_VERDEFNUM 0x6ffffffd /* Number of version definitions */ |
| #define DT_VERNEED 0x6ffffffe /* Address of table with needed |
| versions */ |
| #define DT_VERNEEDNUM 0x6fffffff /* Number of needed versions */ |
| #define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag)) /* Reverse order! */ |
| #define DT_VERSIONTAGNUM 16 |
| |
| /* Sun added these machine-independent extensions in the "processor-specific" |
| range. Be compatible. */ |
| #define DT_AUXILIARY 0x7ffffffd /* Shared object to load before self */ |
| #define DT_FILTER 0x7fffffff /* Shared object to get values from */ |
| #define DT_EXTRATAGIDX(tag) ((Elf32_Word)-((Elf32_Sword) (tag) <<1>>1)-1) |
| #define DT_EXTRANUM 3 |
| |
| /* Values of `d_un.d_val' in the DT_FLAGS entry. */ |
| #define DF_ORIGIN 0x00000001 /* Object may use DF_ORIGIN */ |
| #define DF_SYMBOLIC 0x00000002 /* Symbol resolutions starts here */ |
| #define DF_TEXTREL 0x00000004 /* Object contains text relocations */ |
| #define DF_BIND_NOW 0x00000008 /* No lazy binding for this object */ |
| #define DF_STATIC_TLS 0x00000010 /* Module uses the static TLS model */ |
| |
| /* State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 |
| entry in the dynamic section. */ |
| #define DF_1_NOW 0x00000001 /* Set RTLD_NOW for this object. */ |
| #define DF_1_GLOBAL 0x00000002 /* Set RTLD_GLOBAL for this object. */ |
| #define DF_1_GROUP 0x00000004 /* Set RTLD_GROUP for this object. */ |
| #define DF_1_NODELETE 0x00000008 /* Set RTLD_NODELETE for this object.*/ |
| #define DF_1_LOADFLTR 0x00000010 /* Trigger filtee loading at runtime.*/ |
| #define DF_1_INITFIRST 0x00000020 /* Set RTLD_INITFIRST for this object*/ |
| #define DF_1_NOOPEN 0x00000040 /* Set RTLD_NOOPEN for this object. */ |
| #define DF_1_ORIGIN 0x00000080 /* $ORIGIN must be handled. */ |
| #define DF_1_DIRECT 0x00000100 /* Direct binding enabled. */ |
| #define DF_1_TRANS 0x00000200 |
| #define DF_1_INTERPOSE 0x00000400 /* Object is used to interpose. */ |
| #define DF_1_NODEFLIB 0x00000800 /* Ignore default lib search path. */ |
| #define DF_1_NODUMP 0x00001000 /* Object can't be dldump'ed. */ |
| #define DF_1_CONFALT 0x00002000 /* Configuration alternative created.*/ |
| #define DF_1_ENDFILTEE 0x00004000 /* Filtee terminates filters search. */ |
| #define DF_1_DISPRELDNE 0x00008000 /* Disp reloc applied at build time. */ |
| #define DF_1_DISPRELPND 0x00010000 /* Disp reloc applied at run-time. */ |
| |
| /* Flags for the feature selection in DT_FEATURE_1. */ |
| #define DTF_1_PARINIT 0x00000001 |
| #define DTF_1_CONFEXP 0x00000002 |
| |
| /* Flags in the DT_POSFLAG_1 entry effecting only the next DT_* entry. */ |
| #define DF_P1_LAZYLOAD 0x00000001 /* Lazyload following object. */ |
| #define DF_P1_GROUPPERM 0x00000002 /* Symbols from next object are not |
| generally available. */ |
| |
| /* Special section indices. */ |
| |
| #define SHN_UNDEF 0 /* Undefined section */ |
| #define SHN_LORESERVE 0xff00 /* Start of reserved indices */ |
| #define SHN_LOPROC 0xff00 /* Start of processor-specific */ |
| #define SHN_HIPROC 0xff1f /* End of processor-specific */ |
| #define SHN_LOOS 0xff20 /* Start of OS-specific */ |
| #define SHN_HIOS 0xff3f /* End of OS-specific */ |
| #define SHN_ABS 0xfff1 /* Associated symbol is absolute */ |
| #define SHN_COMMON 0xfff2 /* Associated symbol is common */ |
| #define SHN_XINDEX 0xffff /* Index is in extra table. */ |
| #define SHN_HIRESERVE 0xffff /* End of reserved indices */ |
| |
| /* Legal values for sh_type (section type). */ |
| |
| #define SHT_NULL 0 /* Section header table entry unused */ |
| #define SHT_PROGBITS 1 /* Program data */ |
| #define SHT_SYMTAB 2 /* Symbol table */ |
| #define SHT_STRTAB 3 /* String table */ |
| #define SHT_RELA 4 /* Relocation entries with addends */ |
| #define SHT_HASH 5 /* Symbol hash table */ |
| #define SHT_DYNAMIC 6 /* Dynamic linking information */ |
| #define SHT_NOTE 7 /* Notes */ |
| #define SHT_NOBITS 8 /* Program space with no data (bss) */ |
| #define SHT_REL 9 /* Relocation entries, no addends */ |
| #define SHT_SHLIB 10 /* Reserved */ |
| #define SHT_DYNSYM 11 /* Dynamic linker symbol table */ |
| #define SHT_INIT_ARRAY 14 /* Array of constructors */ |
| #define SHT_FINI_ARRAY 15 /* Array of destructors */ |
| #define SHT_PREINIT_ARRAY 16 /* Array of pre-constructors */ |
| #define SHT_GROUP 17 /* Section group */ |
| #define SHT_SYMTAB_SHNDX 18 /* Extended section indeces */ |
| #define SHT_NUM 19 /* Number of defined types. */ |
| #define SHT_LOOS 0x60000000 /* Start OS-specific */ |
| #define SHT_GNU_LIBLIST 0x6ffffff7 /* Prelink library list */ |
| #define SHT_CHECKSUM 0x6ffffff8 /* Checksum for DSO content. */ |
| #define SHT_LOSUNW 0x6ffffffa /* Sun-specific low bound. */ |
| #define SHT_SUNW_move 0x6ffffffa |
| #define SHT_SUNW_COMDAT 0x6ffffffb |
| #define SHT_SUNW_syminfo 0x6ffffffc |
| #define SHT_GNU_verdef 0x6ffffffd /* Version definition section. */ |
| #define SHT_GNU_verneed 0x6ffffffe /* Version needs section. */ |
| #define SHT_GNU_versym 0x6fffffff /* Version symbol table. */ |
| #define SHT_HISUNW 0x6fffffff /* Sun-specific high bound. */ |
| #define SHT_HIOS 0x6fffffff /* End OS-specific type */ |
| #define SHT_LOPROC 0x70000000 /* Start of processor-specific */ |
| #define SHT_HIPROC 0x7fffffff /* End of processor-specific */ |
| #define SHT_LOUSER 0x80000000 /* Start of application-specific */ |
| #define SHT_HIUSER 0x8fffffff /* End of application-specific */ |
| |
| /* Legal values for sh_flags (section flags). */ |
| |
| #define SHF_WRITE (1 << 0) /* Writable */ |
| #define SHF_ALLOC (1 << 1) /* Occupies memory during execution */ |
| #define SHF_EXECINSTR (1 << 2) /* Executable */ |
| #define SHF_MERGE (1 << 4) /* Might be merged */ |
| #define SHF_STRINGS (1 << 5) /* Contains nul-terminated strings */ |
| #define SHF_INFO_LINK (1 << 6) /* `sh_info' contains SHT index */ |
| #define SHF_LINK_ORDER (1 << 7) /* Preserve order after combining */ |
| #define SHF_OS_NONCONFORMING (1 << 8) /* Non-standard OS specific handling |
| required */ |
| #define SHF_GROUP (1 << 9) /* Section is member of a group. */ |
| #define SHF_TLS (1 << 10) /* Section hold thread-local data. */ |
| #define SHF_MASKOS 0x0ff00000 /* OS-specific. */ |
| #define SHF_MASKPROC 0xf0000000 /* Processor-specific */ |
| |
| /* Section group handling. */ |
| #define GRP_COMDAT 0x1 /* Mark group as COMDAT. */ |
| |
| /* Symbol table entry. */ |
| |
| typedef struct |
| { |
| Elf32_Word st_name; /* Symbol name (string tbl index) */ |
| Elf32_Addr st_value; /* Symbol value */ |
| Elf32_Word st_size; /* Symbol size */ |
| unsigned char st_info; /* Symbol type and binding */ |
| unsigned char st_other; /* Symbol visibility */ |
| Elf32_Section st_shndx; /* Section index */ |
| } Elf32_Sym; |
| |
| typedef struct |
| { |
| Elf64_Word st_name; /* Symbol name (string tbl index) */ |
| unsigned char st_info; /* Symbol type and binding */ |
| unsigned char st_other; /* Symbol visibility */ |
| Elf64_Section st_shndx; /* Section index */ |
| Elf64_Addr st_value; /* Symbol value */ |
| Elf64_Xword st_size; /* Symbol size */ |
| } Elf64_Sym; |
| |
| /* Relocation table entry without addend (in section of type SHT_REL). */ |
| |
| typedef struct |
| { |
| Elf32_Addr r_offset; /* Address */ |
| Elf32_Word r_info; /* Relocation type and symbol index */ |
| } Elf32_Rel; |
| |
| /* I have seen two different definitions of the Elf64_Rel and |
| Elf64_Rela structures, so we'll leave them out until Novell (or |
| whoever) gets their act together. */ |
| /* The following, at least, is used on Sparc v9, MIPS, and Alpha. */ |
| |
| typedef struct |
| { |
| Elf64_Addr r_offset; /* Address */ |
| Elf64_Xword r_info; /* Relocation type and symbol index */ |
| } Elf64_Rel; |
| |
| /* Relocation table entry with addend (in section of type SHT_RELA). */ |
| |
| typedef struct |
| { |
| Elf32_Addr r_offset; /* Address */ |
| Elf32_Word r_info; /* Relocation type and symbol index */ |
| Elf32_Sword r_addend; /* Addend */ |
| } Elf32_Rela; |
| |
| typedef struct |
| { |
| Elf64_Addr r_offset; /* Address */ |
| Elf64_Xword r_info; /* Relocation type and symbol index */ |
| Elf64_Sxword r_addend; /* Addend */ |
| } Elf64_Rela; |
| |
| /* How to extract and insert information held in the r_info field. */ |
| |
| #define ELF32_R_SYM(val) ((val) >> 8) |
| #define ELF32_R_TYPE(val) ((val) & 0xff) |
| #define ELF32_R_INFO(sym, type) (((sym) << 8) + ((type) & 0xff)) |
| |
| #define ELF64_R_SYM(i) ((i) >> 32) |
| #define ELF64_R_TYPE(i) ((i) & 0xffffffff) |
| #define ELF64_R_INFO(sym,type) ((((Elf64_Xword) (sym)) << 32) + (type)) |
| |
| |
| /* Intel 80386 specific definitions. */ |
| |
| /* i386 relocs. */ |
| |
| #define R_386_NONE 0 /* No reloc */ |
| #define R_386_32 1 /* Direct 32 bit */ |
| #define R_386_PC32 2 /* PC relative 32 bit */ |
| #define R_386_GOT32 3 /* 32 bit GOT entry */ |
| #define R_386_PLT32 4 /* 32 bit PLT address */ |
| #define R_386_COPY 5 /* Copy symbol at runtime */ |
| #define R_386_GLOB_DAT 6 /* Create GOT entry */ |
| #define R_386_JMP_SLOT 7 /* Create PLT entry */ |
| #define R_386_RELATIVE 8 /* Adjust by program base */ |
| #define R_386_GOTOFF 9 /* 32 bit offset to GOT */ |
| #define R_386_GOTPC 10 /* 32 bit PC relative offset to GOT */ |
| #define R_386_32PLT 11 |
| #define R_386_TLS_TPOFF 14 /* Offset in static TLS block */ |
| #define R_386_TLS_IE 15 /* Address of GOT entry for static TLS |
| block offset */ |
| #define R_386_TLS_GOTIE 16 /* GOT entry for static TLS block |
| offset */ |
| #define R_386_TLS_LE 17 /* Offset relative to static TLS |
| block */ |
| #define R_386_TLS_GD 18 /* Direct 32 bit for GNU version of |
| general dynamic thread local data */ |
| #define R_386_TLS_LDM 19 /* Direct 32 bit for GNU version of |
| local dynamic thread local data |
| in LE code */ |
| #define R_386_16 20 |
| #define R_386_PC16 21 |
| #define R_386_8 22 |
| #define R_386_PC8 23 |
| #define R_386_TLS_GD_32 24 /* Direct 32 bit for general dynamic |
| thread local data */ |
| #define R_386_TLS_GD_PUSH 25 /* Tag for pushl in GD TLS code */ |
| #define R_386_TLS_GD_CALL 26 /* Relocation for call to |
| __tls_get_addr() */ |
| #define R_386_TLS_GD_POP 27 /* Tag for popl in GD TLS code */ |
| #define R_386_TLS_LDM_32 28 /* Direct 32 bit for local dynamic |
| thread local data in LE code */ |
| #define R_386_TLS_LDM_PUSH 29 /* Tag for pushl in LDM TLS code */ |
| #define R_386_TLS_LDM_CALL 30 /* Relocation for call to |
| __tls_get_addr() in LDM code */ |
| #define R_386_TLS_LDM_POP 31 /* Tag for popl in LDM TLS code */ |
| #define R_386_TLS_LDO_32 32 /* Offset relative to TLS block */ |
| #define R_386_TLS_IE_32 33 /* GOT entry for negated static TLS |
| block offset */ |
| #define R_386_TLS_LE_32 34 /* Negated offset relative to static |
| TLS block */ |
| #define R_386_TLS_DTPMOD32 35 /* ID of module containing symbol */ |
| #define R_386_TLS_DTPOFF32 36 /* Offset in TLS block */ |
| #define R_386_TLS_TPOFF32 37 /* Negated offset in static TLS block */ |
| /* Keep this the last entry. */ |
| #define R_386_NUM 38 |
| |
| #endif /* ASSEMBLY */ |
| |
| #endif /* ELF_H */ |