1// REQUIRES: arm
2// RUN: llvm-mc -filetype=obj -triple=armv7a-linux-gnueabihf --arm-add-build-attributes %s -o %t.o
3// RUN: echo "SECTIONS { \
4// RUN:       .plt  0x2000 : { *(.plt) *(.plt.*) } \
5// RUN:       .text : { *(.text) } \
6// RUN:       }" > %t.script
7
8// RUN: ld.lld --script %t.script --fix-cortex-a8 --shared -verbose %t.o -o %t2
9// RUN: llvm-objdump -d --start-address=0x2020 --stop-address=0x202c --no-show-raw-insn %t2 | FileCheck --check-prefix=CHECK-PLT %s
10// RUN: llvm-objdump -d --start-address=0x2ffa --stop-address=0x3008 --no-show-raw-insn %t2 | FileCheck %s
11
12/// If we patch a branch instruction that is indirected via the PLT then we
13/// must make sure the patch goes via the PLT
14
15// CHECK-PLT:          2020:            add     r12, pc, #0, #12
16// CHECK-PLT-NEXT:     2024:            add     r12, r12, #4096
17// CHECK-PLT-NEXT:     2028:            ldr     pc, [r12, #68]!
18
19 .syntax unified
20 .thumb
21
22 .global external
23 .type external, %function
24
25 .text
26 .balign 2048
27
28 .space 2042
29 .global source
30 .thumb_func
31source:
32 nop.w
33 bl external
34
35// CHECK:      00002ffa <source>:
36// CHECK-NEXT:     2ffa:        nop.w
37// CHECK-NEXT:     2ffe:        blx     0x3004 <__CortexA8657417_2FFE>
38// CHECK:      00003004 <__CortexA8657417_2FFE>:
39// CHECK-NEXT:     3004:        b       0x2020
40