From 3ba4d082da3dd6856887774fab694f81adc15a64 Mon Sep 17 00:00:00 2001 From: Alexander Yermolovich Date: Wed, 19 Apr 2023 16:38:08 -0700 Subject: [PATCH] [dwarfdump][dwarf] Fix parsing of tu-index Fixed issue where {tu,cu}-index fixup code for DWARF5 that would report an error when fixup map is empty. Which is the case when seciton(s) are not over 4GB or --manaully-generate-unit-index is not specified Differential Revision: https://reviews.llvm.org/D148578 --- llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 2 ++ llvm/test/DebugInfo/X86/dwp-v5-tu-index.s | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 347a5c761442..8033ab4d9573 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -869,6 +869,8 @@ void fixupIndexV5(const DWARFObject &DObj, DWARFContext &C, Offset = Header.getNextUnitOffset(); } }); + if (Map.empty()) + return; for (DWARFUnitIndex::Entry &E : Index.getMutableRows()) { if (!E.isValid()) continue; diff --git a/llvm/test/DebugInfo/X86/dwp-v5-tu-index.s b/llvm/test/DebugInfo/X86/dwp-v5-tu-index.s index 6a4f94fa8d7a..8d054e1c7bb0 100644 --- a/llvm/test/DebugInfo/X86/dwp-v5-tu-index.s +++ b/llvm/test/DebugInfo/X86/dwp-v5-tu-index.s @@ -2,8 +2,8 @@ ## compliant to the DWARFv5 standard. # RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o - | \ -# RUN: llvm-dwarfdump -debug-tu-index - | \ -# RUN: FileCheck %s +# RUN: llvm-dwarfdump -debug-tu-index - 2>&1 | \ +# RUN: FileCheck %s --implicit-check-not "could not find unit with signature" # CHECK: .debug_tu_index contents: # CHECK-NEXT: version = 5, units = 1, slots = 2 -- 2.34.1