[llvm-objdump] Properly print MachO aarch64 addend relocations

Previously such relocations fell into the last case for local
symbols, using the relocation addend as symbol index, leading to
a crash.

Differential Revision: https://reviews.llvm.org/D35239

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307927 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Martin Storsjo 2017-07-13 17:03:02 +00:00
parent d7b55ebbd0
commit 5dbda1ece1
3 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,6 @@
RUN: llvm-objdump -r %p/Inputs/reloc-addend.obj.macho-aarch64 | FileCheck %s
CHECK-DAG: 0000000000000004 ARM64_RELOC_ADDEND 0x999
CHECK-DAG: 0000000000000004 ARM64_RELOC_PAGEOFF12 _stringbuf
CHECK-DAG: 0000000000000000 ARM64_RELOC_ADDEND 0x999
CHECK-DAG: 0000000000000000 ARM64_RELOC_PAGE21 _stringbuf

View File

@ -870,7 +870,10 @@ static void printRelocationTargetName(const MachOObjectFile *O,
bool isExtern = O->getPlainRelocationExternal(RE);
uint64_t Val = O->getPlainRelocationSymbolNum(RE);
if (isExtern) {
if (O->getAnyRelocationType(RE) == MachO::ARM64_RELOC_ADDEND) {
fmt << format("0x%x", Val);
return;
} else if (isExtern) {
symbol_iterator SI = O->symbol_begin();
advance(SI, Val);
Expected<StringRef> SOrErr = SI->getName();