In order to correctly link a program which uses libc functions
a few sections are required to satisfy the linker.
This currently adds 0x3C bytes to IWRAM.
When actually utilizing functions from libc, linking will fail
because the functions used from libc have to be defined after libc.
This is the case with libgcc, so we swap their order.
Before, when compiling MultiBootWaitCycles with O3 and MODERN=1, you
might have run into problems during optimizations when the compiler tried
to optimize the function, even if declared NOINLINE.
When rewriting this function as NAKED function, this no longer happens
as the optimizer will treat it as black box and compilation will resume.
Previously, aggressive loop optimizations with a new compiler were not
possible due to undefined behaviour at end of arrays.
A macro "UBFIX" is added to allow ifdefs for fixes which resolve
undefined behavior. For example newer GCC versions will detect various
bugs in the original game code and will otherwise not compile with -Werror.
gcc has this nice option "-print-file-name=" to locate a file
in its search path. This is a more portable way to locate
libgcc.a and libc.a so there is no longer the need to mess around with
devkitARM's path's.
This problem is only going to occur in versions where the palette
buffer isn't aligned to 4 bytes (which it is in a matching pokeemerald).
Since agbcc returns sizeof(PlttData) = 4, it will read words
instead of half words. This causes unnecessary emulator warnings
in the function "BlendPalette".
Aligning the buffers to 4 bytes fixes this.