shithub: scc

Download patch

ref: ad4b2e7209a854e38920dfd1dc25315809b43ce5
parent: c136fcc69d9bb23a8f2a1829015c8e31f444f700
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Dec 12 03:54:45 EST 2017

[as] Emit correct symbol flags

--- a/as/as.h
+++ b/as/as.h
@@ -5,9 +5,9 @@
 enum symflags {
 	FREG    = 1 << 0,
 	FCOMMON = 1 << 1,
-	FLOCAL  = 1 << 2,
-	FEXTERN = 1 << 3,
-	FUNDEF  = 1 << 4,
+	FEXTERN = 1 << 2,
+	FUNDEF  = 1 << 3,
+	FDEDUP  = 1 << 4,
 };
 
 enum secflags {
--- a/as/myro.c
+++ b/as/myro.c
@@ -86,6 +86,22 @@
 	return off;
 }
 
+static unsigned
+getsymflags(Symbol *sym)
+{
+	unsigned flags = 0;
+
+	if (sym->flags & FCOMMON)
+		flags |= MYROSYM_COMMON;
+	if (sym->flags & FEXTERN)
+		flags |= MYROSYM_EXTERN;
+	if (sym->flags & FUNDEF)
+		flags |= MYROSYM_UNDEF;
+	if (sym->flags & FDEDUP)
+		flags |= MYROSYM_DEDUP;
+	return flags;
+}
+
 static size_t
 writesymbols(FILE *fp)
 {
@@ -99,7 +115,7 @@
 		symbol.name = sym->name.offset;
 		symbol.type = -1;
 		symbol.section = -1;
-		symbol.flags = 0;
+		symbol.flags = getsymflags(sym);
 		symbol.offset = off;
 		symbol.len = 0;
 		off += wrmyrosym(fp, &symbol);
--- a/as/symbol.c
+++ b/as/symbol.c
@@ -91,7 +91,7 @@
 
 	sym = xmalloc(sizeof(*sym));
 	sym->name = newstring(name);
-	sym->flags = FLOCAL | FUNDEF | type;
+	sym->flags = FUNDEF | type;
 	sym->value = 0;
 	sym->section = cursec;
 	sym->hash = *list;