[PATCH] D122100: [BOLT] AArch64: Read all static relocations

Vladislav Khmelevsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 20 07:17:05 PDT 2022


yota9 created this revision.
yota9 added reviewers: maksfb, rafauler, Amir.
Herald added subscribers: ayermolo, kristof.beyls.
Herald added a project: All.
yota9 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Read static relocs on the same address, as dynamic in order to update
constant island data address properly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122100

Files:
  bolt/lib/Rewrite/RewriteInstance.cpp
  bolt/test/AArch64/constant_island_pie_update.s


Index: bolt/test/AArch64/constant_island_pie_update.s
===================================================================
--- /dev/null
+++ bolt/test/AArch64/constant_island_pie_update.s
@@ -0,0 +1,31 @@
+// 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 \
+# RUN:    -nostartfiles -nodefaultlibs -lc
+# RUN: llvm-bolt %t.exe -o %t.bolt -use-old-text=0 -lite=0
+# RUN: llvm-objdump -j .text -d %t.bolt | FileCheck %s
+
+# CHECK: bl 0x[[#%x,ADDR:]] <exitLocal>
+# CHECK: {{.*}} <$d>:
+# CHECK-NEXT: {{.*}} .word 0x{{[0]+}}[[#ADDR]]
+
+.global
+.type exitLocal, %function
+exitLocal:
+  bl exit
+
+.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
Index: bolt/lib/Rewrite/RewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/RewriteInstance.cpp
+++ bolt/lib/Rewrite/RewriteInstance.cpp
@@ -2350,7 +2350,7 @@
         continue;
     }
 
-    if (BC->getDynamicRelocationAt(Rel.getOffset())) {
+    if (!IsAArch64 && BC->getDynamicRelocationAt(Rel.getOffset())) {
       LLVM_DEBUG(
           dbgs() << "BOLT-DEBUG: address 0x"
                  << Twine::utohexstr(Rel.getOffset())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122100.416780.patch
Type: text/x-patch
Size: 1444 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220320/abea54cf/attachment.bin>


More information about the llvm-commits mailing list