aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/DWARFLinker
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2023-09-22 11:27:33 -0700
committerGitHub <noreply@github.com>2023-09-22 11:27:33 -0700
commit697b34fd966bef0a94e67870a5517e8102751c46 (patch)
tree7f79a3ceab72abb6b5e032b4283bf40e1d799adc /llvm/lib/DWARFLinker
parentd7359bcc760a1229f8dadae8fde4784cad57a839 (diff)
downloadllvm-697b34fd966bef0a94e67870a5517e8102751c46.zip
llvm-697b34fd966bef0a94e67870a5517e8102751c46.tar.gz
llvm-697b34fd966bef0a94e67870a5517e8102751c46.tar.bz2
[dsymutil] Remove paper trail warnings (#67041)
Remove the paper trail warning from dsymutil and the DWARF linker. The original purpose of this functionality was to leave a paper trail in the output artifact about missing object files. The current implementation however has diverged and is the source of a pretty serious bug: - In the debug map parser, missing object files are not the only warnings we emit. When paper trail warnings are enabled, all of them end up in the dSYM which wasn't the goal. - When warnings are associated with a object file in the debug map, it is skipped by the DWARF linker. This only makes sense if the object file is missing and is obviously incorrect for any other type of warning (such as a missing symbol). The combination of the two means that we can generate broken DWARF when the feature is enabled. AFAIK it was only used by Apple and nobody I spoke to has relied on it, so rather than fixing the broken behavior I propose we remove it.
Diffstat (limited to 'llvm/lib/DWARFLinker')
-rw-r--r--llvm/lib/DWARFLinker/DWARFLinker.cpp66
-rw-r--r--llvm/lib/DWARFLinker/DWARFStreamer.cpp12
2 files changed, 0 insertions, 78 deletions
diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index 35e5cef..5ed4923 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -2584,69 +2584,6 @@ uint64_t DWARFLinker::DIECloner::cloneAllCompileUnits(
return OutputDebugInfoSize - StartOutputDebugInfoSize;
}
-bool DWARFLinker::emitPaperTrailWarnings(const DWARFFile &File,
- OffsetsStringPool &StringPool) {
-
- if (File.Warnings.empty())
- return false;
-
- DIE *CUDie = DIE::get(DIEAlloc, dwarf::DW_TAG_compile_unit);
- CUDie->setOffset(11);
- StringRef Producer;
- StringRef WarningHeader;
-
- switch (DwarfLinkerClientID) {
- case DwarfLinkerClient::Dsymutil:
- Producer = StringPool.internString("dsymutil");
- WarningHeader = "dsymutil_warning";
- break;
-
- default:
- Producer = StringPool.internString("dwarfopt");
- WarningHeader = "dwarfopt_warning";
- break;
- }
-
- StringRef FileName = StringPool.internString(File.FileName);
- CUDie->addValue(DIEAlloc, dwarf::DW_AT_producer, dwarf::DW_FORM_strp,
- DIEInteger(StringPool.getStringOffset(Producer)));
- DIEBlock *String = new (DIEAlloc) DIEBlock();
- DIEBlocks.push_back(String);
- for (auto &C : FileName)
- String->addValue(DIEAlloc, dwarf::Attribute(0), dwarf::DW_FORM_data1,
- DIEInteger(C));
- String->addValue(DIEAlloc, dwarf::Attribute(0), dwarf::DW_FORM_data1,
- DIEInteger(0));
-
- CUDie->addValue(DIEAlloc, dwarf::DW_AT_name, dwarf::DW_FORM_string, String);
- for (const auto &Warning : File.Warnings) {
- DIE &ConstDie = CUDie->addChild(DIE::get(DIEAlloc, dwarf::DW_TAG_constant));
- ConstDie.addValue(DIEAlloc, dwarf::DW_AT_name, dwarf::DW_FORM_strp,
- DIEInteger(StringPool.getStringOffset(WarningHeader)));
- ConstDie.addValue(DIEAlloc, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag,
- DIEInteger(1));
- ConstDie.addValue(DIEAlloc, dwarf::DW_AT_const_value, dwarf::DW_FORM_strp,
- DIEInteger(StringPool.getStringOffset(Warning)));
- }
- unsigned Size = 4 /* FORM_strp */ + FileName.size() + 1 +
- File.Warnings.size() * (4 + 1 + 4) + 1 /* End of children */;
- DIEAbbrev Abbrev = CUDie->generateAbbrev();
- assignAbbrev(Abbrev);
- CUDie->setAbbrevNumber(Abbrev.getNumber());
- Size += getULEB128Size(Abbrev.getNumber());
- // Abbreviation ordering needed for classic compatibility.
- for (auto &Child : CUDie->children()) {
- Abbrev = Child.generateAbbrev();
- assignAbbrev(Abbrev);
- Child.setAbbrevNumber(Abbrev.getNumber());
- Size += getULEB128Size(Abbrev.getNumber());
- }
- CUDie->setSize(Size);
- TheDwarfEmitter->emitPaperTrailWarningsDie(*CUDie);
-
- return true;
-}
-
void DWARFLinker::copyInvariantDebugSection(DWARFContext &Dwarf) {
TheDwarfEmitter->emitSectionContents(Dwarf.getDWARFObj().getLocSection().Data,
"debug_loc");
@@ -2711,9 +2648,6 @@ Error DWARFLinker::link() {
outs() << "OBJECT FILE: " << OptContext.File.FileName << "\n";
}
- if (emitPaperTrailWarnings(OptContext.File, DebugStrPool))
- continue;
-
if (!OptContext.File.Dwarf)
continue;
diff --git a/llvm/lib/DWARFLinker/DWARFStreamer.cpp b/llvm/lib/DWARFLinker/DWARFStreamer.cpp
index 4d5eef5..3bcc5a0 100644
--- a/llvm/lib/DWARFLinker/DWARFStreamer.cpp
+++ b/llvm/lib/DWARFLinker/DWARFStreamer.cpp
@@ -234,18 +234,6 @@ void DwarfStreamer::emitSectionContents(StringRef SecData, StringRef SecName) {
}
}
-/// Emit DIE containing warnings.
-void DwarfStreamer::emitPaperTrailWarningsDie(DIE &Die) {
- switchToDebugInfoSection(/* Version */ 2);
- auto &Asm = getAsmPrinter();
- Asm.emitInt32(11 + Die.getSize() - 4);
- Asm.emitInt16(2);
- Asm.emitInt32(0);
- Asm.emitInt8(MC->getTargetTriple().isArch64Bit() ? 8 : 4);
- DebugInfoSectionSize += 11;
- emitDIE(Die);
-}
-
/// Emit the debug_str section stored in \p Pool.
void DwarfStreamer::emitStrings(const NonRelocatableStringpool &Pool) {
Asm->OutStreamer->switchSection(MOFI->getDwarfStrSection());