// RELOC: RELOCATION RECORDS FOR [.debug_info]:
+// RELOC-NEXT: OFFSET TYPE VALUE
// RELOC-NEXT: 00000006 R_ARM_ABS32 .debug_abbrev
// RELOC-NEXT: 0000000c R_ARM_ABS32 .debug_line
// RELOC-NEXT: R_ARM_ABS32 .text
// RELOC-NOT: RELOCATION RECORDS FOR [.debug_ranges]:
// RELOC: RELOCATION RECORDS FOR [.debug_aranges]:
+// RELOC-NEXT: OFFSET TYPE VALUE
// RELOC-NEXT: 00000006 R_ARM_ABS32 .debug_info
// RELOC-NEXT: 00000010 R_ARM_ABS32 .text
// RELOC-NEXT: 00000018 R_ARM_ABS32 foo
// Offsets are different in DWARF v5 due to different header layout.
// RELOC: RELOCATION RECORDS FOR [.debug_info]:
+// RELOC4-NEXT: OFFSET TYPE VALUE
// RELOC4-NEXT: 00000006 R_ARM_ABS32 .debug_abbrev
// RELOC4-NEXT: 0000000c R_ARM_ABS32 .debug_line
// RELOC4-NEXT: 00000010 R_ARM_ABS32 .debug_ranges
+// RELOC5-NEXT: OFFSET TYPE VALUE
// RELOC5-NEXT: 00000008 R_ARM_ABS32 .debug_abbrev
// RELOC5-NEXT: 0000000d R_ARM_ABS32 .debug_line
// RELOC5-NEXT: 00000011 R_ARM_ABS32 .debug_ranges
// RELOC-NEXT: R_ARM_ABS32 foo
// RELOC: RELOCATION RECORDS FOR [.debug_ranges]:
+// RELOC-NEXT: OFFSET TYPE VALUE
// RELOC-NEXT: 00000004 R_ARM_ABS32 .text
// RELOC-NEXT: 00000014 R_ARM_ABS32 foo
// RELOC: RELOCATION RECORDS FOR [.debug_aranges]:
+// RELOC-NEXT: OFFSET TYPE VALUE
// RELOC-NEXT: 00000006 R_ARM_ABS32 .debug_info
// RELOC-NEXT: 00000010 R_ARM_ABS32 .text
// RELOC-NEXT: 00000018 R_ARM_ABS32 foo
// RELOC: RELOCATION RECORDS FOR [.debug_info]:
+// RELOC-NEXT: OFFSET TYPE VALUE
// RELOC-NEXT: 00000006 R_ARM_ABS32 .debug_abbrev
// RELOC-NEXT: 0000000c R_ARM_ABS32 .debug_line
// RELOC-NEXT: R_ARM_ABS32 foo
// RELOC-NOT: RELOCATION RECORDS FOR [.debug_ranges]:
// RELOC: RELOCATION RECORDS FOR [.debug_aranges]:
+// RELOC-NEXT: OFFSET TYPE VALUE
// RELOC-NEXT: 00000006 R_ARM_ABS32 .debug_info
// RELOC-NEXT: 00000010 R_ARM_ABS32 foo
// RELOC: RELOCATION RECORDS FOR [.debug_info]:
+// RELOC-NEXT: OFFSET TYPE VALUE
// RELOC-NEXT: 00000006 R_ARM_ABS32 .debug_abbrev
// RELOC-NEXT: 0000000c R_ARM_ABS32 .debug_line
// RELOC-NEXT: R_ARM_ABS32 .text
// RELOC-NOT: RELOCATION RECORDS FOR [.debug_ranges]:
// RELOC: RELOCATION RECORDS FOR [.debug_aranges]:
+// RELOC-NEXT: OFFSET TYPE VALUE
// RELOC-NEXT: 00000006 R_ARM_ABS32 .debug_info
// RELOC-NEXT: 00000010 R_ARM_ABS32 .text
.cfi_endproc
// COFF_X86_64: RELOCATION RECORDS FOR [.debug_frame]:
+// COFF_X86_64-NEXT: {{.*}}OFFSET TYPE VALUE
// COFF_X86_64-NEXT: {{.*}} IMAGE_REL_AMD64_SECREL .debug_frame
// COFF_X86_64-NEXT: {{.*}} IMAGE_REL_AMD64_ADDR64 .text
// COFF_X86_64-NEXT: {{.*}} IMAGE_REL_AMD64_SECREL .debug_frame
// COFF_X86_64-NEXT: {{.*}} IMAGE_REL_AMD64_ADDR64 .text
// COFF_I686: RELOCATION RECORDS FOR [.debug_frame]:
+// COFF_I686-NEXT: {{.*}}OFFSET TYPE VALUE
// COFF_I686-NEXT: {{.*}} IMAGE_REL_I386_SECREL .debug_frame
// COFF_I686-NEXT: {{.*}} IMAGE_REL_I386_DIR32 .text
// COFF_I686-NEXT: {{.*}} IMAGE_REL_I386_SECREL .debug_frame
# ELF-MIPSEL: R_MIPS_CALL16 SomeOtherFunction
# WASM: CODE
+# WASM-NEXT: OFFSET TYPE VALUE
# WASM-NEXT: R_WASM_MEMORY_ADDR_SLEB .L.str
# WASM-NEXT: R_WASM_FUNCTION_INDEX_LEB puts
# WASM-NEXT: R_WASM_FUNCTION_INDEX_LEB .LSomeOtherFunction_bitcast
# WASM-NEXT: R_WASM_FUNCTION_INDEX_LEB SomeOtherFunction
# ELF-complex-x86-64: .text
+# ELF-complex-x86-64-NEXT: OFFSET TYPE VALUE
# ELF-complex-x86-64-NEXT: R_X86_64_8 .data-0x4
# ELF-complex-x86-64-NEXT: R_X86_64_16 .data-0x4
# ELF-complex-x86-64-NEXT: R_X86_64_32 .data-0x4
-; RUN: llc -mtriple=wasm32-unknown-unknown -filetype=obj %s -o - | llvm-objdump -r - | FileCheck %s
+; RUN: llc -mtriple=wasm32-unknown-unknown -filetype=obj %s -o - | llvm-objdump -r - | FileCheck %s --strict-whitespace --match-full-lines
@foo = external global i32, align 4
@bar = global i32* @foo, align 4
ret void
}
-; CHECK: RELOCATION RECORDS FOR [CODE]:
-; CHECK-NEXT: 00000006 R_WASM_TYPE_INDEX_LEB 1+0
+; CHECK:RELOCATION RECORDS FOR [CODE]:
+; CHECK-NEXT:OFFSET TYPE VALUE
+; CHECK-NEXT:00000006 R_WASM_TYPE_INDEX_LEB 1+0
-; CHECK: RELOCATION RECORDS FOR [DATA]:
-; CHECK-NEXT: 00000006 R_WASM_MEMORY_ADDR_I32 foo+0
+; CHECK:RELOCATION RECORDS FOR [DATA]:
+; CHECK-NEXT:OFFSET TYPE VALUE
+; CHECK-NEXT:00000006 R_WASM_MEMORY_ADDR_I32 foo+0
// RUN: llvm-objdump -r %p/Inputs/many-relocs.obj-i386 | FileCheck %s
CHECK: RELOCATION RECORDS FOR [.text]:
-CHECK-NEXT: IMAGE_REL_I386_DIR16 foo
-CHECK-NEXT: IMAGE_REL_I386_REL16 foo
-CHECK-NEXT: IMAGE_REL_I386_DIR32 foo
-CHECK-NEXT: IMAGE_REL_I386_DIR32NB foo
-CHECK-NEXT: IMAGE_REL_I386_SEG12 foo
-CHECK-NEXT: IMAGE_REL_I386_SECTION foo
-CHECK-NEXT: IMAGE_REL_I386_SECREL foo
-CHECK-NEXT: IMAGE_REL_I386_TOKEN foo
-CHECK-NEXT: IMAGE_REL_I386_SECREL7 foo
-CHECK-NEXT: IMAGE_REL_I386_REL32 foo
+CHECK-NEXT: TYPE VALUE
+CHECK-NEXT: IMAGE_REL_I386_DIR16 foo
+CHECK-NEXT: IMAGE_REL_I386_REL16 foo
+CHECK-NEXT: IMAGE_REL_I386_DIR32 foo
+CHECK-NEXT: IMAGE_REL_I386_DIR32NB foo
+CHECK-NEXT: IMAGE_REL_I386_SEG12 foo
+CHECK-NEXT: IMAGE_REL_I386_SECTION foo
+CHECK-NEXT: IMAGE_REL_I386_SECREL foo
+CHECK-NEXT: IMAGE_REL_I386_TOKEN foo
+CHECK-NEXT: IMAGE_REL_I386_SECREL7 foo
+CHECK-NEXT: IMAGE_REL_I386_REL32 foo
// RUN: llvm-objdump -r %p/Inputs/win64-unwind.exe.coff-x86_64.obj | FileCheck %s
CHECK: RELOCATION RECORDS FOR [.pdata]:
-CHECK-NEXT: 0 IMAGE_REL_AMD64_ADDR32NB func
-CHECK-NEXT: 4 IMAGE_REL_AMD64_ADDR32NB func
-CHECK-NEXT: 8 IMAGE_REL_AMD64_ADDR32NB .xdata
-CHECK-NEXT: c IMAGE_REL_AMD64_ADDR32NB func
-CHECK-NEXT: 10 IMAGE_REL_AMD64_ADDR32NB func
-CHECK-NEXT: 14 IMAGE_REL_AMD64_ADDR32NB .xdata
-CHECK-NEXT: 18 IMAGE_REL_AMD64_ADDR32NB smallFunc
-CHECK-NEXT: 1c IMAGE_REL_AMD64_ADDR32NB smallFunc
-CHECK-NEXT: 20 IMAGE_REL_AMD64_ADDR32NB .xdata
-CHECK-NEXT: 24 IMAGE_REL_AMD64_ADDR32NB allocFunc
-CHECK-NEXT: 28 IMAGE_REL_AMD64_ADDR32NB allocFunc
-CHECK-NEXT: 2c IMAGE_REL_AMD64_ADDR32NB .xdata
+CHECK-NEXT: OFFSET TYPE VALUE
+CHECK-NEXT: 0000000000000000 IMAGE_REL_AMD64_ADDR32NB func
+CHECK-NEXT: 0000000000000004 IMAGE_REL_AMD64_ADDR32NB func
+CHECK-NEXT: 0000000000000008 IMAGE_REL_AMD64_ADDR32NB .xdata
+CHECK-NEXT: 000000000000000c IMAGE_REL_AMD64_ADDR32NB func
+CHECK-NEXT: 0000000000000010 IMAGE_REL_AMD64_ADDR32NB func
+CHECK-NEXT: 0000000000000014 IMAGE_REL_AMD64_ADDR32NB .xdata
+CHECK-NEXT: 0000000000000018 IMAGE_REL_AMD64_ADDR32NB smallFunc
+CHECK-NEXT: 000000000000001c IMAGE_REL_AMD64_ADDR32NB smallFunc
+CHECK-NEXT: 0000000000000020 IMAGE_REL_AMD64_ADDR32NB .xdata
+CHECK-NEXT: 0000000000000024 IMAGE_REL_AMD64_ADDR32NB allocFunc
+CHECK-NEXT: 0000000000000028 IMAGE_REL_AMD64_ADDR32NB allocFunc
+CHECK-NEXT: 000000000000002c IMAGE_REL_AMD64_ADDR32NB .xdata
# RUN: llvm-objdump -r %t | FileCheck %s
# CHECK: RELOCATION RECORDS FOR [.text]:
-# CHECK-NEXT: 0000000000000000 R_X86_64_32 bar
+# CHECK-NEXT: OFFSET TYPE VALUE
+# CHECK-NEXT: 0000000000000000 R_X86_64_32 bar
--- !ELF
FileHeader:
# RUN: llvm-objdump --reloc %t > %t1
# RUN: llvm-objdump -r %t > %t2
# RUN: cmp %t1 %t2
-# RUN: FileCheck %s --input-file=%t1
+# RUN: FileCheck %s --input-file=%t1 --strict-whitespace --match-full-lines
-# CHECK: RELOCATION RECORDS FOR [.text]:
-# CHECK-NEXT: 0000000000000001 R_X86_64_32 glob1
-# CHECK-NEXT: 0000000000000001 R_X86_64_32S glob2
-# CHECK-NEXT: 0000000000000002 R_X86_64_64 loc1
-# CHECK-NEXT: 0000000000000001 R_X86_64_32 glob1+0x1
-# CHECK-NEXT: 0000000000000001 R_X86_64_32S glob2+0x2
-# CHECK-NEXT: 0000000000000002 R_X86_64_64 loc1+0x3
+# CHECK:RELOCATION RECORDS FOR [.text]:
+# CHECK-NEXT:OFFSET TYPE VALUE
+# CHECK-NEXT:0000000000000001 R_X86_64_32 glob1
+# CHECK-NEXT:0000000000000001 R_X86_64_32S glob2
+# CHECK-NEXT:0000000000000002 R_X86_64_64 loc1
+# CHECK-NEXT:0000000000000001 R_X86_64_32 glob1+0x1
+# CHECK-NEXT:0000000000000001 R_X86_64_32S glob2+0x2
+# CHECK-NEXT:0000000000000002 R_X86_64_64 loc1+0x3
--- !ELF
FileHeader: !FileHeader
Value: 0x0
Size: 0
Binding: STB_GLOBAL
+
+## Check relocation formatting on 32 bit as well to verify the formatting is correct.
+# RUN: yaml2obj --docnum=4 %s > %t4
+# RUN: llvm-objdump -r %t4 | FileCheck %s --check-prefix=ELF32 --strict-whitespace --match-full-lines
+
+# ELF32:RELOCATION RECORDS FOR [.text]:
+# ELF32-NEXT:OFFSET TYPE VALUE
+# ELF32-NEXT:00000001 R_386_32 global
+# ELF32-NEXT:00000002 R_386_PC32 local
+# ELF32-NEXT:00000001 R_386_NONE global+0x1
+# ELF32-NEXT:00000002 R_386_NONE local+0x2
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_386
+Sections:
+- Name: .text
+ Type: SHT_PROGBITS
+- Name: .rel.text
+ Type: SHT_REL
+ Info: .text
+ Relocations:
+ - Offset: 0x1
+ Symbol: global
+ Type: R_386_32
+ - Offset: 0x2
+ Symbol: local
+ Type: R_386_PC32
+- Name: .rela.text
+ Type: SHT_RELA
+ Info: .text
+ Relocations:
+ - Offset: 0x1
+ Addend: 1
+ Symbol: global
+ Type: R_386_NONE
+ - Offset: 0x2
+ Addend: 2
+ Symbol: local
+ Type: R_386_NONE
+Symbols:
+ - Name: local
+ - Name: global
+ Binding: STB_GLOBAL
# FMT: [[FILE]]: file format ELF64-x86-64
# REL: RELOCATION RECORDS FOR []:
-# REL-NEXT: 0000000000000123 R_X86_64_NONE *ABS*+0x141
+# REL-NEXT: OFFSET TYPE VALUE
+# REL-NEXT: 0000000000000123 R_X86_64_NONE *ABS*+0x141
## Executable.
--- !ELF
for (std::pair<SectionRef, std::vector<SectionRef>> &P : SecToRelSec) {
StringRef SecName = unwrapOrError(P.first.getName(), Obj->getFileName());
outs() << "RELOCATION RECORDS FOR [" << SecName << "]:\n";
+ uint32_t OffsetPadding = (Obj->getBytesInAddress() > 4 ? 16 : 8);
+ uint32_t TypePadding = 24;
+ outs() << left_justify("OFFSET", OffsetPadding) << " "
+ << left_justify("TYPE", TypePadding) << " "
+ << "VALUE\n";
for (SectionRef Section : P.second) {
for (const RelocationRef &Reloc : Section.relocations()) {
if (Error E = getRelocationValueString(Reloc, ValueStr))
reportError(std::move(E), Obj->getFileName());
- outs() << format(Fmt.data(), Address) << " " << RelocName << " "
- << ValueStr << "\n";
+ outs() << format(Fmt.data(), Address) << " "
+ << left_justify(RelocName, TypePadding) << " " << ValueStr
+ << "\n";
}
}
outs() << "\n";