shithub: scc

Download patch

ref: b89dac3b626de7901c14bfec3c2372c841496810
parent: 08abc12db33fbddd1896580e4a08064558e88c0e
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Dec 14 10:25:22 EST 2017

[as] Add FRELOC symbol flag

This flag is used to indicate that a symbol needs
relocation after assembling the file. This flags
is equivalent to have an absloument segment, and
it is provided only to make easier some operations
and not mix it with FUNDEF, which should mean
that the symbol is not defined.

--- a/as/as.h
+++ b/as/as.h
@@ -8,6 +8,7 @@
 	FEXTERN = 1 << 2,
 	FUNDEF  = 1 << 3,
 	FDEDUP  = 1 << 4,
+	FRELOC  = 1 << 5,
 };
 
 enum secflags {
--- a/as/ins.c
+++ b/as/ins.c
@@ -35,7 +35,7 @@
 	for ( ; np = *args; ++args) {
 		Symbol *sym = np->sym;
 
-		if (sym->flags & FUNDEF)
+		if (sym->flags & FRELOC)
 			reloc(sym, 0, siz, siz * 8, 0);
 		emit(tobytes(sym->value, siz, endian), siz);
 	}
--- a/as/symbol.c
+++ b/as/symbol.c
@@ -91,7 +91,7 @@
 
 	sym = xmalloc(sizeof(*sym));
 	sym->name = newstring(name);
-	sym->flags = FUNDEF | type;
+	sym->flags = FRELOC | FUNDEF | type;
 	sym->value = 0;
 	sym->section = cursec;
 	sym->hash = *list;
@@ -136,7 +136,8 @@
 	if (pass == 1 && (sym->flags & FUNDEF) == 0)
 		error("redefinition of label '%s'", name);
 	if (cursec->flags & SABS)
-		sym->flags &= ~FUNDEF;
+		sym->flags &= ~FRELOC;
+	sym->flags &= ~FUNDEF;
 	sym->value = cursec->curpc;
 
 	if (*name != '.')