ref: adef2e18cc8b269723109e1a316246e6a2e21513
parent: f0d4750ebc4d3fc5c6c0a2f36d14b59e8dd2d3fa
author: AntonioND <[email protected]>
date: Sat Apr 1 20:18:19 EDT 2017
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 <[email protected]>
--- a/include/link/assign.h
+++ b/include/link/assign.h
@@ -42,6 +42,6 @@
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
--- a/src/link/assign.c
+++ b/src/link/assign.c
@@ -244,7 +244,7 @@
}
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 @@
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;
}
--- a/src/link/script.c
+++ b/src/link/script.c
@@ -213,6 +213,7 @@
/* 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);
}