mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Make BANK("Section") known at assembling time when possible
If the target section is in the current file and its bank is known, this means this value is known prior to linking.
This commit is contained in:
@@ -182,17 +182,25 @@ void rpn_BankSymbol(struct Expression *expr, char *tzSym)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sym_isConstant(tzSym)) {
|
if (sym_isConstant(tzSym)) {
|
||||||
|
yyerror("BANK argument must be a relocatable identifier");
|
||||||
|
} else {
|
||||||
rpn_Init(expr);
|
rpn_Init(expr);
|
||||||
sym_Ref(tzSym);
|
sym_Ref(tzSym);
|
||||||
expr->isReloc = 1;
|
|
||||||
pushbyte(expr, RPN_BANK_SYM);
|
pushbyte(expr, RPN_BANK_SYM);
|
||||||
while (*tzSym)
|
for (unsigned int i = 0; tzSym[i]; i++)
|
||||||
pushbyte(expr, *tzSym++);
|
pushbyte(expr, tzSym[i]);
|
||||||
pushbyte(expr, 0);
|
pushbyte(expr, 0);
|
||||||
expr->nRPNPatchSize += 5;
|
expr->nRPNPatchSize += 5;
|
||||||
} else {
|
|
||||||
yyerror("BANK argument must be a relocatable identifier");
|
/* If the symbol didn't exist, `sym_Ref` created it */
|
||||||
|
struct sSymbol *pSymbol = sym_FindSymbol(tzSym);
|
||||||
|
|
||||||
|
if (pSymbol->pSection && pSymbol->pSection->nBank != -1)
|
||||||
|
/* Symbol's section is known and bank's fixed */
|
||||||
|
expr->nVal = pSymbol->pSection->nBank;
|
||||||
|
else
|
||||||
|
expr->isReloc = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,11 +208,16 @@ void rpn_BankSection(struct Expression *expr, char *tzSectionName)
|
|||||||
{
|
{
|
||||||
rpn_Init(expr);
|
rpn_Init(expr);
|
||||||
|
|
||||||
/*
|
struct Section *pSection = out_FindSectionByName(tzSectionName);
|
||||||
* This symbol is not really relocatable, but this makes the assembler
|
|
||||||
* write this expression as a RPN patch to the object file.
|
if (pSection && pSection->nBank != -1)
|
||||||
*/
|
expr->nVal = pSection->nBank;
|
||||||
expr->isReloc = 1;
|
else
|
||||||
|
/*
|
||||||
|
* This is not really relocatable, but this makes the assembler
|
||||||
|
* write this expression as a RPN patch to the object file.
|
||||||
|
*/
|
||||||
|
expr->isReloc = 1;
|
||||||
|
|
||||||
pushbyte(expr, RPN_BANK_SECT);
|
pushbyte(expr, RPN_BANK_SECT);
|
||||||
expr->nRPNPatchSize++;
|
expr->nRPNPatchSize++;
|
||||||
|
|||||||
Reference in New Issue
Block a user