From 136ea395acf53e44ca3577b70cd6a34ab32164fd Mon Sep 17 00:00:00 2001 From: DizzyEggg Date: Tue, 19 Sep 2023 12:15:03 +0200 Subject: [PATCH] Fix tests breaking on modern (#3319) * Fix tests breaking on modern * modern tests fix - macro and rodata changes * ld script rodata modern --- include/test/battle.h | 3 ++- ld_script_test.txt | 8 ++++---- test/battle/move_effect/stockpile.c | 1 - 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/test/battle.h b/include/test/battle.h index 7bffd10a6..e1b00efbd 100644 --- a/include/test/battle.h +++ b/include/test/battle.h @@ -837,7 +837,8 @@ void SendOut(u32 sourceLine, struct BattlePokemon *, u32 partyIndex); #define ABILITY_POPUP(battler, ...) QueueAbility(__LINE__, battler, (struct AbilityEventContext) { __VA_ARGS__ }) #define ANIMATION(type, id, ...) QueueAnimation(__LINE__, type, id, (struct AnimationEventContext) { __VA_ARGS__ }) #define HP_BAR(battler, ...) QueueHP(__LINE__, battler, (struct HPEventContext) { APPEND_TRUE(__VA_ARGS__) }) -#define MESSAGE(pattern) QueueMessage(__LINE__, (const u8 []) _(pattern)) +// Static const is needed to make the modern compiler put the pattern variable in the .rodata section, instead of putting it on stack(which can break the game). +#define MESSAGE(pattern) do {static const u8 msg[] = _(pattern); QueueMessage(__LINE__, msg);} while (0) #define STATUS_ICON(battler, status) QueueStatus(__LINE__, battler, (struct StatusEventContext) { status }) enum QueueGroupType diff --git a/ld_script_test.txt b/ld_script_test.txt index f7a74e086..f4abad98a 100644 --- a/ld_script_test.txt +++ b/ld_script_test.txt @@ -84,9 +84,9 @@ SECTIONS { .rodata : ALIGN(4) { - src/*.o(.rodata); - gflib/*.o(.rodata); - data/*.o(.rodata); + src/*.o(.rodata*); + gflib/*.o(.rodata*); + data/*.o(.rodata*); } =0 song_data : @@ -111,7 +111,7 @@ SECTIONS { test/*.o(.tests); __stop_tests = .; test/*.o(.text); - test/*.o(.rodata); + test/*.o(.rodata*); } =0 /* DWARF debug sections. diff --git a/test/battle/move_effect/stockpile.c b/test/battle/move_effect/stockpile.c index 0e540bb5d..e5f108a16 100644 --- a/test/battle/move_effect/stockpile.c +++ b/test/battle/move_effect/stockpile.c @@ -250,4 +250,3 @@ DOUBLE_BATTLE_TEST("Stockpile's Def and Sp. Def boost is lost after using Spit U EXPECT_MUL_EQ(results[2].dmgSpecialBefore, UQ_4_12(1.0), results[2].dmgSpecialAfter); } } -