diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2025-04-17 15:37:20 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2025-04-20 01:01:57 -0400 |
commit | 1a710618a51b6cb10ed3d7a5d2fa4ced7bae4228 (patch) | |
tree | 7fe8ea032b7e50048346bec76d4a399126709a57 | |
parent | 5cfabe75dbaef32f1506f02c172219536baff4c4 (diff) | |
download | binutils-1a710618a51b6cb10ed3d7a5d2fa4ced7bae4228.zip binutils-1a710618a51b6cb10ed3d7a5d2fa4ced7bae4228.tar.gz binutils-1a710618a51b6cb10ed3d7a5d2fa4ced7bae4228.tar.bz2 |
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>
-rw-r--r-- | gdb/dwarf2/comp-unit-head.c | 3 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 2 | ||||
-rw-r--r-- | gdb/dwarf2/section.h | 13 |
3 files changed, 2 insertions, 16 deletions
diff --git a/gdb/dwarf2/comp-unit-head.c b/gdb/dwarf2/comp-unit-head.c index 8ec8897..bc80c63 100644 --- a/gdb/dwarf2/comp-unit-head.c +++ b/gdb/dwarf2/comp-unit-head.c @@ -156,8 +156,7 @@ error_check_comp_unit_head (dwarf2_per_objfile *per_objfile, { const char *filename = section->get_file_name (); - if (to_underlying (header->abbrev_sect_off) - >= abbrev_section->get_size (per_objfile->objfile)) + if (to_underlying (header->abbrev_sect_off) >= abbrev_section->size) error (_(DWARF_ERROR_PREFIX "bad offset (%s) in compilation unit header " "(offset %s + 6) [in module %s]"), diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 794c397..28872146 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -19189,7 +19189,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym, /* .debug_loc{,.dwo} may not exist at all, or the offset may be outside the section. If so, fall through to the complaint in the other branch. */ - && attr->as_unsigned () < section->get_size (objfile)) + && attr->as_unsigned () < section->size) { struct dwarf2_loclist_baton *baton; diff --git a/gdb/dwarf2/section.h b/gdb/dwarf2/section.h index 85da485..b9d3c31 100644 --- a/gdb/dwarf2/section.h +++ b/gdb/dwarf2/section.h @@ -81,19 +81,6 @@ struct dwarf2_section_info If the section is compressed, uncompress it before returning. */ void read (struct objfile *objfile); - /* A helper function that returns the size of a section in a safe way. - If you are positive that the section has been read before using the - size, then it is safe to refer to the dwarf2_section_info object's - "size" field directly. 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. */ - bfd_size_type get_size (struct objfile *objfile) - { - if (!readin) - read (objfile); - return size; - } - /* Issue a complaint that something was outside the bounds of this buffer. */ void overflow_complaint () const; |