[Lldb-commits] [lldb] [lldb] Update the String table offset based on the DWARF format (PR #147054)

Hemang Gadhavi via lldb-commits lldb-commits at lists.llvm.org
Fri Jul 4 06:38:03 PDT 2025


https://github.com/HemangGadhavi created https://github.com/llvm/llvm-project/pull/147054

This PR is updating the string table offset (DW_AT_str_offsets_base which is introduces in `DWARF5`) based on the DWARF format, as per the DWARF specification, For the 32-bit DWARF format, each offset is 4 bytes long; for the 64-bit DWARF format, each offset is 8 bytes long.


>From 4ae4d0ab6ba44317e00dced8f247341ec9930c2c Mon Sep 17 00:00:00 2001
From: HemangGadhavi <hemang.gadhavi at ibm.com>
Date: Fri, 4 Jul 2025 09:28:30 -0400
Subject: [PATCH] [lldb] Updated the String table offset based on the DWARF
 format

---
 lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index f216ab13e8936..daaa4eca6f198 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -1077,7 +1077,8 @@ uint32_t DWARFUnit::GetHeaderByteSize() const { return m_header.getSize(); }
 
 std::optional<uint64_t>
 DWARFUnit::GetStringOffsetSectionItem(uint32_t index) const {
-  lldb::offset_t offset = GetStrOffsetsBase() + index * 4;
+  lldb::offset_t offset =
+      GetStrOffsetsBase() + index * m_header.getDwarfOffsetByteSize();
   return m_dwarf.GetDWARFContext().getOrLoadStrOffsetsData().GetU32(&offset);
 }
 



More information about the lldb-commits mailing list