From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 52DFE3858C30 for ; Tue, 22 Nov 2022 16:08:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 52DFE3858C30 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 58AEC1FB; Tue, 22 Nov 2022 08:08:52 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7B89F3F73D; Tue, 22 Nov 2022 08:08:44 -0800 (PST) From: Richard Sandiford To: "Kewen.Lin" Mail-Followup-To: "Kewen.Lin" ,GCC Patches , Jakub Jelinek , Segher Boessenkool , Peter Bergner , jlaw@ventanamicro.com, AlanM , David Edelsohn , Richard Biener , "H.J. Lu" , richard.sandiford@arm.com Cc: GCC Patches , Jakub Jelinek , Segher Boessenkool , Peter Bergner , jlaw@ventanamicro.com, AlanM , David Edelsohn , Richard Biener , "H.J. Lu" Subject: Re: PING^2 [PATCH] Adjust the symbol for SECTION_LINK_ORDER linked_to section [PR99889] References: <0558633c-b553-5ef1-aa6f-c76fcf297454@linux.ibm.com> <52ca56ad-af0f-598f-4ccf-aed61fce67b4@linux.ibm.com> <15b488a5-1f5e-c24e-be12-f402b0dcdb5e@linux.ibm.com> Date: Tue, 22 Nov 2022 16:08:43 +0000 In-Reply-To: (Kewen Lin's message of "Tue, 22 Nov 2022 10:58:04 +0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-39.8 required=5.0 tests=BAYES_00,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_NONE,SPF_NONE,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: "Kewen.Lin" writes: > Hi Richard, > > Many thanks for your review comments! > >>>> on 2022/8/24 16:17, Kewen.Lin via Gcc-patches wrote: >>>>> Hi, >>>>> >>>>> As discussed in PR98125, -fpatchable-function-entry with >>>>> SECTION_LINK_ORDER support doesn't work well on powerpc64 >>>>> ELFv1 because the filled "Symbol" in >>>>> >>>>> .section name,"flags"o,@type,Symbol >>>>> >>>>> sits in .opd section instead of in the function_section >>>>> like .text or named .text*. >>>>> >>>>> Since we already generates one label LPFE* which sits in >>>>> function_section of current_function_decl, this patch is >>>>> to reuse it as the symbol for the linked_to section. It >>>>> avoids the above ABI specific issue when using the symbol >>>>> concluded from current_function_decl. >>>>> >>>>> Besides, with this support some previous workarounds for >>>>> powerpc64 ELFv1 can be reverted. >>>>> >>>>> btw, rs6000_print_patchable_function_entry can be dropped >>>>> but there is another rs6000 patch which needs this rs6000 >>>>> specific hook rs6000_print_patchable_function_entry, not >>>>> sure which one gets landed first, so just leave it here. >>>>> >>>>> Bootstrapped and regtested on below: >>>>> >>>>> 1) powerpc64-linux-gnu P8 with default binutils 2.27 >>>>> and latest binutils 2.39. >>>>> 2) powerpc64le-linux-gnu P9 (default binutils 2.30). >>>>> 3) powerpc64le-linux-gnu P10 (default binutils 2.30). >>>>> 4) x86_64-redhat-linux with default binutils 2.30 >>>>> and latest binutils 2.39. >>>>> 5) aarch64-linux-gnu with default binutils 2.30 >>>>> and latest binutils 2.39. >>>>> > > [snip...] > >>>>> diff --git a/gcc/varasm.cc b/gcc/varasm.cc >>>>> index 4db8506b106..d4de6e164ee 100644 >>>>> --- a/gcc/varasm.cc >>>>> +++ b/gcc/varasm.cc >>>>> @@ -6906,11 +6906,16 @@ default_elf_asm_named_section (const char *name, unsigned int flags, >>>>> fprintf (asm_out_file, ",%d", flags & SECTION_ENTSIZE); >>>>> if (flags & SECTION_LINK_ORDER) >>>>> { >>>>> - tree id = DECL_ASSEMBLER_NAME (decl); >>>>> - ultimate_transparent_alias_target (&id); >>>>> - const char *name = IDENTIFIER_POINTER (id); >>>>> - name = targetm.strip_name_encoding (name); >>>>> - fprintf (asm_out_file, ",%s", name); >>>>> + /* For now, only section "__patchable_function_entries" >>>>> + adopts flag SECTION_LINK_ORDER, internal label LPFE* >>>>> + was emitted in default_print_patchable_function_entry, >>>>> + just place it here for linked_to section. */ >>>>> + gcc_assert (!strcmp (name, "__patchable_function_entries")); >> >> I like the idea of removing the rs600 workaround in favour of making the >> target-independent more robust. But this seems a bit hackish. What >> would we do if SECTION_LINK_ORDER was used for something else in future? >> > > Good question! I think it depends on how we can get the symbol for the > linked_to section, if adopting the name of the decl will suffer the > similar issue which this patch wants to fix, we have to reuse the label > LPFE* or some kind of new artificial label in the related section; or > we can just go with the name of the given decl, or something related to > that decl. Since we can't predict any future uses, I just placed an > assertion here to ensure that we would revisit and adjust this part at > that time. Does it sound reasonable to you? Yeah, I guess that's good enough. If the old scheme ends up being correct for some future use, we can make the new behaviour conditional on __patchable_function_entries. So yeah, the patch LGTM to me, thanks. Richard