Not sure if this is worth it, but did some research into it. Have tried to build with a modern arm cross compiler and found some global changes that needs coordination:
- Rename all files to lowercase, to build on case insensitive filesystem
- Change one file with backslash in
#include "extra\..."
- Change a call to
strcmpi() to strcasecmp() (or somehow provide strcmpi on systems without it)
After the above source fixes, it should still build on all targets like before, but fails to link with modern tools. It's possible to force the link, but then produces a binary of ~160kb (GBAGI supports max 128k).
The linker error messages point at issues in lnkscript and crt0.s, presumably they need to support newer compiler features from the last 20 years, and/or workarounds for bugs in the "ld" program that parses the lnkscript. I tried some stuff directly in the repo, but failed and have moved on to testing in a local Debian instead.
These files have a long history and exists in many versions with subtle differences. There appears to be two major branches of the lnkscript and crt0 for GBA, which also leaves two possible ways forward:
Jeff Frohweins versions
The GBAGI repo uses an older version of Jeff Frohweins lnkscript and crt0. Not maintained by the original author anymore, not anywhere centrally at least.
The main benefit of these are they support interrupts, but the drawback is they don't work as-is :). It's almost as if the SIZEOF() function in ld is broken causing overlapping sections when the code goes above a certain size. The original dev also commented on this issue in the version pulled from his site, with commented remnants from different attempts at workarounds for it - tho the problems appear to have worsened over time:
/* The linker script function "var1 += var2;" sometimes */
/* reports incorrect values in the *.map file but the */
/* actual value it calculates is usually, if not always, */
/* correct. If you leave out the ". = ALIGN(4);" at the */
/* end of each section then the return value of SIZEOF() */
/* is sometimes incorrect and "var1 += var2;" appears to */
/* not work as well. "var1 += var2" style functions are */
/* avoided below as a result. */
(Note, the above comment only mentions issues with +=, but my results indicate same issue with plain assignments and adding)
Potential tasks:
- Figure out why SIZEOF() seems to return wrong values, rewrite how the target addresses are computed
- (I did some hacking, was able to link successfully after extending a section with 32 bytes, but it seemed very random and didn't make sense)
DevKitPro's versions
DevKitPro's linkscript is based on but entirely rewritten from Frohweins version, crt0 looks to be completely different, much smaller and no longer supports interrupts. These are still actively maintained.
I've been able to link with the DevKitPro's gba_mb.ld and crt0 (=multiboot lnkscript) without errors, but not tested yet. It looks like interrupts are defered to an external library: https://github.com/devkitPro/libgba
Potential tasks:
- Pull in libgba, implement interrupts in the GBAGI code
- Deal with the unknown unknowns
Not sure if this is worth it, but did some research into it. Have tried to build with a modern arm cross compiler and found some global changes that needs coordination:
#include "extra\..."strcmpi()tostrcasecmp()(or somehow provide strcmpi on systems without it)After the above source fixes, it should still build on all targets like before, but fails to link with modern tools. It's possible to force the link, but then produces a binary of ~160kb (GBAGI supports max 128k).
The linker error messages point at issues in lnkscript and crt0.s, presumably they need to support newer compiler features from the last 20 years, and/or workarounds for bugs in the "ld" program that parses the lnkscript. I tried some stuff directly in the repo, but failed and have moved on to testing in a local Debian instead.
These files have a long history and exists in many versions with subtle differences. There appears to be two major branches of the lnkscript and crt0 for GBA, which also leaves two possible ways forward:
Jeff Frohweins versions
The GBAGI repo uses an older version of Jeff Frohweins lnkscript and crt0. Not maintained by the original author anymore, not anywhere centrally at least.
The main benefit of these are they support interrupts, but the drawback is they don't work as-is :). It's almost as if the SIZEOF() function in ld is broken causing overlapping sections when the code goes above a certain size. The original dev also commented on this issue in the version pulled from his site, with commented remnants from different attempts at workarounds for it - tho the problems appear to have worsened over time:
(Note, the above comment only mentions issues with
+=, but my results indicate same issue with plain assignments and adding)Potential tasks:
DevKitPro's versions
DevKitPro's linkscript is based on but entirely rewritten from Frohweins version, crt0 looks to be completely different, much smaller and no longer supports interrupts. These are still actively maintained.
I've been able to link with the DevKitPro's gba_mb.ld and crt0 (=multiboot lnkscript) without errors, but not tested yet. It looks like interrupts are defered to an external library: https://github.com/devkitPro/libgba
Potential tasks: