From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by sourceware.org (Postfix) with ESMTPS id 9AA3C3858D32 for ; Wed, 19 Jul 2023 06:33:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9AA3C3858D32 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-x829.google.com with SMTP id d75a77b69052e-401d1d967beso577491cf.0 for ; Tue, 18 Jul 2023 23:33:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689748431; x=1692340431; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=RTrvolQnwTelWpaWFKdhRtwy3UWX9MH5UjDCFtjUgCM=; b=ZaEaq5IVTBCEMmqvGJWFljoh5fpUfcS1pwzkAWza7IDlBRng0BHLEvkRk/EN0S1s5E vJlyOjGgDd57c+qrEjBn0+Fx9KGXG/teoiyK0Xzrmjpl1mUu3IBOumTE5J0BfV5V/XhG rJC+PAVNmd7DC5onL2WZwgTfpKPoO0U/V9KXsqyM/HvHYIy2idG19AeVjydnW9xJ/Sd1 1N5Or1ww99n9jGcMNWA0A6XvStxcrBzp1Nx3VSKhxljUPNy8YJVOkFyvTUg3K9ouoKwy 2+aMk6f5cP7bzQgIa7Xdi2k6cTou/nRdfVJb9udoUrHqdFoZUx/aKpqp1JepsPbxwftQ MjxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689748431; x=1692340431; h=content-transfer-encoding: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=RTrvolQnwTelWpaWFKdhRtwy3UWX9MH5UjDCFtjUgCM=; b=YsrilelSloQW6JDS6JTtWcY1DJt1Uf0UlO5o9qG2/N+kzswkoXO+Ce0v2LJN0lV2nl iQLh1gy/pkKRk7m07Sgi7PGdqiWHDBhva0NHTxu4HBr2yKBkInOQnLtsYEbX6zei1Pdx yMb6KgB4AtKHln2WPE8ELMSS9kRWOyDNIZVh73YjI03yhvki3ZL/56m2MIHS9yU1QJDI em2qeGJLzGz3DxH6giXdeHg0eEbyuUVeb/yMgyEl/1Q6oG4gvjgwVkI9+kaJLO8zflCQ FMmEMzWdUSJlM7XzcnZc2Mix51XrwXjdLJwMksFGpmg6dofYdUiBXM69uf0NPXhF6OUh jEcQ== X-Gm-Message-State: ABy/qLas4WC9JAz2DYPjxC/31Fu0mnBnbvurB9fne/qotwq0LGILljjC yPBJYpzWVFsxT8Au95OMfzCsH8WLMRevL0N2bwyxEQ== X-Google-Smtp-Source: APBJJlHoWEwMJHtqwynI+hX/ZmSbPEUk77oU7O1ppMox0uZA3W6jg4n6uRAN0B9RyPiu6cbQkk3K4QtizRQPtFORys4= X-Received: by 2002:ac8:4e52:0:b0:403:96e3:4745 with SMTP id e18-20020ac84e52000000b0040396e34745mr441081qtw.20.1689748430885; Tue, 18 Jul 2023 23:33:50 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: From: Fangrui Song Date: Tue, 18 Jul 2023 23:33:39 -0700 Message-ID: Subject: Re: PING^2 [PATCH] Adjust the symbol for SECTION_LINK_ORDER linked_to section [PR99889] To: "Kewen.Lin" Cc: richard.sandiford@arm.com, Jakub Jelinek , Segher Boessenkool , GCC Patches , Peter Bergner , David Edelsohn , Richard Biener , "H.J. Lu" , AlanM , jlaw@ventanamicro.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-23.6 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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, Nov 24, 2022 at 7:26=E2=80=AFPM Kewen.Lin via Gcc-patches wrote: > > Hi Richard, > > on 2022/11/23 00:08, Richard Sandiford wrote: > > "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 =3D DECL_ASSEMBLER_NAME (decl); > >>>>>> - ultimate_transparent_alias_target (&id); > >>>>>> - const char *name =3D IDENTIFIER_POINTER (id); > >>>>>> - name =3D 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_entr= y, > >>>>>> + just place it here for linked_to section. */ > >>>>>> + gcc_assert (!strcmp (name, "__patchable_function_entrie= s")); > >>> > >>> 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 futu= re? > >>> > >> > >> Good question! I think it depends on how we can get the symbol for th= e > >> 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 labe= l > >> 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 t= o > >> 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. > > Yes, we can check if the given section name is > "__patchable_function_entries". > > > > > So yeah, the patch LGTM to me, thanks. > > Thanks again! I rebased and re-tested it on x86/aarch64/powerpc64{,le}, > just committed in r13-4294-gf120196382ac5a. > > BR, > Kewen Hi, Kewen, do you think whether your patch fixed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110729 (__patchable_function_entries has wrong sh_link) ? If yes, it may be useful to include some assembly tests... Right now rg '\.section.*__patchable' gcc/testsuite/ returns nothing. --=20 =E5=AE=8B=E6=96=B9=E7=9D=BF