[llvm] 568be31 - [dsymutil] Initialize the debug map before loading the main binary
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 27 22:34:48 PDT 2023
Author: Jonas Devlieghere
Date: 2023-03-27T22:34:42-07:00
New Revision: 568be31c9e50a7d7263417841ee1b12334529903
URL: https://github.com/llvm/llvm-project/commit/568be31c9e50a7d7263417841ee1b12334529903
DIFF: https://github.com/llvm/llvm-project/commit/568be31c9e50a7d7263417841ee1b12334529903.diff
LOG: [dsymutil] Initialize the debug map before loading the main binary
Fix a crash when a warning is emitted while loading the symbols from the
main binary. The warning helper assumes that the resulting debug map is
initialized, but this happened after loading the main binary. Since
there's no dependency between the two the initialization can be moved
up.
rdar://107298776
Added:
Modified:
llvm/tools/dsymutil/MachODebugMapParser.cpp
Removed:
################################################################################
diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp
index 2f391c54e8ca..305a0556d64c 100644
--- a/llvm/tools/dsymutil/MachODebugMapParser.cpp
+++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp
@@ -113,6 +113,8 @@ class MachODebugMapParser {
StringRef BinaryPath);
void Warning(const Twine &Msg, StringRef File = StringRef()) {
+ assert(Result &&
+ "The debug map must be initialized before calling this function");
WithColor::warning() << "("
<< MachOUtils::getArchName(
Result->getTriple().getArchName())
@@ -200,10 +202,9 @@ static std::string getArchName(const object::MachOObjectFile &Obj) {
std::unique_ptr<DebugMap>
MachODebugMapParser::parseOneBinary(const MachOObjectFile &MainBinary,
StringRef BinaryPath) {
+ Result = std::make_unique<DebugMap>(MainBinary.getArchTriple(), BinaryPath,
+ MainBinary.getUuid());
loadMainBinarySymbols(MainBinary);
- ArrayRef<uint8_t> UUID = MainBinary.getUuid();
- Result =
- std::make_unique<DebugMap>(MainBinary.getArchTriple(), BinaryPath, UUID);
MainBinaryStrings = MainBinary.getStringTableData();
for (const SymbolRef &Symbol : MainBinary.symbols()) {
const DataRefImpl &DRI = Symbol.getRawDataRefImpl();
More information about the llvm-commits
mailing list