diff options
author | Andrew Waterman <andrew@sifive.com> | 2017-07-28 10:02:57 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2017-07-28 10:02:57 +0100 |
commit | a808670465869100d4178a572da8a1503d727f3b (patch) | |
tree | db21e0ade037d1b071a16dd282c08cd787b42194 /gas/config | |
parent | 242f30e67cbc2aba8314ba3bf702efb1aaceaad6 (diff) | |
download | gdb-a808670465869100d4178a572da8a1503d727f3b.zip gdb-a808670465869100d4178a572da8a1503d727f3b.tar.gz gdb-a808670465869100d4178a572da8a1503d727f3b.tar.bz2 |
Fix problems parsing RISCV architecture extenstions in the assembler.
* config/tc-riscv.c (riscv_set_arch): Handle the Q subset like
all other subsets.
Obviate use-after-free.
Diffstat (limited to 'gas/config')
-rw-r--r-- | gas/config/tc-riscv.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 55c41c5..4c644ab 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -147,8 +147,8 @@ riscv_add_subset (const char *subset) static void riscv_set_arch (const char *s) { - const char *all_subsets = "imafdc"; - const char *extension = NULL; + const char *all_subsets = "imafdqc"; + char *extension = NULL; const char *p = s; riscv_clear_subsets(); @@ -173,7 +173,7 @@ riscv_set_arch (const char *s) case 'g': p++; - for ( ; *all_subsets != 'c'; all_subsets++) + for ( ; *all_subsets != 'q'; all_subsets++) { const char subset[] = {*all_subsets, '\0'}; riscv_add_subset (subset); @@ -188,7 +188,8 @@ riscv_set_arch (const char *s) { if (*p == 'x') { - char *subset = xstrdup (p), *q = subset; + char *subset = xstrdup (p); + char *q = subset; while (*++q != '\0' && *q != '_') ; @@ -200,7 +201,6 @@ riscv_set_arch (const char *s) extension = subset; riscv_add_subset (subset); p += strlen (subset); - free (subset); } else if (*p == '_') p++; @@ -211,15 +211,11 @@ riscv_set_arch (const char *s) all_subsets++; p++; } - else if (*p == 'q') - { - const char subset[] = {*p, 0}; - riscv_add_subset (subset); - p++; - } else as_fatal ("-march=%s: unsupported ISA subset `%c'", s, *p); } + + free (extension); } /* Handle of the OPCODE hash table. */ |