summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2017-09-26 08:17:28 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2017-09-26 08:17:28 +0000
commit4a5a6337f7b79c8800dc0f5d7119f17b07e527ae (patch)
treed325ed1dbb782f141af6febac97f4881a8ef57b1 /llvm/tools
parentb51c49aa5202823f459d52adb9c20131928712a8 (diff)
downloadbcm5719-llvm-4a5a6337f7b79c8800dc0f5d7119f17b07e527ae.tar.gz
bcm5719-llvm-4a5a6337f7b79c8800dc0f5d7119f17b07e527ae.zip
[dsymutil] Better support for symbol aliases
This patch adds logic to follow a symbol's aliases when the symbol name cannot be found in the current object file. It checks the main binary for the symbol's address and queries the current object for its aliases (symbols with the same address) before printing out a warning. Differential revision: https://reviews.llvm.org/D38230 llvm-svn: 314198
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/dsymutil/MachODebugMapParser.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp
index 75ae67cd53f..866196fb27e 100644
--- a/llvm/tools/dsymutil/MachODebugMapParser.cpp
+++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp
@@ -70,6 +70,7 @@ private:
sys::TimePoint<std::chrono::seconds> Timestamp);
void resetParserState();
uint64_t getMainBinarySymbolAddress(StringRef Name);
+ std::vector<StringRef> getMainBinarySymbolNames(uint64_t Value);
void loadMainBinarySymbols(const MachOObjectFile &MainBinary);
void loadCurrentObjectFileSymbols(const object::MachOObjectFile &Obj);
void handleStabSymbolTableEntry(uint32_t StringIndex, uint8_t Type,
@@ -382,9 +383,21 @@ void MachODebugMapParser::handleStabSymbolTableEntry(uint32_t StringIndex,
}
auto ObjectSymIt = CurrentObjectAddresses.find(Name);
+
+ // If the name of a (non-static) symbol is not in the current object, we
+ // check all its aliases from the main binary.
+ if (ObjectSymIt == CurrentObjectAddresses.end() && Type != MachO::N_STSYM) {
+ for (const auto &Alias : getMainBinarySymbolNames(Value)) {
+ ObjectSymIt = CurrentObjectAddresses.find(Alias);
+ if (ObjectSymIt != CurrentObjectAddresses.end())
+ break;
+ }
+ }
+
if (ObjectSymIt == CurrentObjectAddresses.end())
return Warning("could not find object file symbol for symbol " +
Twine(Name));
+
if (!CurrentDebugMapObject->addSymbol(Name, ObjectSymIt->getValue(), Value,
Size))
return Warning(Twine("failed to insert symbol '") + Name +
@@ -429,6 +442,17 @@ uint64_t MachODebugMapParser::getMainBinarySymbolAddress(StringRef Name) {
return Sym->second;
}
+/// Get all symbol names in the main binary for the given value.
+std::vector<StringRef>
+MachODebugMapParser::getMainBinarySymbolNames(uint64_t Value) {
+ std::vector<StringRef> Names;
+ for (const auto &Entry : MainBinarySymbolAddresses) {
+ if (Entry.second == Value)
+ Names.push_back(Entry.first());
+ }
+ return Names;
+}
+
/// Load the interesting main binary symbols' addresses into
/// MainBinarySymbolAddresses.
void MachODebugMapParser::loadMainBinarySymbols(
OpenPOWER on IntegriCloud