Skip to content

Commit

Permalink
[llvm-objdump] Properly print MachO aarch64 addend relocations
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mstorsjo committed Jul 13, 2017
1 parent d7b55eb commit 5dbda1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Binary file not shown.
6 changes: 6 additions & 0 deletions test/tools/llvm-objdump/AArch64/macho-reloc-addend.test
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion tools/llvm-objdump/llvm-objdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 5dbda1e

Please sign in to comment.