Implement unionized sections in RGBASM

This touched a lot more code than initially expected, for two reasons.

First, this broke a big RGBASM assumption: that sections are always being
written to at their end. This plus other problems required touching
basically the entirety of `section.c`.

Second, I tried different solutions to solve the above problem, and along
the way I cleaned up many things around. (I believe that keeping this to
"cleanup" commits yields subpar results, and since it's boring they get
postponed anyways.)

RGBLINK support still needs to be added, but this will come next.
This commit is contained in:
ISSOtm
2020-03-20 21:02:32 +01:00
parent 46a402f7d7
commit cb52ae0f26
13 changed files with 314 additions and 162 deletions

View File

@@ -62,7 +62,7 @@ static int32_t Callback__LINE__(struct sSymbol const *self)
static int32_t CallbackPC(struct sSymbol const *self)
{
return self->pSection ? self->pSection->nOrg + self->pSection->nPC : 0;
return self->pSection ? self->pSection->nOrg + curOffset : 0;
}
/*
@@ -124,7 +124,6 @@ static struct sSymbol *createsymbol(char const *s)
if (snprintf((*ppsym)->tzName, MAXSYMLEN + 1, "%s", s) > MAXSYMLEN)
warning(WARNING_LONG_STR, "Symbol name is too long: '%s'", s);
(*ppsym)->isConstant = false;
(*ppsym)->isExported = false;
(*ppsym)->isBuiltin = false;
(*ppsym)->isReferenced = false;
@@ -349,7 +348,6 @@ struct sSymbol *sym_AddEqu(char const *tzSym, int32_t value)
nsym->nValue = value;
nsym->type = SYM_EQU;
nsym->isConstant = true;
nsym->pScope = NULL;
updateSymbolFilename(nsym);
@@ -417,7 +415,6 @@ struct sSymbol *sym_AddSet(char const *tzSym, int32_t value)
nsym->nValue = value;
nsym->type = SYM_SET;
nsym->isConstant = true;
nsym->pScope = NULL;
updateSymbolFilename(nsym);
@@ -479,9 +476,8 @@ struct sSymbol *sym_AddReloc(char const *tzSym)
nsym->tzFileName, nsym->nFileLine);
/* If the symbol already exists as a ref, just "take over" it */
nsym->nValue = nPC;
nsym->nValue = curOffset;
nsym->type = SYM_LABEL;
nsym->isConstant = pCurrentSection && pCurrentSection->nOrg != -1;
if (exportall)
nsym->isExported = true;