scc

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

commit 9805cb36b570b5203ac8b76034294f4c867adc58
parent 859c9c112275df118fa42cb0996212ca25ee7f40
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 14 Dec 2017 15:25:22 +0000

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

Diffstat:
Mas/as.h | 1+
Mas/ins.c | 2+-
Mas/symbol.c | 5+++--
3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/as/as.h b/as/as.h @@ -8,6 +8,7 @@ enum symflags { FEXTERN = 1 << 2, FUNDEF = 1 << 3, FDEDUP = 1 << 4, + FRELOC = 1 << 5, }; enum secflags { diff --git a/as/ins.c b/as/ins.c @@ -35,7 +35,7 @@ def(Node **args, int siz) 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); } 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 = FUNDEF | type; + sym->flags = FRELOC | FUNDEF | type; sym->value = 0; sym->section = cursec; sym->hash = *list; @@ -136,7 +136,8 @@ deflabel(char *name) 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 != '.')