diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h @@ -28,7 +28,8 @@ private: void clear(); void extract(DWARFDataExtractor DebugArangesData, - function_ref RecoverableErrorHandler); + function_ref RecoverableErrorHandler, + function_ref WarningHandler); /// Call appendRange multiple times and then call construct. void appendRange(uint64_t CUOffset, uint64_t LowPC, uint64_t HighPC); diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp @@ -22,15 +22,15 @@ void DWARFDebugAranges::extract( DWARFDataExtractor DebugArangesData, - function_ref RecoverableErrorHandler) { + function_ref RecoverableErrorHandler, + function_ref WarningHandler) { if (!DebugArangesData.isValidOffset(0)) return; uint64_t Offset = 0; DWARFDebugArangeSet Set; while (DebugArangesData.isValidOffset(Offset)) { - if (Error E = - Set.extract(DebugArangesData, &Offset, RecoverableErrorHandler)) { + if (Error E = Set.extract(DebugArangesData, &Offset, WarningHandler)) { RecoverableErrorHandler(std::move(E)); return; } @@ -52,7 +52,8 @@ // Extract aranges from .debug_aranges section. DWARFDataExtractor ArangesData(CTX->getDWARFObj().getArangesSection(), CTX->isLittleEndian(), 0); - extract(ArangesData, CTX->getRecoverableErrorHandler()); + extract(ArangesData, CTX->getRecoverableErrorHandler(), + CTX->getWarningHandler()); // Generate aranges from DIEs: even if .debug_aranges section is present, // it may describe only a small subset of compilation units, so we need to diff --git a/llvm/test/tools/llvm-symbolizer/debug-aranges-premature-end.yaml b/llvm/test/tools/llvm-symbolizer/debug-aranges-premature-end.yaml new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-symbolizer/debug-aranges-premature-end.yaml @@ -0,0 +1,19 @@ +# RUN: yaml2obj %s -o %t +# RUN: llvm-symbolizer 0xa --obj=%t 2>&1 | FileCheck %s + +# CHECK: warning: address range table at offset 0x0 has a premature terminator entry at offset 0x10 + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC +DWARF: + debug_aranges: + - Version: 2 + CuOffset: 0 + Descriptors: + - Address: 0 + Length: 0 + - Address: 0x5678 + Length: 0x20