[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / aarch64-thunk-reuse.s
blobbdbd08ab5f28202a99379e62d4ec68cd271b0dd2
1 # REQUIRES: aarch64
2 # RUN: rm -rf %t && split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=aarch64 %t/a.s -o %t/a.o
4 # RUN: ld.lld -pie -T %t/lds %t/a.o -o %t/a
5 # RUN: llvm-objdump -d --no-show-raw-insn %t/a | FileCheck %s
7 ## We create a thunk for dest.
8 # CHECK-LABEL: <mid>:
9 # CHECK-NEXT: 8010008: b 0x801000c <__AArch64ADRPThunk_>
10 # CHECK-EMPTY:
11 # CHECK-NEXT: <__AArch64ADRPThunk_>:
12 # CHECK-NEXT: 801000c: adrp x16, 0x10000
13 # CHECK-NEXT: add x16, x16, #4
14 # CHECK-NEXT: br x16
16 ## The first instruction can reuse the thunk but the second can't.
17 ## If we reuse the thunk for b, we will get an "out of range" error.
18 # CHECK-LABEL: <high>:
19 # CHECK-NEXT: 1001000c: bl 0x801000c <__AArch64ADRPThunk_>
20 # CHECK-NEXT: b 0x10010014 <__AArch64ADRPThunk_>
21 # CHECK-EMPTY:
22 # CHECK-NEXT: <__AArch64ADRPThunk_>:
23 # CHECK-NEXT: 10010014: adrp x16, 0x10000
24 # CHECK-NEXT: add x16, x16, #4
25 # CHECK-NEXT: br x16
27 #--- a.s
28 .section .text_low, "ax", %progbits
29 .globl _start
30 _start:
31 nop
32 dest:
33 ret
35 .section .text_mid, "ax", %progbits
36 mid:
37 b dest
39 .section .text_high, "ax", %progbits
40 high:
41 bl dest
42 b dest
44 #--- lds
45 SECTIONS {
46 .text_low 0x10000: { *(.text_low) }
47 .text_mid 0x8010008 : { *(.text_mid) }
48 .text_high 0x1001000c : { *(.text_high) }