1 # Regression test for https://github.com/llvm/llvm-project/issues/100096
2 # static glibc binaries crash on startup because _init is moved and
3 # shares its address with an array end pointer. The GOT rewriting can't
4 # tell the two pointers apart and incorrectly updates the _array_end
5 # address. Test checks that _init is not moved.
7 # RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
8 # RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -static -Wl,--section-start=.data=0x1000 -Wl,--section-start=.init=0x1004
9 # RUN: llvm-bolt %t.exe -o %t.bolt
10 # RUN: llvm-nm %t.exe | FileCheck --check-prefix=CHECK-ORIGINAL %s
11 # RUN: llvm-nm %t.bolt | FileCheck --check-prefix=CHECK-BOLTED %s
19 .section .init,"ax",@progbits
22 # Check that bolt doesn't move _init.
24 # CHECK-ORIGINAL: 0000000000001004 T _init
25 # CHECK-BOLTED: 0000000000001004 T _init
29 .section .text,"ax",@progbits
32 # Check that bolt is moving some other functions.
34 # CHECK-ORIGINAL: 0000000000001008 T _start
35 # CHECK-BOLTED-NOT: 0000000000001008 T _start
38 adrp x0
, #:got:_array_end
39 ldr x0
, [x0
, #:gotpage_lo15:_array_end]
41 ldr x0
, [x0
, #:gotpage_lo15:_init]