From: Jan Beulich Date: Tue, 21 Dec 2021 08:30:03 +0000 (+0100) Subject: gas/ELF: avoid below-base ref in obj_elf_parse_section_letters() X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ca988435c6138887721d705931abdecd4044f934;p=binutils-gdb.git gas/ELF: avoid below-base ref in obj_elf_parse_section_letters() We would better be prepared for 'm' being the first character of the incoming string. --- diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index a6087a21eb3..3a9835abcaf 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -860,6 +860,17 @@ obj_elf_parse_section_letters (char *str, size_t len, { case 'a': attr |= SHF_ALLOC; + /* Compatibility. */ + if (len > 1 && str[1] == 'm') + { + attr |= SHF_MERGE; + str++, len--; + if (len > 1 && str[1] == 's') + { + attr |= SHF_STRINGS; + str++, len--; + } + } break; case 'e': attr |= SHF_EXCLUDE; @@ -894,19 +905,6 @@ obj_elf_parse_section_letters (char *str, size_t len, case '?': *is_clone = true; break; - /* Compatibility. */ - case 'm': - if (*(str - 1) == 'a') - { - attr |= SHF_MERGE; - if (len > 1 && str[1] == 's') - { - attr |= SHF_STRINGS; - str++, len--; - } - break; - } - /* Fall through. */ default: { const char *bad_msg = _("unrecognized .section attribute:"