shithub: scc

Download patch

ref: ce495115f2dafff304f0dbbdb3fc6831331a04b7
parent: 7dd517166fa92d4fd8d57599b50d8b9394eea693
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Jan 26 13:59:20 EST 2016

[cc2-i386] emit alignment before of the definition of the label

We were emitting the alignment directive after the label, so the result
was wrong, because the data was aligned, but not the label.

--- a/cc2/arch/i386-sysv/code.c
+++ b/cc2/arch/i386-sysv/code.c
@@ -106,9 +106,6 @@
 {
 	char *s;
 
-	if (tp->align != 1)
-		printf("\t.align\t%d\n", tp->align);
-
 	if (tp->flags & STRF) {
 		s = "\t.ascii\t";
 	} else {
@@ -153,8 +150,8 @@
 {
 	int seg, flags = sym->type.flags;
 	char *name = symname(sym);
+	Type *tp = &sym->type;
 
-	putchar('\n');
 	if (flags & FUNF)
 		seg = CODESEG;
 	else if (flags & INITF)
@@ -170,11 +167,16 @@
 		return;
 	case GLOB:
 		printf("\t.global\t%s\n", name);
+		if (seg == BSSSEG) {
+			printf("\t.comm\t%s,%llu\n",
+			       name,
+			       (unsigned long long) tp->size);
+		}
 		break;
 	}
-
+	if (sym->type.align != 1)
+		printf("\t.align\t%d\n",sym->type.align );
 	printf("%s:\n", name);
-
 }
 
 void