llvm-6502/test/tools/llvm-readobj/relocations.test

286 lines
9.7 KiB
Plaintext
Raw Normal View History

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! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178679 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03 18:31:38 +00:00
RUN: llvm-readobj -r %p/Inputs/trivial.obj.coff-i386 \
RUN: | FileCheck %s -check-prefix COFF
RUN: llvm-readobj -r %p/Inputs/bad-relocs.obj.coff-i386 \
RUN: | FileCheck %s -check-prefix BAD-COFF-RELOCS
RUN: llvm-readobj -r %p/Inputs/relocs-no-symtab.obj.coff-i386 \
RUN: | FileCheck %s -check-prefix BAD-COFF-RELOCS
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! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178679 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03 18:31:38 +00:00
RUN: llvm-readobj -r %p/Inputs/trivial.obj.elf-i386 \
RUN: | FileCheck %s -check-prefix ELF
RUN: llvm-readobj -r %p/Inputs/trivial.obj.macho-i386 \
RUN: | FileCheck %s -check-prefix MACHO-I386
RUN: llvm-readobj -r %p/Inputs/trivial.obj.macho-x86-64 \
RUN: | FileCheck %s -check-prefix MACHO-X86-64
RUN: llvm-readobj -r --expand-relocs %p/Inputs/trivial.obj.macho-ppc \
RUN: | FileCheck %s -check-prefix MACHO-PPC
RUN: llvm-readobj -r --expand-relocs %p/Inputs/trivial.obj.macho-ppc64 \
RUN: | FileCheck %s -check-prefix MACHO-PPC64
RUN: llvm-readobj -r -expand-relocs %p/Inputs/trivial.obj.macho-arm \
RUN: | FileCheck %s -check-prefix MACHO-ARM
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! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178679 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03 18:31:38 +00:00
COFF: Relocations [
COFF-NEXT: Section (1) .text {
COFF-NEXT: 0x4 IMAGE_REL_I386_DIR32 .data
COFF-NEXT: 0x9 IMAGE_REL_I386_REL32 _puts
COFF-NEXT: 0xE IMAGE_REL_I386_REL32 _SomeOtherFunction
COFF-NEXT: }
COFF-NEXT: ]
BAD-COFF-RELOCS: Relocations [
BAD-COFF-RELOCS-NEXT: Section (1) sec {
BAD-COFF-RELOCS-NEXT: 0xDEADBEEF IMAGE_REL_I386_ABSOLUTE -
BAD-COFF-RELOCS-NEXT: }
BAD-COFF-RELOCS-NEXT: ]
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! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178679 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03 18:31:38 +00:00
ELF: Relocations [
ELF-NEXT: Section (2) .rel.text {
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! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178679 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-03 18:31:38 +00:00
ELF-NEXT: 0xC R_386_GOTPC _GLOBAL_OFFSET_TABLE_ 0x0
ELF-NEXT: 0x12 R_386_GOTOFF .L.str 0x0
ELF-NEXT: 0x1A R_386_PLT32 puts 0x0
ELF-NEXT: 0x1F R_386_PLT32 SomeOtherFunction 0x0
ELF-NEXT: }
ELF-NEXT: ]
MACHO-I386: Relocations [
MACHO-I386-NEXT: Section __text {
MACHO-I386-NEXT: 0x18 1 2 1 GENERIC_RELOC_VANILLA 0 _SomeOtherFunction
MACHO-I386-NEXT: 0x13 1 2 1 GENERIC_RELOC_VANILLA 0 _puts
MACHO-I386-NEXT: 0xB 0 2 n/a GENERIC_RELOC_LOCAL_SECTDIFF 1 0x22
MACHO-I386-NEXT: 0x0 0 2 n/a GENERIC_RELOC_PAIR 1 0x8
MACHO-I386-NEXT: }
MACHO-I386-NEXT: ]
MACHO-X86-64: Relocations [
MACHO-X86-64-NEXT: Section __text {
MACHO-X86-64-NEXT: 0xE 1 2 1 X86_64_RELOC_BRANCH 0 _SomeOtherFunction
MACHO-X86-64-NEXT: 0x9 1 2 1 X86_64_RELOC_BRANCH 0 _puts
MACHO-X86-64-NEXT: 0x4 1 2 1 X86_64_RELOC_SIGNED 0 L_.str
MACHO-X86-64-NEXT: }
MACHO-X86-64-NEXT:]
MACHO-PPC: Relocations [
MACHO-PPC-NEXT: Section __text {
MACHO-PPC-NEXT: Relocation {
MACHO-PPC-NEXT: Offset: 0x24
MACHO-PPC-NEXT: PCRel: 0
MACHO-PPC-NEXT: Length: 2
MACHO-PPC-NEXT: Type: PPC_RELOC_LO16_SECTDIFF (11)
MACHO-PPC-NEXT: Value: 0x64
MACHO-PPC-NEXT: }
MACHO-PPC-NEXT: Relocation {
MACHO-PPC-NEXT: Offset: 0x0
MACHO-PPC-NEXT: PCRel: 0
MACHO-PPC-NEXT: Length: 2
MACHO-PPC-NEXT: Type: PPC_RELOC_PAIR (1)
MACHO-PPC-NEXT: Value: 0xC
MACHO-PPC-NEXT: }
MACHO-PPC-NEXT: Relocation {
MACHO-PPC-NEXT: Offset: 0x1C
MACHO-PPC-NEXT: PCRel: 0
MACHO-PPC-NEXT: Length: 2
MACHO-PPC-NEXT: Type: PPC_RELOC_HA16_SECTDIFF (12)
MACHO-PPC-NEXT: Value: 0x64
MACHO-PPC-NEXT: }
MACHO-PPC-NEXT: Relocation {
MACHO-PPC-NEXT: Offset: 0x58
MACHO-PPC-NEXT: PCRel: 0
MACHO-PPC-NEXT: Length: 2
MACHO-PPC-NEXT: Type: PPC_RELOC_PAIR (1)
MACHO-PPC-NEXT: Value: 0xC
MACHO-PPC-NEXT: }
MACHO-PPC-NEXT: Relocation {
MACHO-PPC-NEXT: Offset: 0x18
MACHO-PPC-NEXT: PCRel: 1
MACHO-PPC-NEXT: Length: 2
MACHO-PPC-NEXT: Type: PPC_RELOC_BR24 (3)
MACHO-PPC-NEXT: Section: __picsymbolstub1 (2)
MACHO-PPC-NEXT: }
MACHO-PPC-NEXT: }
MACHO-PPC-NEXT: Section __picsymbolstub1 {
MACHO-PPC-NEXT: Relocation {
MACHO-PPC-NEXT: Offset: 0x14
MACHO-PPC-NEXT: PCRel: 0
MACHO-PPC-NEXT: Length: 2
MACHO-PPC-NEXT: Type: PPC_RELOC_LO16_SECTDIFF (11)
MACHO-PPC-NEXT: Value: 0x68
MACHO-PPC-NEXT: }
MACHO-PPC-NEXT: Relocation {
MACHO-PPC-NEXT: Offset: 0x0
MACHO-PPC-NEXT: PCRel: 0
MACHO-PPC-NEXT: Length: 2
MACHO-PPC-NEXT: Type: PPC_RELOC_PAIR (1)
MACHO-PPC-NEXT: Value: 0x48
MACHO-PPC-NEXT: }
MACHO-PPC-NEXT: Relocation {
MACHO-PPC-NEXT: Offset: 0xC
MACHO-PPC-NEXT: PCRel: 0
MACHO-PPC-NEXT: Length: 2
MACHO-PPC-NEXT: Type: PPC_RELOC_HA16_SECTDIFF (12)
MACHO-PPC-NEXT: Value: 0x68
MACHO-PPC-NEXT: }
MACHO-PPC-NEXT: Relocation {
MACHO-PPC-NEXT: Offset: 0x20
MACHO-PPC-NEXT: PCRel: 0
MACHO-PPC-NEXT: Length: 2
MACHO-PPC-NEXT: Type: PPC_RELOC_PAIR (1)
MACHO-PPC-NEXT: Value: 0x48
MACHO-PPC-NEXT: }
MACHO-PPC-NEXT: }
MACHO-PPC-NEXT: Section __la_symbol_ptr {
MACHO-PPC-NEXT: Relocation {
MACHO-PPC-NEXT: Offset: 0x0
MACHO-PPC-NEXT: PCRel: 0
MACHO-PPC-NEXT: Length: 2
MACHO-PPC-NEXT: Type: PPC_RELOC_VANILLA (0)
MACHO-PPC-NEXT: Symbol: dyld_stub_binding_helper (5)
MACHO-PPC-NEXT: }
MACHO-PPC-NEXT: }
MACHO-PPC-NEXT: ]
MACHO-PPC64: Relocations [
MACHO-PPC64-NEXT: Section __text {
MACHO-PPC64-NEXT: Relocation {
MACHO-PPC64-NEXT: Offset: 0x24
MACHO-PPC64-NEXT: PCRel: 0
MACHO-PPC64-NEXT: Length: 2
MACHO-PPC64-NEXT: Type: (14)
MACHO-PPC64-NEXT: Value: 0x64
MACHO-PPC64-NEXT: }
MACHO-PPC64-NEXT: Relocation {
MACHO-PPC64-NEXT: Offset: 0x0
MACHO-PPC64-NEXT: PCRel: 0
MACHO-PPC64-NEXT: Length: 2
MACHO-PPC64-NEXT: Type: (1)
MACHO-PPC64-NEXT: Value: 0xC
MACHO-PPC64-NEXT: }
MACHO-PPC64-NEXT: Relocation {
MACHO-PPC64-NEXT: Offset: 0x1C
MACHO-PPC64-NEXT: PCRel: 0
MACHO-PPC64-NEXT: Length: 2
MACHO-PPC64-NEXT: Type: (12)
MACHO-PPC64-NEXT: Value: 0x64
MACHO-PPC64-NEXT: }
MACHO-PPC64-NEXT: Relocation {
MACHO-PPC64-NEXT: Offset: 0x58
MACHO-PPC64-NEXT: PCRel: 0
MACHO-PPC64-NEXT: Length: 2
MACHO-PPC64-NEXT: Type: (1)
MACHO-PPC64-NEXT: Value: 0xC
MACHO-PPC64-NEXT: }
MACHO-PPC64-NEXT: Relocation {
MACHO-PPC64-NEXT: Offset: 0x18
MACHO-PPC64-NEXT: PCRel: 1
MACHO-PPC64-NEXT: Length: 2
MACHO-PPC64-NEXT: Type: (3)
MACHO-PPC64-NEXT: Section: __picsymbolstub1 (2)
MACHO-PPC64-NEXT: }
MACHO-PPC64-NEXT: }
MACHO-PPC64-NEXT: Section __picsymbolstub1 {
MACHO-PPC64-NEXT: Relocation {
MACHO-PPC64-NEXT: Offset: 0x14
MACHO-PPC64-NEXT: PCRel: 0
MACHO-PPC64-NEXT: Length: 2
MACHO-PPC64-NEXT: Type: (14)
MACHO-PPC64-NEXT: Value: 0x6C
MACHO-PPC64-NEXT: }
MACHO-PPC64-NEXT: Relocation {
MACHO-PPC64-NEXT: Offset: 0x0
MACHO-PPC64-NEXT: PCRel: 0
MACHO-PPC64-NEXT: Length: 2
MACHO-PPC64-NEXT: Type: (1)
MACHO-PPC64-NEXT: Value: 0x48
MACHO-PPC64-NEXT: }
MACHO-PPC64-NEXT: Relocation {
MACHO-PPC64-NEXT: Offset: 0xC
MACHO-PPC64-NEXT: PCRel: 0
MACHO-PPC64-NEXT: Length: 2
MACHO-PPC64-NEXT: Type: (12)
MACHO-PPC64-NEXT: Value: 0x6C
MACHO-PPC64-NEXT: }
MACHO-PPC64-NEXT: Relocation {
MACHO-PPC64-NEXT: Offset: 0x24
MACHO-PPC64-NEXT: PCRel: 0
MACHO-PPC64-NEXT: Length: 2
MACHO-PPC64-NEXT: Type: (1)
MACHO-PPC64-NEXT: Value: 0x48
MACHO-PPC64-NEXT: }
MACHO-PPC64-NEXT: }
MACHO-PPC64-NEXT: Section __la_symbol_ptr {
MACHO-PPC64-NEXT: Relocation {
MACHO-PPC64-NEXT: Offset: 0x0
MACHO-PPC64-NEXT: PCRel: 0
MACHO-PPC64-NEXT: Length: 3
MACHO-PPC64-NEXT: Type: (0)
MACHO-PPC64-NEXT: Symbol: dyld_stub_binding_helper (5)
MACHO-PPC64-NEXT: }
MACHO-PPC64-NEXT: }
MACHO-PPC64-NEXT: ]
MACHO-ARM: Relocations [
MACHO-ARM-NEXT: Section __text {
MACHO-ARM-NEXT: Relocation {
MACHO-ARM-NEXT: Offset: 0x38
MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 2
MACHO-ARM-NEXT: Type: ARM_RELOC_SECTDIFF (2)
MACHO-ARM-NEXT: Value: 0x40
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
MACHO-ARM-NEXT: Offset: 0x0
MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 2
MACHO-ARM-NEXT: Type: ARM_RELOC_PAIR (1)
MACHO-ARM-NEXT: Value: 0x28
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
MACHO-ARM-NEXT: Offset: 0x20
MACHO-ARM-NEXT: PCRel: 1
MACHO-ARM-NEXT: Length: 2
MACHO-ARM-NEXT: Type: ARM_RELOC_BR24 (5)
MACHO-ARM-NEXT: Symbol: _g
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
MACHO-ARM-NEXT: Offset: 0x1C
MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 1
MACHO-ARM-NEXT: Type: ARM_RELOC_HALF (8)
MACHO-ARM-NEXT: Symbol: _g
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
MACHO-ARM-NEXT: Offset: 0x0
MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 1
MACHO-ARM-NEXT: Type: ARM_RELOC_PAIR (1)
MACHO-ARM-NEXT: Section: -
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
MACHO-ARM-NEXT: Offset: 0x18
MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 0
MACHO-ARM-NEXT: Type: ARM_RELOC_HALF (8)
MACHO-ARM-NEXT: Symbol: _g
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
MACHO-ARM-NEXT: Offset: 0x0
MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 0
MACHO-ARM-NEXT: Type: ARM_RELOC_PAIR (1)
MACHO-ARM-NEXT: Section: -
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
MACHO-ARM-NEXT: Offset: 0xC
MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 2
MACHO-ARM-NEXT: Type: ARM_RELOC_SECTDIFF (2)
MACHO-ARM-NEXT: Value: 0x44
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: Relocation {
MACHO-ARM-NEXT: Offset: 0x0
MACHO-ARM-NEXT: PCRel: 0
MACHO-ARM-NEXT: Length: 2
MACHO-ARM-NEXT: Type: ARM_RELOC_PAIR (1)
MACHO-ARM-NEXT: Value: 0x4
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: }
MACHO-ARM-NEXT: ]