scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit e56660180cc119105790ffe7bbd53cf5d2fcfbc5
parent c17fcb83e8bad261d1d50ef2cc36f51d3a5631d1
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 12 Dec 2017 08:54:45 +0000

[as] Emit correct symbol flags

Diffstat:
Mas/as.h | 6+++---
Mas/myro.c | 18+++++++++++++++++-
Mas/symbol.c | 2+-
3 files changed, 21 insertions(+), 5 deletions(-)

diff --git 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 { diff --git a/as/myro.c b/as/myro.c @@ -86,6 +86,22 @@ writesections(FILE *fp) 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 @@ writesymbols(FILE *fp) 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); diff --git a/as/symbol.c b/as/symbol.c @@ -91,7 +91,7 @@ lookup(char *name, int type) 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;