diff --git a/include/gba/defines.h b/include/gba/defines.h index fe775820d8..481f203052 100644 --- a/include/gba/defines.h +++ b/include/gba/defines.h @@ -13,6 +13,7 @@ #define COMMON_DATA __attribute__((section("common_data"))) #define UNUSED __attribute__((unused)) #define USED __attribute__((used)) +#define KEEP_SECTION __attribute__((section(".text.consts"))) #define ARM_FUNC __attribute__((target("arm"))) diff --git a/ld_script_modern.ld b/ld_script_modern.ld index f021ac2916..47989bd91f 100644 --- a/ld_script_modern.ld +++ b/ld_script_modern.ld @@ -54,14 +54,15 @@ SECTIONS { ALIGN(4) { src/rom_header.o(.text*); - src/rom_header_gf.o(.text.*); - src/rom_header_rhh.o(.text.*); + KEEP(*.o(.text.header_gf)); + KEEP(*.o(.text.header_rhh)); src/crt0.o(.text); *libagbsyscall.a:*.o(.text*); *libgcc.a:*.o(.text*); *libc.a:*.o(.text*); *libnosys.a:*.o(.text*); asm/*.o(.text*); + KEEP(*.o(.text.consts)); *.o(.text*); *.o(.eh_frame); } > ROM =0 diff --git a/ld_script_test.ld b/ld_script_test.ld index d279d6b4f6..e1c21bcfbc 100644 --- a/ld_script_test.ld +++ b/ld_script_test.ld @@ -75,8 +75,9 @@ SECTIONS { ALIGN(4) { src/rom_header.o(.text); - src/rom_header_gf.o(.text.*); - src/rom_header_rhh.o(.text.*); + KEEP(*.o(.text.header_gf)); + KEEP(*.o(.text.header_rhh)); + KEEP(*.o(.text.consts)); src/*.o(.text); } > ROM =0 diff --git a/src/agb_flash_1m.c b/src/agb_flash_1m.c index 49696a7bbf..3e2ad719c6 100644 --- a/src/agb_flash_1m.c +++ b/src/agb_flash_1m.c @@ -1,7 +1,7 @@ #include "gba/gba.h" #include "gba/flash_internal.h" -USED static const char AgbLibFlashVersion[] = "FLASH1M_V103"; +KEEP_SECTION USED static const char AgbLibFlashVersion[] = "FLASH1M_V103"; static const struct FlashSetupInfo *const sSetupInfos[] = { diff --git a/src/rom_header.s b/src/rom_header.s index 5ced627a39..eed3c53c63 100644 --- a/src/rom_header.s +++ b/src/rom_header.s @@ -7,34 +7,34 @@ Start:: RomHeaderNintendoLogo:: .space 156 -RomHeaderGameTitle: +RomHeaderGameTitle:: .space 12 RomHeaderGameCode:: .space 4 -RomHeaderMakerCode: +RomHeaderMakerCode:: .space 2 -RomHeaderMagic: +RomHeaderMagic:: .byte 0 -RomHeaderMainUnitCode: +RomHeaderMainUnitCode:: .byte 0 -RomHeaderDeviceType: +RomHeaderDeviceType:: .byte 0 -RomHeaderReserved1: +RomHeaderReserved1:: .space 7 RomHeaderSoftwareVersion:: .byte 0 -RomHeaderChecksum: +RomHeaderChecksum:: .byte 0 -RomHeaderReserved2: +RomHeaderReserved2:: .space 2 .word 0 diff --git a/src/rom_header_gf.c b/src/rom_header_gf.c index 5613fe6152..1662850352 100644 --- a/src/rom_header_gf.c +++ b/src/rom_header_gf.c @@ -97,9 +97,8 @@ struct GFRomHeader }; // This seems to need to be in the text section for some reason. -// To avoid a changed section attributes warning it's put in a special .text.consts section. -__attribute__((section(".text.consts"))) -USED static const struct GFRomHeader sGFRomHeader = { +// To avoid a changed section attributes warning it's put in a special .text.header_gf section. +__attribute__((section(".text.header_gf"))) USED static const struct GFRomHeader sGFRomHeader = { .version = GAME_VERSION, .language = GAME_LANGUAGE, .gameName = "pokemon emerald version", diff --git a/src/rom_header_rhh.c b/src/rom_header_rhh.c index e9310415c3..9a97948e8a 100644 --- a/src/rom_header_rhh.c +++ b/src/rom_header_rhh.c @@ -27,8 +27,7 @@ struct RHHRomHeader /*0x17*/ u8 padding; }; -__attribute__((section(".text.consts"))) -USED static const struct RHHRomHeader sRHHRomHeader = +__attribute__((section(".text.header_rhh"))) USED static const struct RHHRomHeader sRHHRomHeader = { .rhh_magic = { 'R', 'H', 'H', 'E', 'X', 'P' }, .expansionVersionMajor = EXPANSION_VERSION_MAJOR, diff --git a/src/siirtc.c b/src/siirtc.c index 5c511f6815..ecce71a03c 100644 --- a/src/siirtc.c +++ b/src/siirtc.c @@ -75,7 +75,7 @@ static u8 ReadData(); static void EnableGpioPortRead(); static void DisableGpioPortRead(); -USED static const char AgbLibRtcVersion[] = "SIIRTC_V001"; +KEEP_SECTION USED static const char AgbLibRtcVersion[] = "SIIRTC_V001"; void SiiRtcUnprotect(void) {