]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Use DW_FORM_ref_addr for DIE offset in .debug_names
authorTom Tromey <tom@tromey.com>
Sat, 10 Feb 2024 00:40:35 +0000 (17:40 -0700)
committerTom Tromey <tom@tromey.com>
Fri, 1 Mar 2024 00:12:58 +0000 (17:12 -0700)
Today I realized that while the .debug_names writer uses DW_FORM_udata
for the DIE offset, DW_FORM_ref_addr would be more appropriate here.
This patch makes this change.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31361

gdb/dwarf2/index-write.c
gdb/dwarf2/read-debug-names.c

index 0123e7f2435b1579796b2ceb1673565754b7ac1c..a114001f4eec891f98715f797a4ff3dfe1c695f5 100644 (file)
@@ -761,7 +761,7 @@ public:
                   : DW_IDX_type_unit);
                m_abbrev_table.append_unsigned_leb128 (DW_FORM_udata);
                m_abbrev_table.append_unsigned_leb128 (DW_IDX_die_offset);
-               m_abbrev_table.append_unsigned_leb128 (DW_FORM_udata);
+               m_abbrev_table.append_unsigned_leb128 (DW_FORM_ref_addr);
                m_abbrev_table.append_unsigned_leb128 (DW_IDX_GNU_language);
                m_abbrev_table.append_unsigned_leb128 (DW_FORM_udata);
                if ((entry->flags & IS_STATIC) != 0)
@@ -796,7 +796,10 @@ public:
            gdb_assert (it != m_cu_index_htab.cend ());
            m_entry_pool.append_unsigned_leb128 (it->second);
 
-           m_entry_pool.append_unsigned_leb128 (to_underlying (entry->die_offset));
+           m_entry_pool.append_uint (dwarf5_offset_size (),
+                                     m_dwarf5_byte_order,
+                                     to_underlying (entry->die_offset));
+
            m_entry_pool.append_unsigned_leb128 (entry->per_cu->dw_lang ());
 
            if (parent != nullptr)
index e2563e84fcfa02f63d1dd84515450707110e5524..0add8040894c20781f6e297936d038013e5d712b 100644 (file)
@@ -155,6 +155,10 @@ mapped_debug_names_reader::scan_one_entry (const char *name,
          ull = read_unsigned_leb128 (abfd, entry, &bytes_read);
          entry += bytes_read;
          break;
+       case DW_FORM_ref_addr:
+         ull = read_offset (abfd, entry, offset_size);
+         entry += offset_size;
+         break;
        case DW_FORM_ref4:
          ull = read_4_bytes (abfd, entry);
          entry += 4;