From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 0B8193858401 for ; Thu, 18 May 2023 08:46:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B8193858401 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-x636.google.com with SMTP id d9443c01a7336-1ae4c5e12edso14244265ad.3 for ; Thu, 18 May 2023 01:46:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684399577; x=1686991577; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=DCZoe1mNl3fYVzQwLPXOoUX7NTJoaF9XXhSvl9nwwMQ=; b=NVHWhVyTHfkkanIYQuJtE1MkeQZa25Tpbylo2nI8JK7fVkND7E7Nc1sHUiFPAraP2I IPHK7HLKyLzEU+l7S+EEW46H5NU8NGaBuuSG8kxNAW5xPOgmoQaizK/eePpTkPZkf9Vv 0gshpoVdze/Rg5sjt8vj3DBzdHeRfILS1j+v2QMi7wb4JSt+G/i7Lv8wP1c5oMzv7l0+ f5AxpY/dCrmcYpiCZLJ5X/IXW7vBW6G1VtkCBtgTbvHIdNzaqpvoJrHRZu5bJ2uPYoj+ r/nzxo4QFe/XcfKrK/pIouTSYz34maDD2ONopqU4hvWtNEA3di1DkVxZG7dvwHqlEeVw 6JCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684399577; x=1686991577; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=DCZoe1mNl3fYVzQwLPXOoUX7NTJoaF9XXhSvl9nwwMQ=; b=PK/+9IyobMys24Pp5S5nE4A1hwzTGPi89xVwBXFozHHchwKbG3g38sJJCNj0BTlOm5 BxOQjJ/toBZkidn4v3Olv+KUG1AexLBILmQK+WTNCkwwffT13nKfKCn+/52Pd0gMQeAz HmjW1WH4koQfB8V3F6w+JilWpCurQx/gGRc2QCzk+u0kOPWF3B2pD+IHLhTAR7u82NVk 8hpyHEc+aXJzCvGJNHLA0I3xN03FMSU/qcnTUzGm2/f6WnmxcmTs2s0NQNi1YYSgDdCE MwcsIZInW5mXFO7W0jX3SJM9vcF1T9lUm6K+HSf9INL528sLc8bp7sjvlZraLN7Vq5M9 u0aQ== X-Gm-Message-State: AC+VfDwgODEV37nhq3BIonyWnUcU5GbwfvlKzKk148JnEvuDY5fyxn5f m5zg005vewHahYg44IfasPNFAi93Tfg= X-Google-Smtp-Source: ACHHUZ69MxbY2EKaOQgeqVwH2xqlk/+ZLB5iNbBAGThxW8zvoT9JFK0M6wBLMjb7hzscLp6hJZAjtA== X-Received: by 2002:a17:903:234a:b0:1ae:bf5:7a7 with SMTP id c10-20020a170903234a00b001ae0bf507a7mr2267428plh.35.1684399577593; Thu, 18 May 2023 01:46:17 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:7bb3:e3ad:e8f2:5e16]) by smtp.gmail.com with ESMTPSA id c14-20020a170902d48e00b001a6e5c2ebfesm832595plg.152.2023.05.18.01.46.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 01:46:16 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 70CD61141623; Thu, 18 May 2023 18:16:14 +0930 (ACST) Date: Thu, 18 May 2023 18:16:14 +0930 From: Alan Modra To: binutils@sourceware.org Subject: Re: Add section caches to coff_data_type Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-3034.3 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,T_SCC_BODY_TEXT_LINE 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: On Thu, May 18, 2023 at 12:24:27PM +0930, Alan Modra wrote: > NULL. Well, yes, the hash table isn't initialised for the output bfd. > mkobject_hook is the wrong place to do that. One other reason why it's the wrong place to call htab_create is that any memory malloc'd in an object_p function should result in the object_p returning a bfd_cleanup function that frees the memory. bfd_alloc memory is fine in object_p, as alloc'd memory handled by bfd_check_format_matches. Another thing, section target_index is renumbered in coff_compute_section_file_positions and _bfd_xcoff_bfd_final_link. I don't know that there is currently any way that the output bfd section_by_target_index could be populated before this point but clear them out so no one need worry about it. * coffcode.h (coff_compute_section_file_positions): Clear section_by_target_index hash table when changing target_index. (_bfd_xcoff_bfd_final_link): Likewise. diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 777515e82e1..2d429828822 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -3067,6 +3067,9 @@ coff_compute_section_file_positions (bfd * abfd) sofar += bfd_coff_scnhsz (abfd); #endif + if (coff_data (abfd)->section_by_target_index) + htab_empty (coff_data (abfd)->section_by_target_index); + #ifdef COFF_IMAGE_WITH_PE { /* PE requires the sections to be in memory order when listed in diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c index b57ed21afb9..a27721301dd 100644 --- a/bfd/xcofflink.c +++ b/bfd/xcofflink.c @@ -7076,6 +7076,8 @@ _bfd_xcoff_bfd_final_link (bfd *abfd, struct bfd_link_info *info) /* Reset the section indices after inserting the new sections. */ + if (xcoff_data (abfd)->coff.section_by_target_index) + htab_empty (xcoff_data (abfd)->coff.section_by_target_index); indx = 0; for (o = abfd->sections; o != NULL; o = o->next) { -- Alan Modra Australia Development Lab, IBM