Like R_flag_in_section, the o_flag_in_section effective target is a
misnomer.  It actually signifies support for the SHF_LINK_ORDER section
flag.  Therefore this patch uses the et-static framework to determine it
from HAVE_GAS_SECTION_LINK_ORDER in auto-host.h, adapting the existing
uses.

Bootstrapped without regressions on i386-pc-solaris2.11 and
x86_64-pc-linux-gnu.

To be committed to trunk after et-static soak time.

        Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2026-01-13  Rainer Orth  <[email protected]>

        gcc:
        * configure.ac (HAVE_GAS_SECTION_LINK_ORDER): Clarify comment.
        * config.in: Regenerate.

        * doc/sourcebuild.texi (Effective-Target Keywords)
        (o_flag_in_section): Rename to shf_link_order.  Update description.

        testsuite:
        * lib/target-supports.exp
        (check_effective_target_o_flag_in_section): Remove.
        * lib/et-static.def (shf_link_order): New effective target.
        * g++.dg/pr93195a.C: Require shf_link_order.
        * gcc.dg/pr110729.c: Likewise.

# HG changeset patch
# Parent  1db5c4cd26912a4dbdce0037644a394d445d09f3
build: testsuite: Provide link_order and initfini_array effective targets

diff --git a/gcc/config.in b/gcc/config.in
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -1529,7 +1529,7 @@
 #endif
 
 
-/* Define 0/1 if your assembler supports 'o' flag in .section directive. */
+/* Define 0/1 if your assembler and linker support SHF_LINK_ORDER. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_GAS_SECTION_LINK_ORDER
 #endif
diff --git a/gcc/configure.ac b/gcc/configure.ac
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3790,7 +3790,7 @@ case "${target}" in
 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.])
+  [Define 0/1 if your assembler and linker support SHF_LINK_ORDER.])
 
 gcc_GAS_CHECK_FEATURE(section merging support, gcc_cv_as_shf_merge,
  [$fw_as_opt],
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -3141,9 +3141,6 @@ Target supports the @code{noinit} variab
 @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.
 
@@ -3179,6 +3176,9 @@ Target supports section anchors.
 @item shf_gnu_retain
 Target supports SHF_GNU_RETAIN sections.
 
+@item shf_link_order
+Target supports @code{SHF_LINK_ORDER}.
+
 @item short_enums
 Target defaults to short enums.
 
diff --git a/gcc/testsuite/g++.dg/pr93195a.C b/gcc/testsuite/g++.dg/pr93195a.C
--- a/gcc/testsuite/g++.dg/pr93195a.C
+++ b/gcc/testsuite/g++.dg/pr93195a.C
@@ -1,5 +1,5 @@
 /* { dg-do link { target { ! { nvptx*-*-* visium-*-* } } } } */
-// { dg-require-effective-target o_flag_in_section }
+/* { dg-require-effective-target shf_link_order } */
 /* { dg-options "-O0 -fpatchable-function-entry=1" } */
 /* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */
 /* { dg-additional-sources pr93195b.C } */
diff --git a/gcc/testsuite/gcc.dg/pr110729.c b/gcc/testsuite/gcc.dg/pr110729.c
--- a/gcc/testsuite/gcc.dg/pr110729.c
+++ b/gcc/testsuite/gcc.dg/pr110729.c
@@ -1,5 +1,5 @@
 /* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */
-/* { dg-require-effective-target o_flag_in_section } */
+/* { dg-require-effective-target shf_link_order } */
 /* { dg-options "-ffunction-sections -fpatchable-function-entry=2" } */
 /* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */
 
diff --git a/gcc/testsuite/lib/et-static.def b/gcc/testsuite/lib/et-static.def
--- a/gcc/testsuite/lib/et-static.def
+++ b/gcc/testsuite/lib/et-static.def
@@ -52,6 +52,10 @@ shf_gnu_retain
 HAVE_GAS_SHF_GNU_RETAIN
 this target supports SHF_GNU_RETAIN
 
+shf_link_order
+HAVE_GAS_SECTION_LINK_ORDER
+this target supports SHF_LINK_ORDER
+
 sht_init_array
 HAVE_INITFINI_ARRAY_SUPPORT
 this target supports SHT_INIT_ARRAY
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -14098,46 +14098,6 @@ proc check_effective_target_gnu_retain {
                    && [check_effective_target_sht_init_array] } ]
 }
 
-# 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
-	}
-    }]
-}
-
 # Return 1 if LRA is supported.  This must not be called (results in ERROR) for
 # targets that don't do register allocation, and therefore neither use nor
 # don't use LRA.

Reply via email to