From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id C8CEE3858D33 for ; Fri, 3 Mar 2023 03:46:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C8CEE3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-x633.google.com with SMTP id u5so1422296plq.7 for ; Thu, 02 Mar 2023 19:46:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677815177; h=content-disposition:mime-version:message-id:subject:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=8WXEO/KnXqYXJF1jrIoMT2PlSYK1UXlOVLLwmhiON/A=; b=jQ5UeJL96Ie3HCM87gLZofjMI2krsQ+e6Uq6HVOuyPvYH/8Nh7kWeX1kN8BBUqw/Kc kknK6SvtEYw0z+Z5fNCsJ7UxJTQa+wx+bSAXTyJnTkf5qvvIgXUdL4rcofTv4K+mHT7t KvtyfCmIAoBFeBCHaTPSYgL2w+h1tlIFJYCUb9z1c+LSluZ6tapDHlCI2xgn1Mk2+Grk fkmfR0jlI8fSD1QrBU6/zZ6vuiygdRX8nvJB0QOnU2A7sI+5UE9ZVQE6j2wLOlws0I8a IM3B2ws7fubcGDznbSzj1ZQp/TI6xnWp8BoPsjMv3NwGjONsKylBjx7XEyr6kO7HxQI3 D5EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677815177; h=content-disposition:mime-version:message-id:subject:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8WXEO/KnXqYXJF1jrIoMT2PlSYK1UXlOVLLwmhiON/A=; b=Kq6FDb0/7HR+eVoNCTIqEe2lMcjGqLk36Z+6RAr89pEi1WnPkSfyKYPERlCbTLB3ES Mqj548ltEz7dM+jHoeeBT3uZtMOHk6o/fulmWeUYvZDYRWV6YW7DKaUW/axpJ4bcUZnk 9zxQuS/6kMT06IwtSY7ErvXjafMDLmklIlgwRcZJEimqr/zFt1MhyhOqeOHLmFpIvExX xnpuzgBu9gA9pagHE4hwpGo+UkMhuhaTppFSEix/p/FznTLFAN+72OV8elt3txgyrL7L e7XQYU82bojAbX+7nlsNpJFDjUvYxxfcIR7OkriUXVmz54Fib5+del1CeQP0Cht6ysyn jQhQ== X-Gm-Message-State: AO0yUKXJ/wOzvLP8+VdEn9OBFACKJ3pqJ0BiynejgOfK9803kGrnZK2c NvRZgcIPFSWkNgyBcFCOjibfyiSRS/4= X-Google-Smtp-Source: AK7set9R0G7iWLaqDrct2GZh4KGHBgVd3EthxrEHwPAOAJ4j7PoiTedCkfXJRuLSiRcDgpRGghlEuQ== X-Received: by 2002:a17:903:22cf:b0:19a:bbd0:c5cc with SMTP id y15-20020a17090322cf00b0019abbd0c5ccmr669491plg.60.1677815177473; Thu, 02 Mar 2023 19:46:17 -0800 (PST) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:9d58:af40:9a5d:9a54]) by smtp.gmail.com with ESMTPSA id kn7-20020a170903078700b0019e5fc21663sm388858plb.218.2023.03.02.19.46.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 19:46:17 -0800 (PST) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id A1D2D1141C30; Fri, 3 Mar 2023 14:16:14 +1030 (ACDT) Date: Fri, 3 Mar 2023 14:16:14 +1030 From: Alan Modra To: binutils@sourceware.org Subject: binutils coff type list Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3034.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 --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; -- Alan Modra Australia Development Lab, IBM