[llvm] [DWARFLinker] Use different addresses to distinguish invalid DW_AT_LLVM_stmt_sequence offset (PR #149376)
Peter Rong via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 17 11:27:22 PDT 2025
https://github.com/DataCorrupted created https://github.com/llvm/llvm-project/pull/149376
None
>From 00f11a4abb7d266a51204660c0d0b55c03d87931 Mon Sep 17 00:00:00 2001
From: Peter Rong <PeterRong at meta.com>
Date: Thu, 17 Jul 2025 11:21:50 -0700
Subject: [PATCH 1/2] [DWARFLinker] Use different invalid addresses to
distinguish reasons why DW_AT_LLVM_stmt_sequence is invalid.
---
llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
index 222dc88098102..4ed3a90d386c8 100644
--- a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
@@ -23,10 +23,10 @@
#include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
+#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
#include "llvm/DebugInfo/DWARF/DWARFSection.h"
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
-#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/Support/DataExtractor.h"
#include "llvm/Support/Error.h"
@@ -43,6 +43,12 @@ namespace llvm {
using namespace dwarf_linker;
using namespace dwarf_linker::classic;
+enum InvalidStmtSeqOffset {
+ MaxStmtSeqOffset = UINT64_MAX,
+ OrigOffsetMissing = MaxStmtSeqOffset - 1,
+ NewOffsetMissing = MaxStmtSeqOffset - 2,
+};
+
/// Hold the input and output of the debug info size in bytes.
struct DebugInfoSize {
uint64_t Input;
@@ -2315,7 +2321,7 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
// Some sequences are discarded by the DWARFLinker if they are invalid
// (empty).
if (OrigRowIter == SeqOffToOrigRow.end()) {
- StmtSeq.set(UINT64_MAX);
+ StmtSeq.set(OrigOffsetMissing);
continue;
}
size_t OrigRowIndex = OrigRowIter->second;
@@ -2325,7 +2331,7 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
if (NewRowIter == OrigRowToNewRow.end()) {
// If the original row index is not found in the map, update the
// stmt_sequence attribute to the 'invalid offset' magic value.
- StmtSeq.set(UINT64_MAX);
+ StmtSeq.set(NewOffsetMissing);
continue;
}
>From f3a0b8c429a116bb8d78ad6b27c0e8098a4d5e20 Mon Sep 17 00:00:00 2001
From: Peter Rong <PeterRong at meta.com>
Date: Thu, 17 Jul 2025 11:25:43 -0700
Subject: [PATCH 2/2] resolve header
---
llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
index 4ed3a90d386c8..2760bc169ff36 100644
--- a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
@@ -23,7 +23,7 @@
#include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
-#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
+#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
#include "llvm/DebugInfo/DWARF/DWARFSection.h"
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
More information about the llvm-commits
mailing list