📄 elf_file.h
字号:
#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;/* The syminfo section if available contains additional information about every dynamic symbol. */typedef struct{ Elf32_Half si_boundto; /* Direct bindings, symbol bound to */ Elf32_Half si_flags; /* Per symbol flags */} Elf32_Syminfo;typedef struct{ Elf64_Half si_boundto; /* Direct bindings, symbol bound to */ Elf64_Half si_flags; /* Per symbol flags */} Elf64_Syminfo;/* Possible values for si_boundto. */#define SYMINFO_BT_SELF 0xffff /* Symbol bound to self */#define SYMINFO_BT_PARENT 0xfffe /* Symbol bound to parent */#define SYMINFO_BT_LOWRESERVE 0xff00 /* Beginning of reserved entries *//* Possible bitmasks for si_flags. */#define SYMINFO_FLG_DIRECT 0x0001 /* Direct bound symbol */#define SYMINFO_FLG_PASSTHRU 0x0002 /* Pass-thru symbol for translator */#define SYMINFO_FLG_COPY 0x0004 /* Symbol is a copy-reloc */#define SYMINFO_FLG_LAZYLOAD 0x0008 /* Symbol bound to object to be lazy loaded *//* Syminfo version values. */#define SYMINFO_NONE 0#define SYMINFO_CURRENT 1#define SYMINFO_NUM 2/* How to extract and insert information held in the st_info field. */#define ELF32_ST_BIND(val) (((unsigned char) (val)) >> 4)#define ELF32_ST_TYPE(val) ((val) & 0xf)#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))/* Both Elf32_Sym and Elf64_Sym use the same one-byte st_info field. */#define ELF64_ST_BIND(val) ELF32_ST_BIND (val)#define ELF64_ST_TYPE(val) ELF32_ST_TYPE (val)#define ELF64_ST_INFO(bind, type) ELF32_ST_INFO ((bind), (type))/* Legal values for ST_BIND subfield of st_info (symbol binding). */#define STB_LOCAL 0 /* Local symbol */#define STB_GLOBAL 1 /* Global symbol */#define STB_WEAK 2 /* Weak symbol */#define STB_NUM 3 /* Number of defined types. */#define STB_LOOS 10 /* Start of OS-specific */#define STB_HIOS 12 /* End of OS-specific */#define STB_LOPROC 13 /* Start of processor-specific */#define STB_HIPROC 15 /* End of processor-specific *//* Legal values for ST_TYPE subfield of st_info (symbol type). */#define STT_NOTYPE 0 /* Symbol type is unspecified */#define STT_OBJECT 1 /* Symbol is a data object */#define STT_FUNC 2 /* Symbol is a code object */#define STT_SECTION 3 /* Symbol associated with a section */#define STT_FILE 4 /* Symbol's name is file name */#define STT_COMMON 5 /* Symbol is a common data object */#define STT_TLS 6 /* Symbol is thread-local data object*/#define STT_NUM 7 /* Number of defined types. */#define STT_LOOS 10 /* Start of OS-specific */#define STT_HIOS 12 /* End of OS-specific */#define STT_LOPROC 13 /* Start of processor-specific */#define STT_HIPROC 15 /* End of processor-specific *//* Symbol table indices are found in the hash buckets and chain table of a symbol hash table section. This special index value indicates the end of a chain, meaning no further symbols are found in that bucket. */#define STN_UNDEF 0 /* End of a chain. *//* How to extract and insert information held in the st_other field. */#define ELF32_ST_VISIBILITY(o) ((o) & 0x03)/* For ELF64 the definitions are the same. */#define ELF64_ST_VISIBILITY(o) ELF32_ST_VISIBILITY (o)/* Symbol visibility specification encoded in the st_other field. */#define STV_DEFAULT 0 /* Default symbol visibility rules */#define STV_INTERNAL 1 /* Processor specific hidden class */#define STV_HIDDEN 2 /* Sym unavailable in other modules */#define STV_PROTECTED 3 /* Not preemptible, not exported *//* 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))/* Program segment header. */typedef struct{ Elf32_Word p_type; /* Segment type */ Elf32_Off p_offset; /* Segment file offset */ Elf32_Addr p_vaddr; /* Segment virtual address */ Elf32_Addr p_paddr; /* Segment physical address */ Elf32_Word p_filesz; /* Segment size in file */ Elf32_Word p_memsz; /* Segment size in memory */ Elf32_Word p_flags; /* Segment flags */ Elf32_Word p_align; /* Segment alignment */} Elf32_Phdr;typedef struct{ Elf64_Word p_type; /* Segment type */ Elf64_Word p_flags; /* Segment flags */ Elf64_Off p_offset; /* Segment file offset */ Elf64_Addr p_vaddr; /* Segment virtual address */ Elf64_Addr p_paddr; /* Segment physical address */ Elf64_Xword p_filesz; /* Segment size in file */ Elf64_Xword p_memsz; /* Segment size in memory */ Elf64_Xword p_align; /* Segment alignment */} Elf64_Phdr;/* Legal values for p_type (segment type). */#define PT_NULL 0 /* Program header table entry unused */#define PT_LOAD 1 /* Loadable program segment */#define PT_DYNAMIC 2 /* Dynamic linking information */#define PT_INTERP 3 /* Program interpreter */#define PT_NOTE 4 /* Auxiliary information */#define PT_SHLIB 5 /* Reserved */#define PT_PHDR 6 /* Entry for header table itself */#define PT_TLS 7 /* Thread-local storage segment */#define PT_NUM 8 /* Number of defined types */#define PT_LOOS 0x60000000 /* Start of OS-specific */#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */#define PT_LOSUNW 0x6ffffffa#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */#define PT_HISUNW 0x6fffffff#define PT_HIOS 0x6fffffff /* End of OS-specific */#define PT_LOPROC 0x70000000 /* Start of processor-specific */#define PT_HIPROC 0x7fffffff /* End of processor-specific *//* Legal values for p_flags (segment flags). */#define PF_X (1 << 0) /* Segment is executable */#define PF_W (1 << 1) /* Segment is writable */#define PF_R (1 << 2) /* Segment is readable */#define PF_MASKOS 0x0ff00000 /* OS-specific */#define PF_MASKPROC 0xf0000000 /* Processor-specific *//* Legal values for note segment descriptor types for core files. */#define NT_PRSTATUS 1 /* Contains copy of prstatus struct */#define NT_FPREGSET 2 /* Contains copy of fpregset struct */#define NT_PRPSINFO 3 /* Contains copy of prpsinfo struct */#define NT_PRXREG 4 /* Contains copy of prxregset struct */#define NT_TASKSTRUCT 4 /* Contains copy of task structure */#define NT_PLATFORM 5 /* String from sysinfo(SI_PLATFORM) */#define NT_AUXV 6 /* Contains copy of auxv array */#define NT_GWINDOWS 7 /* Contains copy of gwindows struct */#define NT_ASRS 8 /* Contains copy of asrset struct */#define NT_PSTATUS 10 /* Contains copy of pstatus struct */#define NT_PSINFO 13 /* Contains copy of psinfo struct */#define NT_PRCRED 14 /* Contains copy of prcred struct */#define NT_UTSNAME 15 /* Contains copy of utsname struct */#define NT_LWPSTATUS 16 /* Contains copy of lwpstatus struct */#define NT_LWPSINFO 17 /* Contains copy of lwpinfo struct */#define NT_PRFPXREG 20 /* Contains copy of fprxregset struct*//* Legal values for the note segment descriptor types for object files. */#define NT_VERSION 1 /* Contains a version string. *//* 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 DT_MIPS_NUM /* 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 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -