summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
diff options
context:
space:
mode:
authorFrederic Riss <friss@apple.com>2015-08-23 04:44:21 +0000
committerFrederic Riss <friss@apple.com>2015-08-23 04:44:21 +0000
commit7bb12261a35352ce103e64551b49e7c20acc86e2 (patch)
tree278ab9145605ee122b9c3b2d48f7cc266606acf8 /llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
parent1c813407976686f09096406b1d3141290dd93e61 (diff)
downloadbcm5719-llvm-7bb12261a35352ce103e64551b49e7c20acc86e2.tar.gz
bcm5719-llvm-7bb12261a35352ce103e64551b49e7c20acc86e2.zip
[dwarfdump] Do not apply relocations in mach-o files if there is no LoadedObjectInfo.
Not only do we not need to do anything to read correct values from the object files, but the current logic actually wrongly applies twice the section base address when there is no LoadedObjectInfo passed to the DWARFContext creation (as the added test shows). Simply do not apply any relocations on the mach-o debug info if there is no load offset to apply. llvm-svn: 245807
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFContext.cpp')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFContext.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 2e7bcaf96c0..aecd991ff0d 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -637,6 +637,14 @@ DWARFContextInMemory::DWARFContextInMemory(const object::ObjectFile &Obj,
if (L && L->getLoadedSectionContents(*RelocatedSection,RelSecData))
continue;
+ // In Mach-o files, the relocations do not need to be applied if
+ // there is no load offset to apply. The value read at the
+ // relocation point already factors in the section address
+ // (actually applying the relocations will produce wrong results
+ // as the section address will be added twice).
+ if (!L && dyn_cast<MachOObjectFile>(&Obj))
+ continue;
+
RelSecName = RelSecName.substr(
RelSecName.find_first_not_of("._")); // Skip . and _ prefixes.
OpenPOWER on IntegriCloud