aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorAlexey Lapshin <a.v.lapshin@mail.ru>2022-07-25 20:08:46 +0300
committerAlexey Lapshin <a.v.lapshin@mail.ru>2022-07-26 15:25:51 +0300
commit0d191b7553e7efbf7ce57c77274b83c15b681933 (patch)
treecf60c95ae49bade6b027b9e53dff2a555a48fb46 /llvm/lib
parent418d2338f9bad03e002ca1a301ce537102a2f142 (diff)
downloadllvm-0d191b7553e7efbf7ce57c77274b83c15b681933.zip
llvm-0d191b7553e7efbf7ce57c77274b83c15b681933.tar.gz
llvm-0d191b7553e7efbf7ce57c77274b83c15b681933.tar.bz2
[Debuginfo][llvm-dwarfutil] Add check for unsupported debug sections.
Current DWARFLinker implementation does not support some debug sections (mainly DWARF v5 sections). This patch adds diagnostic for such sections. The warning would be displayed for critical(such that could not be removed) sections and the source file would be skipped. Other unsupported sections would be removed and warning message should be displayed. The zero exit status would be returned for both cases. Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D123623
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/DWARFLinker/DWARFLinker.cpp53
1 files changed, 51 insertions, 2 deletions
diff --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index 62b7f62..3e14edb 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -2343,7 +2343,7 @@ void DWARFLinker::addObjectFile(DWARFFile &File) {
updateAccelKind(*ObjectContexts.back().File.Dwarf);
}
-bool DWARFLinker::link() {
+Error DWARFLinker::link() {
assert(Options.NoOutput || TheDwarfEmitter);
// A unique ID that identifies each compile unit.
@@ -2410,6 +2410,55 @@ bool DWARFLinker::link() {
if (!OptContext.File.Dwarf)
continue;
+ // Check whether type units are presented.
+ if (!OptContext.File.Dwarf->types_section_units().empty()) {
+ reportWarning("type units are not currently supported: file will "
+ "be skipped",
+ OptContext.File);
+ OptContext.Skip = true;
+ continue;
+ }
+
+ // Check for unsupported sections. Following sections can be referenced
+ // from .debug_info section. Current DWARFLinker implementation does not
+ // support or update references to these tables. Thus we report warning
+ // and skip corresponding object file.
+ if (!OptContext.File.Dwarf->getDWARFObj()
+ .getRnglistsSection()
+ .Data.empty()) {
+ reportWarning("'.debug_rnglists' is not currently supported: file "
+ "will be skipped",
+ OptContext.File);
+ OptContext.Skip = true;
+ continue;
+ }
+
+ if (!OptContext.File.Dwarf->getDWARFObj()
+ .getLoclistsSection()
+ .Data.empty()) {
+ reportWarning("'.debug_loclists' is not currently supported: file "
+ "will be skipped",
+ OptContext.File);
+ OptContext.Skip = true;
+ continue;
+ }
+
+ if (!OptContext.File.Dwarf->getDWARFObj().getMacroSection().Data.empty()) {
+ reportWarning("'.debug_macro' is not currently supported: file "
+ "will be skipped",
+ OptContext.File);
+ OptContext.Skip = true;
+ continue;
+ }
+
+ if (OptContext.File.Dwarf->getDWARFObj().getMacinfoSection().size() > 1) {
+ reportWarning("'.debug_macinfo' is not currently supported: file "
+ "will be skipped",
+ OptContext.File);
+ OptContext.Skip = true;
+ continue;
+ }
+
// In a first phase, just read in the debug info and load all clang modules.
OptContext.CompileUnits.reserve(
OptContext.File.Dwarf->getNumCompileUnits());
@@ -2660,7 +2709,7 @@ bool DWARFLinker::link() {
"---------------\n\n";
}
- return true;
+ return Error::success();
}
bool DWARFLinker::verify(const DWARFFile &File) {