File tree Expand file tree Collapse file tree 2 files changed +89
-0
lines changed
lib/ExecutionEngine/JITLink
test/ExecutionEngine/JITLink/X86 Expand file tree Collapse file tree 2 files changed +89
-0
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ class ELFLinkGraphBuilder_x86_64 : public ELFLinkGraphBuilder<object::ELF64LE> {
108
108
109
109
enum ELFX86RelocationKind : Edge::Kind {
110
110
Branch32 = Edge::FirstRelocation,
111
+ Pointer32,
111
112
Pointer32Signed,
112
113
Pointer64,
113
114
PCRel32,
@@ -123,6 +124,8 @@ class ELFLinkGraphBuilder_x86_64 : public ELFLinkGraphBuilder<object::ELF64LE> {
123
124
124
125
static Expected<ELFX86RelocationKind> getRelocationKind (const uint32_t Type) {
125
126
switch (Type) {
127
+ case ELF::R_X86_64_32:
128
+ return ELFX86RelocationKind::Pointer32;
126
129
case ELF::R_X86_64_32S:
127
130
return ELFX86RelocationKind::Pointer32Signed;
128
131
case ELF::R_X86_64_PC32:
@@ -207,6 +210,9 @@ class ELFLinkGraphBuilder_x86_64 : public ELFLinkGraphBuilder<object::ELF64LE> {
207
210
case Delta64:
208
211
Kind = x86_64::Delta64;
209
212
break ;
213
+ case Pointer32:
214
+ Kind = x86_64::Pointer32;
215
+ break ;
210
216
case Pointer32Signed:
211
217
Kind = x86_64::Pointer32Signed;
212
218
break ;
Original file line number Diff line number Diff line change
1
+ # Check success and failure cases of R_X86_64_32 handling.
2
+ # This file contains a single R_X86_64_32 relocation. We expect the relocation
3
+ # to apply successfully when we assign x an address in the low 32-bits of the
4
+ # address space, and fail if we assign x an address outside that range.
5
+
6
+ # RUN: yaml2obj -o %t.o %s
7
+ # RUN: llvm-jitlink -abs x=0x12345678 -noexec -check=%s %t.o
8
+ # RUN: not llvm-jitlink -abs x=0x123456789 -noexec %t.o 2>&1 | \
9
+ # RUN: FileCheck -check-prefix=CHECK-ERROR %s
10
+
11
+ # jitlink-check: *{8}xptr = x
12
+
13
+ # CHECK-ERROR: relocation target "x" {{.*}} is out of range of Pointer32 fixup
14
+
15
+ --- !ELF
16
+ FileHeader :
17
+ Class : ELFCLASS64
18
+ Data : ELFDATA2LSB
19
+ Type : ET_REL
20
+ Machine : EM_X86_64
21
+ SectionHeaderStringTable : .strtab
22
+ Sections :
23
+ - Name : .text
24
+ Type : SHT_PROGBITS
25
+ Flags : [ SHF_ALLOC, SHF_EXECINSTR ]
26
+ AddressAlign : 0x10
27
+ Content : 31C0C3
28
+ - Name : .data
29
+ Type : SHT_PROGBITS
30
+ Flags : [ SHF_WRITE, SHF_ALLOC ]
31
+ AddressAlign : 0x8
32
+ Content : ' 0000000000000000'
33
+ - Name : .comment
34
+ Type : SHT_PROGBITS
35
+ Flags : [ SHF_MERGE, SHF_STRINGS ]
36
+ AddressAlign : 0x1
37
+ EntSize : 0x1
38
+ Content : 00636C616E672076657273696F6E2031372E302E302028676974406769746875622E636F6D3A6C6C766D2F6C6C766D2D70726F6A6563742E67697420393361303461303539316331393538643533343466333534313135376662643862386666373337302900
39
+ - Name : .note.GNU-stack
40
+ Type : SHT_PROGBITS
41
+ AddressAlign : 0x1
42
+ - Name : .rela.data
43
+ Type : SHT_RELA
44
+ Flags : [ SHF_INFO_LINK ]
45
+ Link : .symtab
46
+ AddressAlign : 0x8
47
+ Info : .data
48
+ Relocations :
49
+ - Symbol : x
50
+ Type : R_X86_64_32
51
+ - Name : .llvm_addrsig
52
+ Type : SHT_LLVM_ADDRSIG
53
+ Flags : [ SHF_EXCLUDE ]
54
+ Link : .symtab
55
+ AddressAlign : 0x1
56
+ Symbols : [ x ]
57
+ - Type : SectionHeaderTable
58
+ Sections :
59
+ - Name : .strtab
60
+ - Name : .text
61
+ - Name : .data
62
+ - Name : .rela.data
63
+ - Name : .comment
64
+ - Name : .note.GNU-stack
65
+ - Name : .llvm_addrsig
66
+ - Name : .symtab
67
+ Symbols :
68
+ - Name : testcase.c
69
+ Type : STT_FILE
70
+ Index : SHN_ABS
71
+ - Name : main
72
+ Type : STT_FUNC
73
+ Section : .text
74
+ Binding : STB_GLOBAL
75
+ Size : 0x3
76
+ - Name : xptr
77
+ Type : STT_OBJECT
78
+ Section : .data
79
+ Binding : STB_GLOBAL
80
+ Size : 0x8
81
+ - Name : x
82
+ Binding : STB_GLOBAL
83
+ ...
You can’t perform that action at this time.
0 commit comments