Skip to content

Commit 3b1314f

Browse files
committed
[BOLT] AArch64: Read all static relocations
Read static relocs on the same address, as dynamic in order to update constant island data address properly. Differential Revision: https://reviews.llvm.org/D122100
1 parent 0000030 commit 3b1314f

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2350,7 +2350,7 @@ void RewriteInstance::readRelocations(const SectionRef &Section) {
23502350
continue;
23512351
}
23522352

2353-
if (BC->getDynamicRelocationAt(Rel.getOffset())) {
2353+
if (!IsAArch64 && BC->getDynamicRelocationAt(Rel.getOffset())) {
23542354
LLVM_DEBUG(
23552355
dbgs() << "BOLT-DEBUG: address 0x"
23562356
<< Twine::utohexstr(Rel.getOffset())

bolt/test/AArch64/constant-island-alignment.s

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \
66
# RUN: %s -o %t.o
77
# RUN: %clang %cflags -fPIC -pie %t.o -o %t.exe -Wl,-q \
8-
# RUN: -nostartfiles -nodefaultlibs -lc
8+
# RUN: -nostartfiles -nodefaultlibs -Wl,-z,notext
99
# RUN: llvm-bolt %t.exe -o %t.bolt -use-old-text=0 -lite=0 -trap-old-code
1010
# RUN: llvm-objdump -d --disassemble-symbols='$d' %t.bolt | FileCheck %s
1111

@@ -21,16 +21,16 @@ dummy:
2121
.type exitOk, %function
2222
exitOk:
2323
mov x0, #0
24-
bl exit
24+
ret
2525

2626
.global _start
2727
.type _start, %function
2828
_start:
2929
adrp x0, .Lci
3030
ldr x0, [x0, #:lo12:.Lci]
3131
blr x0
32-
mov x1, #1
33-
bl exit
32+
mov x0, #1
33+
ret
3434
nop
3535
# CHECK: {{0|8}} <$d>:
3636
.Lci:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// This test checks that the constant island value is updated if it
2+
// has dynamic relocation.
3+
4+
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \
5+
# RUN: %s -o %t.o
6+
# RUN: %clang %cflags -fPIC -pie %t.o -o %t.exe -Wl,-q -nostdlib -Wl,-z,notext
7+
# RUN: llvm-bolt %t.exe -o %t.bolt -use-old-text=0 -lite=0
8+
# RUN: llvm-objdump -j .text -dR %t.bolt | FileCheck %s
9+
10+
# CHECK: R_AARCH64_RELATIVE *ABS*+0x[[#%x,ADDR:]]
11+
# CHECK: [[#ADDR]] <exitLocal>:
12+
# CHECK: {{.*}} <$d>:
13+
# CHECK-NEXT: {{.*}} .word 0x{{[0]+}}[[#ADDR]]
14+
# CHECK-NEXT: {{.*}} .word 0x00000000
15+
16+
.text
17+
.align 4
18+
.local exitLocal
19+
.type exitLocal, %function
20+
exitLocal:
21+
add x1, x1, #1
22+
add x1, x1, #1
23+
ret
24+
.size exitLocal, .-exitLocal
25+
26+
.global _start
27+
.type _start, %function
28+
_start:
29+
mov x0, #0
30+
adr x1, .Lci
31+
ldr x1, [x1]
32+
blr x1
33+
mov x0, #1
34+
bl exitLocal
35+
nop
36+
.Lci:
37+
.xword exitLocal
38+
.size _start, .-_start

0 commit comments

Comments
 (0)