[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / arm-thumb-branch.s
blob7e97b5567dd7d52f53ce6ebfb9c8933acfe9445a
1 // REQUIRES: arm
2 // RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
3 // RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=thumbv7a-none-linux-gnueabi %S/Inputs/far-arm-thumb-abs.s -o %tfar
4 // RUN: echo "SECTIONS { \
5 // RUN: . = 0xb4; \
6 // RUN: .callee1 : { *(.callee_low) } \
7 // RUN: .caller : { *(.text) } \
8 // RUN: .callee2 : { *(.callee_high) } } " > %t.script
9 // RUN: ld.lld --script %t.script %t %tfar -o %t2
10 // RUN: llvm-objdump -d %t2 | FileCheck %s
12 .syntax unified
13 .thumb
14 .section .callee_low, "ax",%progbits
15 .align 2
16 .type callee_low,%function
17 callee_low:
18 bx lr
20 .section .text, "ax",%progbits
21 .globl _start
22 .balign 0x10000
23 .type _start,%function
24 _start:
25 bl callee_low
26 b callee_low
27 beq callee_low
28 bl callee_high
29 b callee_high
30 bne callee_high
31 bl far_uncond
32 b far_uncond
33 bgt far_cond
34 bx lr
36 .section .callee_high, "ax",%progbits
37 .align 2
38 .type callee_high,%function
39 callee_high:
40 bx lr
42 // CHECK: Disassembly of section .callee1:
43 // CHECK-EMPTY:
44 // CHECK-NEXT: <callee_low>:
45 // CHECK-NEXT: b4: 70 47 bx lr
46 // CHECK-EMPTY:
47 // CHECK-NEXT: Disassembly of section .caller:
48 // CHECK-EMPTY:
49 // CHECK-NEXT: <_start>:
50 // CHECK-NEXT: 10000: f0 f7 58 f8 bl 0xb4 <callee_low>
51 // CHECK-NEXT: 10004: f0 f7 56 b8 b.w 0xb4 <callee_low>
52 // CHECK-NEXT: 10008: 30 f4 54 a8 beq.w 0xb4 <callee_low>
53 // CHECK-NEXT: 1000c: 00 f0 0c f8 bl 0x10028 <callee_high>
54 // CHECK-NEXT: 10010: 00 f0 0a b8 b.w 0x10028 <callee_high>
55 // CHECK-NEXT: 10014: 40 f0 08 80 bne.w 0x10028 <callee_high>
56 /// far_uncond = 0x101001b
57 // CHECK-NEXT: 10018: ff f3 ff d7 bl 0x101001a
58 // CHECK-NEXT: 1001c: ff f3 fd 97 b.w 0x101001a
59 /// far_cond = 0x110023
60 // CHECK-NEXT: 10020: 3f f3 ff af bgt.w 0x110022
61 // CHECK-NEXT: 10024: 70 47 bx lr
62 // CHECK-NEXT: 10026:
63 // CHECK-EMPTY:
64 // CHECK-NEXT: Disassembly of section .callee2:
65 // CHECK-EMPTY:
66 // CHECK-NEXT: <callee_high>:
67 // CHECK-NEXT: 10028: 70 47 bx lr