[PATCH] D124121: [DebugInfo] Give warning instead of error for premature terminator in .debug_aranges section.
Junfeng Dong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 28 21:12:27 PDT 2022
junfd updated this revision to Diff 425965.
junfd added a comment.
Herald added subscribers: rupprecht, MaskRay.
Herald added a reviewer: jhenderson.
Move test into llvm-symbolizer, which calls into the same stack as
llvm-profgen and shows "error:" for premature terminator in
debug_aranges section.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124121/new/
https://reviews.llvm.org/D124121
Files:
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
llvm/test/tools/llvm-symbolizer/debug-aranges-premature-end.s
Index: llvm/test/tools/llvm-symbolizer/debug-aranges-premature-end.s
===================================================================
--- /dev/null
+++ 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,"", at 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
Index: llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFDebugAranges.cpp
@@ -22,15 +22,15 @@
void DWARFDebugAranges::extract(
DWARFDataExtractor DebugArangesData,
- function_ref<void(Error)> RecoverableErrorHandler) {
+ function_ref<void(Error)> RecoverableErrorHandler,
+ function_ref<void(Error)> 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
Index: llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
===================================================================
--- llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAranges.h
@@ -28,7 +28,8 @@
private:
void clear();
void extract(DWARFDataExtractor DebugArangesData,
- function_ref<void(Error)> RecoverableErrorHandler);
+ function_ref<void(Error)> RecoverableErrorHandler,
+ function_ref<void(Error)> WarningHandler);
/// Call appendRange multiple times and then call construct.
void appendRange(uint64_t CUOffset, uint64_t LowPC, uint64_t HighPC);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124121.425965.patch
Type: text/x-patch
Size: 3262 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220429/5f11382c/attachment.bin>
More information about the llvm-commits
mailing list