xref: /llvm-project/lld/test/ELF/arm-undefined-weak.s (revision 75cdab6dc2453a508157a9c383b93373a93078d6)
1// REQUIRES: arm
2// RUN: llvm-mc -arm-add-build-attributes -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t
3// RUN: ld.lld --image-base=0x10000000 %t -o %t2
4// RUN: llvm-objdump --no-print-imm-hex --triple=armv7a-none-linux-gnueabi --no-show-raw-insn -d %t2 | FileCheck %s
5
6/// Check that the ARM ABI rules for undefined weak symbols are applied.
7/// Branch instructions are resolved to the next instruction. Undefined
8/// Symbols in relative are resolved to the place so S - P + A = A.
9/// We place the image-base at 0x10000000 to test that a range extensions thunk
10/// is not generated.
11
12 .syntax unified
13
14 .weak target
15 .type target, %function
16 .weak undefweak2
17 .hidden undefweak2
18 .type undefweak2, %function
19
20 .text
21 .global _start
22_start:
23/// R_ARM_JUMP24
24 b target
25/// R_ARM_CALL
26 bl target
27/// R_ARM_CALL with exchange
28 blx target
29/// R_ARM_MOVT_PREL
30 movt r0, :upper16:target - .
31/// R_ARM_MOVW_PREL_NC
32 movw r0, :lower16:target - .
33/// R_ARM_REL32
34 .word target - .
35
36bl_undefweak2:
37 bl undefweak2
38
39// CHECK: Disassembly of section .text:
40// CHECK-EMPTY:
41// CHECK-NEXT: 100100b4 <_start>:
42// CHECK-NEXT: 100100b4: b       {{.+}} @ imm = #-4
43// CHECK-NEXT: 100100b8: bl      {{.+}} @ imm = #-4
44// CHECK-NEXT: 100100bc: bl      {{.+}} @ imm = #-4
45// CHECK-NEXT: 100100c0: movt    r0, #0
46// CHECK-NEXT: 100100c4: movw    r0, #0
47// CHECK:      100100c8: 00 00 00 00     .word   0x00000000
48// CHECK-LABEL: <bl_undefweak2>
49// CHECK-NEXT:    bl {{.*}} <bl_undefweak2+0x4>
50