[llvm] [Bolt] fix a wrong relocation update issue with weak references (PR #69136)

Vladislav Khmelevsky via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 05:33:37 PDT 2023


================
@@ -0,0 +1,89 @@
+// This test checks whether BOLT can correctly handle
+// relocations against weak symbols.
+
+// The assembly code is generated from the source code
+// below with GCC10.
+// test-1.c:
+// #include <stdlib.h>
+// __attribute__((weak)) void func_1();
+// __attribute__((weak)) void func_2();
+//
+// void _start() {
+//   if (&func_1)
+//     func_1();
+//   if (&func_2)
+//     func_2();
+//   exit0();
+// }
+//
+// test-2.c:
+// void func_2() {}
+
+# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
+# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %S/Inputs/weak_reference_func_2.s -o %t_func2.o
+# RUN: %clang -Wl,-q -nostartfiles -fuse-ld=lld %t.o %t_func2.o -o %t.exe
+# RUN: llvm-bolt %t.exe -o %t.bolt
+# RUN: llvm-nm -n %t.bolt > %t.out.txt
+# RUN: llvm-objdump -dj .rodata %t.bolt >> %t.out.txt
+# RUN: FileCheck %s --input-file=%t.out.txt
+
+# CHECK: {{0+}}[[#%x,ADDR:]] T func_2
+
+# CHECK: {{.*}} <.rodata>:
+# CHECK-NEXT: {{.*}} .word 0x{{[0]+}}[[#ADDR]]
+# CHECK-NEXT: {{.*}} .word 0x00000000
----------------
yota9 wrote:

The func_1 check is missed now

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


More information about the llvm-commits mailing list