[hackers] [scc] [cc2-i386] emit alignment before of the definition of the label || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 26 Jan 2016 19:39:20 +0100 (CET)

commit ce495115f2dafff304f0dbbdb3fc6831331a04b7
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Jan 26 18:59:20 2016 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Jan 26 18:59:20 2016 +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.

diff --git a/cc2/arch/i386-sysv/code.c b/cc2/arch/i386-sysv/code.c
index 9bda841..c9a7612 100644
--- a/cc2/arch/i386-sysv/code.c
+++ b/cc2/arch/i386-sysv/code.c
_AT_@ -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 {
_AT_@ -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)
_AT_@ -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
Received on Tue Jan 26 2016 - 19:39:20 CET

This archive was generated by hypermail 2.3.0 : Tue Jan 26 2016 - 19:48:19 CET