[binutils-gdb] gas/ELF: adjust bad section letter diagnostic
Jan Beulich
jbeulich@sourceware.org
Fri Aug 15 10:21:09 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=21ff588912e47acae7ff34e45f68dc4296b6bcef
commit 21ff588912e47acae7ff34e45f68dc4296b6bcef
Author: Jan Beulich <jbeulich@suse.com>
Date: Fri Aug 15 12:18:51 2025 +0200
gas/ELF: adjust bad section letter diagnostic
Being told of a problem with .section when .pushsection was used can be
irritating, especially when several of them are on the same line.
Diff:
---
gas/config/obj-elf.c | 9 +++++----
gas/testsuite/gas/elf/bad-section-flag.err | 1 +
gas/testsuite/gas/elf/bad-section-flag.s | 1 +
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 4e774dcd7d9..b39c59e54b8 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -870,7 +870,7 @@ obj_elf_change_section (const char *name,
}
static bfd_vma
-obj_elf_parse_section_letters (char *str, size_t len,
+obj_elf_parse_section_letters (char *str, size_t len, bool push,
bool *is_clone, int *inherit, bfd_vma *gnu_attr)
{
bfd_vma attr = 0;
@@ -976,7 +976,8 @@ obj_elf_parse_section_letters (char *str, size_t len,
*inherit = *str == '+' ? 1 : -1;
else
{
- as_bad (_("unrecognized .section attribute: want %s%s%s,? or number"),
+ as_bad (_("unrecognized .%ssection attribute: want %s%s%s,? or number"),
+ push ? "push" : "",
gnu_attr != NULL ? "a,d,e,o,w,x,G,M,R,S,T"
: "a,e,o,w,x,G,M,S,T",
md_extra != NULL ? "," : "", md_extra);
@@ -1268,8 +1269,8 @@ obj_elf_section (int push)
}
const struct elf_backend_data *bed = get_elf_backend_data (stdoutput);
- attr = obj_elf_parse_section_letters (beg, strlen (beg), &is_clone,
- &inherit,
+ attr = obj_elf_parse_section_letters (beg, strlen (beg), push,
+ &is_clone, &inherit,
bed->elf_osabi == ELFOSABI_NONE
|| (bed->elf_osabi
== ELFOSABI_GNU)
diff --git a/gas/testsuite/gas/elf/bad-section-flag.err b/gas/testsuite/gas/elf/bad-section-flag.err
index 919d13f17cf..b3af9c15b6d 100644
--- a/gas/testsuite/gas/elf/bad-section-flag.err
+++ b/gas/testsuite/gas/elf/bad-section-flag.err
@@ -1,2 +1,3 @@
.*: Assembler messages:
.*:1: Error: unrecognized [.]section attribute: .*
+.*:2: Error: unrecognized [.]pushsection attribute: .*
diff --git a/gas/testsuite/gas/elf/bad-section-flag.s b/gas/testsuite/gas/elf/bad-section-flag.s
index 35496bd8e8b..7eaebaead39 100644
--- a/gas/testsuite/gas/elf/bad-section-flag.s
+++ b/gas/testsuite/gas/elf/bad-section-flag.s
@@ -1 +1,2 @@
.section ".rodata", "z~&q"
+ .pushsection ".rodata", "a!"
More information about the Binutils-cvs
mailing list