245 lines
7.3 KiB
Plaintext
245 lines
7.3 KiB
Plaintext
## This is a test case for --section-symbols, --section-relocations and
|
|
## --section-data command line flags and their aliases.
|
|
|
|
# RUN: yaml2obj %s -o %t
|
|
|
|
## Test --section-symbols (--st) displays symbols for each section.
|
|
# RUN: llvm-readobj --sections --st %t > %t.readobj-st
|
|
# RUN: llvm-readobj --sections --section-symbols %t > %t.readobj-st-no-alias
|
|
# RUN: diff %t.readobj-st %t.readobj-st-no-alias
|
|
# RUN: FileCheck %s --input-file=%t.readobj-st --check-prefixes=ALL,ST
|
|
|
|
## Test --section-relocations (--sr) displays relocations for each section.
|
|
# RUN: llvm-readobj --sections --sr %t > %t.readobj-sr
|
|
# RUN: llvm-readobj --sections --section-relocations %t > %t.readobj-sr-no-alias
|
|
# RUN: diff %t.readobj-sr %t.readobj-sr-no-alias
|
|
# RUN: FileCheck %s --input-file=%t.readobj-sr --check-prefixes=ALL,SR
|
|
|
|
## Test --section-data (--sd) displays section data for each section except SHT_NOBITS sections.
|
|
# RUN: llvm-readobj --sections --sd %t > %t.readobj-sd
|
|
# RUN: llvm-readobj --sections --section-data %t > %t.readobj-sd-no-alias
|
|
# RUN: diff %t.readobj-sd %t.readobj-sd-no-alias
|
|
# RUN: FileCheck %s --input-file=%t.readobj-sd --check-prefixes=ALL,SD
|
|
|
|
## Test all options together.
|
|
# RUN: llvm-readobj --sections --section-symbols --section-relocations --section-data %t | \
|
|
# RUN: FileCheck %s --check-prefixes=ALL,ST,SR,SD
|
|
|
|
# ALL: Sections [
|
|
# ALL-NEXT: Section {
|
|
# ALL-NEXT: Index: 0
|
|
# ALL-NEXT: Name: (0)
|
|
# ALL-NEXT: Type: SHT_NULL (0x0)
|
|
# ALL-NEXT: Flags [ (0x0)
|
|
# ALL-NEXT: ]
|
|
# ALL-NEXT: Address: 0x0
|
|
# ALL-NEXT: Offset: 0x0
|
|
# ALL-NEXT: Size: 0
|
|
# ALL-NEXT: Link: 0
|
|
# ALL-NEXT: Info: 0
|
|
# ALL-NEXT: AddressAlignment: 0
|
|
# ALL-NEXT: EntrySize: 0
|
|
# SR-NEXT: Relocations [
|
|
# SR-NEXT: ]
|
|
# ST-NEXT: Symbols [
|
|
# ST-NEXT: ]
|
|
# SD-NEXT: SectionData (
|
|
# SD-NEXT: )
|
|
# ALL-NEXT: }
|
|
# ALL-NEXT: Section {
|
|
# ALL-NEXT: Index: 1
|
|
# ALL-NEXT: Name: .text (6)
|
|
# ALL-NEXT: Type: SHT_PROGBITS (0x1)
|
|
# ALL-NEXT: Flags [ (0x0)
|
|
# ALL-NEXT: ]
|
|
# ALL-NEXT: Address: 0x0
|
|
# ALL-NEXT: Offset: 0x40
|
|
# ALL-NEXT: Size: 0
|
|
# ALL-NEXT: Link: 0
|
|
# ALL-NEXT: Info: 0
|
|
# ALL-NEXT: AddressAlignment: 0
|
|
# ALL-NEXT: EntrySize: 0
|
|
# SR-NEXT: Relocations [
|
|
# SR-NEXT: ]
|
|
# ST-NEXT: Symbols [
|
|
# ST-NEXT: Symbol {
|
|
# ST-NEXT: Name: foo (1)
|
|
# ST-NEXT: Value: 0x0
|
|
# ST-NEXT: Size: 0
|
|
# ST-NEXT: Binding: Local (0x0)
|
|
# ST-NEXT: Type: None (0x0)
|
|
# ST-NEXT: Other: 0
|
|
# ST-NEXT: Section: .text (0x1)
|
|
# ST-NEXT: }
|
|
# ST-NEXT: ]
|
|
# SD-NEXT: SectionData (
|
|
# SD-NEXT: )
|
|
# ALL-NEXT: }
|
|
# ALL-NEXT: Section {
|
|
# ALL-NEXT: Index: 2
|
|
# ALL-NEXT: Name: .rela.text (1)
|
|
# ALL-NEXT: Type: SHT_RELA (0x4)
|
|
# ALL-NEXT: Flags [ (0x0)
|
|
# ALL-NEXT: ]
|
|
# ALL-NEXT: Address: 0x0
|
|
# ALL-NEXT: Offset: 0x40
|
|
# ALL-NEXT: Size: 24
|
|
# ALL-NEXT: Link: 4
|
|
# ALL-NEXT: Info: 1
|
|
# ALL-NEXT: AddressAlignment: 0
|
|
# ALL-NEXT: EntrySize: 24
|
|
# SR-NEXT: Relocations [
|
|
# SR-NEXT: 0x0 R_X86_64_NONE - 0x0
|
|
# SR-NEXT: ]
|
|
# ST-NEXT: Symbols [
|
|
# ST-NEXT: ]
|
|
# SD-NEXT: SectionData (
|
|
# SD-NEXT: 0000: 00000000 00000000 00000000 00000000 |................|
|
|
# SD-NEXT: 0010: 00000000 00000000 |........|
|
|
# SD-NEXT: )
|
|
# ALL-NEXT: }
|
|
# ALL-NEXT: Section {
|
|
# ALL-NEXT: Index: 3
|
|
# ALL-NEXT: Name: .bss (12)
|
|
# ALL-NEXT: Type: SHT_NOBITS (0x8)
|
|
# ALL-NEXT: Flags [ (0x0)
|
|
# ALL-NEXT: ]
|
|
# ALL-NEXT: Address: 0x0
|
|
# ALL-NEXT: Offset: 0x58
|
|
# ALL-NEXT: Size: 4096
|
|
# ALL-NEXT: Link: 0
|
|
# ALL-NEXT: Info: 0
|
|
# ALL-NEXT: AddressAlignment: 0
|
|
# ALL-NEXT: EntrySize: 0
|
|
# SR-NEXT: Relocations [
|
|
# SR-NEXT: ]
|
|
# ST-NEXT: Symbols [
|
|
# ST-NEXT: ]
|
|
# ALL-NEXT: }
|
|
# ALL-NEXT: Section {
|
|
# ALL-NEXT: Index: 4
|
|
# ALL-NEXT: Name: .symtab (35)
|
|
# ALL-NEXT: Type: SHT_SYMTAB (0x2)
|
|
# ALL-NEXT: Flags [ (0x0)
|
|
# ALL-NEXT: ]
|
|
# ALL-NEXT: Address: 0x0
|
|
# ALL-NEXT: Offset: 0x58
|
|
# ALL-NEXT: Size: 48
|
|
# ALL-NEXT: Link: 5
|
|
# ALL-NEXT: Info: 2
|
|
# ALL-NEXT: AddressAlignment: 8
|
|
# ALL-NEXT: EntrySize: 24
|
|
# SR-NEXT: Relocations [
|
|
# SR-NEXT: ]
|
|
# ST-NEXT: Symbols [
|
|
# ST-NEXT: ]
|
|
# SD-NEXT: SectionData (
|
|
# SD-NEXT: 0000: 00000000 00000000 00000000 00000000 |................|
|
|
# SD-NEXT: 0010: 00000000 00000000 01000000 00000100 |................|
|
|
# SD-NEXT: 0020: 00000000 00000000 00000000 00000000 |................|
|
|
# SD-NEXT: )
|
|
# ALL-NEXT: }
|
|
# ALL-NEXT: Section {
|
|
# ALL-NEXT: Index: 5
|
|
# ALL-NEXT: Name: .strtab (27)
|
|
# ALL-NEXT: Type: SHT_STRTAB (0x3)
|
|
# ALL-NEXT: Flags [ (0x0)
|
|
# ALL-NEXT: ]
|
|
# ALL-NEXT: Address: 0x0
|
|
# ALL-NEXT: Offset: 0x88
|
|
# ALL-NEXT: Size: 5
|
|
# ALL-NEXT: Link: 0
|
|
# ALL-NEXT: Info: 0
|
|
# ALL-NEXT: AddressAlignment: 1
|
|
# ALL-NEXT: EntrySize: 0
|
|
# SR-NEXT: Relocations [
|
|
# SR-NEXT: ]
|
|
# ST-NEXT: Symbols [
|
|
# ST-NEXT: ]
|
|
# SD-NEXT: SectionData (
|
|
# SD-NEXT: 0000: 00666F6F 00 |.foo.|
|
|
# SD-NEXT: )
|
|
# ALL-NEXT: }
|
|
# ALL-NEXT: Section {
|
|
# ALL-NEXT: Index: 6
|
|
# ALL-NEXT: Name: .shstrtab (17)
|
|
# ALL-NEXT: Type: SHT_STRTAB (0x3)
|
|
# ALL-NEXT: Flags [ (0x0)
|
|
# ALL-NEXT: ]
|
|
# ALL-NEXT: Address: 0x0
|
|
# ALL-NEXT: Offset: 0x8D
|
|
# ALL-NEXT: Size: 43
|
|
# ALL-NEXT: Link: 0
|
|
# ALL-NEXT: Info: 0
|
|
# ALL-NEXT: AddressAlignment: 1
|
|
# ALL-NEXT: EntrySize: 0
|
|
# SR-NEXT: Relocations [
|
|
# SR-NEXT: ]
|
|
# ST-NEXT: Symbols [
|
|
# ST-NEXT: ]
|
|
# SD-NEXT: SectionData (
|
|
# SD-NEXT: 0000: 002E7265 6C612E74 65787400 2E627373 |..rela.text..bss|
|
|
# SD-NEXT: 0010: 002E7368 73747274 6162002E 73747274 |..shstrtab..strt|
|
|
# SD-NEXT: 0020: 6162002E 73796D74 616200 |ab..symtab.|
|
|
# SD-NEXT: )
|
|
# ALL-NEXT: }
|
|
# ALL-NEXT: ]
|
|
|
|
## Check that --section-symbols, --section-relocations and --section-data
|
|
## options produce no output without --sections.
|
|
# RUN: llvm-readobj --section-symbols --section-relocations --section-data %t | \
|
|
# RUN: FileCheck %s -DFILE=%t --check-prefix=NO-SECTIONS
|
|
|
|
# NO-SECTIONS: File: [[FILE]]
|
|
# NO-SECTIONS-NEXT: Format: elf64-x86-64
|
|
# NO-SECTIONS-NEXT: Arch: x86_64
|
|
# NO-SECTIONS-NEXT: AddressSize: 64bit
|
|
# NO-SECTIONS-NEXT: LoadName: <Not found>
|
|
# NO-SECTIONS-NOT: {{.}}
|
|
|
|
--- !ELF
|
|
FileHeader:
|
|
Class: ELFCLASS64
|
|
Data: ELFDATA2LSB
|
|
Type: ET_REL
|
|
Machine: EM_X86_64
|
|
Sections:
|
|
- Name: .text
|
|
Type: SHT_PROGBITS
|
|
- Name: .rela.text
|
|
Type: SHT_RELA
|
|
Info: .text
|
|
Relocations:
|
|
- Type: R_X86_64_NONE
|
|
- Name: .bss
|
|
Type: SHT_NOBITS
|
|
Size: 0x1000
|
|
Symbols:
|
|
- Name: foo
|
|
Section: .text
|
|
|
|
## Check the output for an arbitrary section when --section-symbols is requested,
|
|
## but there is no symbol table in the object.
|
|
# RUN: yaml2obj --docnum=2 %s -o %t2
|
|
# RUN: llvm-readobj -S --section-symbols %t2 2>&1 | \
|
|
# RUN: FileCheck %s --implicit-check-not=warning: --check-prefix=NOSYMTAB
|
|
|
|
# NOSYMTAB: Section {
|
|
# NOSYMTAB: Index: 1
|
|
# NOSYMTAB-NEXT: Name: .foo
|
|
# NOSYMTAB: Symbols [
|
|
# NOSYMTAB-NEXT: ]
|
|
# NOSYMTAB-NEXT: }
|
|
# NOSYMTAB-NEXT: Section {
|
|
# NOSYMTAB-NEXT: Index: 2
|
|
|
|
--- !ELF
|
|
FileHeader:
|
|
Class: ELFCLASS64
|
|
Data: ELFDATA2LSB
|
|
Type: ET_REL
|
|
Machine: EM_X86_64
|
|
Sections:
|
|
- Name: .foo
|
|
Type: SHT_PROGBITS
|