]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/dwarf: remove dwarf2_section_info::get_size
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 17 Apr 2025 19:37:20 +0000 (15:37 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Sun, 20 Apr 2025 05:01:57 +0000 (01:01 -0400)
commit1a710618a51b6cb10ed3d7a5d2fa4ced7bae4228
tree7fe8ea032b7e50048346bec76d4a399126709a57
parent5cfabe75dbaef32f1506f02c172219536baff4c4
gdb/dwarf: remove dwarf2_section_info::get_size

The comment over dwarf2_section_info::get_size says:

    In other cases, you must call this function, because for compressed
    sections the size field is not set correctly until the section has
    been read

From what I can see (while debugging a test case compiled with -gz on
Linux), that's not true.  For compressed sections, bfd_section_size
returns the uncompressed size.  asection::size contains the uncompressed
size while asection::compressed_size contains the compressed size:

    (top-gdb) p sec
    $13 = (asection *) 0x521000119778
    (top-gdb) p sec.compressed_size
    $14 = 6191
    (top-gdb) p sec.size
    $15 = 12116

I therefore propose to remove dwarf2_section_info::get_size, as it
appears that reading in the section is orthogonal to knowing its size.

If the assumption above is false, it would be nice to document in which
case it's false.

I checked the callers, and I don't think that we need to add any
dwarf2_section_info::read calls to compensate for the fact that get_size
used to do it.

Change-Id: I428571e532301d49f1d8242d687e1fcb819b75c1
Approved-By: Tom Tromey <tom@tromey.com>
gdb/dwarf2/comp-unit-head.c
gdb/dwarf2/read.c
gdb/dwarf2/section.h