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.s b/llvm/test/tools/llvm-symbolizer/debug-aranges-premature-end.s new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-symbolizer/debug-aranges-premature-end.s @@ -0,0 +1,26 @@ +# REQUIRES: x86-registered-target + +foo: + .space 10 + nop + nop + .section .debug_aranges,"",@progbits + .long 60 # Length of ARange Set + .short 2 # DWARF Arange version number + .long 0 # Offset Into Debug Info Section + .byte 8 # Address Size (in bytes) + .byte 0 # Segment Size (in bytes) + .zero 4,255 + .quad 0 # premature warning + .quad 0 + .quad 0x0000000000005678 + .quad 0x20 + .quad 0 # ARange terminator + .quad 0 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -g + +# Check input addresses specified on the command-line. +# RUN: llvm-symbolizer 0xa --obj=%t.o 2>&1 | FileCheck %s + +# CHECK: warning: address range table at offset 0x0 has a premature terminator entry at offset 0x10