brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · bea0dbc Raw
44 lines · plain
1# Regression test for https://github.com/llvm/llvm-project/issues/1000962# static glibc binaries crash on startup because _init is moved and3# shares its address with an array end pointer. The GOT rewriting can't4# tell the two pointers apart and incorrectly updates the _array_end5# address. Test checks that _init is not moved.6 7# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o8# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -static -Wl,--image-base=0,-Tdata=0x1000,--section-start=.init=0x10049# RUN: llvm-bolt %t.exe -o %t.bolt10# RUN: llvm-nm %t.exe | FileCheck --check-prefix=CHECK-ORIGINAL %s11# RUN: llvm-nm %t.bolt | FileCheck --check-prefix=CHECK-BOLTED %s12 13.section .data14.globl _array_end15_array_start:16    .word 0x017 18_array_end:19.section .init,"ax",@progbits20.globl _init21 22# Check that bolt doesn't move _init.23#24# CHECK-ORIGINAL: 0000000000001004 T _init25# CHECK-BOLTED:   0000000000001004 T _init26_init:27    ret28 29.section .text,"ax",@progbits30.globl _start31 32# Check that bolt is moving some other functions.33#34# CHECK-ORIGINAL:   0000000000001008 T _start35# CHECK-BOLTED-NOT: 0000000000001008 T _start36_start:37    bl _init38    adrp x0, #:got:_array_end39    ldr x0, [x0, #:gotpage_lo15:_array_end]40    adrp x0, #:got:_init41    ldr x0, [x0, #:gotpage_lo15:_init]42    ret43 44