Skip to content

Commit fb1b994

Browse files
committed
[JITLink][ELF][AArch64] Add support for ELF R_AARCH64_ABS32 relocation.
This relocation is commonly used in debug sections. Failure to handle it caused the test failure in https://lab.llvm.org/buildbot/#/builders/197/builds/4272, which forced the reversion, in f721fcb, of 57aeb30 ("[JITLink][ELF] Don't skip debug info sections by default"). This fix should allow us to re-land 57aeb30.
1 parent 3af1c48 commit fb1b994

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

llvm/lib/ExecutionEngine/JITLink/ELF_aarch64.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class ELFLinkGraphBuilder_aarch64 : public ELFLinkGraphBuilder<ELFT> {
5858
ELFMovwAbsG1,
5959
ELFMovwAbsG2,
6060
ELFMovwAbsG3,
61+
ELFAbs32,
6162
ELFAbs64,
6263
ELFPrel32,
6364
ELFPrel64,
@@ -98,6 +99,8 @@ class ELFLinkGraphBuilder_aarch64 : public ELFLinkGraphBuilder<ELFT> {
9899
return ELFMovwAbsG2;
99100
case ELF::R_AARCH64_MOVW_UABS_G3:
100101
return ELFMovwAbsG3;
102+
case ELF::R_AARCH64_ABS32:
103+
return ELFAbs32;
101104
case ELF::R_AARCH64_ABS64:
102105
return ELFAbs64;
103106
case ELF::R_AARCH64_PREL32:
@@ -284,6 +287,10 @@ class ELFLinkGraphBuilder_aarch64 : public ELFLinkGraphBuilder<ELFT> {
284287
Kind = aarch64::MoveWide16;
285288
break;
286289
}
290+
case ELFAbs32: {
291+
Kind = aarch64::Pointer32;
292+
break;
293+
}
287294
case ELFAbs64: {
288295
Kind = aarch64::Pointer64;
289296
break;
@@ -357,6 +364,8 @@ class ELFLinkGraphBuilder_aarch64 : public ELFLinkGraphBuilder<ELFT> {
357364
return "ELFMovwAbsG2";
358365
case ELFMovwAbsG3:
359366
return "ELFMovwAbsG3";
367+
case ELFAbs32:
368+
return "ELFAbs32";
360369
case ELFAbs64:
361370
return "ELFAbs64";
362371
case ELFPrel32:
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Check success and failure cases of R_AARCH64_32 handling.
2+
# This file contains a single R_AARCH64_ABS32 relocation. We expect the
3+
# relocation to apply successfully when we assign x an address in the low
4+
# 32-bits of the address space, and fail if we assign x an address outside that
5+
# range.
6+
7+
# RUN: yaml2obj -o %t.o %s
8+
# RUN: llvm-jitlink -abs x=0x12345678 -noexec -check=%s %t.o
9+
# RUN: not llvm-jitlink -abs x=0x123456789 -noexec %t.o 2>&1 | \
10+
# RUN: FileCheck -check-prefix=CHECK-ERROR %s
11+
12+
# jitlink-check: *{8}xptr = x
13+
14+
# CHECK-ERROR: relocation target "x" {{.*}} is out of range of Pointer32 fixup
15+
16+
--- !ELF
17+
FileHeader:
18+
Class: ELFCLASS64
19+
Data: ELFDATA2LSB
20+
Type: ET_REL
21+
Machine: EM_AARCH64
22+
SectionHeaderStringTable: .strtab
23+
Sections:
24+
- Name: .text
25+
Type: SHT_PROGBITS
26+
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
27+
AddressAlign: 0x4
28+
Content: E0031F2AC0035FD6
29+
- Name: .data
30+
Type: SHT_PROGBITS
31+
Flags: [ SHF_WRITE, SHF_ALLOC ]
32+
AddressAlign: 0x8
33+
Content: '0000000000000000'
34+
- Name: .comment
35+
Type: SHT_PROGBITS
36+
Flags: [ SHF_MERGE, SHF_STRINGS ]
37+
AddressAlign: 0x1
38+
EntSize: 0x1
39+
Content: 00636C616E672076657273696F6E2031372E302E30202868747470733A2F2F6769746875622E636F6D2F6C6C766D2F6C6C766D2D70726F6A6563742E67697420333130616161633834363336656336633933383739633138643933653332663537623264383938362900
40+
- Name: .note.GNU-stack
41+
Type: SHT_PROGBITS
42+
AddressAlign: 0x1
43+
- Name: .rela.data
44+
Type: SHT_RELA
45+
Flags: [ SHF_INFO_LINK ]
46+
Link: .symtab
47+
AddressAlign: 0x8
48+
Info: .data
49+
Relocations:
50+
- Symbol: x
51+
Type: R_AARCH64_ABS32
52+
- Name: .llvm_addrsig
53+
Type: SHT_LLVM_ADDRSIG
54+
Flags: [ SHF_EXCLUDE ]
55+
Link: .symtab
56+
AddressAlign: 0x1
57+
Symbols: [ x ]
58+
- Type: SectionHeaderTable
59+
Sections:
60+
- Name: .strtab
61+
- Name: .text
62+
- Name: .data
63+
- Name: .rela.data
64+
- Name: .comment
65+
- Name: .note.GNU-stack
66+
- Name: .llvm_addrsig
67+
- Name: .symtab
68+
Symbols:
69+
- Name: hw.c
70+
Type: STT_FILE
71+
Index: SHN_ABS
72+
- Name: '$x.0'
73+
Section: .text
74+
- Name: '$d.1'
75+
Section: .data
76+
- Name: '$d.2'
77+
Section: .comment
78+
- Name: main
79+
Type: STT_FUNC
80+
Section: .text
81+
Binding: STB_GLOBAL
82+
Size: 0x8
83+
- Name: xptr
84+
Type: STT_OBJECT
85+
Section: .data
86+
Binding: STB_GLOBAL
87+
Size: 0x8
88+
- Name: x
89+
Binding: STB_GLOBAL
90+
...

0 commit comments

Comments
 (0)