summaryrefslogtreecommitdiff
path: root/lib/Object/MachOObjectFile.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2011-10-27 21:53:50 +0000
committerOwen Anderson <resistor@mac.com>2011-10-27 21:53:50 +0000
commitb28bdbf8468e728501828fd41b3f2dba8db62efa (patch)
treec28ae84998984850634187e680b8fc621f6f49f4 /lib/Object/MachOObjectFile.cpp
parentf1b7448201f1933147863273495930864e4af6d4 (diff)
downloadllvm-b28bdbf8468e728501828fd41b3f2dba8db62efa.tar.gz
llvm-b28bdbf8468e728501828fd41b3f2dba8db62efa.tar.bz2
llvm-b28bdbf8468e728501828fd41b3f2dba8db62efa.tar.xz
If we're searching for a symbol reference to pretty-print a scattered relocation address, and we don't find a symbol table entry, try section begin addresses as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@143151 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Object/MachOObjectFile.cpp')
-rw-r--r--lib/Object/MachOObjectFile.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp
index 099ac2c37f..65ce5f882a 100644
--- a/lib/Object/MachOObjectFile.cpp
+++ b/lib/Object/MachOObjectFile.cpp
@@ -821,6 +821,24 @@ void MachOObjectFile::printRelocationTargetName(
return;
}
+ // If we couldn't find a symbol that this relocation refers to, try
+ // to find a section beginning instead.
+ for (section_iterator SI = begin_sections(), SE = end_sections(); SI != SE;
+ SI.increment(ec)) {
+ if (ec) report_fatal_error(ec.message());
+
+ uint64_t Addr;
+ StringRef Name;
+
+ if ((ec = SI->getAddress(Addr)))
+ report_fatal_error(ec.message());
+ if (Addr != Val) continue;
+ if ((ec = SI->getName(Name)))
+ report_fatal_error(ec.message());
+ fmt << Name;
+ return;
+ }
+
fmt << format("0x%x", Val);
return;
}