245 lines · plain
1## This is a test case for --section-symbols, --section-relocations and2## --section-data command line flags and their aliases.3 4# RUN: yaml2obj %s -o %t5 6## Test --section-symbols (--st) displays symbols for each section.7# RUN: llvm-readobj --sections --st %t > %t.readobj-st8# RUN: llvm-readobj --sections --section-symbols %t > %t.readobj-st-no-alias9# RUN: diff %t.readobj-st %t.readobj-st-no-alias10# RUN: FileCheck %s --input-file=%t.readobj-st --check-prefixes=ALL,ST11 12## Test --section-relocations (--sr) displays relocations for each section.13# RUN: llvm-readobj --sections --sr %t > %t.readobj-sr14# RUN: llvm-readobj --sections --section-relocations %t > %t.readobj-sr-no-alias15# RUN: diff %t.readobj-sr %t.readobj-sr-no-alias16# RUN: FileCheck %s --input-file=%t.readobj-sr --check-prefixes=ALL,SR17 18## Test --section-data (--sd) displays section data for each section except SHT_NOBITS sections.19# RUN: llvm-readobj --sections --sd %t > %t.readobj-sd20# RUN: llvm-readobj --sections --section-data %t > %t.readobj-sd-no-alias21# RUN: diff %t.readobj-sd %t.readobj-sd-no-alias22# RUN: FileCheck %s --input-file=%t.readobj-sd --check-prefixes=ALL,SD23 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,SD27 28# ALL: Sections [29# ALL-NEXT: Section {30# ALL-NEXT: Index: 031# ALL-NEXT: Name: (0)32# ALL-NEXT: Type: SHT_NULL (0x0)33# ALL-NEXT: Flags [ (0x0)34# ALL-NEXT: ]35# ALL-NEXT: Address: 0x036# ALL-NEXT: Offset: 0x037# ALL-NEXT: Size: 038# ALL-NEXT: Link: 039# ALL-NEXT: Info: 040# ALL-NEXT: AddressAlignment: 041# ALL-NEXT: EntrySize: 042# SR-NEXT: Relocations [43# SR-NEXT: ]44# ST-NEXT: Symbols [45# ST-NEXT: ]46# SD-NEXT: SectionData (47# SD-NEXT: )48# ALL-NEXT: }49# ALL-NEXT: Section {50# ALL-NEXT: Index: 151# ALL-NEXT: Name: .text (6)52# ALL-NEXT: Type: SHT_PROGBITS (0x1)53# ALL-NEXT: Flags [ (0x0)54# ALL-NEXT: ]55# ALL-NEXT: Address: 0x056# ALL-NEXT: Offset: 0x4057# ALL-NEXT: Size: 058# ALL-NEXT: Link: 059# ALL-NEXT: Info: 060# ALL-NEXT: AddressAlignment: 061# ALL-NEXT: EntrySize: 062# SR-NEXT: Relocations [63# SR-NEXT: ]64# ST-NEXT: Symbols [65# ST-NEXT: Symbol {66# ST-NEXT: Name: foo (1)67# ST-NEXT: Value: 0x068# ST-NEXT: Size: 069# ST-NEXT: Binding: Local (0x0)70# ST-NEXT: Type: None (0x0)71# ST-NEXT: Other: 072# ST-NEXT: Section: .text (0x1)73# ST-NEXT: }74# ST-NEXT: ]75# SD-NEXT: SectionData (76# SD-NEXT: )77# ALL-NEXT: }78# ALL-NEXT: Section {79# ALL-NEXT: Index: 280# ALL-NEXT: Name: .rela.text (1)81# ALL-NEXT: Type: SHT_RELA (0x4)82# ALL-NEXT: Flags [ (0x0)83# ALL-NEXT: ]84# ALL-NEXT: Address: 0x085# ALL-NEXT: Offset: 0x4086# ALL-NEXT: Size: 2487# ALL-NEXT: Link: 488# ALL-NEXT: Info: 189# ALL-NEXT: AddressAlignment: 090# ALL-NEXT: EntrySize: 2491# SR-NEXT: Relocations [92# SR-NEXT: 0x0 R_X86_64_NONE - 0x093# SR-NEXT: ]94# ST-NEXT: Symbols [95# ST-NEXT: ]96# SD-NEXT: SectionData (97# SD-NEXT: 0000: 00000000 00000000 00000000 00000000 |................|98# SD-NEXT: 0010: 00000000 00000000 |........|99# SD-NEXT: )100# ALL-NEXT: }101# ALL-NEXT: Section {102# ALL-NEXT: Index: 3103# ALL-NEXT: Name: .bss (12)104# ALL-NEXT: Type: SHT_NOBITS (0x8)105# ALL-NEXT: Flags [ (0x0)106# ALL-NEXT: ]107# ALL-NEXT: Address: 0x0108# ALL-NEXT: Offset: 0x58109# ALL-NEXT: Size: 4096110# ALL-NEXT: Link: 0111# ALL-NEXT: Info: 0112# ALL-NEXT: AddressAlignment: 0113# ALL-NEXT: EntrySize: 0114# SR-NEXT: Relocations [115# SR-NEXT: ]116# ST-NEXT: Symbols [117# ST-NEXT: ]118# ALL-NEXT: }119# ALL-NEXT: Section {120# ALL-NEXT: Index: 4121# ALL-NEXT: Name: .symtab (35)122# ALL-NEXT: Type: SHT_SYMTAB (0x2)123# ALL-NEXT: Flags [ (0x0)124# ALL-NEXT: ]125# ALL-NEXT: Address: 0x0126# ALL-NEXT: Offset: 0x58127# ALL-NEXT: Size: 48128# ALL-NEXT: Link: 5129# ALL-NEXT: Info: 2130# ALL-NEXT: AddressAlignment: 8131# ALL-NEXT: EntrySize: 24132# SR-NEXT: Relocations [133# SR-NEXT: ]134# ST-NEXT: Symbols [135# ST-NEXT: ]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 |................|140# SD-NEXT: )141# ALL-NEXT: }142# ALL-NEXT: Section {143# ALL-NEXT: Index: 5144# ALL-NEXT: Name: .strtab (27)145# ALL-NEXT: Type: SHT_STRTAB (0x3)146# ALL-NEXT: Flags [ (0x0)147# ALL-NEXT: ]148# ALL-NEXT: Address: 0x0149# ALL-NEXT: Offset: 0x88150# ALL-NEXT: Size: 5151# ALL-NEXT: Link: 0152# ALL-NEXT: Info: 0153# ALL-NEXT: AddressAlignment: 1154# ALL-NEXT: EntrySize: 0155# SR-NEXT: Relocations [156# SR-NEXT: ]157# ST-NEXT: Symbols [158# ST-NEXT: ]159# SD-NEXT: SectionData (160# SD-NEXT: 0000: 00666F6F 00 |.foo.|161# SD-NEXT: )162# ALL-NEXT: }163# ALL-NEXT: Section {164# ALL-NEXT: Index: 6165# ALL-NEXT: Name: .shstrtab (17)166# ALL-NEXT: Type: SHT_STRTAB (0x3)167# ALL-NEXT: Flags [ (0x0)168# ALL-NEXT: ]169# ALL-NEXT: Address: 0x0170# ALL-NEXT: Offset: 0x8D171# ALL-NEXT: Size: 43172# ALL-NEXT: Link: 0173# ALL-NEXT: Info: 0174# ALL-NEXT: AddressAlignment: 1175# ALL-NEXT: EntrySize: 0176# SR-NEXT: Relocations [177# SR-NEXT: ]178# ST-NEXT: Symbols [179# ST-NEXT: ]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.|184# SD-NEXT: )185# ALL-NEXT: }186# ALL-NEXT: ]187 188## Check that --section-symbols, --section-relocations and --section-data189## 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-SECTIONS192 193# NO-SECTIONS: File: [[FILE]]194# NO-SECTIONS-NEXT: Format: elf64-x86-64195# NO-SECTIONS-NEXT: Arch: x86_64196# NO-SECTIONS-NEXT: AddressSize: 64bit197# NO-SECTIONS-NEXT: LoadName: <Not found>198# NO-SECTIONS-NOT: {{.}}199 200--- !ELF201FileHeader:202 Class: ELFCLASS64203 Data: ELFDATA2LSB204 Type: ET_REL205 Machine: EM_X86_64206Sections:207 - Name: .text208 Type: SHT_PROGBITS209 - Name: .rela.text210 Type: SHT_RELA211 Info: .text212 Relocations:213 - Type: R_X86_64_NONE214 - Name: .bss215 Type: SHT_NOBITS216 Size: 0x1000217Symbols:218 - Name: foo219 Section: .text220 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 %t2224# RUN: llvm-readobj -S --section-symbols %t2 2>&1 | \225# RUN: FileCheck %s --implicit-check-not=warning: --check-prefix=NOSYMTAB226 227# NOSYMTAB: Section {228# NOSYMTAB: Index: 1229# NOSYMTAB-NEXT: Name: .foo230# NOSYMTAB: Symbols [231# NOSYMTAB-NEXT: ]232# NOSYMTAB-NEXT: }233# NOSYMTAB-NEXT: Section {234# NOSYMTAB-NEXT: Index: 2235 236--- !ELF237FileHeader:238 Class: ELFCLASS64239 Data: ELFDATA2LSB240 Type: ET_REL241 Machine: EM_X86_64242Sections:243 - Name: .foo244 Type: SHT_PROGBITS245