commit 8130fb4222269cbe669a68372c1d2a28d1c34f9d
parent 57603b6bf3f5e0d060012e759be7d280e94f28ab
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sat, 16 Dec 2017 08:47:29 +0100
[as] Create a symbol for string
We need the symbol to be able to access to the string stored
in the name field.
Diffstat:
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/as/expr.c b/as/expr.c
@@ -237,9 +237,13 @@ string(void)
int c;
char *p;
- for (++endp; *endp++ != '"'; )
+ for (++endp; *endp != '"'; ++endp)
;
+ ++endp;
tok2str();
+ yylval.sym = tmpsym(0);
+ /* FIXME: this memory is not freed ever */
+ yylval.sym->name.buf = xstrdup(yytext);
return STRING;
}
diff --git a/as/ins.c b/as/ins.c
@@ -80,8 +80,12 @@ void
section(Op *op, Node **args)
{
Symbol *sym = args[0]->sym;
+ char *attr = NULL;
- setsec(sym->name.buf, NULL);
+ if (args[1])
+ attr = args[1]->sym->name.buf;
+
+ setsec(sym->name.buf, attr);
}
void