aboutsummaryrefslogtreecommitdiff
path: root/gas/config/obj-elf.c
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2021-12-21 09:30:03 +0100
committerJan Beulich <jbeulich@suse.com>2021-12-21 09:30:03 +0100
commitca988435c6138887721d705931abdecd4044f934 (patch)
treec1e5d052cbf0878a6c242bf296961ebfedcafad7 /gas/config/obj-elf.c
parent5ab88688f0651c6eafbbd8071888d2c213368c86 (diff)
downloadgdb-ca988435c6138887721d705931abdecd4044f934.zip
gdb-ca988435c6138887721d705931abdecd4044f934.tar.gz
gdb-ca988435c6138887721d705931abdecd4044f934.tar.bz2
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.
Diffstat (limited to 'gas/config/obj-elf.c')
-rw-r--r--gas/config/obj-elf.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index a6087a2..3a9835a 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:"