diff options
-rw-r--r-- | llvm/test/tools/dsymutil/Inputs/empty-CU.o | bin | 0 -> 388 bytes | |||
-rw-r--r-- | llvm/test/tools/dsymutil/Inputs/empty-CU.s | 16 | ||||
-rw-r--r-- | llvm/test/tools/dsymutil/X86/empty-CU.test | 7 | ||||
-rw-r--r-- | llvm/tools/dsymutil/DwarfLinker.cpp | 16 |
4 files changed, 38 insertions, 1 deletions
diff --git a/llvm/test/tools/dsymutil/Inputs/empty-CU.o b/llvm/test/tools/dsymutil/Inputs/empty-CU.o Binary files differnew file mode 100644 index 00000000000..11c5905bc12 --- /dev/null +++ b/llvm/test/tools/dsymutil/Inputs/empty-CU.o diff --git a/llvm/test/tools/dsymutil/Inputs/empty-CU.s b/llvm/test/tools/dsymutil/Inputs/empty-CU.s new file mode 100644 index 00000000000..c539588da17 --- /dev/null +++ b/llvm/test/tools/dsymutil/Inputs/empty-CU.s @@ -0,0 +1,16 @@ + .section __DWARF,__debug_info,regular,debug +.long 8 # CU length +.short 3 # Version +.long 0 # Abbrev offset +.byte 4 # AddrSize +.byte 1 # Abbrev 1 +.long 7 # Unit lengthh... +.short 3 +.long 0 +.byte 4 + .section __DWARF,__debug_abbrev,regular,debug +.byte 1 # Abbrev code +.byte 0x11 # TAG_compile_unit +.byte 0 # no children +.byte 0 # no attributes +.byte 0 diff --git a/llvm/test/tools/dsymutil/X86/empty-CU.test b/llvm/test/tools/dsymutil/X86/empty-CU.test new file mode 100644 index 00000000000..c55a3ca8659 --- /dev/null +++ b/llvm/test/tools/dsymutil/X86/empty-CU.test @@ -0,0 +1,7 @@ +RUN: dsymutil --update -f %p/../Inputs/empty-CU.o -o - | llvm-dwarfdump -v - -debug-info | FileCheck %s + +CHECK: .debug_info contents: +CHECK: 0x00000000: Compile Unit: length = 0x00000008 version = 0x0003 abbr_offset = 0x0000 addr_size = 0x04 (next unit at 0x0000000c) + +CHECK: 0x0000000b: DW_TAG_compile_unit [1] +CHECK: 0x0000000c: Compile Unit: length = 0x00000007 version = 0x0003 abbr_offset = 0x0000 addr_size = 0x04 (next unit at 0x00000017) diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp index a670b600987..42f65049f3b 100644 --- a/llvm/tools/dsymutil/DwarfLinker.cpp +++ b/llvm/tools/dsymutil/DwarfLinker.cpp @@ -342,6 +342,10 @@ public: Info.resize(OrigUnit.getNumDIEs()); auto CUDie = OrigUnit.getUnitDIE(false); + if (!CUDie) { + HasODR = false; + return; + } if (auto Lang = dwarf::toUnsigned(CUDie.find(dwarf::DW_AT_language))) HasODR = CanUseODR && (*Lang == dwarf::DW_LANG_C_plus_plus || *Lang == dwarf::DW_LANG_C_plus_plus_03 || @@ -4024,6 +4028,8 @@ Error DwarfLinker::loadClangModule(StringRef Filename, StringRef ModulePath, // Recursively get all modules imported by this one. auto CUDie = CU->getUnitDIE(false); + if (!CUDie) + continue; if (!registerModuleReference(CUDie, *CU, ModuleMap, DMO, Ranges, StringPool, UniquingStringPool, ODRContexts, UnitID, Indent)) { @@ -4083,6 +4089,10 @@ void DwarfLinker::DIECloner::cloneAllCompileUnits( for (auto &CurrentUnit : CompileUnits) { auto InputDIE = CurrentUnit->getOrigUnit().getUnitDIE(); CurrentUnit->setStartOffset(Linker.OutputDebugInfoSize); + if (!InputDIE) { + Linker.OutputDebugInfoSize = CurrentUnit->computeNextUnitOffset(); + continue; + } if (CurrentUnit->getInfo(0).Keep) { // Clone the InputDIE into your Unit DIE in our compile unit since it // already has a DIE inside of it. @@ -4320,10 +4330,14 @@ bool DwarfLinker::link(const DebugMap &Map) { } // Now build the DIE parent links that we will use during the next phase. - for (auto &CurrentUnit : LinkContext.CompileUnits) + for (auto &CurrentUnit : LinkContext.CompileUnits) { + auto CUDie = CurrentUnit->getOrigUnit().getUnitDIE(); + if (!CUDie) + continue; analyzeContextInfo(CurrentUnit->getOrigUnit().getUnitDIE(), 0, *CurrentUnit, &ODRContexts.getRoot(), UniquingStringPool, ODRContexts); + } std::unique_lock<std::mutex> LockGuard(ProcessedFilesMutex); ProcessedFiles.set(i); |