aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-12-15 10:04:48 +1030
committerAlan Modra <amodra@gmail.com>2023-12-15 12:56:45 +1030
commite838a672aa787fb593d4819fa4836cad7db49e66 (patch)
treed5c91d4812dbcfa36fcc84b62c72f300db2a5957 /binutils
parentb291c12e8d08d01e598526ac6c9cb20543f41293 (diff)
downloadgdb-e838a672aa787fb593d4819fa4836cad7db49e66.zip
gdb-e838a672aa787fb593d4819fa4836cad7db49e66.tar.gz
gdb-e838a672aa787fb593d4819fa4836cad7db49e66.tar.bz2
Re: readelf..debug-dump=loc displays bogus base addresses
Commit b05efa39b479 removed checks I added in commit f22f27f46c75 to prevent segfaults when debug_info_p is NULL, which can be the case with fuzzed objects. Restore those checks. Also, for dwo look at rnglists_dwo rather than rnglists.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/dwarf.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 1504690..b5e5ea8 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -2771,7 +2771,9 @@ read_and_display_attr_value (unsigned long attribute,
if (form == DW_FORM_loclistx)
{
- if (dwo)
+ if (debug_info_p == NULL)
+ idx = -1;
+ else if (dwo)
{
idx = fetch_indexed_offset (uvalue, loclists_dwo,
debug_info_p->loclists_base,
@@ -2779,7 +2781,7 @@ read_and_display_attr_value (unsigned long attribute,
if (idx != (uint64_t) -1)
idx += (offset_size == 8) ? 20 : 12;
}
- else if (debug_info_p == NULL || dwarf_version > 4)
+ else if (dwarf_version > 4)
{
idx = fetch_indexed_offset (uvalue, loclists,
debug_info_p->loclists_base,
@@ -2804,21 +2806,13 @@ read_and_display_attr_value (unsigned long attribute,
}
else if (form == DW_FORM_rnglistx)
{
- if (dwo)
- {
- idx = fetch_indexed_offset (uvalue, rnglists,
- debug_info_p->rnglists_base,
- debug_info_p->offset_size);
- }
+ if (debug_info_p == NULL)
+ idx = -1;
else
- {
- if (debug_info_p == NULL)
- base = 0;
- else
- base = debug_info_p->rnglists_base;
- idx = fetch_indexed_offset (uvalue, rnglists, base,
- debug_info_p->offset_size);
- }
+ idx = fetch_indexed_offset (uvalue,
+ dwo ? rnglists_dwo : rnglists,
+ debug_info_p->rnglists_base,
+ debug_info_p->offset_size);
}
else
{