xv6-simplified
0.1
简化版xv6
Loading...
Searching...
No Matches
src
include
elf.h
Go to the documentation of this file.
1
10
#define ELF_MAGIC 0x464C457FU
// 小端
11
12
// 文件头
13
struct
elfhdr
{
14
uint
magic
;
// 魔数,必须等于ELF_MAGIC
15
uchar
elf
[12];
// 类型等信息
16
ushort
type
;
// 文件类型,如可执行文件、目标文件等
17
ushort
machine
;
// 目标机器类型
18
uint
version
;
// 文件版本
19
uint64
entry
;
// 程序入口地址
20
uint64
phoff
;
// program header表在文件中的偏移
21
uint64
shoff
;
// section header表在文件中的偏移
22
uint
flags
;
// 一些标识信息
23
ushort
ehsize
;
// elf header大小
24
ushort
phentsize
;
// program header表中每个条目大小
25
ushort
phnum
;
// program header表中条目数量
26
ushort
shentsize
;
// section header表中每个条目大小
27
ushort
shnum
;
// section header表中条目数量
28
ushort
shstrndx
;
// 包含节名称字符串表的节头索引
29
};
30
31
// 程序段头部
32
// 程序头表项描述了一个加载段(Loadable Segment)在可执行文件中的位置和大小信息
33
struct
proghdr
34
{
35
// 这个程序头表项的类型,可能的值:PT_NULL, PT_LOAD, PT_DYNAMIC, PT_INTERP, PT_NOTE, PT_SHLIB, PT_PHDR等
36
uint32
type
;
37
uint32
flags
;
// 程序头表项的标志信息
38
uint64
off
;
// 程序头表项的第一个字节在文件中的偏移量
39
uint64
vaddr
;
// 程序头表项的第一个字节在内存中的虚拟地址
40
uint64
paddr
;
// 程序头表项的第一个字节在内存中的物理地址
41
uint64
filesz
;
// 程序头表项在文件中的大小(字节)
42
uint64
memsz
;
// 程序头表项在内存中的大小(字节)
43
uint64
align
;
// 程序头表项在文件和内存中的对齐方式
44
};
45
46
// proghdr类型的值
47
#define ELF_PROG_LOAD 1
48
49
// proghdr的flags的标志位
50
#define ELF_PROG_FLAG_EXEC 1
51
#define ELF_PROG_FLAG_WRITE 2
52
#define ELF_PROG_FLAG_READ 4
53
elfhdr
Definition
elf.h:13
elfhdr::shoff
uint64 shoff
Definition
elf.h:21
elfhdr::phentsize
ushort phentsize
Definition
elf.h:24
elfhdr::machine
ushort machine
Definition
elf.h:17
elfhdr::phoff
uint64 phoff
Definition
elf.h:20
elfhdr::shnum
ushort shnum
Definition
elf.h:27
elfhdr::flags
uint flags
Definition
elf.h:22
elfhdr::ehsize
ushort ehsize
Definition
elf.h:23
elfhdr::shstrndx
ushort shstrndx
Definition
elf.h:28
elfhdr::magic
uint magic
Definition
elf.h:14
elfhdr::phnum
ushort phnum
Definition
elf.h:25
elfhdr::entry
uint64 entry
Definition
elf.h:19
elfhdr::version
uint version
Definition
elf.h:18
elfhdr::elf
uchar elf[12]
Definition
elf.h:15
elfhdr::shentsize
ushort shentsize
Definition
elf.h:26
elfhdr::type
ushort type
Definition
elf.h:16
proghdr
Definition
elf.h:34
proghdr::paddr
uint64 paddr
Definition
elf.h:40
proghdr::vaddr
uint64 vaddr
Definition
elf.h:39
proghdr::off
uint64 off
Definition
elf.h:38
proghdr::flags
uint32 flags
Definition
elf.h:37
proghdr::align
uint64 align
Definition
elf.h:43
proghdr::filesz
uint64 filesz
Definition
elf.h:41
proghdr::memsz
uint64 memsz
Definition
elf.h:42
proghdr::type
uint32 type
Definition
elf.h:36
uint32
unsigned int uint32
Definition
types.h:22
uint64
unsigned long uint64
Definition
types.h:24
uchar
unsigned char uchar
Definition
types.h:15
uint
unsigned int uint
Definition
types.h:11
ushort
unsigned short ushort
Definition
types.h:13
Generated by
1.9.7