[llvm] Do not replace dead constant references in metadata with undef
[llvm-project.git] / lld / test / ELF / arm-force-pi-thunk.s
blob8cec1ab9de158f12448c49c59ce9a39638fd9648
1 // REQUIRES: arm
2 // RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
3 // RUN: echo "SECTIONS { \
4 // RUN: . = SIZEOF_HEADERS; \
5 // RUN: .text_low : { *(.text_low) *(.text_low2) } \
6 // RUN: .text_high 0x2000000 : { *(.text_high) *(.text_high2) } \
7 // RUN: } " > %t.script
8 // RUN: ld.lld --pic-veneer --no-rosegment --script %t.script %t -o %t2
9 // RUN: llvm-objdump -d %t2 | FileCheck %s
11 // Test that we can force generation of position independent thunks even when
12 // inputs are not pic.
14 .syntax unified
15 .section .text_low, "ax", %progbits
16 .thumb
17 .globl _start
18 _start: bx lr
19 .globl low_target
20 .type low_target, %function
21 low_target:
22 bl high_target
23 bl high_target2
25 .section .text_low2, "ax", %progbits
26 .thumb
27 .globl low_target2
28 .type low_target2, %function
29 low_target2:
30 bl high_target
31 bl high_target2
33 // CHECK: Disassembly of section .text_low:
34 // CHECK-EMPTY:
35 // CHECK-NEXT: <_start>:
36 // CHECK-NEXT: 94: 70 47 bx lr
37 // CHECK: <low_target>:
38 // CHECK-NEXT: 96: 00 f0 03 f8 bl 0xa0 <__ThumbV7PILongThunk_high_target>
39 // CHECK-NEXT: 9a: 00 f0 07 f8 bl 0xac <__ThumbV7PILongThunk_high_target2>
40 // CHECK-NEXT: 9e: d4 d4
41 // CHECK: <__ThumbV7PILongThunk_high_target>:
42 // CHECK-NEXT: a0: 4f f6 55 7c movw r12, #65365
43 // CHECK-NEXT: a4: c0 f2 ff 1c movt r12, #511
44 // CHECK-NEXT: a8: fc 44 add r12, pc
45 // CHECK-NEXT: aa: 60 47 bx r12
46 // CHECK: <__ThumbV7PILongThunk_high_target2>:
47 // CHECK-NEXT: ac: 4f f6 69 7c movw r12, #65385
48 // CHECK-NEXT: b0: c0 f2 ff 1c movt r12, #511
49 // CHECK-NEXT: b4: fc 44 add r12, pc
50 // CHECK-NEXT: b6: 60 47 bx r12
51 // CHECK: <low_target2>:
52 // CHECK-NEXT: b8: ff f7 f2 ff bl 0xa0 <__ThumbV7PILongThunk_high_target>
53 // CHECK-NEXT: bc: ff f7 f6 ff bl 0xac <__ThumbV7PILongThunk_high_target2>
56 .section .text_high, "ax", %progbits
57 .thumb
58 .globl high_target
59 .type high_target, %function
60 high_target:
61 bl low_target
62 bl low_target2
64 .section .text_high2, "ax", %progbits
65 .thumb
66 .globl high_target2
67 .type high_target2, %function
68 high_target2:
69 bl low_target
70 bl low_target2
72 // CHECK: Disassembly of section .text_high:
73 // CHECK-EMPTY:
74 // CHECK-NEXT: <high_target>:
75 // CHECK-NEXT: 2000000: 00 f0 02 f8 bl 0x2000008 <__ThumbV7PILongThunk_low_target>
76 // CHECK-NEXT: 2000004: 00 f0 06 f8 bl 0x2000014 <__ThumbV7PILongThunk_low_target2>
77 // CHECK: <__ThumbV7PILongThunk_low_target>:
78 // CHECK-NEXT: 2000008: 40 f2 83 0c movw r12, #131
79 // CHECK-NEXT: 200000c: cf f6 00 6c movt r12, #65024
80 // CHECK-NEXT: 2000010: fc 44 add r12, pc
81 // CHECK-NEXT: 2000012: 60 47 bx r12
82 // CHECK: <__ThumbV7PILongThunk_low_target2>:
83 // CHECK-NEXT: 2000014: 40 f2 99 0c movw r12, #153
84 // CHECK-NEXT: 2000018: cf f6 00 6c movt r12, #65024
85 // CHECK-NEXT: 200001c: fc 44 add r12, pc
86 // CHECK-NEXT: 200001e: 60 47 bx r12
87 // CHECK: <high_target2>:
88 // CHECK-NEXT: 2000020: ff f7 f2 ff bl 0x2000008 <__ThumbV7PILongThunk_low_target>
89 // CHECK-NEXT: 2000024: ff f7 f6 ff bl 0x2000014 <__ThumbV7PILongThunk_low_target2>