-
Notifications
You must be signed in to change notification settings - Fork 9
/
elf_reloc_x86_64.h
94 lines (81 loc) · 2.23 KB
/
elf_reloc_x86_64.h
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* elf_reloc_x86_64.h ELF relocation types for x86 64-bit architecture */
/* (c) in 2011 by Frank Wille */
#define R_X86_64_NONE 0
#define R_X86_64_64 1
#define R_X86_64_PC32 2
#define R_X86_64_GOT32 3
#define R_X86_64_PLT32 4
#define R_X86_64_COPY 5
#define R_X86_64_GLOB_DAT 6
#define R_X86_64_JUMP_SLOT 7
#define R_X86_64_RELATIVE 8
#define R_X86_64_GOTPCREL 9
#define R_X86_64_32 10
#define R_X86_64_32S 11
#define R_X86_64_16 12
#define R_X86_64_PC16 13
#define R_X86_64_8 14
#define R_X86_64_PC8 15
/* TLS relocations */
#define R_X86_64_DTPMOD64 16
#define R_X86_64_DTPOFF64 17
#define R_X86_64_TPOFF64 18
#define R_X86_64_TLSGD 19
#define R_X86_64_TLSLD 20
#define R_X86_64_DTPOFF32 21
#define R_X86_64_GOTTPOFF 22
#define R_X86_64_TPOFF32 23
if ((*rl)->type <= LAST_STANDARD_RELOC) {
nreloc *r = (nreloc *)(*rl)->reloc;
*refsym = r->sym;
*addend = r->addend;
pos = r->bitoffset;
size = r->size;
*roffset = r->byteoffset;
mask = r->mask;
switch ((*rl)->type) {
case REL_NONE:
t = R_X86_64_NONE;
break;
case REL_ABS:
if (pos==0 && mask==~0) {
if (size == 64)
t = R_X86_64_64;
else if (size == 32)
t = R_X86_64_32;
else if (size == 16)
t = R_X86_64_16;
else if (size == 8)
t = R_X86_64_8;
}
break;
case REL_PC:
if (pos==0 && mask==~0) {
if (size == 32)
t = R_X86_64_PC32;
else if (size == 16)
t = R_X86_64_PC16;
else if (size == 8)
t = R_X86_64_PC8;
}
break;
case REL_GOT:
if (pos==0 && mask==~0) {
if (size == 32)
t = R_X86_64_GOT32;
}
break;
case REL_GOTPC:
if (pos==0 && mask==~0) {
if (size == 32)
t = R_X86_64_GOTPCREL;
}
break;
case REL_PLT:
if (pos==0 && mask==~0) {
if (size == 32)
t = R_X86_64_PLT32;
}
break;
}
}