[PATCH] dwp: Supports the analysis of DWO_id for Dwarf-5.

Sockke liuke.gehry@bytedance.com
Thu May 15 12:25:58 GMT 2025


In dwarf5, DWO_id is an 8-byte hash value in the CU Header. If it is not parsed in do_parse(...), it will cause the value of die_offset to be incorrect which cause a malformed debug section after merge.

Signed-off-by: Sockke <liuke.gehry@bytedance.com>
---
 gold/dwarf_reader.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gold/dwarf_reader.cc b/gold/dwarf_reader.cc
index fb2a152572a..74b616f2c2f 100644
--- a/gold/dwarf_reader.cc
+++ b/gold/dwarf_reader.cc
@@ -1321,6 +1321,10 @@ Dwarf_info_reader::do_parse()
 	  pinfo += this->offset_size_;
 	}
 
+      // DWARF 5: Read the DWO id (8 bytes).
+      if (this->cu_version_ >= 5)
+        pinfo += 8;
+
       // Read the .debug_abbrev table.
       this->abbrev_table_.read_abbrevs(this->object_, abbrev_shndx,
 				       abbrev_offset);
-- 
2.20.1



More information about the Binutils mailing list