From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id 402F33858C2C for ; Sun, 9 Jul 2023 13:35:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 402F33858C2C 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-pf1-x435.google.com with SMTP id d2e1a72fcca58-66c729f5618so3082459b3a.1 for ; Sun, 09 Jul 2023 06:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688909723; x=1691501723; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=F8Kpb1Bc6oyvzjVW+bhTN1BfpT+5JgOXJ3q9faMMcUQ=; b=R8d+ZjUK+244Dy51pGSpehE4i01FmThIqJFvLyjumjup+b9WZU/8Py2mRqRNcKWfk/ 8ni6z7kbkUY/oiArtsGQ4D8q7U4+sxVC9xsreTZWrfl7HjPzRIVzFfjkHq4YTjynCvR0 EYRh3eXCU1lOjwnJex1nQ1FX3gZcSMlEJIMKN+CgwekEDH2lIO5F/jfcMNwK+5sC4CAY KC2HYwaRVRh3rGC9etByHi/WJPoiDSh4fvJ/GuOuSlFcPymBAnEYXvrmkMgWvqoNo3yP Ls2tGml+jH+9pJU6QMZWUaAY9Nzz5jnWW6fqHC9XUfTae7qALLVjKtJ9DZgIorIbUhvt gO9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688909723; x=1691501723; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=F8Kpb1Bc6oyvzjVW+bhTN1BfpT+5JgOXJ3q9faMMcUQ=; b=g6H6EDn+TWWBQAQjap21ELObBsMflTErozJx+EfFhYo1lN4yWVSXBi/rCy9G81saBc 2dQgIiIy9ukTET3P0wNOyCb5sesUhEjBuXaS2mocHI0ZzeFMqzYlDwbIonvkiJ2Dt6ff tPdN722m59F1wfhCCnMiquzB/CfClQB/ObUwQljxK0gK3qqmUszXxeYUWlxjlcRAs4aX ZJxUhWIST1WAE6wWurfax/HEPPQbLFyIGaNZQEYk087WEYRPSULLUltAqVeBUqyahoRp IRsD/KI60I8/W2pOoTN7R8xSUBdw6sp/+8WvXAOWMUaUUp3ohzmIW9LclFlcT14ozMHQ WJ1g== X-Gm-Message-State: ABy/qLbd8bHn1JBNo67GtvLx/xjhQwnTFjvDb5oTUvaf7brRvK9ZB7Do AUbpJMBLjFgK6hUjFvUSiWY= X-Google-Smtp-Source: APBJJlEMJi000dZUVHhLikE1VflZVniad1RrWvy3XoZTEeg+HEoa5TltFHwy+5Ddzdpfqt75aiQi7g== X-Received: by 2002:a05:6a00:14cc:b0:641:3bf8:6514 with SMTP id w12-20020a056a0014cc00b006413bf86514mr14757678pfu.10.1688909723070; Sun, 09 Jul 2023 06:35:23 -0700 (PDT) Received: from squeak.grove.modra.org (158.106.96.58.static.exetel.com.au. [58.96.106.158]) by smtp.gmail.com with ESMTPSA id p13-20020aa7860d000000b0066a6059d399sm5527982pfn.116.2023.07.09.06.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 06:35:22 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id C02651142CDB; Sun, 9 Jul 2023 23:05:19 +0930 (ACST) Date: Sun, 9 Jul 2023 23:05:19 +0930 From: Alan Modra To: Fangrui Song Cc: binutils@sourceware.org Subject: Re: [PATCH v4] PR30592 objcopy: allow --set-section-flags to add or remove SHF_X86_64_LARGE Message-ID: References: <20230708053035.528911-1-maskray@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230708053035.528911-1-maskray@google.com> X-Spam-Status: No, score=-3028.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,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 Fri, Jul 07, 2023 at 10:30:35PM -0700, Fangrui Song via Binutils wrote: > +static bool > +elf_x86_64_copy_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED, > + asection *isec, > + bfd *obfd ATTRIBUTE_UNUSED, > + asection *osec) { > + /* objcopy --set-section-flags without "large" drops SHF_X86_64_LARGE. */ > + elf_section_flags (osec) = (elf_section_flags (isec) & ~SHF_X86_64_LARGE); > + > + return true; > +} > + Unlike the other two functions, this one replaces the standard _bfd_elf_copy_private_section_data. You'll want to call it, and distinguish between a call from objcopy.c and a call from ldwrite.c. I think you're OK accessing elf_section_flags for osec without first checking for an elf bfd, because bfd_copy_private_section_data invokes the obfd xvec function. Like this: static bool elf_x86_64_copy_private_section_data (bfd *ibfd, asection *isec, bfd *obfd, asection *osec) { if (!_bfd_elf_copy_private_section_data (ibfd, isec, obfd, osec)) return false; /* objcopy --set-section-flags without "large" drops SHF_X86_64_LARGE. */ if (ibfd != obfd) elf_section_flags (osec) &= ~SHF_X86_64_LARGE; return true; } The patch looks OK to me with the above replacement. -- Alan Modra Australia Development Lab, IBM