📄 elf.h
字号:
#define ELF_GOT ".got" /* global offset table */#define ELF_HASH ".hash" /* symbol hash table */#define ELF_INIT ".init" /* initialization code */#define ELF_INIT_ARRAY ".init_array" /* Array of constuctors */#define ELF_INTERP ".interp" /* Pathname of program interpreter */#define ELF_LINE ".line" /* Symbolic line numnber information */#define ELF_NOTE ".note" /* Contains note section */#define ELF_PLT ".plt" /* Procedure linkage table */#define ELF_PREINIT_ARRAY ".preinit_array" /* Array of pre-constructors */#define ELF_REL_DATA ".rel.data" /* relocation data */#define ELF_REL_FINI ".rel.fini" /* relocation termination code */#define ELF_REL_INIT ".rel.init" /* relocation initialization code */#define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */#define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */#define ELF_REL_TEXT ".rel.text" /* relocation code */#define ELF_RODATA ".rodata" /* read-only data */#define ELF_RODATA1 ".rodata1" /* read-only data */#define ELF_SHSTRTAB ".shstrtab" /* section header string table */#define ELF_STRTAB ".strtab" /* string table */#define ELF_SYMTAB ".symtab" /* symbol table */#define ELF_SYMTAB_SHNDX ".symtab_shndx"/* symbol table section index */#define ELF_TBSS ".tbss" /* thread local uninit data */#define ELF_TDATA ".tdata" /* thread local init data */#define ELF_TDATA1 ".tdata1" /* thread local init data */#define ELF_TEXT ".text" /* code *//* Section Attribute Flags - sh_flags */#define SHF_WRITE 0x1 /* Writable */#define SHF_ALLOC 0x2 /* occupies memory */#define SHF_EXECINSTR 0x4 /* executable */#define SHF_MERGE 0x10 /* Might be merged */#define SHF_STRINGS 0x20 /* Contains NULL terminated strings */#define SHF_INFO_LINK 0x40 /* sh_info contains SHT index */#define SHF_LINK_ORDER 0x80 /* Preserve order after combining*/#define SHF_OS_NONCONFORMING 0x100 /* Non-standard OS specific handling */#define SHF_GROUP 0x200 /* Member of section group */#define SHF_TLS 0x400 /* Thread local storage */#define SHF_MASKOS 0x0ff00000 /* OS specific */#define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */ /* specific section attributes *//* Section Group Flags */#define GRP_COMDAT 0x1 /* COMDAT group */#define GRP_MASKOS 0x0ff00000 /* Mask OS specific flags */#define GRP_MASKPROC 0xf0000000 /* Mask processor specific flags *//* Symbol Table Entry */typedef struct elf32_sym { Elf32_Word st_name; /* name - index into string table */ Elf32_Addr st_value; /* symbol value */ Elf32_Word st_size; /* symbol size */ unsigned char st_info; /* type and binding */ unsigned char st_other; /* 0 - no defined meaning */ Elf32_Half st_shndx; /* section header index */} Elf32_Sym;/* Symbol table index */#define STN_UNDEF 0 /* undefined *//* Extract symbol info - st_info */#define ELF32_ST_BIND(x) ((x) >> 4)#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)#define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))#define ELF32_ST_VISIBILITY(x) ((x) & 0x3)/* Symbol Binding - ELF32_ST_BIND - st_info */#define STB_LOCAL 0 /* Local symbol */#define STB_GLOBAL 1 /* Global symbol */#define STB_WEAK 2 /* like global - lower precedence */#define STB_NUM 3 /* number of symbol bindings */#define STB_LOOS 10 /* reserved range for operating */#define STB_HIOS 12 /* system specific symbol bindings */#define STB_LOPROC 13 /* reserved range for processor */#define STB_HIPROC 15 /* specific symbol bindings *//* Symbol type - ELF32_ST_TYPE - st_info */#define STT_NOTYPE 0 /* not specified */#define STT_OBJECT 1 /* data object */#define STT_FUNC 2 /* function */#define STT_SECTION 3 /* section */#define STT_FILE 4 /* file */#define STT_NUM 5 /* number of symbol types */#define STT_TLS 6 /* Thread local storage symbol */#define STT_LOOS 10 /* reserved range for operating */#define STT_HIOS 12 /* system specific symbol types */#define STT_LOPROC 13 /* reserved range for processor */#define STT_HIPROC 15 /* specific symbol types *//* Symbol visibility - ELF32_ST_VISIBILITY - st_other */#define STV_DEFAULT 0 /* Normal visibility rules */#define STV_INTERNAL 1 /* Processor specific hidden class */#define STV_HIDDEN 2 /* Symbol unavailable in other mods */#define STV_PROTECTED 3 /* Not preemptible, not exported *//* Relocation entry with implicit addend */typedef struct{ Elf32_Addr r_offset; /* offset of relocation */ Elf32_Word r_info; /* symbol table index and type */} Elf32_Rel;/* Relocation entry with explicit addend */typedef struct{ Elf32_Addr r_offset; /* offset of relocation */ Elf32_Word r_info; /* symbol table index and type */ Elf32_Sword r_addend;} Elf32_Rela;/* Extract relocation info - r_info */#define ELF32_R_SYM(i) ((i) >> 8)#define ELF32_R_TYPE(i) ((unsigned char) (i))#define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t))/* Program Header */typedef struct { Elf32_Word p_type; /* segment type */ Elf32_Off p_offset; /* segment offset */ Elf32_Addr p_vaddr; /* virtual address of segment */ Elf32_Addr p_paddr; /* physical address - ignored? */ Elf32_Word p_filesz; /* number of bytes in file for seg. */ Elf32_Word p_memsz; /* number of bytes in mem. for seg. */ Elf32_Word p_flags; /* flags */ Elf32_Word p_align; /* memory alignment */} Elf32_Phdr;/* Segment types - p_type */#define PT_NULL 0 /* unused */#define PT_LOAD 1 /* loadable segment */#define PT_DYNAMIC 2 /* dynamic linking section */#define PT_INTERP 3 /* the RTLD */#define PT_NOTE 4 /* auxiliary information */#define PT_SHLIB 5 /* reserved - purpose undefined */#define PT_PHDR 6 /* program header */#define PT_TLS 7 /* Thread local storage template */#define PT_NUM 8 /* Number of segment types */#define PT_LOOS 0x60000000 /* reserved range for operating */#define PT_HIOS 0x6fffffff /* system specific segment types */#define PT_LOPROC 0x70000000 /* reserved range for processor */#define PT_HIPROC 0x7fffffff /* specific segment types *//* Segment flags - p_flags */#define PF_X 0x1 /* Executable */#define PF_W 0x2 /* Writable */#define PF_R 0x4 /* Readable */#define PF_MASKOS 0x0ff00000 /* OS specific segment flags */#define PF_MASKPROC 0xf0000000 /* reserved bits for processor */ /* specific segment flags *//* Dynamic structure */typedef struct{ Elf32_Sword d_tag; /* controls meaning of d_val */ union { Elf32_Word d_val; /* Multiple meanings - see d_tag */ Elf32_Addr d_ptr; /* program virtual address */ } d_un;} Elf32_Dyn;extern Elf32_Dyn _DYNAMIC[];/* Dynamic Array Tags - d_tag */#define DT_NULL 0 /* marks end of _DYNAMIC array */#define DT_NEEDED 1 /* string table offset of needed lib */#define DT_PLTRELSZ 2 /* size of relocation entries in PLT */#define DT_PLTGOT 3 /* address PLT/GOT */#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 relocation table */#define DT_RELASZ 8 /* size of relocation table */#define DT_RELAENT 9 /* size of relocation entry */#define DT_STRSZ 10 /* size of string table */#define DT_SYMENT 11 /* size of symbol table entry */#define DT_INIT 12 /* address of initialization func. */#define DT_FINI 13 /* address of termination function */#define DT_SONAME 14 /* string table offset of shared obj */#define DT_RPATH 15 /* string table offset of library search path */#define DT_SYMBOLIC 16 /* start sym search in shared obj. */#define DT_REL 17 /* address of rel. tbl. w addends */#define DT_RELSZ 18 /* size of DT_REL relocation table */#define DT_RELENT 19 /* size of DT_REL relocation entry */#define DT_PLTREL 20 /* PLT referenced relocation entry */#define DT_DEBUG 21 /* bugger */#define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */#define DT_JMPREL 23 /* add. of PLT's relocation entries */#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 0x60000000 /* reserved range for OS */#define DT_HIOS 0x6fffffff /* specific dynamic array tags */#define DT_LOPROC 0x70000000 /* reserved range for processor */#define DT_HIPROC 0x7fffffff /* specific dynamic array tags *//* Dynamic Tag Flags - d_un.d_val */#define DF_ORIGIN 0x01 /* Object may use DF_ORIGIN */#define DF_SYMBOLIC 0x02 /* Symbol resolutions starts here */#define DF_TEXTREL 0x04 /* Object contains text relocations */#define DF_BIND_NOW 0x08 /* No lazy binding for this object */#define DF_STATIC_TLS 0x10 /* Static thread local storage *//* Standard ELF hashing function */unsigned long elf_hash(const unsigned char *name);#define ELF_TARG_VER 1 /* The ver for which this code is intended *//* * XXX - PowerPC defines really don't belong in here, * but we'll put them in for simplicity. *//* Values for Elf32/64_Ehdr.e_flags. */#define EF_PPC_EMB 0x80000000 /* PowerPC embedded flag *//* Cygnus local bits below */#define EF_PPC_RELOCATABLE 0x00010000 /* PowerPC -mrelocatable flag*/#define EF_PPC_RELOCATABLE_LIB 0x00008000 /* PowerPC -mrelocatable-lib flag *//* PowerPC relocations defined by the ABIs */#define R_PPC_NONE 0#define R_PPC_ADDR32 1 /* 32bit absolute address */#define R_PPC_ADDR24 2 /* 26bit address, 2 bits ignored. */#define R_PPC_ADDR16 3 /* 16bit absolute address */#define R_PPC_ADDR16_LO 4 /* lower 16bit of absolute address */#define R_PPC_ADDR16_HI 5 /* high 16bit of absolute address */#define R_PPC_ADDR16_HA 6 /* adjusted high 16bit */#define R_PPC_ADDR14 7 /* 16bit address, 2 bits ignored */#define R_PPC_ADDR14_BRTAKEN 8#define R_PPC_ADDR14_BRNTAKEN 9#define R_PPC_REL24 10 /* PC relative 26 bit */#define R_PPC_REL14 11 /* PC relative 16 bit */#define R_PPC_REL14_BRTAKEN 12#define R_PPC_REL14_BRNTAKEN 13#define R_PPC_GOT16 14#define R_PPC_GOT16_LO 15#define R_PPC_GOT16_HI 16#define R_PPC_GOT16_HA 17#define R_PPC_PLTREL24 18#define R_PPC_COPY 19#define R_PPC_GLOB_DAT 20#define R_PPC_JMP_SLOT 21#define R_PPC_RELATIVE 22#define R_PPC_LOCAL24PC 23#define R_PPC_UADDR32 24#define R_PPC_UADDR16 25#define R_PPC_REL32 26#define R_PPC_PLT32 27#define R_PPC_PLTREL32 28#define R_PPC_PLT16_LO 29#define R_PPC_PLT16_HI 30#define R_PPC_PLT16_HA 31#define R_PPC_SDAREL16 32#define R_PPC_SECTOFF 33#define R_PPC_SECTOFF_LO 34#define R_PPC_SECTOFF_HI 35#define R_PPC_SECTOFF_HA 36/* Keep this the last entry. */#define R_PPC_NUM 37/* The remaining relocs are from the Embedded ELF ABI, and are not in the SVR4 ELF ABI. */#define R_PPC_EMB_NADDR32 101#define R_PPC_EMB_NADDR16 102#define R_PPC_EMB_NADDR16_LO 103#define R_PPC_EMB_NADDR16_HI 104#define R_PPC_EMB_NADDR16_HA 105#define R_PPC_EMB_SDAI16 106#define R_PPC_EMB_SDA2I16 107#define R_PPC_EMB_SDA2REL 108#define R_PPC_EMB_SDA21 109 /* 16 bit offset in SDA */#define R_PPC_EMB_MRKREF 110#define R_PPC_EMB_RELSEC16 111#define R_PPC_EMB_RELST_LO 112#define R_PPC_EMB_RELST_HI 113#define R_PPC_EMB_RELST_HA 114#define R_PPC_EMB_BIT_FLD 115#define R_PPC_EMB_RELSDA 116 /* 16 bit relative offset in SDA *//* Diab tool relocations. */#define R_PPC_DIAB_SDA21_LO 180 /* like EMB_SDA21, but lower 16 bit */#define R_PPC_DIAB_SDA21_HI 181 /* like EMB_SDA21, but high 16 bit */#define R_PPC_DIAB_SDA21_HA 182 /* like EMB_SDA21, adjusted high 16 */#define R_PPC_DIAB_RELSDA_LO 183 /* like EMB_RELSDA, but lower 16 bit */#define R_PPC_DIAB_RELSDA_HI 184 /* like EMB_RELSDA, but high 16 bit */#define R_PPC_DIAB_RELSDA_HA 185 /* like EMB_RELSDA, adjusted high 16 *//* This is a phony reloc to handle any old fashioned TOC16 references that may still be in object files. */#define R_PPC_TOC16 255#endif /* _ELF_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -