From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x32.google.com (mail-oa1-x32.google.com [IPv6:2001:4860:4864:20::32]) by sourceware.org (Postfix) with ESMTPS id 0FE003858D35 for ; Wed, 28 Dec 2022 17:23:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0FE003858D35 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-oa1-x32.google.com with SMTP id 586e51a60fabf-1441d7d40c6so19159421fac.8 for ; Wed, 28 Dec 2022 09:23:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Bw2ZSw+G/vPIL6RbDmzEQrParMKcXifCh/UJuyNQ3L4=; b=VjvHF06JiuZrJYHPvQSI4JntQzI/EX+uUXWcvtU+UkdAalzEB9k5wPestnyUGe9C9P KoArNuHRSUwINOkgtrxGCFdUQ/IWrW/DJ3ECzI3W+5C7hnA2T5MLMEtioayovYeZILLF Pja/WtxT4HN41SnwApY1wvr8PVBM1Mu7UXSp3x0CTXGogrr2Z5L7wL2DtoA1Q9OSPXBm zgUI4g2Zb6NXCO44EN3XtlCmHLfyhfHYTGtfrgquxLkC899lQ8fxLpuW4iAypzdT9pN+ 8GYPXYBlHlmQoj0FpGq4tqSYOjx6ir7XaO+6FNS7bbiM6RouC8FHvo6tbk9v5dbnKHf4 H3Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Bw2ZSw+G/vPIL6RbDmzEQrParMKcXifCh/UJuyNQ3L4=; b=0nK8VPFG9H/RRAe0S6hXydjnXoBw53tztUblAfOqBwdV3RAW2MhghAL1SSUQr/e38i 3DZqvIDLdDOxJ1HCS3ObIj2wDY8Vq9Bm9O+fmnVRX/suSukkLspPrUkf4NwgJo7EMTDW Bmq8MmW3TTrOYhJR8fUvQYkukDOQ4YOMvM/Na3HcWyFltPyuiaZTmp6ARNgQHyj0UaLg s4Nkc164DgFjP4KkVnn8ZQ8IJfWTpwMquMoik/2DKjfJvi44ic/FG4qPoFbWQvPMhHxJ rX5fcmMnYjQgL/BLKotImCjes0GiIGxr6txpyD7JXKMSgsDJu7H+6EM1AU8deb8psraW vaWQ== X-Gm-Message-State: AFqh2kp84Tu5lE7GdKsvsXU2zOqSR/xuPbQ5ejw6FYh33coRwqy2XPwN EjSFPZskjcDC4Yyq3NrGLDm5dr9z8gA/vKG9m6E= X-Google-Smtp-Source: AMrXdXuokhqCwrEQb456uhnbn/0MrZwTFwlGT4dfLojYqRdy7MpvK1BkpGPLgvvttj031Dt5RREPKO2VgkiA2IcEbA4= X-Received: by 2002:a05:6870:5249:b0:148:2d85:b411 with SMTP id o9-20020a056870524900b001482d85b411mr1904730oai.266.1672248237258; Wed, 28 Dec 2022 09:23:57 -0800 (PST) MIME-Version: 1.0 References: <20221227194756.448332-1-hjl.tools@gmail.com> In-Reply-To: From: "H.J. Lu" Date: Wed, 28 Dec 2022 09:23:21 -0800 Message-ID: Subject: Re: [PATCH] x86-64: Allocate input section memory if needed To: Alan Modra Cc: binutils@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3016.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,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: On Tue, Dec 27, 2022 at 5:16 PM Alan Modra wrote: > > On Tue, Dec 27, 2022 at 11:47:56AM -0800, H.J. Lu via Binutils wrote: > > + /* Cache the section contents for > > + elf_link_input_bfd. */ > > + elf_section_data (sec)->this_hdr.contents > > + = contents; > > You shouldn't really be caching unaltered section contents when > !info->keep_memory. I'm not saying the patch is wrong, but please fix > this when you have some time. > > -- > Alan Modra > Australia Development Lab, IBM elf_x86_64_scan_relocs has if (elf_section_data (sec)->this_hdr.contents != contents) { if (!converted && !_bfd_link_keep_memory (info)) free (contents); else { /* Cache the section contents for elf_link_input_bfd if any load is converted or --no-keep-memory isn't used. */ elf_section_data (sec)->this_hdr.contents = contents; info->cache_size += sec->size; } } Are you suggesting that it should be if (elf_section_data (sec)->this_hdr.contents != contents) { if (!converted) free (contents); else { /* Cache the section contents for elf_link_input_bfd if any load is converted. */ elf_section_data (sec)->this_hdr.contents = contents; info->cache_size += sec->size; } } Thanks. -- H.J.