--- /dev/null
+# Show that llvm-readobj can handle an empty .dynamic section.
+
+# RUN: yaml2obj %s -o %t.o
+# RUN: llvm-readobj --dynamic-table %t.o | FileCheck %s --check-prefix LLVM
+# RUN: llvm-readelf --dynamic-table %t.o | FileCheck %s --check-prefix GNU --allow-empty
+
+# LLVM: File: {{.*}}.o
+# LLVM-NOT: DynamicSection
+# GNU-NOT: {{.}}
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Address: 0x1000
+ProgramHeaders:
+ - Type: PT_LOAD
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynamic
+ - Type: PT_DYNAMIC
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynamic
--- /dev/null
+# Test handling of a dynamic section size which is not a multiple of its entry size.
+# RUN: yaml2obj %s --docnum=1 -o %t.bad-size
+# RUN: not llvm-readobj --dynamic-table %t.bad-size 2>&1 | FileCheck %s --check-prefix ERR-SIZE
+# RUN: not llvm-readelf --dynamic-table %t.bad-size 2>&1 | FileCheck %s --check-prefix ERR-SIZE
+
+# ERR-SIZE: Error reading file: Invalid entity size.
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Address: 0x1000
+ Content: "01234567"
+ProgramHeaders:
+ - Type: PT_LOAD
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynamic
+ - Type: PT_DYNAMIC
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynamic
+
+# Test handling of a .dynamic section with an invalid entsize (i.e. not 2 * sizeof(Elf_Dyn)).
+# RUN: yaml2obj %s --docnum=2 -o %t.bad-entsize
+# RUN: llvm-readobj --dynamic-table %t.bad-entsize | FileCheck %s --check-prefix BAD-ENTSIZE
+# RUN: llvm-readelf --dynamic-table %t.bad-entsize | FileCheck %s --check-prefix BAD-ENTSIZE
+
+# BAD-ENTSIZE: DynamicSection [ (2 entries)
+# BAD-ENTSIZE-NEXT: Tag Type Name/Value
+# BAD-ENTSIZE-NEXT: 0x0000000000000015 DEBUG 0x0
+# BAD-ENTSIZE-NEXT: 0x0000000000000000 NULL 0x0
+# BAD-ENTSIZE-NEXT: ]
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Address: 0x1000
+ EntSize: 0x2
+ Entries:
+ - Tag: DT_DEBUG
+ Value: 0
+ - Tag: DT_NULL
+ Value: 0
+ProgramHeaders:
+ - Type: PT_LOAD
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynamic
+ - Type: PT_DYNAMIC
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynamic
+
+# Test handling of string references pointing past the end of the dynamic string table. In this case,
+# we have a DT_NEEDED tag pointing at offset 1 in a 1-byte string table.
+# RUN: yaml2obj %s --docnum=3 -o %t.bad-string
+# RUN: not llvm-readobj --dynamic-table %t.bad-string 2>&1 | FileCheck %s --check-prefix BAD-STRING
+# RUN: not llvm-readelf --dynamic-table %t.bad-string 2>&1 | FileCheck %s --check-prefix BAD-STRING
+
+# BAD-STRING: Error reading file: Invalid dynamic string table reference.
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynstr
+ Type: SHT_STRTAB
+ Address: 0x1000
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Address: 0x1010
+ Entries:
+ - Tag: DT_STRTAB
+ Value: 0x1000
+ - Tag: DT_STRSZ
+ Value: 1
+ - Tag: DT_NEEDED
+ Value: 1
+ - Tag: DT_NULL
+ Value: 0
+ProgramHeaders:
+ - Type: PT_LOAD
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynstr
+ - Section: .dynamic
+ - Type: PT_DYNAMIC
+ VAddr: 0x1010
+ Sections:
+ - Section: .dynamic
+
+# Test handling of DT_STRTAB pointing outside the file's address space.
+# RUN: yaml2obj %s --docnum=4 -o %t.bad-strtab
+# RUN: not llvm-readobj --dynamic-table %t.bad-strtab 2>&1 | FileCheck %s --check-prefix BAD-STRTAB
+# RUN: not llvm-readelf --dynamic-table %t.bad-strtab 2>&1 | FileCheck %s --check-prefix BAD-STRTAB
+
+# BAD-STRTAB: LLVM ERROR: Virtual address is not in any segment
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Address: 0x1000
+ Entries:
+ - Tag: DT_STRTAB
+ Value: 0x2000000
+ - Tag: DT_STRSZ
+ Value: 10
+ - Tag: DT_NEEDED
+ Value: 1
+ - Tag: DT_NULL
+ Value: 0x0
+ProgramHeaders:
+ - Type: PT_LOAD
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynamic
+ - Type: PT_DYNAMIC
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynamic
+
+# Test handling of other d_ptr tags pointing outside the file's address space.
+# RUN: yaml2obj %s --docnum=5 -o %t.bad-rela
+# RUN: not llvm-readobj --dynamic-table %t.bad-rela 2>&1 | FileCheck %s --check-prefix BAD-RELA
+# RUN: not llvm-readelf --dynamic-table %t.bad-rela 2>&1 | FileCheck %s --check-prefix BAD-RELA
+
+# BAD-RELA: LLVM ERROR: Virtual address is not in any segment
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Address: 0x1000
+ Entries:
+ - Tag: DT_RELA
+ Value: 0x1000000
+ - Tag: DT_NULL
+ Value: 0x0
+ProgramHeaders:
+ - Type: PT_LOAD
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynamic
+ - Type: PT_DYNAMIC
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynamic
--- /dev/null
+# Show that no dumping occurs if there is no PT_DYNAMIC header.
+# RUN: yaml2obj %s -o %t.no-phdr
+# RUN: llvm-readobj --dynamic-table %t.no-phdr | FileCheck %s --check-prefix=LLVM
+# RUN: llvm-readelf --dynamic-table %t.no-phdr | FileCheck %s --check-prefix=GNU --allow-empty
+
+# LLVM: File: {{.*}}.no-phdr
+# LLVM-NEXT: Format: ELF64-x86-64
+# LLVM-NEXT: Arch: x86_64
+# LLVM-NEXT: AddressSize: 64bit
+# LLVM-NEXT: LoadName:{{ *}}
+# LLVM-NOT: {{.}}
+
+# GNU-NOT: {{.}}
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Address: 0x1000
+ Entries:
+ - Tag: DT_NULL
+ Value: 0
+ProgramHeaders:
+ - Type: PT_LOAD
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynamic
--- /dev/null
+# Test that hexagon machine-specific tags can be dumped.
+# RUN: yaml2obj --docnum=1 %s -o %t.hex
+# RUN: llvm-readobj --dynamic-table %t.hex | FileCheck %s --check-prefix=LLVM-HEXAGON
+# RUN: llvm-readelf --dynamic-table %t.hex | FileCheck %s --check-prefix=GNU-HEXAGON
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_HEXAGON
+Sections:
+ - Name: .dynstr
+ Type: SHT_STRTAB
+ Address: 0x1000
+ Size: 0x10
+ Content: "004400550066007700"
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Address: 0x1010
+ Entries:
+ - Tag: DT_HEXAGON_SYMSZ
+ Value: 0x10
+ - Tag: DT_HEXAGON_VER
+ Value: 0x1000
+ - Tag: DT_HEXAGON_PLT
+ Value: 0x1000
+ - Tag: DT_NULL
+ Value: 0
+ProgramHeaders:
+ - Type: PT_LOAD
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynstr
+ - Section: .dynamic
+ - Type: PT_DYNAMIC
+ VAddr: 0x1010
+ Sections:
+ - Section: .dynamic
+
+# LLVM-HEXAGON: DynamicSection [ (4 entries)
+# LLVM-HEXAGON-NEXT: Tag Type Name/Value
+# LLVM-HEXAGON-NEXT: 0x0000000070000000 HEXAGON_SYMSZ 0x10
+# LLVM-HEXAGON-NEXT: 0x0000000070000001 HEXAGON_VER 4096
+# LLVM-HEXAGON-NEXT: 0x0000000070000002 HEXAGON_PLT 0x1000
+# LLVM-HEXAGON-NEXT: 0x0000000000000000 NULL 0x0
+# LLVM-HEXAGON-NEXT: ]
+
+# GNU-HEXAGON: DynamicSection [ (4 entries)
+# GNU-HEXAGON-NEXT: Tag Type Name/Value
+# GNU-HEXAGON-NEXT: 0x0000000070000000 HEXAGON_SYMSZ 0x10
+# GNU-HEXAGON-NEXT: 0x0000000070000001 HEXAGON_VER 4096
+# GNU-HEXAGON-NEXT: 0x0000000070000002 HEXAGON_PLT 0x1000
+# GNU-HEXAGON-NEXT: 0x0000000000000000 NULL 0x0
+# GNU-HEXAGON-NEXT: ]
+
+# Test that MIPS machine-specific tags can be dumped.
+# RUN: yaml2obj --docnum=2 %s -o %t.mips
+# RUN: llvm-readobj --dynamic-table %t.mips | FileCheck %s --check-prefix=LLVM-MIPS
+# RUN: llvm-readelf --dynamic-table %t.mips | FileCheck %s --check-prefix=GNU-MIPS
+
+# LLVM-MIPS: DynamicSection [ (46 entries)
+# LLVM-MIPS-NEXT: Tag Type Name/Value
+# LLVM-MIPS-NEXT: 0x0000000070000001 MIPS_RLD_VERSION 305419896
+# LLVM-MIPS-NEXT: 0x0000000070000002 MIPS_TIME_STAMP 0x11223344
+# LLVM-MIPS-NEXT: 0x0000000070000003 MIPS_ICHECKSUM 0x11112222
+# LLVM-MIPS-NEXT: 0x0000000070000004 MIPS_IVERSION 0x1
+# LLVM-MIPS-NEXT: 0x0000000070000005 MIPS_FLAGS QUICKSTART SGI_ONLY PIXIE CORD
+# LLVM-MIPS-NEXT: 0x0000000070000006 MIPS_BASE_ADDRESS 0x87654321
+# LLVM-MIPS-NEXT: 0x0000000070000007 MIPS_MSYM 0x1000
+# LLVM-MIPS-NEXT: 0x0000000070000008 MIPS_CONFLICT 0x1000
+# LLVM-MIPS-NEXT: 0x0000000070000009 MIPS_LIBLIST 0x1000
+# LLVM-MIPS-NEXT: 0x000000007000000A MIPS_LOCAL_GOTNO 1
+# LLVM-MIPS-NEXT: 0x000000007000000B MIPS_CONFLICTNO 0x1
+# LLVM-MIPS-NEXT: 0x0000000070000010 MIPS_LIBLISTNO 0x1
+# LLVM-MIPS-NEXT: 0x0000000070000011 MIPS_SYMTABNO 1
+# LLVM-MIPS-NEXT: 0x0000000070000012 MIPS_UNREFEXTNO 0
+# LLVM-MIPS-NEXT: 0x0000000070000013 MIPS_GOTSYM 0x0
+# LLVM-MIPS-NEXT: 0x0000000070000014 MIPS_HIPAGENO 0x88776655
+# LLVM-MIPS-NEXT: 0x0000000070000016 MIPS_RLD_MAP 0x1000
+# LLVM-MIPS-NEXT: 0x0000000070000017 MIPS_DELTA_CLASS 0x1000
+# LLVM-MIPS-NEXT: 0x0000000070000018 MIPS_DELTA_CLASS_NO 0x1
+# LLVM-MIPS-NEXT: 0x0000000070000019 MIPS_DELTA_INSTANCE 0x1000
+# LLVM-MIPS-NEXT: 0x000000007000001A MIPS_DELTA_INSTANCE_NO0x1
+# LLVM-MIPS-NEXT: 0x000000007000001B MIPS_DELTA_RELOC 0x1000
+# LLVM-MIPS-NEXT: 0x000000007000001C MIPS_DELTA_RELOC_NO 0x1
+# LLVM-MIPS-NEXT: 0x000000007000001D MIPS_DELTA_SYM 0x1000
+# LLVM-MIPS-NEXT: 0x000000007000001E MIPS_DELTA_SYM_NO 0x1
+# LLVM-MIPS-NEXT: 0x0000000070000020 MIPS_DELTA_CLASSSYM 0x1000
+# LLVM-MIPS-NEXT: 0x0000000070000021 MIPS_DELTA_CLASSSYM_NO0x1
+# LLVM-MIPS-NEXT: 0x0000000070000022 MIPS_CXX_FLAGS 0x88887777
+# LLVM-MIPS-NEXT: 0x0000000070000023 MIPS_PIXIE_INIT 0x1000
+# LLVM-MIPS-NEXT: 0x0000000070000025 MIPS_LOCALPAGE_GOTIDX0x1
+# LLVM-MIPS-NEXT: 0x0000000070000026 MIPS_LOCAL_GOTIDX 0x1
+# LLVM-MIPS-NEXT: 0x0000000070000027 MIPS_HIDDEN_GOTIDX 0x1
+# LLVM-MIPS-NEXT: 0x0000000070000028 MIPS_PROTECTED_GOTIDX0x1
+# LLVM-MIPS-NEXT: 0x0000000070000029 MIPS_OPTIONS 0x1000
+# LLVM-MIPS-NEXT: 0x000000007000002A MIPS_INTERFACE 0x1000
+# LLVM-MIPS-NEXT: 0x000000007000002B MIPS_DYNSTR_ALIGN 0x88888888
+# LLVM-MIPS-NEXT: 0x000000007000002C MIPS_INTERFACE_SIZE 0x10
+# LLVM-MIPS-NEXT: 0x000000007000002D MIPS_RLD_TEXT_RESOLVE_ADDR0x8
+# LLVM-MIPS-NEXT: 0x000000007000002E MIPS_PERF_SUFFIX 0x0
+# LLVM-MIPS-NEXT: 0x000000007000002F MIPS_COMPACT_SIZE 0x10
+# LLVM-MIPS-NEXT: 0x0000000070000030 MIPS_GP_VALUE 0x1
+# LLVM-MIPS-NEXT: 0x0000000070000031 MIPS_AUX_DYNAMIC 0x1000
+# LLVM-MIPS-NEXT: 0x0000000070000032 MIPS_PLTGOT 0x1000
+# LLVM-MIPS-NEXT: 0x0000000070000034 MIPS_RWPLT 0x1000
+# LLVM-MIPS-NEXT: 0x0000000070000035 MIPS_RLD_MAP_REL 0x1000
+# LLVM-MIPS-NEXT: 0x0000000000000000 NULL 0x0
+# LLVM-MIPS-NEXT: ]
+
+# GNU-MIPS: DynamicSection [ (46 entries)
+# GNU-MIPS-NEXT: Tag Type Name/Value
+# GNU-MIPS-NEXT: 0x0000000070000001 MIPS_RLD_VERSION 305419896
+# GNU-MIPS-NEXT: 0x0000000070000002 MIPS_TIME_STAMP 0x11223344
+# GNU-MIPS-NEXT: 0x0000000070000003 MIPS_ICHECKSUM 0x11112222
+# GNU-MIPS-NEXT: 0x0000000070000004 MIPS_IVERSION 0x1
+# GNU-MIPS-NEXT: 0x0000000070000005 MIPS_FLAGS QUICKSTART SGI_ONLY PIXIE CORD
+# GNU-MIPS-NEXT: 0x0000000070000006 MIPS_BASE_ADDRESS 0x87654321
+# GNU-MIPS-NEXT: 0x0000000070000007 MIPS_MSYM 0x1000
+# GNU-MIPS-NEXT: 0x0000000070000008 MIPS_CONFLICT 0x1000
+# GNU-MIPS-NEXT: 0x0000000070000009 MIPS_LIBLIST 0x1000
+# GNU-MIPS-NEXT: 0x000000007000000a MIPS_LOCAL_GOTNO 1
+# GNU-MIPS-NEXT: 0x000000007000000b MIPS_CONFLICTNO 0x1
+# GNU-MIPS-NEXT: 0x0000000070000010 MIPS_LIBLISTNO 0x1
+# GNU-MIPS-NEXT: 0x0000000070000011 MIPS_SYMTABNO 1
+# GNU-MIPS-NEXT: 0x0000000070000012 MIPS_UNREFEXTNO 0
+# GNU-MIPS-NEXT: 0x0000000070000013 MIPS_GOTSYM 0x0
+# GNU-MIPS-NEXT: 0x0000000070000014 MIPS_HIPAGENO 0x88776655
+# GNU-MIPS-NEXT: 0x0000000070000016 MIPS_RLD_MAP 0x1000
+# GNU-MIPS-NEXT: 0x0000000070000017 MIPS_DELTA_CLASS 0x1000
+# GNU-MIPS-NEXT: 0x0000000070000018 MIPS_DELTA_CLASS_NO 0x1
+# GNU-MIPS-NEXT: 0x0000000070000019 MIPS_DELTA_INSTANCE 0x1000
+# GNU-MIPS-NEXT: 0x000000007000001a MIPS_DELTA_INSTANCE_NO0x1
+# GNU-MIPS-NEXT: 0x000000007000001b MIPS_DELTA_RELOC 0x1000
+# GNU-MIPS-NEXT: 0x000000007000001c MIPS_DELTA_RELOC_NO 0x1
+# GNU-MIPS-NEXT: 0x000000007000001d MIPS_DELTA_SYM 0x1000
+# GNU-MIPS-NEXT: 0x000000007000001e MIPS_DELTA_SYM_NO 0x1
+# GNU-MIPS-NEXT: 0x0000000070000020 MIPS_DELTA_CLASSSYM 0x1000
+# GNU-MIPS-NEXT: 0x0000000070000021 MIPS_DELTA_CLASSSYM_NO0x1
+# GNU-MIPS-NEXT: 0x0000000070000022 MIPS_CXX_FLAGS 0x88887777
+# GNU-MIPS-NEXT: 0x0000000070000023 MIPS_PIXIE_INIT 0x1000
+# GNU-MIPS-NEXT: 0x0000000070000025 MIPS_LOCALPAGE_GOTIDX0x1
+# GNU-MIPS-NEXT: 0x0000000070000026 MIPS_LOCAL_GOTIDX 0x1
+# GNU-MIPS-NEXT: 0x0000000070000027 MIPS_HIDDEN_GOTIDX 0x1
+# GNU-MIPS-NEXT: 0x0000000070000028 MIPS_PROTECTED_GOTIDX0x1
+# GNU-MIPS-NEXT: 0x0000000070000029 MIPS_OPTIONS 0x1000
+# GNU-MIPS-NEXT: 0x000000007000002a MIPS_INTERFACE 0x1000
+# GNU-MIPS-NEXT: 0x000000007000002b MIPS_DYNSTR_ALIGN 0x88888888
+# GNU-MIPS-NEXT: 0x000000007000002c MIPS_INTERFACE_SIZE 0x10
+# GNU-MIPS-NEXT: 0x000000007000002d MIPS_RLD_TEXT_RESOLVE_ADDR0x8
+# GNU-MIPS-NEXT: 0x000000007000002e MIPS_PERF_SUFFIX 0x0
+# GNU-MIPS-NEXT: 0x000000007000002f MIPS_COMPACT_SIZE 0x10
+# GNU-MIPS-NEXT: 0x0000000070000030 MIPS_GP_VALUE 0x1
+# GNU-MIPS-NEXT: 0x0000000070000031 MIPS_AUX_DYNAMIC 0x1000
+# GNU-MIPS-NEXT: 0x0000000070000032 MIPS_PLTGOT 0x1000
+# GNU-MIPS-NEXT: 0x0000000070000034 MIPS_RWPLT 0x1000
+# GNU-MIPS-NEXT: 0x0000000070000035 MIPS_RLD_MAP_REL 0x1000
+# GNU-MIPS-NEXT: 0x0000000000000000 NULL 0x0
+# GNU-MIPS-NEXT: ]
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_MIPS
+Sections:
+ - Name: .dynstr
+ Type: SHT_STRTAB
+ Address: 0x1000
+ Size: 0x10
+ Content: "004400550066007700"
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Address: 0x1010
+ Entries:
+ - Tag: DT_MIPS_RLD_VERSION
+ Value: 0x12345678
+ - Tag: DT_MIPS_TIME_STAMP
+ Value: 0x11223344
+ - Tag: DT_MIPS_ICHECKSUM
+ Value: 0x11112222
+ - Tag: DT_MIPS_IVERSION
+ Value: 0x1
+ - Tag: DT_MIPS_FLAGS
+ Value: 0x11111111
+ - Tag: DT_MIPS_BASE_ADDRESS
+ Value: 0x87654321
+ - Tag: DT_MIPS_MSYM
+ Value: 0x1000
+ - Tag: DT_MIPS_CONFLICT
+ Value: 0x1000
+ - Tag: DT_MIPS_LIBLIST
+ Value: 0x1000
+ - Tag: DT_MIPS_LOCAL_GOTNO
+ Value: 0x1
+ - Tag: DT_MIPS_CONFLICTNO
+ Value: 0x1
+ - Tag: DT_MIPS_LIBLISTNO
+ Value: 0x1
+ - Tag: DT_MIPS_SYMTABNO
+ Value: 0x1
+ - Tag: DT_MIPS_UNREFEXTNO
+ Value: 0x0
+ - Tag: DT_MIPS_GOTSYM
+ Value: 0x0
+ - Tag: DT_MIPS_HIPAGENO
+ Value: 0x88776655
+ - Tag: DT_MIPS_RLD_MAP
+ Value: 0x1000
+ - Tag: DT_MIPS_DELTA_CLASS
+ Value: 0x1000
+ - Tag: DT_MIPS_DELTA_CLASS_NO
+ Value: 0x1
+ - Tag: DT_MIPS_DELTA_INSTANCE
+ Value: 0x1000
+ - Tag: DT_MIPS_DELTA_INSTANCE_NO
+ Value: 0x1
+ - Tag: DT_MIPS_DELTA_RELOC
+ Value: 0x1000
+ - Tag: DT_MIPS_DELTA_RELOC_NO
+ Value: 0x1
+ - Tag: DT_MIPS_DELTA_SYM
+ Value: 0x1000
+ - Tag: DT_MIPS_DELTA_SYM_NO
+ Value: 0x1
+ - Tag: DT_MIPS_DELTA_CLASSSYM
+ Value: 0x1000
+ - Tag: DT_MIPS_DELTA_CLASSSYM_NO
+ Value: 0x1
+ - Tag: DT_MIPS_CXX_FLAGS
+ Value: 0x88887777
+ - Tag: DT_MIPS_PIXIE_INIT
+ Value: 0x1000
+ - Tag: DT_MIPS_LOCALPAGE_GOTIDX
+ Value: 0x1
+ - Tag: DT_MIPS_LOCAL_GOTIDX
+ Value: 0x1
+ - Tag: DT_MIPS_HIDDEN_GOTIDX
+ Value: 0x1
+ - Tag: DT_MIPS_PROTECTED_GOTIDX
+ Value: 0x1
+ - Tag: DT_MIPS_OPTIONS
+ Value: 0x1000
+ - Tag: DT_MIPS_INTERFACE
+ Value: 0x1000
+ - Tag: DT_MIPS_DYNSTR_ALIGN
+ Value: 0x88888888
+ - Tag: DT_MIPS_INTERFACE_SIZE
+ Value: 0x10
+ - Tag: DT_MIPS_RLD_TEXT_RESOLVE_ADDR
+ Value: 0x8
+ - Tag: DT_MIPS_PERF_SUFFIX
+ Value: 0x0
+ - Tag: DT_MIPS_COMPACT_SIZE
+ Value: 0x10
+ - Tag: DT_MIPS_GP_VALUE
+ Value: 0x1
+ - Tag: DT_MIPS_AUX_DYNAMIC
+ Value: 0x1000
+ - Tag: DT_MIPS_PLTGOT
+ Value: 0x1000
+ - Tag: DT_MIPS_RWPLT
+ Value: 0x1000
+ - Tag: DT_MIPS_RLD_MAP_REL
+ Value: 0x1000
+ - Tag: DT_NULL
+ Value: 0
+ProgramHeaders:
+ - Type: PT_LOAD
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynstr
+ - Section: .dynamic
+ - Type: PT_DYNAMIC
+ VAddr: 0x1010
+ Sections:
+ - Section: .dynamic
+
+# Test that PPC64 machine-specific tags can be dumped.
+# RUN: yaml2obj --docnum=3 %s -o %t.ppc
+# RUN: llvm-readobj --dynamic-table %t.ppc | FileCheck %s --check-prefix=LLVM-PPC
+# RUN: llvm-readelf --dynamic-table %t.ppc | FileCheck %s --check-prefix=GNU-PPC
+
+# LLVM-PPC: DynamicSection [ (2 entries)
+# LLVM-PPC-NEXT: Tag Type Name/Value
+# LLVM-PPC-NEXT: 0x0000000070000000 PPC64_GLINK 0x1000
+# LLVM-PPC-NEXT: 0x0000000000000000 NULL 0x0
+# LLVM-PPC-NEXT: ]
+
+# GNU-PPC: DynamicSection [ (2 entries)
+# GNU-PPC-NEXT: Tag Type Name/Value
+# GNU-PPC-NEXT: 0x0000000070000000 PPC64_GLINK 0x1000
+# GNU-PPC-NEXT: 0x0000000000000000 NULL 0x0
+# GNU-PPC-NEXT: ]
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_PPC64
+Sections:
+ - Name: .dynstr
+ Type: SHT_STRTAB
+ Address: 0x1000
+ Size: 0x10
+ Content: "004400550066007700"
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Address: 0x1010
+ Entries:
+ - Tag: DT_PPC64_GLINK
+ Value: 0x1000
+ - Tag: DT_NULL
+ Value: 0
+ProgramHeaders:
+ - Type: PT_LOAD
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynstr
+ - Section: .dynamic
+ - Type: PT_DYNAMIC
+ VAddr: 0x1010
+ Sections:
+ - Section: .dynamic
--- /dev/null
+# Show that all non-machine specific tags can be read and printed correctly.
+# RUN: yaml2obj %s > %t
+# RUN: llvm-readobj --dynamic-table %t | FileCheck %s --check-prefix=LLVM
+# RUN: llvm-readelf --dynamic-table %t | FileCheck %s --check-prefix=GNU
+
+# LLVM: DynamicSection [ (60 entries)
+# LLVM-NEXT: Tag Type Name/Value
+# LLVM-NEXT: 0x0000000000000001 NEEDED Shared library: [D]
+# LLVM-NEXT: 0x0000000000000002 PLTRELSZ 16 (bytes)
+# LLVM-NEXT: 0x0000000000000003 PLTGOT 0x1000
+# LLVM-NEXT: 0x0000000000000004 HASH 0x1000
+# LLVM-NEXT: 0x0000000000000005 STRTAB 0x1000
+# LLVM-NEXT: 0x0000000000000006 SYMTAB 0x1000
+# LLVM-NEXT: 0x0000000000000007 RELA 0x1000
+# LLVM-NEXT: 0x0000000000000008 RELASZ 16 (bytes)
+# LLVM-NEXT: 0x0000000000000009 RELAENT 1929 (bytes)
+# LLVM-NEXT: 0x000000000000000A STRSZ 16 (bytes)
+# LLVM-NEXT: 0x000000000000000B SYMENT 2439 (bytes)
+# LLVM-NEXT: 0x000000000000000C INIT 0x1000
+# LLVM-NEXT: 0x000000000000000D FINI 0x1000
+# LLVM-NEXT: 0x000000000000000E SONAME Library soname: [U]
+# LLVM-NEXT: 0x000000000000000F RPATH f
+# LLVM-NEXT: 0x0000000000000010 SYMBOLIC 0x1234567890ABCDEF
+# LLVM-NEXT: 0x0000000000000011 REL 0x1000
+# LLVM-NEXT: 0x0000000000000012 RELSZ 16 (bytes)
+# LLVM-NEXT: 0x0000000000000013 RELENT 291 (bytes)
+# LLVM-NEXT: 0x0000000000000014 PLTREL RELA
+# LLVM-NEXT: 0x0000000000000015 DEBUG 0xFEDCBA0987654321
+# LLVM-NEXT: 0x0000000000000016 TEXTREL 0x1122334455667788
+# LLVM-NEXT: 0x0000000000000017 JMPREL 0x1000
+# LLVM-NEXT: 0x0000000000000018 BIND_NOW 0x8877665544332211
+# LLVM-NEXT: 0x0000000000000019 INIT_ARRAY 0x1000
+# LLVM-NEXT: 0x000000000000001A FINI_ARRAY 0x1000
+# LLVM-NEXT: 0x000000000000001B INIT_ARRAYSZ 16 (bytes)
+# LLVM-NEXT: 0x000000000000001C FINI_ARRAYSZ 16 (bytes)
+# LLVM-NEXT: 0x000000000000001D RUNPATH w
+# LLVM-NEXT: 0x000000000000001E FLAGS ORIGIN SYMBOLIC TEXTREL BIND_NOW STATIC_TLS {{$}}
+# LLVM-NEXT: 0x0000000000000020 PREINIT_ARRAY 0x1000
+# LLVM-NEXT: 0x0000000000000021 PREINIT_ARRAYSZ 16 (bytes)
+# LLVM-NEXT: 0x0000000000000022 SYMTAB_SHNDX 0x1000
+# LLVM-NEXT: 0x0000000000000023 RELRSZ 0x10
+# LLVM-NEXT: 0x0000000000000024 RELR 0x1000
+# LLVM-NEXT: 0x0000000000000025 RELRENT 0x4321
+# LLVM-NEXT: 0x000000006000000F ANDROID_REL 0x1000
+# LLVM-NEXT: 0x0000000060000010 ANDROID_RELSZ 16 (bytes)
+# LLVM-NEXT: 0x0000000060000011 ANDROID_RELA 0x1000
+# LLVM-NEXT: 0x0000000060000012 ANDROID_RELASZ 16 (bytes)
+# LLVM-NEXT: 0x000000006FFFE000 ANDROID_RELR 0x1000
+# LLVM-NEXT: 0x000000006FFFE001 ANDROID_RELRSZ 0x10
+# LLVM-NEXT: 0x000000006FFFE003 ANDROID_RELRENT 0x1234
+# LLVM-NEXT: 0x000000006FFFFEF5 GNU_HASH 0x1000
+# LLVM-NEXT: 0x000000006FFFFEF6 TLSDESC_PLT 0x1000
+# LLVM-NEXT: 0x000000006FFFFEF7 TLSDESC_GOT 0x1000
+# LLVM-NEXT: 0x000000006FFFFFF9 RELACOUNT 0
+# LLVM-NEXT: 0x000000006FFFFFFA RELCOUNT 0
+# LLVM-NEXT: 0x000000006FFFFFFB FLAGS_1 NOW GLOBAL GROUP NODELETE LOADFLTR INITFIRST NOOPEN ORIGIN DIRECT TRANS INTERPOSE NODEFLIB NODUMP CONFALT ENDFILTEE DISPRELDNE DISPRELPND NODIRECT IGNMULDEF NOKSYMS NOHDR EDITED NORELOC SYMINTPOSE GLOBAUDIT SINGLETON {{$}}
+# LLVM-NEXT: 0x000000006FFFFFF0 VERSYM 0x1000
+# LLVM-NEXT: 0x000000006FFFFFFC VERDEF 0x1000
+# LLVM-NEXT: 0x000000006FFFFFFD VERDEFNUM 0
+# LLVM-NEXT: 0x000000006FFFFFFE VERNEED 0x1000
+# LLVM-NEXT: 0x000000006FFFFFFF VERNEEDNUM 0
+# LLVM-NEXT: 0x000000007FFFFFFD AUXILIARY Auxiliary library: [D]
+# LLVM-NEXT: 0x000000007FFFFFFF FILTER Filter library: [U]
+# LLVM-NEXT: 0x0000000012345678 unknown 0x8765432187654321
+# LLVM-NEXT: 0x000000006ABCDEF0 unknown 0x9988776655443322
+# LLVM-NEXT: 0x0000000076543210 unknown 0x5555666677778888
+# LLVM-NEXT: 0x0000000000000000 NULL 0x0
+# LLVM-NEXT: ]
+
+# GNU: DynamicSection [ (60 entries)
+# GNU-NEXT: Tag Type Name/Value
+# GNU-NEXT: 0x0000000000000001 NEEDED Shared library: [D]
+# GNU-NEXT: 0x0000000000000002 PLTRELSZ 16 (bytes)
+# GNU-NEXT: 0x0000000000000003 PLTGOT 0x1000
+# GNU-NEXT: 0x0000000000000004 HASH 0x1000
+# GNU-NEXT: 0x0000000000000005 STRTAB 0x1000
+# GNU-NEXT: 0x0000000000000006 SYMTAB 0x1000
+# GNU-NEXT: 0x0000000000000007 RELA 0x1000
+# GNU-NEXT: 0x0000000000000008 RELASZ 16 (bytes)
+# GNU-NEXT: 0x0000000000000009 RELAENT 1929 (bytes)
+# GNU-NEXT: 0x000000000000000a STRSZ 16 (bytes)
+# GNU-NEXT: 0x000000000000000b SYMENT 2439 (bytes)
+# GNU-NEXT: 0x000000000000000c INIT 0x1000
+# GNU-NEXT: 0x000000000000000d FINI 0x1000
+# GNU-NEXT: 0x000000000000000e SONAME Library soname: [U]
+# GNU-NEXT: 0x000000000000000f RPATH f
+# GNU-NEXT: 0x0000000000000010 SYMBOLIC 0x1234567890abcdef
+# GNU-NEXT: 0x0000000000000011 REL 0x1000
+# GNU-NEXT: 0x0000000000000012 RELSZ 16 (bytes)
+# GNU-NEXT: 0x0000000000000013 RELENT 291 (bytes)
+# GNU-NEXT: 0x0000000000000014 PLTREL RELA
+# GNU-NEXT: 0x0000000000000015 DEBUG 0xfedcba0987654321
+# GNU-NEXT: 0x0000000000000016 TEXTREL 0x1122334455667788
+# GNU-NEXT: 0x0000000000000017 JMPREL 0x1000
+# GNU-NEXT: 0x0000000000000018 BIND_NOW 0x8877665544332211
+# GNU-NEXT: 0x0000000000000019 INIT_ARRAY 0x1000
+# GNU-NEXT: 0x000000000000001a FINI_ARRAY 0x1000
+# GNU-NEXT: 0x000000000000001b INIT_ARRAYSZ 16 (bytes)
+# GNU-NEXT: 0x000000000000001c FINI_ARRAYSZ 16 (bytes)
+# GNU-NEXT: 0x000000000000001d RUNPATH w
+# GNU-NEXT: 0x000000000000001e FLAGS ORIGIN SYMBOLIC TEXTREL BIND_NOW STATIC_TLS {{$}}
+# GNU-NEXT: 0x0000000000000020 PREINIT_ARRAY 0x1000
+# GNU-NEXT: 0x0000000000000021 PREINIT_ARRAYSZ 16 (bytes)
+# GNU-NEXT: 0x0000000000000022 SYMTAB_SHNDX 0x1000
+# GNU-NEXT: 0x0000000000000023 RELRSZ 0x10
+# GNU-NEXT: 0x0000000000000024 RELR 0x1000
+# GNU-NEXT: 0x0000000000000025 RELRENT 0x4321
+# GNU-NEXT: 0x000000006000000f ANDROID_REL 0x1000
+# GNU-NEXT: 0x0000000060000010 ANDROID_RELSZ 16 (bytes)
+# GNU-NEXT: 0x0000000060000011 ANDROID_RELA 0x1000
+# GNU-NEXT: 0x0000000060000012 ANDROID_RELASZ 16 (bytes)
+# GNU-NEXT: 0x000000006fffe000 ANDROID_RELR 0x1000
+# GNU-NEXT: 0x000000006fffe001 ANDROID_RELRSZ 0x10
+# GNU-NEXT: 0x000000006fffe003 ANDROID_RELRENT 0x1234
+# GNU-NEXT: 0x000000006ffffef5 GNU_HASH 0x1000
+# GNU-NEXT: 0x000000006ffffef6 TLSDESC_PLT 0x1000
+# GNU-NEXT: 0x000000006ffffef7 TLSDESC_GOT 0x1000
+# GNU-NEXT: 0x000000006ffffff9 RELACOUNT 0
+# GNU-NEXT: 0x000000006ffffffa RELCOUNT 0
+# GNU-NEXT: 0x000000006ffffffb FLAGS_1 NOW GLOBAL GROUP NODELETE LOADFLTR INITFIRST NOOPEN ORIGIN DIRECT TRANS INTERPOSE NODEFLIB NODUMP CONFALT ENDFILTEE DISPRELDNE DISPRELPND NODIRECT IGNMULDEF NOKSYMS NOHDR EDITED NORELOC SYMINTPOSE GLOBAUDIT SINGLETON {{$}}
+# GNU-NEXT: 0x000000006ffffff0 VERSYM 0x1000
+# GNU-NEXT: 0x000000006ffffffc VERDEF 0x1000
+# GNU-NEXT: 0x000000006ffffffd VERDEFNUM 0
+# GNU-NEXT: 0x000000006ffffffe VERNEED 0x1000
+# GNU-NEXT: 0x000000006fffffff VERNEEDNUM 0
+# GNU-NEXT: 0x000000007ffffffd AUXILIARY Auxiliary library: [D]
+# GNU-NEXT: 0x000000007fffffff FILTER Filter library: [U]
+# GNU-NEXT: 0x0000000012345678 unknown 0x8765432187654321
+# GNU-NEXT: 0x000000006abcdef0 unknown 0x9988776655443322
+# GNU-NEXT: 0x0000000076543210 unknown 0x5555666677778888
+# GNU-NEXT: 0x0000000000000000 NULL 0x0
+# GNU-NEXT: ]
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynstr
+ Type: SHT_STRTAB
+ Address: 0x1000
+ Size: 0x10
+ Content: "004400550066007700"
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Address: 0x1010
+ Entries:
+ - Tag: DT_NEEDED
+ Value: 0x1
+ - Tag: DT_PLTRELSZ
+ Value: 0x10
+ - Tag: DT_PLTGOT
+ Value: 0x1000
+ - Tag: DT_HASH
+ Value: 0x1000
+ - Tag: DT_STRTAB
+ Value: 0x1000
+ - Tag: DT_SYMTAB
+ Value: 0x1000
+ - Tag: DT_RELA
+ Value: 0x1000
+ - Tag: DT_RELASZ
+ Value: 0x10
+ - Tag: DT_RELAENT
+ Value: 0x789
+ - Tag: DT_STRSZ
+ Value: 0x10
+ - Tag: DT_SYMENT
+ Value: 0x987
+ - Tag: DT_INIT
+ Value: 0x1000
+ - Tag: DT_FINI
+ Value: 0x1000
+ - Tag: DT_SONAME
+ Value: 0x3
+ - Tag: DT_RPATH
+ Value: 0x5
+ - Tag: DT_SYMBOLIC
+ Value: 0x1234567890abcdef
+ - Tag: DT_REL
+ Value: 0x1000
+ - Tag: DT_RELSZ
+ Value: 0x10
+ - Tag: DT_RELENT
+ Value: 0x123
+ - Tag: DT_PLTREL
+ Value: 0x7
+ - Tag: DT_DEBUG
+ Value: 0xfedcba0987654321
+ - Tag: DT_TEXTREL
+ Value: 0x1122334455667788
+ - Tag: DT_JMPREL
+ Value: 0x1000
+ - Tag: DT_BIND_NOW
+ Value: 0x8877665544332211
+ - Tag: DT_INIT_ARRAY
+ Value: 0x1000
+ - Tag: DT_FINI_ARRAY
+ Value: 0x1000
+ - Tag: DT_INIT_ARRAYSZ
+ Value: 0x10
+ - Tag: DT_FINI_ARRAYSZ
+ Value: 0x10
+ - Tag: DT_RUNPATH
+ Value: 0x7
+ - Tag: DT_FLAGS
+ Value: 0xffffffffffffffff
+ - Tag: DT_PREINIT_ARRAY
+ Value: 0x1000
+ - Tag: DT_PREINIT_ARRAYSZ
+ Value: 0x10
+ - Tag: DT_SYMTAB_SHNDX
+ Value: 0x1000
+ - Tag: DT_RELRSZ
+ Value: 0x10
+ - Tag: DT_RELR
+ Value: 0x1000
+ - Tag: DT_RELRENT
+ Value: 0x4321
+ - Tag: DT_ANDROID_REL
+ Value: 0x1000
+ - Tag: DT_ANDROID_RELSZ
+ Value: 0x10
+ - Tag: DT_ANDROID_RELA
+ Value: 0x1000
+ - Tag: DT_ANDROID_RELASZ
+ Value: 0x10
+ - Tag: DT_ANDROID_RELR
+ Value: 0x1000
+ - Tag: DT_ANDROID_RELRSZ
+ Value: 0x10
+ - Tag: DT_ANDROID_RELRENT
+ Value: 0x1234
+ - Tag: DT_GNU_HASH
+ Value: 0x1000
+ - Tag: DT_TLSDESC_PLT
+ Value: 0x1000
+ - Tag: DT_TLSDESC_GOT
+ Value: 0x1000
+ - Tag: DT_RELACOUNT
+ Value: 0x0
+ - Tag: DT_RELCOUNT
+ Value: 0x0
+ - Tag: DT_FLAGS_1
+ Value: 0xffffffffffffffff
+ - Tag: DT_VERSYM
+ Value: 0x1000
+ - Tag: DT_VERDEF
+ Value: 0x1000
+ - Tag: DT_VERDEFNUM
+ Value: 0x0
+ - Tag: DT_VERNEED
+ Value: 0x1000
+ - Tag: DT_VERNEEDNUM
+ Value: 0x0
+ - Tag: DT_AUXILIARY
+ Value: 0x1
+ - Tag: DT_FILTER
+ Value: 0x3
+ # Show behaviour for unknown values in special and un-marked ranges.
+ - Tag: 0x12345678
+ Value: 0x8765432187654321
+ - Tag: 0x6abcdef0
+ Value: 0x9988776655443322
+ - Tag: 0x76543210
+ Value: 0x5555666677778888
+ - Tag: DT_NULL
+ Value: 0x0
+ProgramHeaders:
+ - Type: PT_LOAD
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynstr
+ - Section: .dynamic
+ - Type: PT_DYNAMIC
+ VAddr: 0x1010
+ Sections:
+ - Section: .dynamic
--- /dev/null
+# If the offset and/or size fields of the PT_DYNAMIC field become corrupted,
+# it will be impossible to read the dynamic segment validly. This test shows
+# that a sensible error message is given in this situation.
+
+# Creating such a malformed file is hard. The easiest way to simulate it is to
+# truncate the file. Note that the section headers must first be stripped or
+# llvm-readobj will fail to parse the file due to the section header table
+# offset pointing outside the file.
+
+# RUN: yaml2obj %s -o %t.base
+# RUN: llvm-objcopy --strip-sections %t.base %t.stripped
+
+# Test case where the size is too large to fit in the file, but the start is
+# within the file.
+# RUN: cp %t.stripped %t.truncated1
+# RUN: %python -c "with open(r'%t.truncated1', 'r+') as f: f.truncate(0x1001)"
+# RUN: not llvm-readobj %t.truncated1 --dynamic-table 2>&1 | FileCheck %s
+
+# Test case where the offset is too large to be in the file.
+# RUN: cp %t.stripped %t.truncated2
+# RUN: %python -c "with open(r'%t.truncated2', 'r+') as f: f.truncate(0xFFF)"
+# RUN: not llvm-readobj %t.truncated2 --dynamic-table 2>&1 | FileCheck %s
+
+# CHECK: Error reading file: Invalid data was encountered while parsing the file.
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynamic
+ Type: SHT_DYNAMIC
+ Address: 0x1000
+ AddressAlign: 0x1000
+ Entries:
+ - Tag: DT_NULL
+ Value: 0
+ProgramHeaders:
+ - Type: PT_LOAD
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynamic
+ - Type: PT_DYNAMIC
+ VAddr: 0x1000
+ Sections:
+ - Section: .dynamic
--- /dev/null
+# Show that llvm-readobj can handle no program headers when --program-headers
+# is requested, both for LLVM and GNU output.
+
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-readobj %t --program-headers | FileCheck %s --check-prefix=LLVM
+# RUN: llvm-readelf %t --program-headers | FileCheck %s --check-prefix=GNU
+
+# LLVM: ProgramHeaders [
+# LLVM-NEXT: ]
+
+# GNU: There are 0 program headers
+# GNU: Program Headers:
+# GNU-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
+# GNU-EMPTY:
+# GNU-NEXT: Section to Segment mapping:
+# GNU-NEXT: Segment Sections...
+# GNU-NEXT: None .symtab .strtab .shstrtab
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
--- /dev/null
+# Show that llvm-readobj can handle no relocations when --relocations is
+# requested, both for LLVM and GNU output, both for no relocation sections and
+# for empty relocation sections.
+
+# RUN: yaml2obj %s -o %t.no_relocs
+# RUN: llvm-readobj %t.no_relocs --relocations | FileCheck %s --check-prefix NO-RELOCS-LLVM
+# RUN: llvm-readelf %t.no_relocs --relocations | FileCheck %s --check-prefix NO-RELOCS-GNU
+
+# RUN: llvm-objcopy -R .rela.text -R .rel.text %t.no_relocs %t.no_sec
+# RUN: llvm-readobj %t.no_sec --relocations | FileCheck %s --check-prefix NO-SEC-LLVM
+# RUN: llvm-readelf %t.no_sec --relocations | FileCheck %s --check-prefix NO-SEC-GNU
+
+# NO-RELOCS-LLVM: Relocations [
+# NO-RELOCS-LLVM-NEXT: Section (2) .rela.text {
+# NO-RELOCS-LLVM-NEXT: }
+# NO-RELOCS-LLVM-NEXT: Section (3) .rel.text {
+# NO-RELOCS-LLVM-NEXT: }
+# NO-RELOCS-LLVM-NEXT: ]
+
+# NO-RELOCS-GNU: Relocation section '.rela.text' at offset {{.*}} contains 0 entries:
+# NO-RELOCS-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
+# NO-RELOCS-GNU-EMPTY:
+# NO-RELOCS-GNU-NEXT: Relocation section '.rel.text' at offset {{.*}} contains 0 entries:
+# NO-RELOCS-GNU-NEXT: Offset Info Type Symbol's Value Symbol's Name
+# NO-RELOCS-GNU-EMPTY:
+
+# NO-SEC-LLVM: Relocations [
+# NO-SEC-LLVM-NEXT: ]
+
+# NO-SEC-GNU: There are no relocations in this file.
+
+--- !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
+ Link: .symtab
+ - Name: .rel.text
+ Type: SHT_REL
+ Info: .text
+ Link: .symtab
--- /dev/null
+# Show that llvm-readobj can handle ELF files where the section header table has
+# been stripped, both for GNU and LLVM style output.
+
+# RUN: yaml2obj %s -o %t.raw
+# RUN: llvm-objcopy --strip-sections %t.raw %t.o
+# RUN: llvm-readobj --file-headers --section-headers --symbols %t.o | FileCheck %s --check-prefix=LLVM
+# RUN: llvm-readelf --file-headers --section-headers --symbols %t.o | FileCheck %s --check-prefix=GNU --allow-empty
+
+# LLVM: SectionHeaderCount: 0
+# LLVM: StringTableSectionIndex: 0
+# LLVM: Sections [
+# LLVM-NEXT: ]
+# LLVM-NEXT: Symbols [
+# LLVM-NEXT: ]
+
+# GNU: Number of section headers: 0
+# GNU: Section header string table index: 0
+# GNU: There are 0 section headers
+# GNU-NOT: Symbol table '{{.*}}' contains {{.*}} entries
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+Symbols:
+ Global:
+ - Name: foobar
+ Section: .text
--- /dev/null
+# Show that llvm-readobj can handle all standard ELF types.
+# RUN: yaml2obj %s --docnum=1 -o %t.none
+# RUN: llvm-readobj --file-headers %t.none | FileCheck %s --check-prefix=LLVM-NONE
+# RUN: llvm-readelf --file-headers %t.none | FileCheck %s --check-prefix=GNU-NONE
+
+# LLVM-NONE: Type: None (0x0)
+# GNU-NONE: Type: NONE (none)
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_NONE
+ Machine: EM_X86_64
+
+# RUN: yaml2obj %s --docnum=2 -o %t.rel
+# RUN: llvm-readobj --file-headers %t.rel | FileCheck %s --check-prefix=LLVM-REL
+# RUN: llvm-readelf --file-headers %t.rel | FileCheck %s --check-prefix=GNU-REL
+
+# LLVM-REL: Type: Relocatable (0x1)
+# GNU-REL: Type: REL (Relocatable file)
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+
+
+# RUN: yaml2obj %s --docnum=3 -o %t.exec
+# RUN: llvm-readobj --file-headers %t.exec | FileCheck %s --check-prefix=LLVM-EXEC
+# RUN: llvm-readelf --file-headers %t.exec | FileCheck %s --check-prefix=GNU-EXEC
+
+# LLVM-EXEC: Type: Executable (0x2)
+# GNU-EXEC: Type: EXEC (Executable file)
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+
+# RUN: yaml2obj %s --docnum=4 -o %t.so
+# RUN: llvm-readobj --file-headers %t.so | FileCheck %s --check-prefix=LLVM-SO
+# RUN: llvm-readelf --file-headers %t.so | FileCheck %s --check-prefix=GNU-SO
+
+# LLVM-SO: Type: SharedObject (0x3)
+# GNU-SO: Type: DYN (Shared object file)
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_DYN
+ Machine: EM_X86_64
+
+# RUN: yaml2obj %s --docnum=5 -o %t.core
+# RUN: llvm-readobj --file-headers %t.core | FileCheck %s --check-prefix=LLVM-CORE
+# RUN: llvm-readelf --file-headers %t.core | FileCheck %s --check-prefix=GNU-CORE
+
+# LLVM-CORE: Type: Core (0x4)
+# GNU-CORE: Type: CORE (Core file)
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_CORE
+ Machine: EM_X86_64
+
+# Show that llvm-readobj can handle an unknown ELF type.
+# RUN: yaml2obj %s --docnum=6 -o %t.unknown
+# RUN: llvm-readobj --file-headers %t.unknown | FileCheck %s --check-prefix=LLVM-UNKNOWN
+# RUN: llvm-readelf --file-headers %t.unknown | FileCheck %s --check-prefix=GNU-UNKNOWN
+
+# LLVM-UNKNOWN: Type: 0x42
+# GNU-UNKNOWN: Type: 42
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: 0x42
+ Machine: EM_X86_64
+
+# Show that llvm-readobj can handle an unknown OS-specific ELF type.
+# RUN: yaml2obj %s --docnum=7 -o %t.os
+# RUN: llvm-readobj --file-headers %t.os | FileCheck %s --check-prefix=LLVM-OS
+# RUN: llvm-readelf --file-headers %t.os | FileCheck %s --check-prefix=GNU-OS
+
+# LLVM-OS: Type: 0xFE00
+# GNU-OS: Type: fe00
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: 0xfe00
+ Machine: EM_X86_64
+
+# Show that llvm-readobj can handle an unknown machine-specific ELF type.
+# RUN: yaml2obj %s --docnum=8 -o %t.proc
+# RUN: llvm-readobj --file-headers %t.proc | FileCheck %s --check-prefix=LLVM-PROC
+# RUN: llvm-readelf --file-headers %t.proc | FileCheck %s --check-prefix=GNU-PROC
+
+# LLVM-PROC: Type: 0xFF00
+# GNU-PROC: Type: ff00
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: 0xff00
+ Machine: EM_X86_64
--- /dev/null
+# Check the dumping of a section as strings.
+# RUN: yaml2obj %s > %t
+
+# RUN: llvm-readobj --string-dump=.strings --string-dump=.not_null_terminated %t | FileCheck %s
+# RUN: llvm-readobj -p=.strings -p=.not_null_terminated %t | FileCheck %s
+# RUN: llvm-readobj --string-dump=1 --string-dump=2 %t | FileCheck %s
+
+# RUN: llvm-readelf --string-dump=.strings --string-dump=.not_null_terminated %t | FileCheck %s
+# RUN: llvm-readelf -p=.strings -p=.not_null_terminated %t | FileCheck %s
+# RUN: llvm-readelf --string-dump=1 --string-dump=2 %t | FileCheck %s
+
+# CHECK: String dump of section '.strings':
+# CHECK-NEXT: [ 0] here
+# CHECK-NEXT: [ 5] are
+# CHECK-NEXT: [ 9] some
+# CHECK-NEXT: [ e] strings
+# CHECK-NEXT: String dump of section '.not_null_terminated':
+# CHECK-NEXT: [ 0] no
+# CHECK-NEXT: [ 3] null{{$}}
+# CHECK-NOT: {{.}}
+
+# RUN: not llvm-readobj --string-dump=does_not_exist %t 2>&1 | FileCheck %s --check-prefix=ERR
+# RUN: not llvm-readobj --string-dump=42 %t 2>&1 | FileCheck %s --check-prefix=ERR
+
+# RUN: not llvm-readelf --string-dump=does_not_exist %t 2>&1 | FileCheck %s --check-prefix=ERR
+# RUN: not llvm-readelf --string-dump=42 %t 2>&1 | FileCheck %s --check-prefix=ERR
+
+# ERR: Error reading file: invalid section reference.
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .strings
+ Type: SHT_PROGBITS
+ Content: 686572650061726500736f6d6500737472696e677300
+ - Name: .not_null_terminated
+ Type: SHT_PROGBITS
+ Content: 6e6f006e756c6c