summaryrefslogtreecommitdiffstats
path: root/llvm/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
commitdebe01c660b0dfee1a880e497d57560accab3392 (patch)
tree388a3c629e11297558486cbec3a747223e4afbbe /llvm/lib/Object/MachOObjectFile.cpp
parentbc2dac225a7e8df4d342a6b1f485155b81bc27e8 (diff)
downloadbcm5719-llvm-debe01c660b0dfee1a880e497d57560accab3392.tar.gz
bcm5719-llvm-debe01c660b0dfee1a880e497d57560accab3392.zip
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.
llvm-svn: 143151
Diffstat (limited to 'llvm/lib/Object/MachOObjectFile.cpp')
-rw-r--r--llvm/lib/Object/MachOObjectFile.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index 099ac2c37f9..65ce5f882a0 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/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;
}
OpenPOWER on IntegriCloud