Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/bolt
diff options
context:
space:
mode:
authorVladislav Khmelevsky <och95@yandex.ru>2022-03-20 17:15:56 +0300
committerVladislav Khmelevsky <och95@yandex.ru>2022-04-03 19:03:35 +0300
commit3b1314f4de63db771f1d93e1da06f14e7f3babab (patch)
tree5b9c769b27a5fbe8849bacba23beb2084d0bcba5 /bolt
parent0000030b18c1e60e5e4f7444e30694bac9ffc14e (diff)
[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
Diffstat (limited to 'bolt')
-rw-r--r--bolt/lib/Rewrite/RewriteInstance.cpp2
-rw-r--r--bolt/test/AArch64/constant-island-alignment.s8
-rw-r--r--bolt/test/AArch64/constant_island_pie_update.s38
3 files changed, 43 insertions, 5 deletions
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 8c8c55bc30ee..b342d2cdbed6 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -2350,7 +2350,7 @@ void RewriteInstance::readRelocations(const SectionRef &Section) {
continue;
}
- if (BC->getDynamicRelocationAt(Rel.getOffset())) {
+ if (!IsAArch64 && BC->getDynamicRelocationAt(Rel.getOffset())) {
LLVM_DEBUG(
dbgs() << "BOLT-DEBUG: address 0x"
<< Twine::utohexstr(Rel.getOffset())
diff --git a/bolt/test/AArch64/constant-island-alignment.s b/bolt/test/AArch64/constant-island-alignment.s
index faf7b0451cd1..a71d7ce3eba2 100644
--- a/bolt/test/AArch64/constant-island-alignment.s
+++ b/bolt/test/AArch64/constant-island-alignment.s
@@ -5,7 +5,7 @@
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \
# RUN: %s -o %t.o
# RUN: %clang %cflags -fPIC -pie %t.o -o %t.exe -Wl,-q \
-# RUN: -nostartfiles -nodefaultlibs -lc
+# RUN: -nostartfiles -nodefaultlibs -Wl,-z,notext
# RUN: llvm-bolt %t.exe -o %t.bolt -use-old-text=0 -lite=0 -trap-old-code
# RUN: llvm-objdump -d --disassemble-symbols='$d' %t.bolt | FileCheck %s
@@ -21,7 +21,7 @@ dummy:
.type exitOk, %function
exitOk:
mov x0, #0
- bl exit
+ ret
.global _start
.type _start, %function
@@ -29,8 +29,8 @@ _start:
adrp x0, .Lci
ldr x0, [x0, #:lo12:.Lci]
blr x0
- mov x1, #1
- bl exit
+ mov x0, #1
+ ret
nop
# CHECK: {{0|8}} <$d>:
.Lci:
diff --git a/bolt/test/AArch64/constant_island_pie_update.s b/bolt/test/AArch64/constant_island_pie_update.s
new file mode 100644
index 000000000000..26e4bd5df69e
--- /dev/null
+++ b/bolt/test/AArch64/constant_island_pie_update.s
@@ -0,0 +1,38 @@
+// This test checks that the constant island value is updated if it
+// has dynamic relocation.
+
+# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \
+# RUN: %s -o %t.o
+# RUN: %clang %cflags -fPIC -pie %t.o -o %t.exe -Wl,-q -nostdlib -Wl,-z,notext
+# RUN: llvm-bolt %t.exe -o %t.bolt -use-old-text=0 -lite=0
+# RUN: llvm-objdump -j .text -dR %t.bolt | FileCheck %s
+
+# CHECK: R_AARCH64_RELATIVE *ABS*+0x[[#%x,ADDR:]]
+# CHECK: [[#ADDR]] <exitLocal>:
+# CHECK: {{.*}} <$d>:
+# CHECK-NEXT: {{.*}} .word 0x{{[0]+}}[[#ADDR]]
+# CHECK-NEXT: {{.*}} .word 0x00000000
+
+ .text
+ .align 4
+ .local exitLocal
+ .type exitLocal, %function
+exitLocal:
+ add x1, x1, #1
+ add x1, x1, #1
+ ret
+ .size exitLocal, .-exitLocal
+
+ .global _start
+ .type _start, %function
+_start:
+ mov x0, #0
+ adr x1, .Lci
+ ldr x1, [x1]
+ blr x1
+ mov x0, #1
+ bl exitLocal
+ nop
+.Lci:
+ .xword exitLocal
+ .size _start, .-_start