mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Simplify symbol-writing logic
This commit is contained in:
@@ -195,42 +195,15 @@ static void writesection(struct Section *pSect, FILE *f)
|
|||||||
*/
|
*/
|
||||||
static void writesymbol(struct sSymbol const *pSym, FILE *f)
|
static void writesymbol(struct sSymbol const *pSym, FILE *f)
|
||||||
{
|
{
|
||||||
uint32_t type;
|
|
||||||
uint32_t offset;
|
|
||||||
int32_t sectid;
|
|
||||||
|
|
||||||
if (!sym_IsDefined(pSym))
|
|
||||||
type = SYMTYPE_IMPORT;
|
|
||||||
else if (pSym->isExported)
|
|
||||||
type = SYMTYPE_EXPORT;
|
|
||||||
else
|
|
||||||
type = SYMTYPE_LOCAL;
|
|
||||||
|
|
||||||
switch (type) {
|
|
||||||
case SYMTYPE_LOCAL:
|
|
||||||
offset = pSym->nValue;
|
|
||||||
sectid = getsectid(pSym->pSection);
|
|
||||||
break;
|
|
||||||
case SYMTYPE_IMPORT:
|
|
||||||
offset = 0;
|
|
||||||
sectid = -1;
|
|
||||||
break;
|
|
||||||
case SYMTYPE_EXPORT:
|
|
||||||
offset = pSym->nValue;
|
|
||||||
sectid = pSym->type == SYM_LABEL ? getsectid(pSym->pSection)
|
|
||||||
: -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
fputstring(pSym->tzName, f);
|
fputstring(pSym->tzName, f);
|
||||||
fputc(type, f);
|
if (!sym_IsDefined(pSym)) {
|
||||||
|
fputc(SYMTYPE_IMPORT, f);
|
||||||
if (type != SYMTYPE_IMPORT) {
|
} else {
|
||||||
|
fputc(pSym->isExported ? SYMTYPE_EXPORT : SYMTYPE_LOCAL, f);
|
||||||
fputstring(pSym->tzFileName, f);
|
fputstring(pSym->tzFileName, f);
|
||||||
fputlong(pSym->nFileLine, f);
|
fputlong(pSym->nFileLine, f);
|
||||||
|
fputlong(pSym->pSection ? getsectid(pSym->pSection) : -1, f);
|
||||||
fputlong(sectid, f);
|
fputlong(pSym->nValue, f);
|
||||||
fputlong(offset, f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user