1 ## This is a test case for --section-symbols, --section-relocations and
2 ## --section-data command line flags and their aliases.
4 # RUN: yaml2obj %s -o %t
6 ## Test --section-symbols (--st) displays symbols for each section.
7 # RUN: llvm-readobj --sections --st %t > %t.readobj-st
8 # RUN: llvm-readobj --sections --section-symbols %t > %t.readobj-st-no-alias
9 # RUN: diff %t.readobj-st %t.readobj-st-no-alias
10 # RUN: FileCheck %s --input-file=%t.readobj-st --check-prefixes=ALL,ST
12 ## Test --section-relocations (--sr) displays relocations for each section.
13 # RUN: llvm-readobj --sections --sr %t > %t.readobj-sr
14 # RUN: llvm-readobj --sections --section-relocations %t > %t.readobj-sr-no-alias
15 # RUN: diff %t.readobj-sr %t.readobj-sr-no-alias
16 # RUN: FileCheck %s --input-file=%t.readobj-sr --check-prefixes=ALL,SR
18 ## Test --section-data (--sd) displays section data for each section except SHT_NOBITS sections.
19 # RUN: llvm-readobj --sections --sd %t > %t.readobj-sd
20 # RUN: llvm-readobj --sections --section-data %t > %t.readobj-sd-no-alias
21 # RUN: diff %t.readobj-sd %t.readobj-sd-no-alias
22 # RUN: FileCheck %s --input-file=%t.readobj-sd --check-prefixes=ALL,SD
24 ## Test all options together.
25 # RUN: llvm-readobj --sections --section-symbols --section-relocations --section-data %t | \
26 # RUN: FileCheck %s --check-prefixes=ALL,ST,SR,SD
32 # ALL-NEXT: Type: SHT_NULL (0x0)
33 # ALL-NEXT: Flags [ (0x0)
35 # ALL-NEXT: Address: 0x0
36 # ALL-NEXT: Offset: 0x0
40 # ALL-NEXT: AddressAlignment: 0
41 # ALL-NEXT: EntrySize: 0
42 # SR-NEXT: Relocations [
46 # SD-NEXT: SectionData (
51 # ALL-NEXT: Name: .text (6)
52 # ALL-NEXT: Type: SHT_PROGBITS (0x1)
53 # ALL-NEXT: Flags [ (0x0)
55 # ALL-NEXT: Address: 0x0
56 # ALL-NEXT: Offset: 0x40
60 # ALL-NEXT: AddressAlignment: 0
61 # ALL-NEXT: EntrySize: 0
62 # SR-NEXT: Relocations [
66 # ST-NEXT: Name: foo (1)
69 # ST-NEXT: Binding: Local (0x0)
70 # ST-NEXT: Type: None (0x0)
72 # ST-NEXT: Section: .text (0x1)
75 # SD-NEXT: SectionData (
80 # ALL-NEXT: Name: .rela.text (1)
81 # ALL-NEXT: Type: SHT_RELA (0x4)
82 # ALL-NEXT: Flags [ (0x0)
84 # ALL-NEXT: Address: 0x0
85 # ALL-NEXT: Offset: 0x40
89 # ALL-NEXT: AddressAlignment: 0
90 # ALL-NEXT: EntrySize: 24
91 # SR-NEXT: Relocations [
92 # SR-NEXT: 0x0 R_X86_64_NONE - 0x0
96 # SD-NEXT: SectionData (
97 # SD-NEXT: 0000: 00000000 00000000 00000000 00000000 |................|
98 # SD-NEXT: 0010: 00000000 00000000 |........|
101 # ALL-NEXT: Section {
103 # ALL-NEXT: Name: .bss (12)
104 # ALL-NEXT: Type: SHT_NOBITS (0x8)
105 # ALL-NEXT: Flags [ (0x0)
107 # ALL-NEXT: Address: 0x0
108 # ALL-NEXT: Offset: 0x58
109 # ALL-NEXT: Size: 4096
112 # ALL-NEXT: AddressAlignment: 0
113 # ALL-NEXT: EntrySize: 0
114 # SR-NEXT: Relocations [
119 # ALL-NEXT: Section {
121 # ALL-NEXT: Name: .symtab (35)
122 # ALL-NEXT: Type: SHT_SYMTAB (0x2)
123 # ALL-NEXT: Flags [ (0x0)
125 # ALL-NEXT: Address: 0x0
126 # ALL-NEXT: Offset: 0x58
130 # ALL-NEXT: AddressAlignment: 8
131 # ALL-NEXT: EntrySize: 24
132 # SR-NEXT: Relocations [
136 # SD-NEXT: SectionData (
137 # SD-NEXT: 0000: 00000000 00000000 00000000 00000000 |................|
138 # SD-NEXT: 0010: 00000000 00000000 01000000 00000100 |................|
139 # SD-NEXT: 0020: 00000000 00000000 00000000 00000000 |................|
142 # ALL-NEXT: Section {
144 # ALL-NEXT: Name: .strtab (27)
145 # ALL-NEXT: Type: SHT_STRTAB (0x3)
146 # ALL-NEXT: Flags [ (0x0)
148 # ALL-NEXT: Address: 0x0
149 # ALL-NEXT: Offset: 0x88
153 # ALL-NEXT: AddressAlignment: 1
154 # ALL-NEXT: EntrySize: 0
155 # SR-NEXT: Relocations [
159 # SD-NEXT: SectionData (
160 # SD-NEXT: 0000: 00666F6F 00 |.foo.|
163 # ALL-NEXT: Section {
165 # ALL-NEXT: Name: .shstrtab (17)
166 # ALL-NEXT: Type: SHT_STRTAB (0x3)
167 # ALL-NEXT: Flags [ (0x0)
169 # ALL-NEXT: Address: 0x0
170 # ALL-NEXT: Offset: 0x8D
174 # ALL-NEXT: AddressAlignment: 1
175 # ALL-NEXT: EntrySize: 0
176 # SR-NEXT: Relocations [
180 # SD-NEXT: SectionData (
181 # SD-NEXT: 0000: 002E7265 6C612E74 65787400 2E627373 |..rela.text..bss|
182 # SD-NEXT: 0010: 002E7368 73747274 6162002E 73747274 |..shstrtab..strt|
183 # SD-NEXT: 0020: 6162002E 73796D74 616200 |ab..symtab.|
188 ## Check that --section-symbols, --section-relocations and --section-data
189 ## options produce no output without --sections.
190 # RUN: llvm-readobj --section-symbols --section-relocations --section-data %t | \
191 # RUN: FileCheck %s -DFILE=%t --check-prefix=NO-SECTIONS
193 # NO-SECTIONS: File: [[FILE]]
194 # NO-SECTIONS-NEXT: Format: elf64-x86-64
195 # NO-SECTIONS-NEXT: Arch: x86_64
196 # NO-SECTIONS-NEXT: AddressSize: 64bit
197 # NO-SECTIONS-NEXT: LoadName: <Not found>
198 # NO-SECTIONS-NOT: {{.}}
213 - Type: R_X86_64_NONE
221 ## Check the output for an arbitrary section when --section-symbols is requested,
222 ## but there is no symbol table in the object.
223 # RUN: yaml2obj --docnum=2 %s -o %t2
224 # RUN: llvm-readobj -S --section-symbols %t2 2>&1 | \
225 # RUN: FileCheck %s --implicit-check-not=warning: --check-prefix=NOSYMTAB
227 # NOSYMTAB: Section {
229 # NOSYMTAB-NEXT: Name: .foo
230 # NOSYMTAB: Symbols [
233 # NOSYMTAB-NEXT: Section {
234 # NOSYMTAB-NEXT: Index: 2