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: .R_ARM_PC11_1 : { *(.R_ARM_PC11_1) } \ 6// RUN: .caller : { *(.caller) } \ 7// RUN: .R_ARM_PC11_2 : { *(.R_ARM_PC11_2) } \ 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 --triple=thumbv7a-none-linux-gnueabi %t2 | FileCheck %s 11 12// Test the R_ARM_PC11 relocation which is used with the narrow encoding of B.N 13// the source of these relocations is a binary file arm-thumb-narrow-branch.o 14// which has been assembled with the GNU assembler as llvm-mc doesn't emit it 15// as the range of +-2048 bytes is too small to be practically useful for out 16// of section branches. 17 .syntax unified 18 19.global callee_low_far 20.type callee_low_far,%function 21callee_low_far = 0x809 22 23 .section .R_ARM_PC11_1,"ax",%progbits 24 .thumb 25 .balign 0x1000 26 .type callee_low,%function 27 .globl callee_low 28callee_low: 29 bx lr 30 31 .text 32 .align 2 33 .thumb 34 .globl _start 35 .type _start, %function 36_start: 37 bl callers 38 bx lr 39 40 .section .R_ARM_PC11_2,"ax",%progbits 41 .thumb 42 .align 2 43 .type callee_high,%function 44 .globl callee_high 45callee_high: 46 bx lr 47 48.global callee_high_far 49.type callee_high_far,%function 50callee_high_far = 0x180d 51 52// CHECK: Disassembly of section .R_ARM_PC11_1: 53// CHECK-EMPTY: 54// CHECK-NEXT: <callee_low>: 55// CHECK-NEXT: 1000: 70 47 bx lr 56// CHECK-EMPTY: 57// CHECK-NEXT: Disassembly of section .caller: 58// CHECK-EMPTY: 59// CHECK-NEXT: <callers>: 60// 1004 - 0x800 (2048) + 4 = 0x808 = callee_low_far 61// CHECK-NEXT: 1004: 00 e4 b #-2048 62// 1006 - 0xa (10) + 4 = 0x1000 = callee_low 63// CHECK-NEXT: 1006: fb e7 b #-10 64// 1008 + 4 + 4 = 0x1010 = callee_high 65// CHECK-NEXT: 1008: 02 e0 b #4 66// 100a + 0x7fe (2046) + 4 = 0x180c = callee_high_far 67// CHECK-NEXT: 100a: ff e3 b #2046 68// CHECK-NEXT: 100c: 70 47 bx lr 69// CHECK-NEXT: 100e: 00 bf nop 70// CHECK-EMPTY: 71// CHECK-NEXT: Disassembly of section .R_ARM_PC11_2: 72// CHECK-EMPTY: 73// CHECK-NEXT: <callee_high>: 74// CHECK-NEXT: 1010: 70 47 bx lr 75// CHECK-EMPTY: 76// CHECK-NEXT: Disassembly of section .text: 77// CHECK-EMPTY: 78// CHECK-NEXT: <_start>: 79// CHECK-NEXT: 1014: ff f7 f6 ff bl #-20 80// CHECK-NEXT: 1018: 70 47 bx lr 81