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.
This commit is contained in:
parent
242f30e67c
commit
a808670465
@ -1,3 +1,9 @@
|
||||
2017-07-28 Andrew Waterman <andrew@sifive.com>
|
||||
|
||||
* config/tc-riscv.c (riscv_set_arch): Handle the Q subset like
|
||||
all other subsets.
|
||||
Obviate use-after-free.
|
||||
|
||||
2017-07-25 Nick Clifton <nickc@redhat.com>
|
||||
|
||||
PR 21739
|
||||
|
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user