-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelfdef.go
53 lines (45 loc) · 1019 Bytes
/
elfdef.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package main
// EiNident 定义ELF文件的魔数字节的数量
const EiNident = 16
// ElfMagic 定义ELF文件的魔术字节为全局常量
const ElfMagic = "\x7fELF"
// EmRiscV 规定了CPU架构
const EmRiscV = 243
// EiClass Elf文件位数相关
const EiClass = 4
const ElfClassNone = 0
const ElfClass32 = 1
const ElfClass64 = 2
const ElfClassSum = 3
// Elf64PhdrPTypeLoad 代表这个段是否是要加载到内存的
const Elf64PhdrPTypeLoad = 1
// PFX 标识LEF文件中这个segment段的属性
const PFX = 0x1
const PFW = 0x2
const PFR = 0x4
type Elf64EhdrT struct {
EIdent [EiNident]uint8
EType uint16
EMachine uint16
EVersion uint32
EEntry uint64
EPhoff uint64
EShoff uint64
EFlags uint32
EEhsize uint16
EPhentsize uint16
EPhnum uint16
EShentsize uint16
EShnum uint16
EShstrndx uint16
}
type Elf64PhdrT struct {
PType uint32
PFlags uint32
POffset uint64
PVaddr uint64
PPaddr uint64
PFilesz uint64
PMemsz uint64
PAlign uint64
}