[PATCH v2 4/5] gas/ELF: adjust bad section letter diagnostic
Jan Beulich
jbeulich@suse.com
Fri Aug 1 13:25:48 GMT 2025
Being told of a problem with .section when .pushsection was used can be
irritating, especially when several of them are on the same line.
---
For translation, is it perhaps better to use
push ? "pushsection" : "section",
? Even if the directive name itself of course may not be translated.
---
v2: New.
--- 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
*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)
--- 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: .*
--- 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
mailing list