aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2024-08-28 21:37:13 +0930
committerAlan Modra <amodra@gmail.com>2024-08-29 21:05:57 +0930
commitf2a15e7cde98af543a016090e4063180851a6d09 (patch)
tree9f21ca1e1a5c497caaac88cd2de06659e7e9538d /binutils
parent9459f695d3b79ac5509d8da8b1f4f7d68d91e840 (diff)
downloadbinutils-f2a15e7cde98af543a016090e4063180851a6d09.zip
binutils-f2a15e7cde98af543a016090e4063180851a6d09.tar.gz
binutils-f2a15e7cde98af543a016090e4063180851a6d09.tar.bz2
get_type_abbrev_from_form tidy
* dwarf.c (get_type_abbrev_from_form): Make uvalue param a uint64_t. Localise variables. Don't bother clearing *data_return and *addrev_num_return for a NULL return value.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/dwarf.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/binutils/dwarf.c b/binutils/dwarf.c
index 13a9162..424353c 100644
--- a/binutils/dwarf.c
+++ b/binutils/dwarf.c
@@ -2035,7 +2035,7 @@ skip_attr_bytes (unsigned long form,
static abbrev_entry *
get_type_abbrev_from_form (unsigned long form,
- unsigned long uvalue,
+ uint64_t uvalue,
uint64_t cu_offset,
unsigned char *cu_end,
const struct dwarf_section *section,
@@ -2043,16 +2043,6 @@ get_type_abbrev_from_form (unsigned long form,
unsigned char **data_return,
abbrev_map **map_return)
{
- unsigned long abbrev_number;
- abbrev_map * map;
- abbrev_entry * entry;
- unsigned char * data;
-
- if (abbrev_num_return != NULL)
- * abbrev_num_return = 0;
- if (data_return != NULL)
- * data_return = NULL;
-
switch (form)
{
case DW_FORM_GNU_ref_alt:
@@ -2063,8 +2053,8 @@ get_type_abbrev_from_form (unsigned long form,
case DW_FORM_ref_addr:
if (uvalue >= section->size)
{
- warn (_("Unable to resolve ref_addr form: uvalue %lx "
- "> section size %" PRIx64 " (%s)\n"),
+ warn (_("Unable to resolve ref_addr form: uvalue %" PRIx64
+ " >= section size %" PRIx64 " (%s)\n"),
uvalue, section->size, section->name);
return NULL;
}
@@ -2082,8 +2072,8 @@ get_type_abbrev_from_form (unsigned long form,
if (uvalue + cu_offset < uvalue
|| uvalue + cu_offset > (size_t) (cu_end - section->start))
{
- warn (_("Unable to resolve ref form: uvalue %lx + cu_offset %" PRIx64
- " > CU size %tx\n"),
+ warn (_("Unable to resolve ref form: uvalue %" PRIx64
+ " + cu_offset %" PRIx64 " > CU size %tx\n"),
uvalue, cu_offset, cu_end - section->start);
return NULL;
}
@@ -2097,17 +2087,18 @@ get_type_abbrev_from_form (unsigned long form,
return NULL;
}
- data = (unsigned char *) section->start + uvalue;
- map = find_abbrev_map_by_offset (uvalue);
+ abbrev_map *map = find_abbrev_map_by_offset (uvalue);
if (map == NULL)
{
- warn (_("Unable to find abbreviations for CU offset %#lx\n"), uvalue);
+ warn (_("Unable to find abbreviations for CU offset %" PRIx64 "\n"),
+ uvalue);
return NULL;
}
if (map->list == NULL)
{
- warn (_("Empty abbreviation list encountered for CU offset %lx\n"), uvalue);
+ warn (_("Empty abbreviation list encountered for CU offset %" PRIx64 "\n"),
+ uvalue);
return NULL;
}
@@ -2119,20 +2110,23 @@ get_type_abbrev_from_form (unsigned long form,
*map_return = NULL;
}
+ unsigned char *data = section->start + uvalue;
if (form == DW_FORM_ref_addr)
cu_end = section->start + map->end;
+ unsigned long abbrev_number;
READ_ULEB (abbrev_number, data, cu_end);
- for (entry = map->list->first_abbrev; entry != NULL; entry = entry->next)
- if (entry->number == abbrev_number)
- break;
-
if (abbrev_num_return != NULL)
- * abbrev_num_return = abbrev_number;
+ *abbrev_num_return = abbrev_number;
if (data_return != NULL)
- * data_return = data;
+ *data_return = data;
+
+ abbrev_entry *entry;
+ for (entry = map->list->first_abbrev; entry != NULL; entry = entry->next)
+ if (entry->number == abbrev_number)
+ break;
if (entry == NULL)
warn (_("Unable to find entry for abbreviation %lu\n"), abbrev_number);