Print the name of each section along with the size, base and end
addresses. If a section is empty, don't print the end address, as it
can overflow if the base address is 0.
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).
Yay, more refactoring of the section assignment… This version of the linker will allocate sections by their alignment, and then by their size (largest first, in both cases).
In future, this may be improved by using dense packing (as suggested by #83).
Aligned sections can now be created with out_NewAlignedSection(). This information is stored in created object files, and read by the linker.
The names of each section are also included in the object file, enabling potential improvements to error messages in the future.
Instead of reading into a pre-sized buffer, this function now uses malloc to create a buffer, and resizes it if necessary.
This reduces the risk of memory issues if a long string (< 255 chars) was encountered.
Ensure that IF constructs, REPT blocks, and MACRO defintions are terminated with ENDC, ENDR, or ENDM respectively. If they are not, print an error and stop assembly.
As well as aiding a forgetful programmer, this reduces the risk of memory problems if the file ends less than four bytes after the block starts.
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()
Previously, the copyrept() and copymacro() functions would halt their
first loop (in which they determine the length of the block)
prematurely, causing an underflow when setting len, eventually causing
memory issues.
Whilst this doesn’t solve the len underflow entirely (e.g. if the file
ends immediately without an ENDR/ENDM), it should help with this exact
scenario of null bytes (as #50).
Previously, if BANK is used when defining a section that’s not ROMX,
WRMAX, SRAM or VRAM, a second error message would appear, e.g. “(null)
bank value $1 out of range $5d to $0”.
This would appear due to the usage of uninitialised variables. This
change ensures that the uninitialised variables are not accessed when
using an invalid section.
This also silences compiler warnings about usage of uninitialised
variables.
GNU make actually looks for ‘GNUmakefile’, not ‘GNUMakefile’.
Consequently, GNU make would erroneously attempt to use the standard
makefile, instead of the GNU-specific one. This would cause an error
when attempting to import png.h, due to PNGFLAGS not being correctly
set.
Increase number of include paths that can be passed through the
command line interface. The previous number, 16, is only good enough
for small projects. 128 is still an arbitrary number, but it is harder
to reach.