1// REQUIRES: arm
2// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/arm-shared.s -o %t1.o
3// RUN: ld.lld %t1.o --shared -soname=t1.so -o %t1.so
4// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
5// RUN: ld.lld %t.o %t1.so -o %t
6// RUN: llvm-objdump -d --triple=armv7a-none-linux-gnueabi --start-address=0x201e4 --stop-address=0x20204 %t | FileCheck %s
7
8/// When we are dynamic linking, undefined weak references have a PLT entry so
9/// we must create a thunk for the branch to the PLT entry.
10
11 .text
12 .globl bar2
13 .weak undefined_weak_we_expect_a_plt_entry_for
14_start:
15 .globl _start
16 .type _start, %function
17 b undefined_weak_we_expect_a_plt_entry_for
18 bl bar2
19/// Create 32 Mb gap between the call to the weak reference and the PLT so that
20/// the b and bl need a range-extension thunk.
21 .section .text.1, "ax", %progbits
22 .space 32 * 1024 * 1024
23
24// CHECK: Disassembly of section .text:
25// CHECK-EMPTY:
26// CHECK-NEXT: <_start>:
27// CHECK-NEXT:    201e4:       00 00 00 ea     b       #0 <__ARMv7ABSLongThunk_undefined_weak_we_expect_a_plt_entry_for>
28// CHECK-NEXT:    201e8:       02 00 00 eb     bl      #8 <__ARMv7ABSLongThunk_bar2>
29// CHECK: <__ARMv7ABSLongThunk_undefined_weak_we_expect_a_plt_entry_for>:
30// CHECK-NEXT:    201ec:        30 c2 00 e3     movw    r12, #560
31// CHECK-NEXT:    201f0:        02 c2 40 e3     movt    r12, #514
32// CHECK-NEXT:    201f4:        1c ff 2f e1     bx      r12
33// CHECK: <__ARMv7ABSLongThunk_bar2>:
34// CHECK-NEXT:    201f8:        40 c2 00 e3     movw    r12, #576
35// CHECK-NEXT:    201fc:        02 c2 40 e3     movt    r12, #514
36// CHECK-NEXT:    20200:        1c ff 2f e1     bx      r12
37