llvm-mirror/test/Object/readobj-shared-object.test
Eric Christopher df46cef31b Implements low-level object file format specific output for COFF and
ELF with support for:

- File headers
- Section headers + data
- Relocations
- Symbols
- Unwind data (only COFF/Win64)

The output format follows a few rules:
- Values are almost always output one per line (as elf-dump/coff-dump already do). - Many values are translated to something readable (like enum names), with the raw value in parentheses.
- Hex numbers are output in uppercase, prefixed with "0x".
- Flags are sorted alphabetically.
- Lists and groups are always delimited.

Example output:
---------- snip ----------
Sections [
  Section {
    Index: 1
    Name: .text (5)
    Type: SHT_PROGBITS (0x1)
    Flags [ (0x6)
      SHF_ALLOC (0x2)
      SHF_EXECINSTR (0x4)
    ]
    Address: 0x0
    Offset: 0x40
    Size: 33
    Link: 0
    Info: 0
    AddressAlignment: 16
    EntrySize: 0
    Relocations [
      0x6 R_386_32 .rodata.str1.1 0x0
      0xB R_386_PC32 puts 0x0
      0x12 R_386_32 .rodata.str1.1 0x0
      0x17 R_386_PC32 puts 0x0
    ]
    SectionData (
      0000: 83EC04C7 04240000 0000E8FC FFFFFFC7  |.....$..........|
      0010: 04240600 0000E8FC FFFFFF31 C083C404  |.$.........1....|
      0020: C3                                   |.|
    )
  }
]
---------- snip ----------

Relocations and symbols can be output standalone or together with the section header as displayed in the example.
This feature set supports all tests in test/MC/COFF and test/MC/ELF (and I suspect all additional tests using elf-dump), making elf-dump and coff-dump deprecated.

Patch by Nico Rieck!

llvm-svn: 178679
2013-04-03 18:31:38 +00:00

320 lines
6.7 KiB
Plaintext

RUN: llvm-readobj -s -t -dt -dynamic-table -needed-libs \
RUN: %p/Inputs/shared-object-test.elf-i386 \
RUN: | FileCheck %s -check-prefix ELF
RUN: llvm-readobj -s -t -dt -dynamic-table -needed-libs \
RUN: %p/Inputs/shared-object-test.elf-i386 \
RUN: | FileCheck %s -check-prefix ELF32
RUN: llvm-readobj -s -t -dt -dynamic-table -needed-libs \
RUN: %p/Inputs/shared-object-test.elf-x86-64 \
RUN: | FileCheck %s -check-prefix ELF
RUN: llvm-readobj -s -t -dt -dynamic-table -needed-libs \
RUN: %p/Inputs/shared-object-test.elf-x86-64 \
RUN: | FileCheck %s -check-prefix ELF64
ELF64: Format: ELF64-x86-64
ELF64: Arch: x86_64
ELF64: AddressSize: 64bit
ELF64: LoadName: libfoo.so
ELF32: Format: ELF32-i386
ELF32: Arch: i386
ELF32: AddressSize: 32bit
ELF32: LoadName: libfoo.so
ELF: Sections [
ELF: Section {
ELF: Name: (0)
ELF: Type: SHT_NULL
ELF: Flags [ (0x0)
ELF: ]
ELF: }
ELF: Section {
ELF: Name: .hash
ELF: Type: SHT_HASH
ELF: Flags [ (0x2)
ELF: SHF_ALLOC
ELF: ]
ELF: }
ELF: Section {
ELF: Name: .dynsym
ELF: Type: SHT_DYNSYM
ELF: Flags [ (0x2)
ELF: SHF_ALLOC
ELF: ]
ELF: }
ELF: Section {
ELF: Name: .dynstr
ELF: Type: SHT_STRTAB
ELF: Flags [ (0x2)
ELF: SHF_ALLOC
ELF: ]
ELF: }
ELF: Section {
ELF: Name: .text
ELF: Type: SHT_PROGBITS
ELF: Flags [ (0x6)
ELF: SHF_ALLOC
ELF: SHF_EXECINSTR
ELF: ]
ELF: }
ELF: Section {
ELF: Name: .eh_frame
ELF: Type: SHT_PROGBITS
ELF: Flags [ (0x2)
ELF: SHF_ALLOC
ELF: ]
ELF: }
ELF: Section {
ELF: Name: .tdata
ELF: Type: SHT_PROGBITS
ELF: Flags [ (0x403)
ELF: SHF_ALLOC
ELF: SHF_TLS
ELF: SHF_WRITE
ELF: ]
ELF: }
ELF: Section {
ELF: Name: .dynamic
ELF: Type: SHT_DYNAMIC
ELF: Flags [ (0x3)
ELF: SHF_ALLOC
ELF: SHF_WRITE
ELF: ]
ELF: }
ELF: Section {
ELF: Name: .got.plt
ELF: Type: SHT_PROGBITS
ELF: Flags [ (0x3)
ELF: SHF_ALLOC
ELF: SHF_WRITE
ELF: ]
ELF: }
ELF: Section {
ELF: Name: .data
ELF: Type: SHT_PROGBITS
ELF: Flags [ (0x3)
ELF: SHF_ALLOC
ELF: SHF_WRITE
ELF: ]
ELF: }
ELF: Section {
ELF: Name: .bss
ELF: Type: SHT_NOBITS
ELF: Flags [ (0x3)
ELF: SHF_ALLOC
ELF: SHF_WRITE
ELF: ]
ELF: }
ELF: Section {
ELF: Name: .shstrtab
ELF: Type: SHT_STRTAB
ELF: Flags [ (0x0)
ELF: ]
ELF: }
ELF: Section {
ELF: Name: .symtab
ELF: Type: SHT_SYMTAB
ELF: Flags [ (0x0)
ELF: ]
ELF: }
ELF: Section {
ELF: Name: .strtab
ELF: Type: SHT_STRTAB
ELF: Flags [ (0x0)
ELF: ]
ELF: }
ELF: ]
ELF: Symbols [
ELF: Symbol {
ELF: Name: .hash
ELF: Binding: Local
ELF: Type: Section
ELF: Section: .hash
ELF: }
ELF: Symbol {
ELF: Name: .dynsym
ELF: Binding: Local
ELF: Type: Section
ELF: Section: .dynsym
ELF: }
ELF: Symbol {
ELF: Name: .dynstr
ELF: Binding: Local
ELF: Type: Section
ELF: Section: .dynstr
ELF: }
ELF: Symbol {
ELF: Name: .text
ELF: Binding: Local
ELF: Type: Section
ELF: Section: .text
ELF: }
ELF: Symbol {
ELF: Name: .eh_frame
ELF: Binding: Local
ELF: Type: Section
ELF: Section: .eh_frame
ELF: }
ELF: Symbol {
ELF: Name: .tdata
ELF: Binding: Local
ELF: Type: Section
ELF: Section: .tdata
ELF: }
ELF: Symbol {
ELF: Name: .dynamic
ELF: Binding: Local
ELF: Type: Section
ELF: Section: .dynamic
ELF: }
ELF: Symbol {
ELF: Name: .got.plt
ELF: Binding: Local
ELF: Type: Section
ELF: Section: .got.plt
ELF: }
ELF: Symbol {
ELF: Name: .data
ELF: Binding: Local
ELF: Type: Section
ELF: Section: .data
ELF: }
ELF: Symbol {
ELF: Name: .bss
ELF: Binding: Local
ELF: Type: Section
ELF: Section: .bss
ELF: }
ELF: Symbol {
ELF: Name: shared.ll
ELF: Binding: Local
ELF: Type: File
ELF: Section: (0xFFF1)
ELF: }
ELF: Symbol {
ELF: Name: local_func
ELF: Binding: Local
ELF: Type: Function
ELF: Section: .text
ELF: }
ELF: Symbol {
ELF: Name: _GLOBAL_OFFSET_TABLE_
ELF: Binding: Local
ELF: Type: Object
ELF: Section: (0xFFF1)
ELF: }
ELF: Symbol {
ELF: Name: _DYNAMIC
ELF: Binding: Local
ELF: Type: Object
ELF: Section: (0xFFF1)
ELF: }
ELF: Symbol {
ELF: Name: common_sym
ELF: Binding: Global
ELF: Type: Object
ELF: Section: .bss
ELF: }
ELF: Symbol {
ELF: Name: tls_sym
ELF: Binding: Global
ELF: Type: TLS
ELF: Section: .tdata
ELF: }
ELF: Symbol {
ELF: Name: defined_sym
ELF: Binding: Global
ELF: Type: Object
ELF: Section: .data
ELF: }
ELF: Symbol {
ELF: Name: __bss_start
ELF: Binding: Global
ELF: Type: None
ELF: Section: (0xFFF1)
ELF: }
ELF: Symbol {
ELF: Name: _end
ELF: Binding: Global
ELF: Type: None
ELF: Section: (0xFFF1)
ELF: }
ELF: Symbol {
ELF: Name: global_func
ELF: Binding: Global
ELF: Type: Function
ELF: Section: .text
ELF: }
ELF: Symbol {
ELF: Name: _edata
ELF: Binding: Global
ELF: Type: None
ELF: Section: (0xFFF1)
ELF: }
ELF: ]
ELF: DynamicSymbols [
ELF: Symbol {
ELF: Name: common_sym
ELF: Binding: Global
ELF: Type: Object
ELF: Section: .bss
ELF: }
ELF: Symbol {
ELF: Name: tls_sym
ELF: Binding: Global
ELF: Type: TLS
ELF: Section: .tdata
ELF: }
ELF: Symbol {
ELF: Name: defined_sym
ELF: Binding: Global
ELF: Type: Object
ELF: Section: .data
ELF: }
ELF: Symbol {
ELF: Name: __bss_start
ELF: Binding: Global
ELF: Type: None
ELF: Section: (0xFFF1)
ELF: }
ELF: Symbol {
ELF: Name: _end
ELF: Binding: Global
ELF: Type: None
ELF: Section: (0xFFF1)
ELF: }
ELF: Symbol {
ELF: Name: global_func
ELF: Binding: Global
ELF: Type: Function
ELF: Section: .text
ELF: }
ELF: Symbol {
ELF: Name: _edata
ELF: Binding: Global
ELF: Type: None
ELF: Section: (0xFFF1)
ELF: }
ELF: ]
ELF: DynamicSection [ (9 entries)
ELF: Tag Type Name/Value
ELF: 00000001 NEEDED SharedLibrary (libc.so.6)
ELF: 00000001 NEEDED SharedLibrary (libm.so.6)
ELF: 0000000E SONAME LibrarySoname (libfoo.so)
ELF: 00000004 HASH {{[0-9a-f]+}}
ELF: 00000005 STRTAB {{[0-9a-f]+}}
ELF: 00000006 SYMTAB {{[0-9a-f]+}}
ELF: 0000000A STRSZ {{[0-9]+}} (bytes)
ELF: 0000000B SYMENT {{[0-9]+}} (bytes)
ELF: 00000000 NULL 0x0
ELF: ]
ELF: NeededLibraries [
ELF-NEXT: libc.so.6
ELF-NEXT: libm.so.6
ELF-NEXT: ]