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:
AntonioND
2017-04-02 00:18:19 +01:00
parent f0d4750ebc
commit adef2e18cc
3 changed files with 7 additions and 3 deletions

View File

@@ -42,6 +42,6 @@ int
IsSectionSameTypeBankAndFloating(const char *name, enum eSectionType type, int bank); IsSectionSameTypeBankAndFloating(const char *name, enum eSectionType type, int bank);
unsigned int unsigned int
AssignSectionAddressByName(const char *name, unsigned int address); AssignSectionAddressAndBankByName(const char *name, unsigned int address, int bank);
#endif #endif

View File

@@ -244,7 +244,7 @@ IsSectionSameTypeBankAndFloating(const char *name, enum eSectionType type, int b
} }
unsigned int unsigned int
AssignSectionAddressByName(const char *name, unsigned int address) AssignSectionAddressAndBankByName(const char *name, unsigned int address, int bank)
{ {
struct sSection *pSection; struct sSection *pSection;
@@ -254,7 +254,10 @@ AssignSectionAddressByName(const char *name, unsigned int address)
if (strcmp(pSection->pzName, name) == 0) { if (strcmp(pSection->pzName, name) == 0) {
if (pSection->nOrg != -1 || pSection->nAlign != 1) if (pSection->nOrg != -1 || pSection->nAlign != 1)
errx(1, "Section \"%s\" from linkerscript isn't floating.\n", name); 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->nOrg = address;
pSection->nBank = bank;
pSection->nAlign = -1; pSection->nAlign = -1;
return pSection->nByteSize; return pSection->nByteSize;
} }

View File

@@ -213,6 +213,7 @@ void script_OutputSection(const char *section_name)
/* Move section to its place. */ /* Move section to its place. */
bank[current_bank].address += bank[current_bank].address +=
AssignSectionAddressByName(section_name, bank[current_bank].address); AssignSectionAddressAndBankByName(section_name,
bank[current_bank].address, current_real_bank);
} }