From a1b33b8cc47a7b215be399c7ddb431a8470ead99 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Fri, 15 Aug 2025 12:18:03 +0200 Subject: [PATCH] gas/ELF: drop bogus check for ELFOSABI_STANDALONE 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. --- gas/config/obj-elf.c | 5 ++--- gas/testsuite/gas/elf/elf.exp | 3 +-- gas/testsuite/gas/elf/{section23a.d => section23.d} | 0 gas/testsuite/gas/elf/section23b.d | 6 ------ gas/testsuite/gas/elf/section23b.err | 2 -- 5 files changed, 3 insertions(+), 13 deletions(-) rename gas/testsuite/gas/elf/{section23a.d => section23.d} (100%) delete mode 100644 gas/testsuite/gas/elf/section23b.d delete mode 100644 gas/testsuite/gas/elf/section23b.err diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index 315d08ea996..a209a9be7d6 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -950,14 +950,13 @@ obj_elf_parse_section_letters (char *str, size_t len, 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 diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp index 1f42c3f3723..ab97e5e751b 100644 --- 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" diff --git a/gas/testsuite/gas/elf/section23a.d b/gas/testsuite/gas/elf/section23.d similarity index 100% rename from gas/testsuite/gas/elf/section23a.d rename to gas/testsuite/gas/elf/section23.d diff --git a/gas/testsuite/gas/elf/section23b.d b/gas/testsuite/gas/elf/section23b.d deleted file mode 100644 index c85200e5ff7..00000000000 --- 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. diff --git a/gas/testsuite/gas/elf/section23b.err b/gas/testsuite/gas/elf/section23b.err deleted file mode 100644 index 83de60c3975..00000000000 --- 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 -- 2.47.3