aboutsummaryrefslogtreecommitdiff
path: root/binutils/rdcoff.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-03-03 09:13:03 +1030
committerAlan Modra <amodra@gmail.com>2023-03-03 10:35:54 +1030
commitde357ff4e4f8fa7aaf621d680fde72a010b026d2 (patch)
treef2e471074b76272cac8fabad7a646a7af4946a84 /binutils/rdcoff.c
parent425ec1add752deb6ef6021b8be4175f9081ab344 (diff)
downloadgdb-de357ff4e4f8fa7aaf621d680fde72a010b026d2.zip
gdb-de357ff4e4f8fa7aaf621d680fde72a010b026d2.tar.gz
gdb-de357ff4e4f8fa7aaf621d680fde72a010b026d2.tar.bz2
binutils coff type list
As for commit 72d225ef9cc7, handle type numbers starting anywhere. PR 17512 * rdcoff.c (struct coff_slots): Add base_index. (coff_get_slot): Delete pr17512 excessively large slot check. Don't allocate entire array from 0 to type number, allocate a sparse array.
Diffstat (limited to 'binutils/rdcoff.c')
-rw-r--r--binutils/rdcoff.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/binutils/rdcoff.c b/binutils/rdcoff.c
index 50e19a7..1a4f00d 100644
--- a/binutils/rdcoff.c
+++ b/binutils/rdcoff.c
@@ -68,6 +68,8 @@ struct coff_slots
{
/* Next set of slots. */
struct coff_slots *next;
+ /* Where the SLOTS array starts. */
+ unsigned int base_index;
/* Slots. */
#define COFF_SLOTS (16)
debug_type slots[COFF_SLOTS];
@@ -107,29 +109,21 @@ static debug_type *
coff_get_slot (struct coff_types *types, long indx)
{
struct coff_slots **pps;
+ unsigned int base_index;
pps = &types->slots;
+ base_index = indx / COFF_SLOTS * COFF_SLOTS;
+ indx -= base_index;
- /* PR 17512: file: 078-18333-0.001:0.1.
- FIXME: The value of 1000 is a guess. Maybe a better heuristic is needed. */
- if (indx / COFF_SLOTS > 1000)
- fatal (_("Excessively large slot index: %lx"), indx);
+ while (*pps && (*pps)->base_index < base_index)
+ pps = &(*pps)->next;
- while (indx >= COFF_SLOTS)
+ if (*pps == NULL || (*pps)->base_index != base_index)
{
- if (*pps == NULL)
- {
- *pps = (struct coff_slots *) xmalloc (sizeof **pps);
- memset (*pps, 0, sizeof **pps);
- }
- pps = &(*pps)->next;
- indx -= COFF_SLOTS;
- }
-
- if (*pps == NULL)
- {
- *pps = (struct coff_slots *) xmalloc (sizeof **pps);
- memset (*pps, 0, sizeof **pps);
+ struct coff_slots *n = xcalloc (1, sizeof (*n));
+ n->next = *pps;
+ n->base_index = base_index;
+ *pps = n;
}
return (*pps)->slots + indx;