1# REQUIRES: arm 2# RUN: rm -rf %t && split-file %s %t 3# RUN: llvm-mc -filetype=obj -triple=armv7-a-none-eabi --arm-add-build-attributes %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 --no-print-imm-hex -d --no-show-raw-insn %t/a | FileCheck %s 6# RUN: llvm-objdump -s --triple=armv7a-none-linux-gnueabi %t/a | FileCheck --check-prefix=CHECK-LE %s 7 8# RUN: llvm-mc -filetype=obj -triple=armv7eb-a-none-eabi --arm-add-build-attributes -mcpu=cortex-a8 %t/a.s -o %t/a.o 9# RUN: ld.lld -pie -T %t/lds %t/a.o -o %t/a 10# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t/a | FileCheck %s 11# RUN: llvm-objdump -s --triple=armv7eb-a-none-eabi %t/a| FileCheck --check-prefix=CHECK-EB %s 12# RUN: ld.lld --be8 -pie -T %t/lds %t/a.o -o %t/a 13# RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t/a | FileCheck %s 14# RUN: llvm-objdump -s --triple=armv7eb-a-none-eabi %t/a| FileCheck --check-prefix=CHECK-LE %s 15 16## We create a thunk for dest. 17# CHECK-LABEL: <mid>: 18# CHECK-NEXT: 2010004: b 0x2010008 <__ARMV7PILongThunk_dest> 19# CHECK-EMPTY: 20# CHECK-NEXT: <__ARMV7PILongThunk_dest>: 21# CHECK-NEXT: 2010008: movw r12, #65516 22# CHECK-NEXT: movt r12, #65023 23# CHECK-NEXT: add r12, r12, pc 24# CHECK-NEXT: bx r12 25 26## The first instruction can reuse the thunk but the second can't. 27## If we reuse the thunk for b, we will get an "out of range" error. 28# CHECK-LABEL: <high>: 29# CHECK-NEXT: 4010000: bl 0x2010008 <__ARMV7PILongThunk_dest> 30# CHECK-NEXT: b 0x4010008 <__ARMV7PILongThunk_dest> 31# CHECK-EMPTY: 32# CHECK-NEXT: <__ARMV7PILongThunk_dest>: 33# CHECK-NEXT: 4010008: movw r12, #65516 34# CHECK-NEXT: movt r12, #64511 35# CHECK-NEXT: add r12, r12, pc 36# CHECK-NEXT: bx r12 37 38# CHECK-EB: Contents of section .text_low: 39# CHECK-EB-NEXT: 10000 e320f000 e12fff1e 40# CHECK-EB: Contents of section .text_mid: 41# CHECK-EB-NEXT: 2010004 eaffffff e30fcfec e34fcdff e08cc00f 42# CHECK-EB-NEXT: 2010014 e12fff1c 43# CHECK-EB: Contents of section .text_high: 44# CHECK-EB-NEXT: 4010000 eb800000 eaffffff e30fcfec e34fcbff 45# CHECK-EB-NEXT: 4010010 e08cc00f e12fff1c 46 47# CHECK-LE: Contents of section .text_low: 48# CHECK-LE-NEXT: 10000 00f020e3 1eff2fe1 49# CHECK-LE: Contents of section .text_mid: 50# CHECK-LE-NEXT: 2010004 ffffffea eccf0fe3 ffcd4fe3 0fc08ce0 51# CHECK-LE-NEXT: 2010014 1cff2fe1 52# CHECK-LE: Contents of section .text_high: 53# CHECK-LE-NEXT: 4010000 000080eb ffffffea eccf0fe3 ffcb4fe3 54# CHECK-LE-NEXT: 4010010 0fc08ce0 1cff2fe1 55 56#--- a.s 57.section .text_low, "ax", %progbits 58 59.globl _start 60_start: 61 nop 62dest: 63 bx lr 64 65.section .text_mid, "ax", %progbits 66mid: 67 b dest 68 69.section .text_high, "ax", %progbits 70high: 71 bl dest 72 b dest 73 74#--- lds 75SECTIONS { 76 .text_low 0x10000: { *(.text_low) } 77 .text_mid 0x2010004 : { *(.text_mid) } 78 .text_high 0x4010000 : { *(.text_high) } 79} 80