Ai
1 Star 0 Fork 0

博尔特烦恼/hello-elf

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
elf.h 4.53 KB
一键复制 编辑 原始数据 按行查看 历史
博尔特烦恼 提交于 2020-12-17 17:35 +08:00 . hello test gitlab aliyun
#ifndef ELF_H
#define ELF_H
//#include <sys/stat.h>
//#include <sys/types.h>
//#include <unistd.h>
//#include <fcntl.h>
#define EI_NIDENT (16)
struct Elf32_Ehdr
{
unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
unsigned short e_type; /* Object file type */
unsigned short e_machine; /* Architecture */
unsigned int e_version; /* Object file version */
unsigned int e_entry; /* Entry point virtual address */
unsigned int e_phoff; /* Program header table file offset */
unsigned int e_shoff; /* Section header table file offset */
unsigned int e_flags; /* Processor-specific flags */
unsigned short e_ehsize; /* ELF header size in bytes */
unsigned short e_phentsize; /* Program header table entry size */
unsigned short e_phnum; /* Program header table entry count */
unsigned short e_shentsize; /* Section header table entry size */
unsigned short e_shnum; /* Section header table entry count */
unsigned short e_shstrndx; /* Section header string table index */
};
struct Elf64_Ehdr
{
unsigned char e_ident[EI_NIDENT]; /* Magic number and other info */
unsigned short e_type; /* Object file type */
unsigned short e_machine; /* Architecture */
unsigned int e_version; /* Object file version */
unsigned long long e_entry; /* Entry point virtual address */
unsigned long long e_phoff; /* Program header table file offset */
unsigned long long e_shoff; /* Section header table file offset */
unsigned int e_flags; /* Processor-specific flags */
unsigned short e_ehsize; /* ELF header size in bytes */
unsigned short e_phentsize; /* Program header table entry size */
unsigned short e_phnum; /* Program header table entry count */
unsigned short e_shentsize; /* Section header table entry size */
unsigned short e_shnum; /* Section header table entry count */
unsigned short e_shstrndx; /* Section header string table index */
};
struct Elf64_Shdr
{
unsigned int sh_name; /* Section name (string tbl index) */
unsigned int sh_type; /* Section type */
unsigned long long sh_flags; /* Section flags */
unsigned long long sh_addr; /* Section virtual addr at execution */
unsigned long long sh_offset; /* Section file offset */
unsigned long long sh_size; /* Section size in bytes */
unsigned int sh_link; /* Link to another section */
unsigned int sh_info; /* Additional section information */
unsigned long long sh_addralign; /* Section alignment */
unsigned long long sh_entsize; /* Entry size if section holds table */
} ;
struct Elf64_Dyn
{
long long d_tag; /* Dynamic entry type */
union
{
unsigned long long d_val; /* Integer value */
unsigned long long d_ptr; /* Address value */
} d_un;
} ;
struct Elf64_Phdr
{
unsigned int p_type; /* Segment type */
unsigned int p_flags; /* Segment flags */
unsigned long long p_offset; /* Segment file offset */
unsigned long long p_vaddr; /* Segment virtual address */
unsigned long long p_paddr; /* Segment physical address */
unsigned long long p_filesz; /* Segment size in file */
unsigned long long p_memsz; /* Segment size in memory */
unsigned long long p_align; /* Segment alignment */
} ;
/* 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 */
/* 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 */
#endif
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/home-coder/hello-elf.git
git@gitee.com:home-coder/hello-elf.git
home-coder
hello-elf
hello-elf
master

搜索帮助