summaryrefslogtreecommitdiff
path: root/lib/Object
diff options
context:
space:
mode:
authorAhmed Bougacha <ahmed.bougacha@gmail.com>2013-05-14 22:41:29 +0000
committerAhmed Bougacha <ahmed.bougacha@gmail.com>2013-05-14 22:41:29 +0000
commitebb9f17240dd72f3983d2de884d77f03d6eea4c8 (patch)
tree8661ae0012117a00c0423782c3e96f1b0f56da8a /lib/Object
parent101a36117c2e5e760ebb2b476d6c5b2b52cac6e8 (diff)
downloadllvm-ebb9f17240dd72f3983d2de884d77f03d6eea4c8.tar.gz
llvm-ebb9f17240dd72f3983d2de884d77f03d6eea4c8.tar.bz2
llvm-ebb9f17240dd72f3983d2de884d77f03d6eea4c8.tar.xz
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
Diffstat (limited to 'lib/Object')
-rw-r--r--lib/Object/MachOObjectFile.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp
index af14c72145..654af081f9 100644
--- a/lib/Object/MachOObjectFile.cpp
+++ b/lib/Object/MachOObjectFile.cpp
@@ -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);
}