shithub: rgbds

Download patch

ref: f01a227470c9fa8eb89b272190533e8ac3b7814f
parent: 91b65c9380bcfadc96a1fab304f0a55a53d65e75
author: ISSOtm <[email protected]>
date: Thu Feb 13 15:12:19 EST 2020

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.

--- a/include/asm/symbol.h
+++ b/include/asm/symbol.h
@@ -70,6 +70,7 @@
 	return sym->isExported;
 }
 
+int32_t sym_GetValue(struct sSymbol const *sym);
 uint32_t sym_CalcHash(const char *s);
 void sym_SetExportAll(uint8_t set);
 void sym_AddLocalReloc(char const *tzSym);
--- a/src/asm/rpn.c
+++ b/src/asm/rpn.c
@@ -442,7 +442,7 @@
 		struct sSymbol const *symbol1 = symbolOf(src1);
 		struct sSymbol const *symbol2 = symbolOf(src2);
 
-		expr->nVal = symbol1->nValue - symbol2->nValue;
+		expr->nVal = sym_GetValue(symbol1) - sym_GetValue(symbol2);
 		expr->isKnown = true;
 	} else {
 		/* If it's not known, start computing the RPN expression */
--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -72,7 +72,7 @@
 /*
  * 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)
 		return sym->Callback(sym);
@@ -268,11 +268,11 @@
 		if (pCurrentSection->nOrg == -1)
 			yyerror("Expected constant PC but section is not fixed");
 		else
-			return getvaluefield(psym);
+			return sym_GetValue(psym);
 
 	} else if (psym != NULL) {
 		if (sym_IsConstant(psym))
-			return getvaluefield(psym);
+			return sym_GetValue(psym);
 
 		fatalerror("\"%s\" does not have a constant value", s);
 	}
@@ -294,7 +294,7 @@
 			if (!sym_IsNumeric(psym))
 				yyerror("'%s' is a macro or string symbol", s);
 
-			return getvaluefield(psym);
+			return sym_GetValue(psym);
 		}
 	}