mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-16 16:37:42 +00:00
Object: Fix Mach-O relocation printing.
There were two problems that made llvm-objdump -r crash: - for non-scattered relocations, the symbol/section index is actually in the (aptly named) symbolnum field. - sections are 1-indexed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181843 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
101a36117c
commit
ebb9f17240
@ -339,7 +339,7 @@ static void printRelocationTargetName(const MachOObjectFile *O,
|
||||
|
||||
StringRef S;
|
||||
bool isExtern = O->getPlainRelocationExternal(RE);
|
||||
uint64_t Val = O->getAnyRelocationAddress(RE);
|
||||
uint64_t Val = O->getPlainRelocationSymbolNum(RE);
|
||||
|
||||
if (isExtern) {
|
||||
symbol_iterator SI = O->begin_symbols();
|
||||
@ -347,7 +347,8 @@ static void printRelocationTargetName(const MachOObjectFile *O,
|
||||
SI->getName(S);
|
||||
} else {
|
||||
section_iterator SI = O->begin_sections();
|
||||
advanceTo(SI, Val);
|
||||
// Adjust for the fact that sections are 1-indexed.
|
||||
advanceTo(SI, Val - 1);
|
||||
SI->getName(S);
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,10 @@ RUN: llvm-objdump -d -r %p/../Inputs/trivial-object-test.coff-i386 \
|
||||
RUN: | FileCheck %s -check-prefix COFF-i386
|
||||
RUN: llvm-objdump -d -r %p/../Inputs/trivial-object-test.coff-x86-64 \
|
||||
RUN: | FileCheck %s -check-prefix COFF-x86-64
|
||||
RUN: llvm-objdump -d -r %p/../Inputs/trivial-object-test.macho-i386 \
|
||||
RUN: | FileCheck %s -check-prefix MACHO-i386
|
||||
RUN: llvm-objdump -d -r %p/../Inputs/trivial-object-test.macho-x86-64 \
|
||||
RUN: | FileCheck %s -check-prefix MACHO-x86-64
|
||||
|
||||
COFF-i386: file format COFF-i386
|
||||
COFF-i386: Disassembly of section .text:
|
||||
@ -30,3 +34,34 @@ COFF-x86-64: 19: IMAGE_REL_AMD64_REL32 SomeOtherFun
|
||||
COFF-x86-64: 1d: 8b 44 24 24 movl 36(%rsp), %eax
|
||||
COFF-x86-64: 21: 48 83 c4 28 addq $40, %rsp
|
||||
COFF-x86-64: 25: c3 ret
|
||||
|
||||
MACHO-i386: file format Mach-O 32-bit i386
|
||||
MACHO-i386: Disassembly of section __TEXT,__text:
|
||||
MACHO-i386: _main:
|
||||
MACHO-i386: 0: 83 ec 0c subl $12, %esp
|
||||
MACHO-i386: 3: c7 44 24 08 00 00 00 00 movl $0, 8(%esp)
|
||||
MACHO-i386: b: c7 04 24 24 00 00 00 movl $36, (%esp)
|
||||
MACHO-i386: e: GENERIC_RELOC_VANILLA __cstring
|
||||
MACHO-i386: 12: e8 1f 00 00 00 calll 31
|
||||
MACHO-i386: 13: GENERIC_RELOC_VANILLA __jump_table
|
||||
MACHO-i386: 17: e8 15 00 00 00 calll 21
|
||||
MACHO-i386: 18: GENERIC_RELOC_VANILLA __jump_table
|
||||
MACHO-i386: 1c: 8b 44 24 08 movl 8(%esp), %eax
|
||||
MACHO-i386: 20: 83 c4 0c addl $12, %esp
|
||||
MACHO-i386: 23: c3 ret
|
||||
|
||||
MACHO-x86-64: file format Mach-O 64-bit x86-64
|
||||
MACHO-x86-64: Disassembly of section __TEXT,__text:
|
||||
MACHO-x86-64: _main:
|
||||
MACHO-x86-64: 0: 48 83 ec 08 subq $8, %rsp
|
||||
MACHO-x86-64: 4: c7 44 24 04 00 00 00 00 movl $0, 4(%rsp)
|
||||
MACHO-x86-64: c: 48 8d 3d 00 00 00 00 leaq (%rip), %rdi
|
||||
MACHO-x86-64: f: X86_64_RELOC_SIGNED L_.str
|
||||
MACHO-x86-64: 13: e8 00 00 00 00 callq 0
|
||||
MACHO-x86-64: 14: X86_64_RELOC_BRANCH _puts
|
||||
MACHO-x86-64: 18: 30 c0 xorb %al, %al
|
||||
MACHO-x86-64: 1a: e8 00 00 00 00 callq 0
|
||||
MACHO-x86-64: 1b: X86_64_RELOC_BRANCH _SomeOtherFunction
|
||||
MACHO-x86-64: 1f: 8b 44 24 04 movl 4(%rsp), %eax
|
||||
MACHO-x86-64: 23: 48 83 c4 08 addq $8, %rsp
|
||||
MACHO-x86-64: 27: c3 ret
|
||||
|
Loading…
Reference in New Issue
Block a user