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

Vladislav Khmelevsky via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 14:04:15 PDT 2023


================
@@ -0,0 +1,55 @@
+// This test checks whether BOLT can correctly update
+// a symbol that is weak and undefined.
+
+// The assembly code is generated from the source code
+// below with GCC10.
+// #include <stdlib.h>
+// __attribute__((weak)) void func();
+// void _start() {
+//   if (func)
+//     func();
+//  exit(0);
+// }
+
+# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
+# RUN: %clang -Wl,-q -nostartfiles %t.o -o %t.exe
+# RUN: llvm-bolt %t.exe -o %t.bolt
+# RUN: obj2yaml %t.bolt | FileCheck %s
+
+# CHECK:  - Name: .rodata
+# CHECK-NEXT:    Type:            SHT_PROGBITS
+# CHECK-NEXT:    Flags:           [ SHF_ALLOC ]
+# CHECK-NEXT:    Address:         0x{{0*}}
+# CHECK-NEXT:    AddressAlign:    0x{{0*}}
+# CHECK-NEXT:    Content:         '{{0+}}'
+
+        .text
+        .align  2
+        .global _start
+        .type   _start, %function
+_start:
+.LFB6:
+        .cfi_startproc
----------------
yota9 wrote:

I think we need to add  second case in test, where the symbol is actually emitted

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


More information about the llvm-commits mailing list