From: Jan Beulich Date: Fri, 15 Aug 2025 10:18:51 +0000 (+0200) Subject: gas/ELF: adjust bad section letter diagnostic X-Git-Tag: gdb-17-branchpoint~303 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=21ff588912e47acae7ff34e45f68dc4296b6bcef;p=thirdparty%2Fbinutils-gdb.git 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 --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!"