From adef2e18cc8b269723109e1a316246e6a2e21513 Mon Sep 17 00:00:00 2001 From: AntonioND Date: Sun, 2 Apr 2017 00:18:19 +0100 Subject: [PATCH] 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 --- include/link/assign.h | 2 +- src/link/assign.c | 5 ++++- src/link/script.c | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/link/assign.h b/include/link/assign.h index 1dab916a..a8e8f409 100644 --- a/include/link/assign.h +++ b/include/link/assign.h @@ -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 diff --git a/src/link/assign.c b/src/link/assign.c index 00829b9e..f3ff0f5e 100644 --- a/src/link/assign.c +++ b/src/link/assign.c @@ -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; } diff --git a/src/link/script.c b/src/link/script.c index 32d6da4f..fb73c92c 100644 --- a/src/link/script.c +++ b/src/link/script.c @@ -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); }