summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/tools/dsymutil/DebugMap.cpp19
-rw-r--r--llvm/tools/dsymutil/DebugMap.h13
-rw-r--r--llvm/tools/dsymutil/DwarfLinker.cpp18
-rw-r--r--llvm/tools/dsymutil/MachODebugMapParser.cpp2
4 files changed, 31 insertions, 21 deletions
diff --git a/llvm/tools/dsymutil/DebugMap.cpp b/llvm/tools/dsymutil/DebugMap.cpp
index 4717085f432..d2d5b615a32 100644
--- a/llvm/tools/dsymutil/DebugMap.cpp
+++ b/llvm/tools/dsymutil/DebugMap.cpp
@@ -24,13 +24,13 @@ DebugMapObject::DebugMapObject(StringRef ObjectFilename,
sys::TimeValue Timestamp)
: Filename(ObjectFilename), Timestamp(Timestamp) {}
-bool DebugMapObject::addSymbol(StringRef Name, uint64_t ObjectAddress,
+bool DebugMapObject::addSymbol(StringRef Name, Optional<uint64_t> ObjectAddress,
uint64_t LinkedAddress, uint32_t Size) {
auto InsertResult = Symbols.insert(
std::make_pair(Name, SymbolMapping(ObjectAddress, LinkedAddress, Size)));
- if (InsertResult.second)
- AddressToMapping[ObjectAddress] = &*InsertResult.first;
+ if (ObjectAddress && InsertResult.second)
+ AddressToMapping[*ObjectAddress] = &*InsertResult.first;
return InsertResult.second;
}
@@ -47,8 +47,11 @@ void DebugMapObject::print(raw_ostream &OS) const {
Entries.begin(), Entries.end(),
[](const Entry &LHS, const Entry &RHS) { return LHS.first < RHS.first; });
for (const auto &Sym : Entries) {
- OS << format("\t%016" PRIx64 " => %016" PRIx64 "+0x%x\t%s\n",
- uint64_t(Sym.second.ObjectAddress),
+ if (Sym.second.ObjectAddress)
+ OS << format("\t%016" PRIx64, uint64_t(*Sym.second.ObjectAddress));
+ else
+ OS << "\t????????????????";
+ OS << format(" => %016" PRIx64 "+0x%x\t%s\n",
uint64_t(Sym.second.BinaryAddress), uint32_t(Sym.second.Size),
Sym.first.data());
}
@@ -136,7 +139,7 @@ struct MappingTraits<dsymutil::DebugMapObject>::YamlDMO {
void MappingTraits<std::pair<std::string, DebugMapObject::SymbolMapping>>::
mapping(IO &io, std::pair<std::string, DebugMapObject::SymbolMapping> &s) {
io.mapRequired("sym", s.first);
- io.mapRequired("objAddr", s.second.ObjectAddress);
+ io.mapOptional("objAddr", s.second.ObjectAddress);
io.mapRequired("binAddr", s.second.BinaryAddress);
io.mapOptional("size", s.second.Size);
}
@@ -237,7 +240,9 @@ MappingTraits<dsymutil::DebugMapObject>::YamlDMO::denormalize(IO &IO) {
dsymutil::DebugMapObject Res(Path, TV);
for (auto &Entry : Entries) {
auto &Mapping = Entry.second;
- uint64_t ObjAddress = Mapping.ObjectAddress;
+ Optional<uint64_t> ObjAddress;
+ if (Mapping.ObjectAddress)
+ ObjAddress = *Mapping.ObjectAddress;
auto AddressIt = SymbolAddresses.find(Entry.first);
if (AddressIt != SymbolAddresses.end())
ObjAddress = AddressIt->getValue();
diff --git a/llvm/tools/dsymutil/DebugMap.h b/llvm/tools/dsymutil/DebugMap.h
index 4907b8f1a72..1a3d62b67b7 100644
--- a/llvm/tools/dsymutil/DebugMap.h
+++ b/llvm/tools/dsymutil/DebugMap.h
@@ -117,12 +117,15 @@ public:
class DebugMapObject {
public:
struct SymbolMapping {
- yaml::Hex64 ObjectAddress;
+ Optional<yaml::Hex64> ObjectAddress;
yaml::Hex64 BinaryAddress;
yaml::Hex32 Size;
- SymbolMapping(uint64_t ObjectAddress, uint64_t BinaryAddress, uint32_t Size)
- : ObjectAddress(ObjectAddress), BinaryAddress(BinaryAddress),
- Size(Size) {}
+ SymbolMapping(Optional<uint64_t> ObjectAddr, uint64_t BinaryAddress,
+ uint32_t Size)
+ : BinaryAddress(BinaryAddress), Size(Size) {
+ if (ObjectAddr)
+ ObjectAddress = *ObjectAddr;
+ }
/// For YAML IO support
SymbolMapping() = default;
};
@@ -132,7 +135,7 @@ public:
/// \brief Adds a symbol mapping to this DebugMapObject.
/// \returns false if the symbol was already registered. The request
/// is discarded in this case.
- bool addSymbol(llvm::StringRef SymName, uint64_t ObjectAddress,
+ bool addSymbol(llvm::StringRef SymName, Optional<uint64_t> ObjectAddress,
uint64_t LinkedAddress, uint32_t Size);
/// \brief Lookup a symbol mapping.
diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp
index 37dd02851dc..fe971e99607 100644
--- a/llvm/tools/dsymutil/DwarfLinker.cpp
+++ b/llvm/tools/dsymutil/DwarfLinker.cpp
@@ -1854,10 +1854,10 @@ void DwarfLinker::startDebugObject(DWARFContext &Dwarf, DebugMapObject &Obj) {
// -gline-tables-only on Darwin.
for (const auto &Entry : Obj.symbols()) {
const auto &Mapping = Entry.getValue();
- if (Mapping.Size)
- Ranges[Mapping.ObjectAddress] = std::make_pair(
- Mapping.ObjectAddress + Mapping.Size,
- int64_t(Mapping.BinaryAddress) - Mapping.ObjectAddress);
+ if (Mapping.Size && Mapping.ObjectAddress)
+ Ranges[*Mapping.ObjectAddress] = std::make_pair(
+ *Mapping.ObjectAddress + Mapping.Size,
+ int64_t(Mapping.BinaryAddress) - *Mapping.ObjectAddress);
}
}
@@ -1988,14 +1988,16 @@ hasValidRelocation(uint32_t StartOffset, uint32_t EndOffset,
const auto &ValidReloc = ValidRelocs[NextValidReloc++];
const auto &Mapping = ValidReloc.Mapping->getValue();
+ uint64_t ObjectAddress =
+ Mapping.ObjectAddress ? uint64_t(*Mapping.ObjectAddress) : UINT64_MAX;
if (Linker.Options.Verbose)
outs() << "Found valid debug map entry: " << ValidReloc.Mapping->getKey()
- << " " << format("\t%016" PRIx64 " => %016" PRIx64,
- uint64_t(Mapping.ObjectAddress),
+ << " " << format("\t%016" PRIx64 " => %016" PRIx64, ObjectAddress,
uint64_t(Mapping.BinaryAddress));
- Info.AddrAdjust = int64_t(Mapping.BinaryAddress) + ValidReloc.Addend -
- Mapping.ObjectAddress;
+ Info.AddrAdjust = int64_t(Mapping.BinaryAddress) + ValidReloc.Addend;
+ if (Mapping.ObjectAddress)
+ Info.AddrAdjust -= ObjectAddress;
Info.InDebugMap = true;
return true;
}
diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp
index 4412db25426..33845f40cba 100644
--- a/llvm/tools/dsymutil/MachODebugMapParser.cpp
+++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp
@@ -391,7 +391,7 @@ void MachODebugMapParser::handleStabSymbolTableEntry(uint32_t StringIndex,
Twine(Name));
if (!ObjectSymIt->getValue())
return;
- if (!CurrentDebugMapObject->addSymbol(Name, *ObjectSymIt->getValue(), Value,
+ if (!CurrentDebugMapObject->addSymbol(Name, ObjectSymIt->getValue(), Value,
Size))
return Warning(Twine("failed to insert symbol '") + Name +
"' in the debug map.");
OpenPOWER on IntegriCloud