scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit ce495115f2dafff304f0dbbdb3fc6831331a04b7
parent 7dd517166fa92d4fd8d57599b50d8b9394eea693
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 26 Jan 2016 18:59:20 +0100

[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.

Diffstat:
cc2/arch/i386-sysv/code.c | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/cc2/arch/i386-sysv/code.c b/cc2/arch/i386-sysv/code.c @@ -106,9 +106,6 @@ size2asm(Type *tp) { 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 @@ label(Symbol *sym) { 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 @@ label(Symbol *sym) 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