From 6579120d9efb986ef38eee1c85539618aa09d00a Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Fri, 27 Mar 2020 12:30:41 +0100 Subject: [PATCH] Simplify symbol-writing logic --- src/asm/output.c | 39 ++++++--------------------------------- 1 file changed, 6 insertions(+), 33 deletions(-) diff --git a/src/asm/output.c b/src/asm/output.c index de688b82..a23ed1b5 100644 --- a/src/asm/output.c +++ b/src/asm/output.c @@ -195,42 +195,15 @@ static void writesection(struct Section *pSect, 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); - fputc(type, f); - - if (type != SYMTYPE_IMPORT) { + if (!sym_IsDefined(pSym)) { + fputc(SYMTYPE_IMPORT, f); + } else { + fputc(pSym->isExported ? SYMTYPE_EXPORT : SYMTYPE_LOCAL, f); fputstring(pSym->tzFileName, f); fputlong(pSym->nFileLine, f); - - fputlong(sectid, f); - fputlong(offset, f); + fputlong(pSym->pSection ? getsectid(pSym->pSection) : -1, f); + fputlong(pSym->nValue, f); } }