xref: /llvm-project/lld/test/ELF/arm-thumb-undefined-weak-narrow.test (revision 75cdab6dc2453a508157a9c383b93373a93078d6)
1# REQUIRES: arm
2# RUN: yaml2obj %s -o %t.o
3# RUN: ld.lld %t.o -o %t
4# RUN: llvm-objdump --no-print-imm-hex -d %t | FileCheck %s
5
6# CHECK: Disassembly of section .text:
7# CHECK-EMPTY:
8# CHECK-NEXT: <_start>:
9# CHECK-NEXT:    e7ff    b       0x200b6 <_start+0x2> @ imm = #-2
10# CHECK-NEXT:    d0fe    beq     0x200b6 <_start+0x2> @ imm = #-4
11
12# Test the R_ARM_THM_JUMP11 (102) and R_ARM_THM_JUMP8 (103) relocations to an
13# undefined weak reference.  It should resolve to the next instruction, which
14# is an offset of -2 which when added to the Thumb PC-bias of 4 is +2. We can't
15# use llvm-mc to construct the object as it relaxes b.n to b.w (R_ARM_JUMP24).
16
17!ELF
18FileHeader:
19  Class:           ELFCLASS32
20  Data:            ELFDATA2LSB
21  Type:            ET_REL
22  Machine:         EM_ARM
23Sections:
24  - Type:            SHT_PROGBITS
25    Name:            .text
26    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
27    Content:         "fee7fed0"
28  - Type:            SHT_REL
29    Name:            .rel.text
30    Link:            .symtab
31    Info:            .text
32    Relocations:
33      - Symbol:          undefined_weak
34        Type:            R_ARM_THM_JUMP11
35      - Symbol:          undefined_weak
36        Type:            R_ARM_THM_JUMP8
37
38Symbols:
39  - Type:             STT_NOTYPE
40    Name:             "$t"
41    Section:          .text
42    Value:            0
43  - Type:             STT_FUNC
44    Name:             _start
45    Value:            1
46    Section:          .text
47    Binding:          STB_GLOBAL
48  - Type:             STT_NOTYPE
49    Name:             undefined_weak
50    Value:            0
51    Binding:          STB_WEAK
52