From: Alan Modra <amodra@sourceware.org>
To: bfd-cvs@sourceware.org
Subject: [binutils-gdb] binutils coff type list
Date: Fri, 3 Mar 2023 03:47:43 +0000 (GMT) [thread overview]
Message-ID: <20230303034743.6A8443858425@sourceware.org> (raw)
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=de357ff4e4f8fa7aaf621d680fde72a010b026d2
commit de357ff4e4f8fa7aaf621d680fde72a010b026d2
Author: Alan Modra <amodra@gmail.com>
Date: Fri Mar 3 09:13:03 2023 +1030
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.
Diff:
---
binutils/rdcoff.c | 30 ++++++++++++------------------
1 file changed, 12 insertions(+), 18 deletions(-)
diff --git a/binutils/rdcoff.c b/binutils/rdcoff.c
index 50e19a757af..1a4f00da913 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;
reply other threads:[~2023-03-03 3:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230303034743.6A8443858425@sourceware.org \
--to=amodra@sourceware.org \
--cc=bfd-cvs@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).