Skip to content

Commit 8308e81

Browse files
committed
[JITLink][ELF][x86-64] Implement ELF::R_X86_64_NONE.
R_X86_64_NONE is a no-op, so we just need to return from addSingleRelocation early.
1 parent 06fd423 commit 8308e81

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ class ELFLinkGraphBuilder_x86_64 : public ELFLinkGraphBuilder<object::ELF64LE> {
129129
Block &BlockToFix) {
130130
using Base = ELFLinkGraphBuilder<ELFT>;
131131

132+
auto ELFReloc = Rel.getType(false);
133+
134+
// R_X86_64_NONE is a no-op.
135+
if (LLVM_UNLIKELY(ELFReloc == ELF::R_X86_64_NONE))
136+
return Error::success();
137+
132138
uint32_t SymbolIndex = Rel.getSymbol(false);
133139
auto ObjSymbol = Base::Obj.getRelocationSymbol(Rel, Base::SymTabSec);
134140
if (!ObjSymbol)
@@ -147,7 +153,6 @@ class ELFLinkGraphBuilder_x86_64 : public ELFLinkGraphBuilder<object::ELF64LE> {
147153
int64_t Addend = Rel.r_addend;
148154
Edge::Kind Kind = Edge::Invalid;
149155

150-
auto ELFReloc = Rel.getType(false);
151156
switch (ELFReloc) {
152157
case ELF::R_X86_64_PC32:
153158
Kind = x86_64::Delta32;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# RUN: yaml2obj -o %t.o %s
2+
# RUN: llvm-jitlink -noexec -check=%s %t.o
3+
#
4+
# Check that R_X86_64_NONE relocations are handled without modifying the fixup
5+
# location.
6+
7+
# jitlink-check: *{8}P = 42
8+
9+
--- !ELF
10+
FileHeader:
11+
Class: ELFCLASS64
12+
Data: ELFDATA2LSB
13+
Type: ET_REL
14+
Machine: EM_X86_64
15+
SectionHeaderStringTable: .strtab
16+
Sections:
17+
- Name: .text
18+
Type: SHT_PROGBITS
19+
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
20+
AddressAlign: 0x4
21+
- Name: .text.main
22+
Type: SHT_PROGBITS
23+
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
24+
AddressAlign: 0x10
25+
Content: 31C0C3
26+
- Name: .data
27+
Type: SHT_PROGBITS
28+
Flags: [ SHF_WRITE, SHF_ALLOC ]
29+
AddressAlign: 0x8
30+
Content: '2A00000000000000'
31+
- Name: .rela.data
32+
Type: SHT_RELA
33+
Flags: [ SHF_INFO_LINK ]
34+
Link: .symtab
35+
AddressAlign: 0x8
36+
Info: .data
37+
Relocations:
38+
- Symbol: P
39+
Type: R_X86_64_NONE
40+
- Type: SectionHeaderTable
41+
Sections:
42+
- Name: .strtab
43+
- Name: .text
44+
- Name: .text.main
45+
- Name: .data
46+
- Name: .rela.data
47+
- Name: .symtab
48+
Symbols:
49+
- Name: main
50+
Type: STT_FUNC
51+
Section: .text.main
52+
Binding: STB_GLOBAL
53+
Size: 0x3
54+
- Name: P
55+
Type: STT_OBJECT
56+
Section: .data
57+
Binding: STB_GLOBAL
58+
Size: 0x8
59+
...

0 commit comments

Comments
 (0)