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>
Previously, some instances of the number of banks for each section remained hardcoded. These have been replaced with BANK_COUNT_* constants.
As a side-effect, this could fix a theoretical bug when using BANK(label) when the label is in a high SRAM bank (≥ 4).
Deduplicates and generalises a lot of code in assign.c:
- Replace area_AllocAbs*AnyBank() with area_AllocAbsAnyBank() function
that accepts a section type parameter
- Replace area_Alloc*AnyBank() with area_AllocAnyBank()
- Replace FindLargest*() with FindLargestSection()
- Replace Assign*Sections() with AssignBankedSections()
- Add VerifyAndSetBank(), which enables bank checks (and addition with
BANK_*) to be centralised
- Refactor the initialisation of AssignSections(), removing some magic
numbers and only setting MaxAvail[i] once
- Overhaul the duplicated cases throughout AssignSections()
Merging lai's source with this one is very irritating because
they have different indentation styles. I couldn't find what profile
vegard used for his version, so I used these flags (which should bring
the source close to KNF):
-bap
-br
-ce
-ci4
-cli0
-d0
-di0
-i8
-ip
-l79
-nbc
-ncdb
-ndj
-ei
-nfc1
-nlp
-npcs
-psl
-sc
-sob