diff options
author | Frederic Riss <friss@apple.com> | 2016-01-31 04:29:34 +0000 |
---|---|---|
committer | Frederic Riss <friss@apple.com> | 2016-01-31 04:29:34 +0000 |
commit | 6c8521ad32d61943d031ad165c5c2412e3d64bc6 (patch) | |
tree | 70f15e9ae122b652524dfec6b9de78275e3cfb03 /llvm/tools | |
parent | d8c33dc2f60becafd0460d4e24d211316f64e521 (diff) | |
download | bcm5719-llvm-6c8521ad32d61943d031ad165c5c2412e3d64bc6.tar.gz bcm5719-llvm-6c8521ad32d61943d031ad165c5c2412e3d64bc6.zip |
[dsymutil] Fix handling of common symbols.
llvm-dsymutil was misinterpreting the value of common symbols as their
address when it actually contains their size. This didn't impact
llvm-dsymutil's ability to link the debug information for common symbols
because these are always found by name and not by address. Things could
however go wrong when the size of a common object matched the object
file address of another symbol. Depending on the link order of the symbols
the common object might incorrectly evict this other object from the
address to symbol mapping, and then link the evicted symbol with a wrong
binary address.
Use the new ability to have symbols without an object file address to fix
this.
llvm-svn: 259318
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/dsymutil/DebugMap.cpp | 3 | ||||
-rw-r--r-- | llvm/tools/dsymutil/MachODebugMapParser.cpp | 17 |
2 files changed, 11 insertions, 9 deletions
diff --git a/llvm/tools/dsymutil/DebugMap.cpp b/llvm/tools/dsymutil/DebugMap.cpp index d2d5b615a32..114e22c0745 100644 --- a/llvm/tools/dsymutil/DebugMap.cpp +++ b/llvm/tools/dsymutil/DebugMap.cpp @@ -229,7 +229,8 @@ MappingTraits<dsymutil::DebugMapObject>::YamlDMO::denormalize(IO &IO) { for (const auto &Sym : ErrOrObjectFile->symbols()) { uint64_t Address = Sym.getValue(); ErrorOr<StringRef> Name = Sym.getName(); - if (!Name) + if (!Name || + (Sym.getFlags() & (SymbolRef::SF_Absolute | SymbolRef::SF_Common))) continue; SymbolAddresses[*Name] = Address; } diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp index 33845f40cba..02c3ab07f6a 100644 --- a/llvm/tools/dsymutil/MachODebugMapParser.cpp +++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp @@ -389,8 +389,6 @@ void MachODebugMapParser::handleStabSymbolTableEntry(uint32_t StringIndex, if (ObjectSymIt == CurrentObjectAddresses.end()) return Warning("could not find object file symbol for symbol " + Twine(Name)); - if (!ObjectSymIt->getValue()) - return; if (!CurrentDebugMapObject->addSymbol(Name, ObjectSymIt->getValue(), Value, Size)) return Warning(Twine("failed to insert symbol '") + Name + @@ -407,12 +405,15 @@ void MachODebugMapParser::loadCurrentObjectFileSymbols( ErrorOr<StringRef> Name = Sym.getName(); if (!Name) continue; - // Objective-C on i386 uses artificial absolute symbols to - // perform some link time checks. Those symbols have a fixed 0 - // address that might conflict with real symbols in the object - // file. As I cannot see a way for absolute symbols to find - // their way into the debug information, let's just ignore those. - if (Sym.getFlags() & SymbolRef::SF_Absolute) + // The value of some categories of symbols isn't meaningful. For + // example common symbols store their size in the value field, not + // their address. Absolute symbols have a fixed address that can + // conflict with standard symbols. These symbols (especially the + // common ones), might still be referenced by relocations. These + // relocations will use the symbol itself, and won't need an + // object file address. The object file address field is optional + // in the DebugMap, leave it unassigned for these symbols. + if (Sym.getFlags() & (SymbolRef::SF_Absolute | SymbolRef::SF_Common)) CurrentObjectAddresses[*Name] = None; else CurrentObjectAddresses[*Name] = Addr; |