[PATCH v2 2/5] gas/ELF: drop bogus check for ELFOSABI_STANDALONE

Jan Beulich jbeulich@suse.com
Fri Aug 1 13:22:21 GMT 2025


obj_elf_parse_section_letters() checking for that ABI, when the checking
at the bottom of obj_elf_section() and the logic in
_bfd_elf_final_write_processing() don't, makes no sense. Either
STANDALONE is meant to be GNU-ish, or it is not, I would think. Drop the
one inconsistent check.

If it was not GNU-ish (as the other two locations suggest), what did the
section23b testcase actually mean to check? The numeric attribute value
0x200000 has an entirely unknown (or more precisely, OS-defined, which
we may or may not know of) meaning then, so ought to be accepted. If it
was GNU-ish, the other testcase, elf/section23a, would want running for
those targets as well, and the testcase in question would still be wrong
to have. Hence that testcase is removed, and section23a is renamed to
just section23.
---
v2: New.

--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -950,14 +950,13 @@ obj_elf_parse_section_letters (char *str
 		  bed = get_elf_backend_data (stdoutput);
 
 		  if (bed->elf_osabi == ELFOSABI_NONE
-		      || bed->elf_osabi == ELFOSABI_STANDALONE
 		      || bed->elf_osabi == ELFOSABI_GNU
 		      || bed->elf_osabi == ELFOSABI_FREEBSD)
 		    {
 		      /* Add flags in the SHF_MASKOS range to gnu_attr for
 			 OSABIs that support those flags.
-			 Also adding the flags for ELFOSABI_{NONE,STANDALONE}
-			 allows them to be validated later in obj_elf_section.
+			 Also adding the flags for ELFOSABI_NONE allows them
+			 to be validated later in obj_elf_section.
 			 We can't just always set these bits in gnu_attr for
 			 all OSABIs, since Binutils does not recognize all
 			 SHF_MASKOS bits for non-GNU OSABIs.  It's therefore
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -281,8 +281,7 @@ if { [is_elf_format] } then {
     run_dump_test "section20"
     run_dump_test "section21"
     run_dump_test "section22"
-    run_dump_test "section23a"
-    run_dump_test "section23b"
+    run_dump_test "section23"
     run_dump_test "section24a"
     run_dump_test "section24b"
     run_dump_test "section25"
--- /dev/null
+++ b/gas/testsuite/gas/elf/section23.d
@@ -0,0 +1,10 @@
+#name: SHF_GNU_RETAIN set with numeric flag value in .section
+#source: section23.s
+#target: [supports_gnu_osabi]
+#readelf: -h -S --wide
+
+#...
+ +OS/ABI: +UNIX - (GNU|FreeBSD)
+#...
+  \[..\] .data.retain_var[ 	]+PROGBITS[ 	]+[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00 WAR.*
+#pass
--- a/gas/testsuite/gas/elf/section23a.d
+++ /dev/null
@@ -1,10 +0,0 @@
-#name: SHF_GNU_RETAIN set with numeric flag value in .section
-#source: section23.s
-#target: [supports_gnu_osabi]
-#readelf: -h -S --wide
-
-#...
- +OS/ABI: +UNIX - (GNU|FreeBSD)
-#...
-  \[..\] .data.retain_var[ 	]+PROGBITS[ 	]+[0-9a-f]+ [0-9a-f]+ [0-9a-f]+ 00 WAR.*
-#pass
--- a/gas/testsuite/gas/elf/section23b.d
+++ /dev/null
@@ -1,6 +0,0 @@
-#name: SHF_GNU_RETAIN set with numeric flag value in .section for non-GNU OSABI target
-#source: section23.s
-#error_output: section23b.err
-#target: msp430-*-elf visium-*-elf
-
-# This test only runs for targets which set ELFOSABI_STANDALONE.
--- a/gas/testsuite/gas/elf/section23b.err
+++ /dev/null
@@ -1,2 +0,0 @@
-.*: Assembler messages:
-.*:1: Error: GNU_RETAIN section is supported only by GNU and FreeBSD targets



More information about the Binutils mailing list