mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 04:32:44 +01:00
[llvm-objdump] Add column headers for relocation printing
This allows us better readability and compatibility with what GNU objdump prints. Fixes https://bugs.llvm.org/show_bug.cgi?id=43941 Reviewed by: jhenderson, MaskRay Differential Revision: https://reviews.llvm.org/D72992
This commit is contained in:
parent
f18c59e9e1
commit
7dc65bf930
@ -50,6 +50,7 @@ b:
|
||||
|
||||
|
||||
// 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
|
||||
@ -60,6 +61,7 @@ b:
|
||||
// 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
|
||||
|
@ -78,9 +78,11 @@ b:
|
||||
|
||||
// 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
|
||||
@ -88,10 +90,12 @@ b:
|
||||
// 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
|
||||
|
@ -43,6 +43,7 @@ b:
|
||||
|
||||
|
||||
// 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
|
||||
@ -52,5 +53,6 @@ b:
|
||||
// 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
|
||||
|
@ -42,6 +42,7 @@ a:
|
||||
|
||||
|
||||
// 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
|
||||
@ -51,5 +52,6 @@ a:
|
||||
// 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
|
||||
|
@ -14,12 +14,14 @@ f2:
|
||||
.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
|
||||
|
@ -119,12 +119,14 @@ Symbols:
|
||||
# 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
|
||||
|
@ -1,4 +1,4 @@
|
||||
; 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
|
||||
@ -9,8 +9,10 @@ entry:
|
||||
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
|
||||
|
@ -2,6 +2,7 @@
|
||||
// RUN: llvm-objdump -r %p/Inputs/many-relocs.obj-i386 | FileCheck %s
|
||||
|
||||
CHECK: RELOCATION RECORDS FOR [.text]:
|
||||
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
|
||||
|
@ -2,16 +2,17 @@
|
||||
// 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
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
# RUN: llvm-objdump -r %t | FileCheck %s
|
||||
|
||||
# CHECK: RELOCATION RECORDS FOR [.text]:
|
||||
# CHECK-NEXT: OFFSET TYPE VALUE
|
||||
# CHECK-NEXT: 0000000000000000 R_X86_64_32 bar
|
||||
|
||||
--- !ELF
|
||||
|
@ -2,15 +2,16 @@
|
||||
# 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
|
||||
@ -143,3 +144,50 @@ Symbols:
|
||||
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
|
||||
|
@ -10,6 +10,7 @@
|
||||
# FMT: [[FILE]]: file format ELF64-x86-64
|
||||
|
||||
# REL: RELOCATION RECORDS FOR []:
|
||||
# REL-NEXT: OFFSET TYPE VALUE
|
||||
# REL-NEXT: 0000000000000123 R_X86_64_NONE *ABS*+0x141
|
||||
|
||||
## Executable.
|
||||
|
@ -1645,6 +1645,11 @@ void printRelocations(const ObjectFile *Obj) {
|
||||
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()) {
|
||||
@ -1657,8 +1662,9 @@ void printRelocations(const ObjectFile *Obj) {
|
||||
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";
|
||||
|
Loading…
Reference in New Issue
Block a user