From patchwork Fri Mar 3 03:46:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 63749 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp207125wrd; Thu, 2 Mar 2023 19:46:30 -0800 (PST) X-Google-Smtp-Source: AK7set8Cw2gglcIMcWxZo/LDC9tMBU+s/s8OeWfIXc01fxRls9YarF1rrGdKa1mYMuYQ+p7zVuHw X-Received: by 2002:a17:907:a583:b0:8b1:326e:5374 with SMTP id vs3-20020a170907a58300b008b1326e5374mr162646ejc.46.1677815189926; Thu, 02 Mar 2023 19:46:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677815189; cv=none; d=google.com; s=arc-20160816; b=sn3tuKsourVh6I6SjrYLMFYPdncphRDVNjlO/pj8o5VY9bOJJT/JewqfunNLraCIBV P0UVFxLrsHgg55YVmTfQxD3tcOCTmg2N8FRlttfMqtgRE3D4tC5eoeitTbN/mCHumPXX 3u5phIFP2JyF+iyeOcpG6z9HmZrTLj7MctYECpd2eYZ0E7oBUycDyt0vpxJV1fp2xBbG I//0tKdzuPTDfqQM0cxa1+/nN9Yrb/9Euxek1AoG/Y8K3ftfNivZR+jPS9PyURTHviAz 38osYsMk2hdGgSfzm2livaXx2q0fxaOTMS5LDvXHcg28ovayu9RXCeSaFiFHZWTo8BQU 6q7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=8WXEO/KnXqYXJF1jrIoMT2PlSYK1UXlOVLLwmhiON/A=; b=b88TC2UM43/a0lRx/5dR1u85WfIiGixN9zg/YmR8hCFMJ6wk91Jr8NIKDbfSsp11KH yADoS7BF/b/t7bkm7nAkmGrSZOMzPaXJenlY1Jih0ZSNvXehXmiUFSsFLTheZQrgIrxy 4NycZBGx+OEuumo2t84vtQYIq7VY+3dJlPhswPuuImEGwqmtIsbY1GK2Ua6oXSoQD9O7 b8R3JOU681hSvZ0i30hSXKjDDSrMOFHcC2UyWctOtPkQoSXL9iUExFIQPMQjh6iAy104 99RbkBdouqYEY4WNkai9pCv3QXjF63a25pKpQBsJUrk6vKwGIeUeNQ/krnwcJy52XdDe FKsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="d/T4yJMF"; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i26-20020a170906265a00b008de34abc459si1096610ejc.143.2023.03.02.19.46.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 19:46:29 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="d/T4yJMF"; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B572D3858284 for ; Fri, 3 Mar 2023 03:46:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B572D3858284 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677815188; bh=8WXEO/KnXqYXJF1jrIoMT2PlSYK1UXlOVLLwmhiON/A=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=d/T4yJMF1eBPflrRPu0s8qXO3BoJwoSHRc9LA1YhQBnhPh8NehW6N0wKukvL4rr4z PLOsrhGG970E9EBX+11RQxum67dhygsztNQUi33BJ1hLIlOcOUpoRFGTfDetpLuQ8B 7eJusBl6mmpoiiyCqLF8potyVNixdmMAYwoLjT20= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org 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 Received: by mail-pl1-x633.google.com with SMTP id u5so1422296plq.7 for ; Thu, 02 Mar 2023 19:46:18 -0800 (PST) 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-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 To: binutils@sourceware.org Subject: binutils coff type list Message-ID: MIME-Version: 1.0 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Alan Modra via Binutils From: Alan Modra Reply-To: Alan Modra Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759316740498144654?= X-GMAIL-MSGID: =?utf-8?q?1759316740498144654?= 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;