mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-19 17:24:57 +00:00
[DWARF parser] Fix nasty memory corruption in .dwo files handling.
Forge a test case where llvm-symbolizer has to use external .dwo file to produce the inlining information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217270 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -235,11 +235,14 @@ size_t DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) {
|
||||
return DieArray.size();
|
||||
}
|
||||
|
||||
DWARFUnit::DWOHolder::DWOHolder(std::unique_ptr<object::ObjectFile> DWOFile)
|
||||
: DWOFile(std::move(DWOFile)),
|
||||
DWOContext(
|
||||
cast<DWARFContext>(DIContext::getDWARFContext(*this->DWOFile))),
|
||||
DWOU(nullptr) {
|
||||
DWARFUnit::DWOHolder::DWOHolder(StringRef DWOPath)
|
||||
: DWOFile(), DWOContext(), DWOU(nullptr) {
|
||||
auto Obj = object::ObjectFile::createObjectFile(DWOPath);
|
||||
if (!Obj)
|
||||
return;
|
||||
DWOFile = std::move(Obj.get());
|
||||
DWOContext.reset(
|
||||
cast<DWARFContext>(DIContext::getDWARFContext(*DWOFile.getBinary())));
|
||||
if (DWOContext->getNumDWOCompileUnits() > 0)
|
||||
DWOU = DWOContext->getDWOCompileUnitAtIndex(0);
|
||||
}
|
||||
@@ -261,12 +264,7 @@ bool DWARFUnit::parseDWO() {
|
||||
sys::path::append(AbsolutePath, CompilationDir);
|
||||
}
|
||||
sys::path::append(AbsolutePath, DWOFileName);
|
||||
ErrorOr<object::OwningBinary<object::ObjectFile>> DWOFile =
|
||||
object::ObjectFile::createObjectFile(AbsolutePath);
|
||||
if (!DWOFile)
|
||||
return false;
|
||||
// Reset DWOHolder.
|
||||
DWO = llvm::make_unique<DWOHolder>(std::move(DWOFile->getBinary()));
|
||||
DWO = llvm::make_unique<DWOHolder>(AbsolutePath);
|
||||
DWARFUnit *DWOCU = DWO->getUnit();
|
||||
// Verify that compile unit in .dwo file is valid.
|
||||
if (!DWOCU || DWOCU->getDWOId() != getDWOId()) {
|
||||
|
Reference in New Issue
Block a user