mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Fix bank assignments from linkerscript
Even though the bank number was read from the linkerscript and the linker verified that each section could be mapped in the final rom, the bank number was never actually set by the linkerscript parser. Signed-off-by: AntonioND <antonio_nd@outlook.com>
This commit is contained in:
@@ -42,6 +42,6 @@ int
|
||||
IsSectionSameTypeBankAndFloating(const char *name, enum eSectionType type, int bank);
|
||||
|
||||
unsigned int
|
||||
AssignSectionAddressByName(const char *name, unsigned int address);
|
||||
AssignSectionAddressAndBankByName(const char *name, unsigned int address, int bank);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -244,7 +244,7 @@ IsSectionSameTypeBankAndFloating(const char *name, enum eSectionType type, int b
|
||||
}
|
||||
|
||||
unsigned int
|
||||
AssignSectionAddressByName(const char *name, unsigned int address)
|
||||
AssignSectionAddressAndBankByName(const char *name, unsigned int address, int bank)
|
||||
{
|
||||
struct sSection *pSection;
|
||||
|
||||
@@ -254,7 +254,10 @@ AssignSectionAddressByName(const char *name, unsigned int address)
|
||||
if (strcmp(pSection->pzName, name) == 0) {
|
||||
if (pSection->nOrg != -1 || pSection->nAlign != 1)
|
||||
errx(1, "Section \"%s\" from linkerscript isn't floating.\n", name);
|
||||
if (pSection->nBank != -1 && pSection->nBank != bank)
|
||||
errx(1, "Section \"%s\" from linkerscript has different bank number than in the source.\n", name);
|
||||
pSection->nOrg = address;
|
||||
pSection->nBank = bank;
|
||||
pSection->nAlign = -1;
|
||||
return pSection->nByteSize;
|
||||
}
|
||||
|
||||
@@ -213,6 +213,7 @@ void script_OutputSection(const char *section_name)
|
||||
|
||||
/* Move section to its place. */
|
||||
bank[current_bank].address +=
|
||||
AssignSectionAddressByName(section_name, bank[current_bank].address);
|
||||
AssignSectionAddressAndBankByName(section_name,
|
||||
bank[current_bank].address, current_real_bank);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user