Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / arm-thumb-narrow-branch-check.s
blob394c7a00830a2d913de4c250164d2889b06fa533
1 // REQUIRES: arm
2 // RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t
3 // RUN: echo "SECTIONS { \
4 // RUN: . = SIZEOF_HEADERS; \
5 // RUN: .callee_low : { *(.callee_low) } \
6 // RUN: .caller : { *(.caller) } \
7 // RUN: .callee_high : { *(.callee_high) } \
8 // RUN: .text : { *(.text) } } " > %t.script
9 // RUN: ld.lld --script %t.script %t %S/Inputs/arm-thumb-narrow-branch.o -o %t2
10 // RUN: llvm-objdump -d %t2 | FileCheck %s
12 // Test the R_ARM_THM_JUMP11 and R_ARM_THM_JUMP8 relocations which are used
13 // with the narrow encoding of B.N and BEQ.N.
15 // The source of these relocations is a binary file arm-thumb-narrow-branch.o
16 // which has been assembled with the GNU assembler as llvm-mc doesn't emit it
17 // as the range of +-2048 bytes is too small to be practically useful for out
18 // of section branches.
19 .syntax unified
21 .global callee_low_far
22 .type callee_low_far,%function
23 callee_low_far = 0x809
25 .global callee_low_near
26 .type callee_low_near,%function
27 callee_low_near = 0xfff
29 .section .callee_low,"ax",%progbits
30 .thumb
31 .balign 0x1000
32 .type callee_low,%function
33 .globl callee_low
34 callee_low:
35 bx lr
37 .text
38 .align 2
39 .thumb
40 .globl _start
41 .type _start, %function
42 _start:
43 bl callers
44 bx lr
46 .section .callee_high,"ax",%progbits
47 .thumb
48 .align 2
49 .type callee_high,%function
50 .globl callee_high
51 callee_high:
52 bx lr
54 .global callee_high_near
55 .type callee_high_near,%function
56 callee_high_near = 0x10ff
58 .global callee_high_far
59 .type callee_high_far,%function
60 callee_high_far = 0x180d
62 // CHECK: Disassembly of section .callee_low:
63 // CHECK-EMPTY:
64 // CHECK-NEXT: <callee_low>:
65 // CHECK-NEXT: 1000: 4770 bx lr
66 // CHECK-EMPTY:
67 // CHECK-NEXT: Disassembly of section .caller:
68 // CHECK-EMPTY:
69 // CHECK-NEXT: <callers>:
70 /// callee_low_far = 0x809
71 // CHECK-NEXT: 1004: e400 b 0x808
72 // CHECK-NEXT: 1006: e7fb b 0x1000 <callee_low>
73 // CHECK-NEXT: 1008: e006 b 0x1018 <callee_high>
74 /// callee_high_far = 0x180d
75 // CHECK-NEXT: 100a: e3ff b 0x180c
76 /// callee_low_near = 0xfff
77 // CHECK-NEXT: 100c: d0f7 beq 0xffe
78 // CHECK-NEXT: 100e: d0f7 beq 0x1000 <callee_low>
79 // CHECK-NEXT: 1010: d002 beq 0x1018 <callee_high>
80 /// callee_high_near = 0x10ff
81 // CHECK-NEXT: 1012: d074 beq 0x10fe
82 // CHECK-NEXT: 1014: 4770 bx lr
83 // CHECK-NEXT: 1016: 46c0 mov r8, r8
84 // CHECK-EMPTY:
85 // CHECK-NEXT: Disassembly of section .callee_high:
86 // CHECK-EMPTY:
87 // CHECK-NEXT: <callee_high>:
88 // CHECK-NEXT: 1018: 4770 bx lr
89 // CHECK-EMPTY:
90 // CHECK-NEXT: Disassembly of section .text:
91 // CHECK-EMPTY:
92 // CHECK-NEXT: <_start>:
93 // CHECK-NEXT: 101c: f7ff fff2 bl 0x1004 <callers>
94 // CHECK-NEXT: 1020: 4770 bx lr