xref: /llvm-project/llvm/test/tools/llvm-objdump/X86/elf-bbaddrmap-symbolize-relocatable.yaml (revision acec6419e811a46050b0603dfa72fc6a169aa0f7)
1## Test that in the presence of SHT_LLVM_BB_ADDR_MAP sections,
2## --symbolize-operands can display <BB*> labels properly in a relocatable
3## object file.
4
5## Relocatable Object file.
6# RUN: yaml2obj %s -o %t1
7# RUN: llvm-objdump %t1 -d --symbolize-operands -M att --no-show-raw-insn --no-leading-addr | \
8# RUN:   FileCheck %s -DSYM=symbol --match-full-lines
9
10--- !ELF
11FileHeader:
12  Class:           ELFCLASS64
13  Data:            ELFDATA2LSB
14  Type:            ET_REL
15  Machine:         EM_X86_64
16  SectionHeaderStringTable: .strtab
17Sections:
18  - Name:    .text
19    Type:    SHT_PROGBITS
20    Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
21    Content: FFFF
22  - Name:    .llvm_bb_addr_map
23    Type:    SHT_LLVM_BB_ADDR_MAP
24    Link:    .text
25    Entries:
26      - Version: 2
27        BBRanges:
28          - BBEntries:
29             - ID:              0
30               AddressOffset:   0x0
31               Size:            0x1
32               Metadata:        0xa
33      - Version: 2
34        BBRanges:
35          - BBEntries:
36            - ID:              0
37              AddressOffset:   0x0
38              Size:            0x1
39              Metadata:        0xb
40      - Version: 2
41        Feature: 0x8
42        BBRanges:
43          - BBEntries:
44            - ID:              0
45              AddressOffset:   0x0
46              Size:            0x1
47              Metadata:        0xc
48          - BBEntries:
49            - ID:              1
50              AddressOffset:   0x0
51              Size:            0x1
52              Metadata:        0xd
53  - Name:  .rela.llvm_bb_addr_map
54    Type:  SHT_RELA
55    Flags: [ SHF_INFO_LINK ]
56    Link:  .symtab
57    Info:  .llvm_bb_addr_map
58    Relocations:
59      - Offset: 0x2
60        Symbol: .text
61        Type:   R_X86_64_64
62      - Offset: 0x11
63        Symbol: .text
64        Type:   R_X86_64_64
65        Addend: 1
66      - Offset: 0x21
67        Symbol: .text
68        Type:   R_X86_64_64
69        Addend: 0x2
70      - Offset: 0x2e
71        Symbol: .text
72        Type:   R_X86_64_64
73        Addend: 0x3
74
75Symbols:
76  - Name:    a
77    Section: .text
78    Value:   0x0
79  - Name:    c
80    Section: .text
81    Value:   0x1
82  - Name:    h
83    Section: .text
84    Value:   0x2
85  - Name:    h1
86    Section: .text
87    Value:   0x3
88  - Name:    .text
89    Type:    STT_SECTION
90    Section: .text
91
92# CHECK:      <a>:
93# CHECK-NEXT: <BB0>:
94# CHECK:      <c>:
95# CHECK-NEXT: <BB0>:
96
97## Check that if we're missing a relocation section we get the appropriate
98## warning.
99
100# RUN: yaml2obj %s --docnum=2 -o %t2
101# RUN: llvm-readobj %t2 --bb-addr-map 2>&1 | FileCheck %s --check-prefix=NO-RELA-SECTION -DFILE=%t2
102
103--- !ELF
104FileHeader:
105  Class:           ELFCLASS64
106  Data:            ELFDATA2LSB
107  Type:            ET_REL
108  Machine:         EM_X86_64
109Sections:
110  - Name:    .text
111    Type:    SHT_PROGBITS
112    Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
113    Content: FF
114  - Name:    .llvm_bb_addr_map
115    Type:    SHT_LLVM_BB_ADDR_MAP
116    Link:    .text
117
118# NO-RELA-SECTION: warning: '[[FILE]]': unable to get relocation section for SHT_LLVM_BB_ADDR_MAP section with index 2
119