From patchwork Wed Dec 2 13:15:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1409729 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=JebwIsBK; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CmKGw5YjRz9sRK for ; Thu, 3 Dec 2020 00:16:07 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5F8623857031; Wed, 2 Dec 2020 13:16:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5F8623857031 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1606914964; bh=nlRZeR37q2bdOruuTmS3aa+GvR4FVMgkedZ4Nrz3JkU=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=JebwIsBKDtFDxHXHJjpfbKjShwe0Vv7hU+n/u7gHG7Fgwu8U8j++BIF+0gKjMUcaZ lFtv4+qqV/0BgaR7zWgVtthezUuF5XvvuETLfvpJDPAs+0aJ3L1aAyx6jdy29/bB/+ NdSiIKfHa41E5xcDgX3HsqbMSIFe4Rch5/uC7UvI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-oo1-xc2c.google.com (mail-oo1-xc2c.google.com [IPv6:2607:f8b0:4864:20::c2c]) by sourceware.org (Postfix) with ESMTPS id 9A82A3858D37 for ; Wed, 2 Dec 2020 13:15:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9A82A3858D37 Received: by mail-oo1-xc2c.google.com with SMTP id t142so340488oot.7 for ; Wed, 02 Dec 2020 05:15:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nlRZeR37q2bdOruuTmS3aa+GvR4FVMgkedZ4Nrz3JkU=; b=k8bJElgFfInWakEK7EJzZWOku3kD3tZSLbU64sKqMA4tK5oXCINIiwQVuuXe5h8e2R ygBTJEYYo5EaN/S7YHKClUvVDRn5U88tsIOdQmf05/n5fK5XOoch6tqlakScc5X2svqS nabNhpqD3J/+5j+CeftNaOEDcxTlT0pStu3UVUNicMvlkCPqyRkSYsoR61Xf0Rl+2Hik v5+lXYrC1qwsHrq8D/PFujE1OpPS0Z0IAyQjST+JHBzOnYVTMpjumBJM2ME9WxIju5t8 RZcab+/YWGGFe8YcRjS3ykONyL95SmHqJybajfHsfDlDvfx5lu+KENSDEYvKH33+GQ+Q WCoA== X-Gm-Message-State: AOAM5339Ns7bQ4gRUIjOiBzN3oRmD097UzOdF/vdOmUdjBbje7lxAEB5 xuAx3294uqQpLsMo713R6uaYSg3LjdcfzAbXgo8= X-Google-Smtp-Source: ABdhPJxVnfINMK0rEZLntuK1piY88UEdSSXbBW9TLy4wZwBut9Yn5j77r1Srbeve0DmSfNN4oYxahLzhi5xD5M05raQ= X-Received: by 2002:a4a:91de:: with SMTP id e30mr1603178ooh.58.1606914957917; Wed, 02 Dec 2020 05:15:57 -0800 (PST) MIME-Version: 1.0 References: <20200207025710.474289-1-hjl.tools@gmail.com> <8193889c-5f8a-62f9-b064-f28ab8aa030e@redhat.com> In-Reply-To: <8193889c-5f8a-62f9-b064-f28ab8aa030e@redhat.com> Date: Wed, 2 Dec 2020 05:15:21 -0800 Message-ID: Subject: V2 [PATCH] Use the section flag 'o' for __patchable_function_entries To: Jeff Law X-Spam-Status: No, score=-3038.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "H.J. Lu via Gcc-patches" From: "H.J. Lu" Reply-To: "H.J. Lu" Cc: Jakub Jelinek , GCC Patches , Richard Sandiford Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" On Tue, Dec 1, 2020 at 9:23 PM Jeff Law wrote: > > > > On 11/18/20 7:00 AM, H.J. Lu wrote: > > On Sat, Nov 7, 2020 at 7:47 AM H.J. Lu wrote: > >> On Sat, Oct 31, 2020 at 5:01 AM H.J. Lu wrote: > >>> On Fri, Oct 23, 2020 at 5:41 AM H.J. Lu wrote: > >>>> On Fri, Oct 2, 2020 at 6:00 AM H.J. Lu wrote: > >>>>> On Thu, Feb 6, 2020 at 6:57 PM H.J. Lu wrote: > >>>>>> This commit in GNU binutils 2.35: > >>>>>> > >>>>>> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=b7d072167715829eed0622616f6ae0182900de3e > >>>>>> > >>>>>> added the section flag 'o' to .section directive: > >>>>>> > >>>>>> .section __patchable_function_entries,"awo",@progbits,foo > >>>>>> > >>>>>> which specifies the symbol name which the section references. Assembler > >>>>>> creates a unique __patchable_function_entries section with the section, > >>>>>> where foo is defined, as its linked-to section. Linker keeps a section > >>>>>> if its linked-to section is kept during garbage collection. > >>>>>> > >>>>>> This patch checks assembler support for the section flag 'o' and uses > >>>>>> it to implement __patchable_function_entries section. Since Solaris may > >>>>>> use GNU assembler with Solairs ld. Even if GNU assembler supports the > >>>>>> section flag 'o', it doesn't mean that Solairs ld supports it. This > >>>>>> feature is disabled for Solairs targets. > >>>>>> > >>>>>> gcc/ > >>>>>> > >>>>>> PR middle-end/93195 > >>>>>> PR middle-end/93197 > >>>>>> * configure.ac (HAVE_GAS_SECTION_LINK_ORDER): New. Define if > >>>>>> the assembler supports the section flag 'o' for specifying > >>>>>> section with link-order. > >>>>>> * dwarf2out.c (output_comdat_type_unit): Pass 0 as flags2 > >>>>>> to targetm.asm_out.named_section. > >>>>>> * config/sol2.c (solaris_elf_asm_comdat_section): Likewise. > >>>>>> * output.h (SECTION2_LINK_ORDER): New. > >>>>>> (switch_to_section): Add an unsigned int argument. > >>>>>> (default_no_named_section): Likewise. > >>>>>> (default_elf_asm_named_section): Likewise. > >>>>>> * target.def (asm_out.named_section): Likewise. > >>>>>> * targhooks.c (default_print_patchable_function_entry): Pass > >>>>>> current_function_decl to get_section and SECTION2_LINK_ORDER > >>>>>> to switch_to_section. > >>>>>> * varasm.c (default_no_named_section): Add an unsigned int > >>>>>> argument. > >>>>>> (default_elf_asm_named_section): Add an unsigned int argument, > >>>>>> flags2. Use 'o' flag for SECTION2_LINK_ORDER if assembler > >>>>>> supports it. > >>>>>> (switch_to_section): Add an unsigned int argument and pass it > >>>>>> to targetm.asm_out.named_section. > >>>>>> (handle_vtv_comdat_section): Pass 0 to > >>>>>> targetm.asm_out.named_section. > >>>>>> * config.in: Regenerated. > >>>>>> * configure: Likewise. > >>>>>> * doc/tm.texi: Likewise. > >>>>>> > >>>>>> gcc/testsuite/ > >>>>>> > >>>>>> PR middle-end/93195 > >>>>>> * g++.dg/pr93195a.C: New test. > >>>>>> * g++.dg/pr93195b.C: Likewise. > >>>>>> * lib/target-supports.exp > >>>>>> (check_effective_target_o_flag_in_section): New proc. > >>>>> PING > >>>>> > >>>>> https://gcc.gnu.org/pipermail/gcc-patches/2020-February/539963.html > >>>> PING. > >>>> > >>> PING. > >>> > >> PING. > > Here is a simpler patch. OK for master? > > > > This commit in GNU binutils 2.35: > > > > https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=b7d072167715 > > 829eed0622616f6ae0182900de3e > > > > added the section flag 'o' to .section directive: > > > > .section __patchable_function_entries,"awo",@progbits,foo > > > > which specifies the symbol name which the section references. Assembler > > creates a unique __patchable_function_entries section with the section, > > where foo is defined, as its linked-to section. Linker keeps a section > > if its linked-to section is kept during garbage collection. > > > > This patch checks assembler support for the section flag 'o' and uses > > it to implement __patchable_function_entries section. Since Solaris may > > use GNU assembler with Solairs ld. Even if GNU assembler supports the > > section flag 'o', it doesn't mean that Solairs ld supports it. This > > feature is disabled for Solairs targets. > > > > gcc/ > > > > PR middle-end/93195 > > PR middle-end/93197 > > * configure.ac (HAVE_GAS_SECTION_LINK_ORDER): New. Define 1 if > > the assembler supports the section flag 'o' for specifying > > section with link-order. > > * output.h (SECTION_LINK_ORDER): New. Defined to 0x4000000. > > (SECTION_MACH_DEP): Changed from 0x4000000 to 0x8000000. > > * targhooks.c (default_print_patchable_function_entry): Pass > > SECTION_LINK_ORDER to switch_to_section if the section flag 'o' > > works. Pass current_function_decl to switch_to_section. > > * varasm.c (default_elf_asm_named_section): Use 'o' flag for > > SECTION_LINK_ORDER if assembler supports it. > > * config.in: Regenerated. > > * configure: Likewise. > > > > gcc/testsuite/ > > > > PR middle-end/93195 > > * g++.dg/pr93195a.C: New test. > > * g++.dg/pr93195b.C: Likewise. > > * lib/target-supports.exp > > (check_effective_target_o_flag_in_section): New proc. > So you need to document the new effective target test in > sourcebuild.texi. I see new #if in targhooks.c. If that could be made Fixed. > a if (...) it'd be greatly appreciated. Fixed. > OK with those changes. > This is the patch I am checking in. Thanks. From 5fc5a1c35a95398036b3858cfef448621a4d1514 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 3 Feb 2020 11:55:43 -0800 Subject: [PATCH] Use the section flag 'o' for __patchable_function_entries This commit in GNU binutils 2.35: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=b7d072167715829eed0622616f6ae0182900de3e added the section flag 'o' to .section directive: .section __patchable_function_entries,"awo",@progbits,foo which specifies the symbol name which the section references. Assembler creates a unique __patchable_function_entries section with the section, where foo is defined, as its linked-to section. Linker keeps a section if its linked-to section is kept during garbage collection. This patch checks assembler support for the section flag 'o' and uses it to implement __patchable_function_entries section. Since Solaris may use GNU assembler with Solairs ld. Even if GNU assembler supports the section flag 'o', it doesn't mean that Solairs ld supports it. This feature is disabled for Solairs targets. gcc/ PR middle-end/93195 PR middle-end/93197 * configure.ac (HAVE_GAS_SECTION_LINK_ORDER): New. Define 1 if the assembler supports the section flag 'o' for specifying section with link-order. * output.h (SECTION_LINK_ORDER): New. Defined to 0x8000000. (SECTION_MACH_DEP): Changed from 0x8000000 to 0x10000000. * targhooks.c (default_print_patchable_function_entry): Pass SECTION_LINK_ORDER to switch_to_section if the section flag 'o' works. Pass current_function_decl to switch_to_section. * varasm.c (default_elf_asm_named_section): Use 'o' flag for SECTION_LINK_ORDER if assembler supports it. * config.in: Regenerated. * configure: Likewise. gcc/testsuite/ PR middle-end/93195 * g++.dg/pr93195a.C: New test. * g++.dg/pr93195b.C: Likewise. * lib/target-supports.exp (check_effective_target_o_flag_in_section): New proc. --- gcc/config.in | 6 ++++ gcc/configure | 52 +++++++++++++++++++++++++++ gcc/configure.ac | 22 ++++++++++++ gcc/doc/sourcebuild.texi | 3 ++ gcc/output.h | 3 +- gcc/targhooks.c | 5 ++- gcc/testsuite/g++.dg/pr93195a.C | 27 ++++++++++++++ gcc/testsuite/g++.dg/pr93195b.C | 14 ++++++++ gcc/testsuite/lib/target-supports.exp | 40 +++++++++++++++++++++ gcc/varasm.c | 10 ++++++ 10 files changed, 180 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/pr93195a.C create mode 100644 gcc/testsuite/g++.dg/pr93195b.C diff --git a/gcc/config.in b/gcc/config.in index b6e041d311e..216505abd2c 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1386,6 +1386,12 @@ #endif +/* Define 0/1 if your assembler supports 'o' flag in .section directive. */ +#ifndef USED_FOR_TARGET +#undef HAVE_GAS_SECTION_LINK_ORDER +#endif + + /* Define 0/1 if your assembler supports marking sections with SHF_GNU_RETAIN flag. */ #ifndef USED_FOR_TARGET diff --git a/gcc/configure b/gcc/configure index 747822208f2..785d6560987 100755 --- a/gcc/configure +++ b/gcc/configure @@ -24481,6 +24481,58 @@ cat >>confdefs.h <<_ACEOF _ACEOF +# Test if the assembler supports the section flag 'o' for specifying +# section with link-order. +case "${target}" in + # Solaris may use GNU assembler with Solairs ld. Even if GNU + # assembler supports the section flag 'o', it doesn't mean that + # Solairs ld supports it. + *-*-solaris2*) + gcc_cv_as_section_link_order=no + ;; + *) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for section 'o' flag" >&5 +$as_echo_n "checking assembler for section 'o' flag... " >&6; } +if ${gcc_cv_as_section_link_order+:} false; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_section_link_order=no + if test $in_tree_gas = yes; then + if test $gcc_cv_gas_vers -ge `expr \( \( 2 \* 1000 \) + 35 \) \* 1000 + 0` + then gcc_cv_as_section_link_order=yes +fi + elif test x$gcc_cv_as != x; then + $as_echo '.section .foo,"a" +.byte 0 +.section __patchable_function_entries,"awo",%progbits,.foo +.byte 0' > conftest.s + if { ac_try='$gcc_cv_as $gcc_cv_as_flags --fatal-warnings -o conftest.o conftest.s >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + gcc_cv_as_section_link_order=yes + else + echo "configure: failed program was" >&5 + cat conftest.s >&5 + fi + rm -f conftest.o conftest.s + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_section_link_order" >&5 +$as_echo "$gcc_cv_as_section_link_order" >&6; } + + + ;; +esac + +cat >>confdefs.h <<_ACEOF +#define HAVE_GAS_SECTION_LINK_ORDER `if test $gcc_cv_as_section_link_order = yes; then echo 1; else echo 0; fi` +_ACEOF + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for section merging support" >&5 $as_echo_n "checking assembler for section merging support... " >&6; } if ${gcc_cv_as_shf_merge+:} false; then : diff --git a/gcc/configure.ac b/gcc/configure.ac index 478d0d6f238..062f57fa12b 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -3350,6 +3350,28 @@ AC_DEFINE_UNQUOTED(HAVE_GAS_SHF_GNU_RETAIN, [`if test $gcc_cv_as_shf_gnu_retain = yes; then echo 1; else echo 0; fi`], [Define 0/1 if your assembler supports marking sections with SHF_GNU_RETAIN flag.]) +# Test if the assembler supports the section flag 'o' for specifying +# section with link-order. +case "${target}" in + # Solaris may use GNU assembler with Solairs ld. Even if GNU + # assembler supports the section flag 'o', it doesn't mean that + # Solairs ld supports it. + *-*-solaris2*) + gcc_cv_as_section_link_order=no + ;; + *) + gcc_GAS_CHECK_FEATURE([section 'o' flag], gcc_cv_as_section_link_order, + [2,35,0], [--fatal-warnings], + [.section .foo,"a" +.byte 0 +.section __patchable_function_entries,"awo",%progbits,.foo +.byte 0]) + ;; +esac +AC_DEFINE_UNQUOTED(HAVE_GAS_SECTION_LINK_ORDER, + [`if test $gcc_cv_as_section_link_order = yes; then echo 1; else echo 0; fi`], + [Define 0/1 if your assembler supports 'o' flag in .section directive.]) + gcc_GAS_CHECK_FEATURE(section merging support, gcc_cv_as_shf_merge, [elf,2,12,0], [--fatal-warnings], [.section .rodata.str, "aMS", @progbits, 1]) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 55538c3586b..586dce75740 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2548,6 +2548,9 @@ Target supports the @code{noinit} variable attribute. @item nonpic Target does not generate PIC by default. +@item o_flag_in_section +Target supports the 'o' flag in .section directive in assembly inputs. + @item offload_gcn Target has been configured for OpenACC/OpenMP offloading on AMD GCN. diff --git a/gcc/output.h b/gcc/output.h index 729c52099e6..fa8ace1f394 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -382,10 +382,11 @@ extern void no_asm_to_stream (FILE *); #define SECTION_RELRO 0x1000000 /* data is readonly after relocation processing */ #define SECTION_EXCLUDE 0x2000000 /* discarded by the linker */ #define SECTION_RETAIN 0x4000000 /* retained by the linker. */ +#define SECTION_LINK_ORDER 0x8000000 /* section needs link-order. */ /* NB: The maximum SECTION_MACH_DEP is 0x10000000 since AVR needs 4 bits in SECTION_MACH_DEP. */ -#define SECTION_MACH_DEP 0x8000000 /* subsequent bits reserved for target */ +#define SECTION_MACH_DEP 0x10000000 /* subsequent bits reserved for target */ /* This SECTION_STYLE is used for unnamed sections that we can switch to using a special assembler directive. */ diff --git a/gcc/targhooks.c b/gcc/targhooks.c index e634df3f6c6..6e12e13d68e 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -1864,8 +1864,11 @@ default_print_patchable_function_entry (FILE *file, patch_area_number++; ASM_GENERATE_INTERNAL_LABEL (buf, "LPFE", patch_area_number); + unsigned int flags = SECTION_WRITE | SECTION_RELRO; + if (HAVE_GAS_SECTION_LINK_ORDER) + flags |= SECTION_LINK_ORDER; switch_to_section (get_section ("__patchable_function_entries", - SECTION_WRITE | SECTION_RELRO, NULL)); + flags, current_function_decl)); assemble_align (POINTER_SIZE); fputs (asm_op, file); assemble_name_raw (file, buf); diff --git a/gcc/testsuite/g++.dg/pr93195a.C b/gcc/testsuite/g++.dg/pr93195a.C new file mode 100644 index 00000000000..26d265da74e --- /dev/null +++ b/gcc/testsuite/g++.dg/pr93195a.C @@ -0,0 +1,27 @@ +/* { dg-do link { target { ! { nvptx*-*-* visium-*-* } } } } */ +// { dg-require-effective-target o_flag_in_section } +/* { dg-options "-O0 -fpatchable-function-entry=1" } */ +/* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */ +/* { dg-additional-sources pr93195b.C } */ + +extern void bar1 (void); + +inline void +foo (void) +{ +} + +void +bar (void) +{ + foo (); + bar1 (); +} + +int +main () +{ + bar (); + return 0; +} + diff --git a/gcc/testsuite/g++.dg/pr93195b.C b/gcc/testsuite/g++.dg/pr93195b.C new file mode 100644 index 00000000000..303d8588c0f --- /dev/null +++ b/gcc/testsuite/g++.dg/pr93195b.C @@ -0,0 +1,14 @@ +/* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ +/* { dg-options "-O0 -fpatchable-function-entry=1" } */ +/* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */ + +inline void +foo (void) +{ +} + +void +bar1 (void) +{ + foo (); +} diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 9d0a25d77e5..89c4f67554f 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -10702,3 +10702,43 @@ proc check_effective_target_R_flag_in_section { } { } }] } + +# Return 1 if this target supports 'o' flag in .section directive, 0 +# otherwise. Cache the result. + +proc check_effective_target_o_flag_in_section { } { + global tool + global GCC_UNDER_TEST + + # Need auto-host.h to check linker support. + if { ![file exists ../../auto-host.h ] } { + return 0 + } + + return [check_cached_effective_target o_flag_in_section { + + set src pie[pid].c + set obj pie[pid].o + + set f [open $src "w"] + puts $f "#include \"../../auto-host.h\"" + puts $f "#if HAVE_GAS_SECTION_LINK_ORDER == 0" + puts $f "# error Assembler does not support 'o' flag in .section directive." + puts $f "#endif" + close $f + + verbose "check_effective_target_o_flag_in_section compiling testfile $src" 2 + set lines [${tool}_target_compile $src $obj object ""] + + file delete $src + file delete $obj + + if [string match "" $lines] then { + verbose "check_effective_target_o_flag_in_section testfile compilation passed" 2 + return 1 + } else { + verbose "check_effective_target_o_flag_in_section testfile compilation failed" 2 + return 0 + } + }] +} diff --git a/gcc/varasm.c b/gcc/varasm.c index 6c13f528f7b..961d2d6fe3b 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -6789,6 +6789,8 @@ default_elf_asm_named_section (const char *name, unsigned int flags, *f++ = 'G'; if (flags & SECTION_RETAIN) *f++ = 'R'; + if (flags & SECTION_LINK_ORDER) + *f++ = 'o'; #ifdef MACH_DEP_SECTION_ASM_FLAG if (flags & SECTION_MACH_DEP) *f++ = MACH_DEP_SECTION_ASM_FLAG; @@ -6821,6 +6823,14 @@ default_elf_asm_named_section (const char *name, unsigned int flags, if (flags & SECTION_ENTSIZE) 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); + } if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE)) { if (TREE_CODE (decl) == IDENTIFIER_NODE) -- 2.28.0