Fix non-const labels with callbacks having incorrect values when diffed

Basically, this broke PC, which is currently the only label-typed symbol
with a callback.
This commit is contained in:
ISSOtm
2020-02-13 20:12:19 +01:00
parent 91b65c9380
commit f01a227470
3 changed files with 6 additions and 5 deletions

View File

@@ -70,6 +70,7 @@ static inline bool sym_IsExported(struct sSymbol const *sym)
return sym->isExported; return sym->isExported;
} }
int32_t sym_GetValue(struct sSymbol const *sym);
uint32_t sym_CalcHash(const char *s); uint32_t sym_CalcHash(const char *s);
void sym_SetExportAll(uint8_t set); void sym_SetExportAll(uint8_t set);
void sym_AddLocalReloc(char const *tzSym); void sym_AddLocalReloc(char const *tzSym);

View File

@@ -442,7 +442,7 @@ void rpn_BinaryOp(enum RPNCommand op, struct Expression *expr,
struct sSymbol const *symbol1 = symbolOf(src1); struct sSymbol const *symbol1 = symbolOf(src1);
struct sSymbol const *symbol2 = symbolOf(src2); struct sSymbol const *symbol2 = symbolOf(src2);
expr->nVal = symbol1->nValue - symbol2->nValue; expr->nVal = sym_GetValue(symbol1) - sym_GetValue(symbol2);
expr->isKnown = true; expr->isKnown = true;
} else { } else {
/* If it's not known, start computing the RPN expression */ /* If it's not known, start computing the RPN expression */

View File

@@ -72,7 +72,7 @@ static int32_t CallbackPC(struct sSymbol const *self)
/* /*
* Get the nValue field of a symbol * Get the nValue field of a symbol
*/ */
static int32_t getvaluefield(struct sSymbol const *sym) int32_t sym_GetValue(struct sSymbol const *sym)
{ {
if (sym->Callback) if (sym->Callback)
return sym->Callback(sym); return sym->Callback(sym);
@@ -268,11 +268,11 @@ uint32_t sym_GetConstantValue(char const *s)
if (pCurrentSection->nOrg == -1) if (pCurrentSection->nOrg == -1)
yyerror("Expected constant PC but section is not fixed"); yyerror("Expected constant PC but section is not fixed");
else else
return getvaluefield(psym); return sym_GetValue(psym);
} else if (psym != NULL) { } else if (psym != NULL) {
if (sym_IsConstant(psym)) if (sym_IsConstant(psym))
return getvaluefield(psym); return sym_GetValue(psym);
fatalerror("\"%s\" does not have a constant value", s); fatalerror("\"%s\" does not have a constant value", s);
} }
@@ -294,7 +294,7 @@ uint32_t sym_GetDefinedValue(char const *s)
if (!sym_IsNumeric(psym)) if (!sym_IsNumeric(psym))
yyerror("'%s' is a macro or string symbol", s); yyerror("'%s' is a macro or string symbol", s);
return getvaluefield(psym); return sym_GetValue(psym);
} }
} }