From: Jonas Devlieghere Date: Tue, 28 Mar 2023 05:29:54 +0000 (-0700) Subject: [dsymutil] Initialize the debug map before loading the main binary X-Git-Tag: upstream/17.0.6~13478 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=568be31c9e50a7d7263417841ee1b12334529903;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp index 2f391c5..305a055 100644 --- a/llvm/tools/dsymutil/MachODebugMapParser.cpp +++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp @@ -113,6 +113,8 @@ private: 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 MachODebugMapParser::parseOneBinary(const MachOObjectFile &MainBinary, StringRef BinaryPath) { + Result = std::make_unique(MainBinary.getArchTriple(), BinaryPath, + MainBinary.getUuid()); loadMainBinarySymbols(MainBinary); - ArrayRef UUID = MainBinary.getUuid(); - Result = - std::make_unique(MainBinary.getArchTriple(), BinaryPath, UUID); MainBinaryStrings = MainBinary.getStringTableData(); for (const SymbolRef &Symbol : MainBinary.symbols()) { const DataRefImpl &DRI = Symbol.getRawDataRefImpl();