[llvm] [lld] [llvm][lld] Support R_AARCH64_GOTPCREL32 (PR #72584)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 6 21:36:52 PST 2023


================
@@ -0,0 +1,22 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o
+// RUN: ld.lld %t.o -o %t.so -shared
+// RUN: llvm-readelf -S %t.so | FileCheck --check-prefix=SEC %s
+// RUN: llvm-objdump --no-print-imm-hex -s -d %t.so | FileCheck %s
+
+// SEC: .got PROGBITS 0000000000020350
+
+  .section .data
+  .globl bar
+bar:
+
+  .globl _start
+_start:
+// bar at GOTPCREL   = 0x20350 (got entry for `bar`) - 0x30358 (.) = 0xfffefff8
+// bar at GOTPCREL+4 = 0x20350 (got entry for `bar`) - 0x3035c (.) + 4 = 0xfffefff8
+// bar at GOTPCREL-4 = 0x20350 (got entry for `bar`) - 0x30360 (.) + 4 = 0xfffeffec
+// CHECK: Contents of section .data:
+// CHECK:  30358 f8fffeff f8fffeff ecfffeff
----------------
MaskRay wrote:

`// CHECK-NEXT: {{.*}} f8fffeff f8fffeff ecfffeff`

Omit the address so that it's less address sensitive. I think the difference is not affected by `-z [no]separate-code`

https://github.com/llvm/llvm-project/pull/72584


More information about the llvm-commits mailing list