summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-02-13 00:32:06 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-02-13 00:32:06 +0000
commit1bf1b9857f8733eabe009da9f529e0b1b5323a28 (patch)
treec1de1ead0d5d1b09c3756a8cb59178b54c561370 /llvm/tools
parent8bb5d7e76a37228b687b9b95a3129b0f2624cbec (diff)
downloadbcm5719-llvm-1bf1b9857f8733eabe009da9f529e0b1b5323a28.tar.gz
bcm5719-llvm-1bf1b9857f8733eabe009da9f529e0b1b5323a28.zip
[dsymutil] Don't clone empty CUs
The DWARF standard says that an empty compile unit is not valid: > Each such contribution consists of a compilation unit header (see > Section 7.5.1.1 on page 200) followed by a single DW_TAG_compile_unit or > DW_TAG_partial_unit debugging information entry, together with its > children. Therefore we shouldn't clone them in dsymutil. Differential revision: https://reviews.llvm.org/D57979 llvm-svn: 353903
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/dsymutil/CompileUnit.cpp9
-rw-r--r--llvm/tools/dsymutil/DwarfLinker.cpp8
2 files changed, 8 insertions, 9 deletions
diff --git a/llvm/tools/dsymutil/CompileUnit.cpp b/llvm/tools/dsymutil/CompileUnit.cpp
index 3eb6abbb852..670591a9436 100644
--- a/llvm/tools/dsymutil/CompileUnit.cpp
+++ b/llvm/tools/dsymutil/CompileUnit.cpp
@@ -55,12 +55,11 @@ void CompileUnit::markEverythingAsKept() {
}
uint64_t CompileUnit::computeNextUnitOffset() {
- NextUnitOffset = StartOffset + 11 /* Header size */;
- // The root DIE might be null, meaning that the Unit had nothing to
- // contribute to the linked output. In that case, we will emit the
- // unit header without any actual DIE.
- if (NewUnit)
+ NextUnitOffset = StartOffset;
+ if (NewUnit) {
+ NextUnitOffset += 11 /* Header size */;
NextUnitOffset += NewUnit->getUnitDie().getSize();
+ }
return NextUnitOffset;
}
diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp
index 384805808e5..ce8653173c3 100644
--- a/llvm/tools/dsymutil/DwarfLinker.cpp
+++ b/llvm/tools/dsymutil/DwarfLinker.cpp
@@ -2266,10 +2266,10 @@ void DwarfLinker::DIECloner::cloneAllCompileUnits(
if (LLVM_LIKELY(!Linker.Options.Update))
Linker.generateUnitRanges(*CurrentUnit);
CurrentUnit->fixupForwardReferences();
- Linker.Streamer->emitCompileUnitHeader(*CurrentUnit);
- if (!CurrentUnit->getOutputUnitDIE())
- continue;
- Linker.Streamer->emitDIE(*CurrentUnit->getOutputUnitDIE());
+ if (CurrentUnit->getOutputUnitDIE()) {
+ Linker.Streamer->emitCompileUnitHeader(*CurrentUnit);
+ Linker.Streamer->emitDIE(*CurrentUnit->getOutputUnitDIE());
+ }
}
}
OpenPOWER on IntegriCloud