From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id 6A8443858425; Fri, 3 Mar 2023 03:47:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A8443858425 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: bfd-cvs@sourceware.org Subject: [binutils-gdb] binutils coff type list X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: 425ec1add752deb6ef6021b8be4175f9081ab344 X-Git-Newrev: de357ff4e4f8fa7aaf621d680fde72a010b026d2 Message-Id: <20230303034743.6A8443858425@sourceware.org> Date: Fri, 3 Mar 2023 03:47:43 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Mar 2023 03:47:43 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dde357ff4e4f8= fa7aaf621d680fde72a010b026d2 commit de357ff4e4f8fa7aaf621d680fde72a010b026d2 Author: Alan Modra Date: Fri Mar 3 09:13:03 2023 +1030 binutils coff type list =20 As for commit 72d225ef9cc7, handle type numbers starting anywhere. =20 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; =20 pps =3D &types->slots; + base_index =3D indx / COFF_SLOTS * COFF_SLOTS; + indx -=3D base_index; =20 - /* PR 17512: file: 078-18333-0.001:0.1. - FIXME: The value of 1000 is a guess. Maybe a better heuristic is nee= ded. */ - if (indx / COFF_SLOTS > 1000) - fatal (_("Excessively large slot index: %lx"), indx); + while (*pps && (*pps)->base_index < base_index) + pps =3D &(*pps)->next; =20 - while (indx >=3D COFF_SLOTS) + if (*pps =3D=3D NULL || (*pps)->base_index !=3D base_index) { - if (*pps =3D=3D NULL) - { - *pps =3D (struct coff_slots *) xmalloc (sizeof **pps); - memset (*pps, 0, sizeof **pps); - } - pps =3D &(*pps)->next; - indx -=3D COFF_SLOTS; - } - - if (*pps =3D=3D NULL) - { - *pps =3D (struct coff_slots *) xmalloc (sizeof **pps); - memset (*pps, 0, sizeof **pps); + struct coff_slots *n =3D xcalloc (1, sizeof (*n)); + n->next =3D *pps; + n->base_index =3D base_index; + *pps =3D n; } =20 return (*pps)->slots + indx;