shithub: scc

Download patch

ref: 5477869521457e8c088f7480104316b68914ce88
parent: 5d8b5ae1ef2dd2b2e33e2683968dc62ce25a3cac
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Dec 16 03:47:29 EST 2017

[as] Create a symbol for string

We need the symbol to be able to access to the string stored
in the name field.

--- a/as/expr.c
+++ b/as/expr.c
@@ -237,9 +237,13 @@
 	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;
 }
--- a/as/ins.c
+++ b/as/ins.c
@@ -80,8 +80,12 @@
 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