diff --git a/include/weak_data_1811.h b/include/weak_data_1811.h index 845a8007c..611df4bd8 100644 --- a/include/weak_data_1811.h +++ b/include/weak_data_1811.h @@ -2,22 +2,35 @@ #define WEAK_DATA_1811_H // Fake header. + +#include "dolphin/gx/GXEnum.h" +#include "weak_data_2100_2080.h" // IWYU pragma: keep + // @1811 is a weak object that gets included in the .data sections of several TUs. // Its true source is this line: // u8 attnFnTbl[] = { GX_AF_NONE, GX_AF_SPEC, GX_AF_NONE, GX_AF_SPOT }; // Which appears in the weak function J3DColorChan::getAttnFn, which is supposed to go in a header. -// But for some reason, that line causes the weak objects to appear in .rodata. +// But that line causes the weak object to appear in .rodata, while this weak object need to be in .data. // So for now, that function is moved to the .cpp file, and TUs that need this object should include this header. -#include "weak_data_2100_2080.h" // IWYU pragma: keep +static inline void fake_getAttnFn() { + // Value is equivalent to: {0x02, 0x00, 0x02, 0x01} + static u8 attnFnTbl_1811[] = { GX_AF_NONE, GX_AF_SPEC, GX_AF_NONE, GX_AF_SPOT }; +} -static u8 data_1811[] = {0x02, 0x00, 0x02, 0x01}; +// These two weak objects are strange, as they have no symbols associated with them. +// They always seems to come after @1811 ends at offset 0x1C, getting padded to start at 0x20 and ending at 0x30. +// These are likely the 3.0 and .5 double literals from std::sqrtf. +// But those literals get placed in .rodata, while these weak objects need to be in .data. +// Also, the order of these two literals is reversed. std::sqrtf has _half before _three. +// static f64 data_no_symbol_3_5[2] = {3.0, 0.5}; -// This object is strange, as it has no symbol associated with it. -// It always seems to come after @1811 ends at offset 0x1C, getting padded to start at 0x20 and ending at 0x30. -// It being an array of two doubles is guessed based on how it looks and its apparently 0x8 byte alignment. -// Its actual purpose is unknown since it's never used. -// Could this be somehow related to the two double constants in std::sqrtf? -static f64 data_no_symbol_3_5[2] = {3.0, 0.5}; +extern inline void fake_sqrtf(float x) { + static double _three[1] = {3.0}; + static double _half[1] = {.5}; +} + +// Note: These weak objects get stripped out for main.dol, because all three of them are within the +// 8-byte limit for .sdata. They do not get stripped out in RELs. #endif /* WEAK_DATA_1811_H */ diff --git a/include/weak_data_2100_2080.h b/include/weak_data_2100_2080.h index f66af5afb..578f1ef30 100644 --- a/include/weak_data_2100_2080.h +++ b/include/weak_data_2100_2080.h @@ -2,16 +2,26 @@ #define WEAK_DATA_2100_2080_H // Fake header. -// These are weak objects that get included in the .data sections of several TUs. -// Their true source is likely this line of code that appears twice in J3DJoint.h: -// J3DSys::mParentS = (Vec){1.0f, 1.0f, 1.0f}; -// But for some reason, that line causes the weak objects to appear in .rodata. -// So for now, the line is commented out, and TUs that need these objects should include this header. -// Note: For d_snap and J3DUClipper, these objects *are* supposed to appear in .rodata, but those are the only ones. #include "dolphin/mtx/vec.h" -static Vec data_2100 = {1.0f, 1.0f, 1.0f}; -static Vec data_2080 = {1.0f, 1.0f, 1.0f}; +// @2100 and @2080 are weak objects that get included in the .data sections of several TUs. +// Their true source is likely this line of code that appears twice in J3DJoint.h: +// J3DSys::mParentS = (Vec){1.0f, 1.0f, 1.0f}; +// But that line causes the weak objects to appear in .rodata, while this weak object need to be in .data. +// So for now, the line is commented out, and TUs that need these objects should include this header. +// Note: For d_snap and J3DUClipper, these objects *are* supposed to appear in .rodata, but those are the only ones. +// Also, d_snap and J3DUClipper seem to be the only ones where the two symbols are in order by the compiler-generated +// names. In TUs where they appear in .data instead, their order is reversed (@2100 coming before @2080). + +static inline void fake_data_2100() { + // Value is equivalent to: {0x3F800000, 0x3F800000, 0x3F800000} + static Vec data_2100 = {1.0f, 1.0f, 1.0f}; +} + +static inline void fake_data_2080() { + // Value is equivalent to: {0x3F800000, 0x3F800000, 0x3F800000} + static Vec data_2080 = {1.0f, 1.0f, 1.0f}; +} #endif /* WEAK_DATA_2100_2080_H */ diff --git a/src/d/actor/d_a_agb.cpp b/src/d/actor/d_a_agb.cpp index 47e3d2858..5ed12678f 100644 --- a/src/d/actor/d_a_agb.cpp +++ b/src/d/actor/d_a_agb.cpp @@ -25,7 +25,7 @@ #include "stdio.h" #include "weak_bss_3569.h" // IWYU pragma: keep -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep static mDoDvdThd_toMainRam_c* l_gbaCommand; diff --git a/src/d/actor/d_a_arrow.cpp b/src/d/actor/d_a_arrow.cpp index 71a965064..147bab1f9 100644 --- a/src/d/actor/d_a_arrow.cpp +++ b/src/d/actor/d_a_arrow.cpp @@ -23,7 +23,7 @@ u32 daPy_py_c::checkPlayerFly() const { return 0; } #include "d/d_s_play.h" #include "d/res/res_link.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep s16 daArrow_c::m_count; diff --git a/src/d/actor/d_a_bomb2.cpp b/src/d/actor/d_a_bomb2.cpp index 7e2fb2ead..0cdc27b29 100644 --- a/src/d/actor/d_a_bomb2.cpp +++ b/src/d/actor/d_a_bomb2.cpp @@ -14,7 +14,7 @@ #include "f_op/f_op_kankyo_mng.h" #include "m_Do/m_Do_mtx.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep namespace daBomb2 { namespace { diff --git a/src/d/actor/d_a_bomb3.inc b/src/d/actor/d_a_bomb3.inc index e49f1ab5c..e8f507ae5 100644 --- a/src/d/actor/d_a_bomb3.inc +++ b/src/d/actor/d_a_bomb3.inc @@ -15,7 +15,7 @@ #include "m_Do/m_Do_lib.h" #include "d/res/res_vbakh.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep namespace { enum AttrSt_e { diff --git a/src/d/actor/d_a_dai_item.cpp b/src/d/actor/d_a_dai_item.cpp index b4ea9290f..3bb6a9ee5 100644 --- a/src/d/actor/d_a_dai_item.cpp +++ b/src/d/actor/d_a_dai_item.cpp @@ -13,7 +13,7 @@ #include "f_op/f_op_actor.h" #include "weak_bss_3569.h" // IWYU pragma: keep -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep const char daStandItem_c::m_arcname[] = "Fdai"; const s16 daStandItem_c::m_bmdidx[] = { diff --git a/src/d/actor/d_a_hookshot.cpp b/src/d/actor/d_a_hookshot.cpp index 2b67e7c9a..b1501b273 100644 --- a/src/d/actor/d_a_hookshot.cpp +++ b/src/d/actor/d_a_hookshot.cpp @@ -10,7 +10,7 @@ #include "d/actor/d_a_player_main.h" #include "d/d_procname.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep #include "assets/l_chainS3TCTEX__d_hookshot.h" const u16 l_chainS3TCTEX__width = 32; diff --git a/src/d/actor/d_a_ib.cpp b/src/d/actor/d_a_ib.cpp index d22e9631c..c1d0ee2cc 100644 --- a/src/d/actor/d_a_ib.cpp +++ b/src/d/actor/d_a_ib.cpp @@ -14,7 +14,7 @@ #include "global.h" #include "m_Do/m_Do_mtx.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep struct daIball_c__data { /* 0x00 */ u8 m00; diff --git a/src/d/actor/d_a_item.cpp b/src/d/actor/d_a_item.cpp index ba0a7a826..9ae45a89e 100644 --- a/src/d/actor/d_a_item.cpp +++ b/src/d/actor/d_a_item.cpp @@ -14,7 +14,7 @@ #include "m_Do/m_Do_mtx.h" #include "m_Do/m_Do_controller_pad.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep s32 daItem_c::m_timer_max = 10000; diff --git a/src/d/actor/d_a_player_main_data.inc b/src/d/actor/d_a_player_main_data.inc index 2f8f9a615..5c7fb0a08 100644 --- a/src/d/actor/d_a_player_main_data.inc +++ b/src/d/actor/d_a_player_main_data.inc @@ -2,7 +2,7 @@ #include "d/actor/d_a_player_main.h" #include "d/actor/d_a_player_main_data.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep char l_arcName[] = "Link"; diff --git a/src/d/d_chain.cpp b/src/d/d_chain.cpp index a61e49892..7bccdc5a4 100644 --- a/src/d/d_chain.cpp +++ b/src/d/d_chain.cpp @@ -8,7 +8,7 @@ #include "d/d_s_play.h" #include "m_Do/m_Do_mtx.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep #include "assets/l_chainS3TCTEX__d_chain.h" const u16 l_chainS3TCTEX__width = 32; diff --git a/src/d/d_drawlist.cpp b/src/d/d_drawlist.cpp index 93257ef91..844b48128 100644 --- a/src/d/d_drawlist.cpp +++ b/src/d/d_drawlist.cpp @@ -41,7 +41,7 @@ public: GXTexObj dDlst_shadowControl_c::mSimpleTexObj; -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep /* 800804A4-800804C0 .text setViewPort__14dDlst_window_cFffffff */ void dDlst_window_c::setViewPort(f32 x, f32 y, f32 w, f32 h, f32 n, f32 f) { diff --git a/src/d/d_grass.cpp b/src/d/d_grass.cpp index 167bc6094..c90d8c168 100644 --- a/src/d/d_grass.cpp +++ b/src/d/d_grass.cpp @@ -18,7 +18,7 @@ #include "dolphin/gf/GFGeometry.h" #include "dolphin/gf/GFTev.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep #include "assets/l_K_kusa_00TEX.h" const u32 l_K_kusa_00TEX__width = 64; diff --git a/src/d/d_item_data.cpp b/src/d/d_item_data.cpp index 294d7fd6b..670de5e09 100644 --- a/src/d/d_item_data.cpp +++ b/src/d/d_item_data.cpp @@ -114,7 +114,7 @@ #include "d/res/res_vtin5.h" #include "d/res/res_vbeso.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep /* 80383F20-803840E0 .data item_arcname_tbl__10dItem_data */ char* dItem_data::item_arcname_tbl[0x70] = { diff --git a/src/d/d_kankyo.cpp b/src/d/d_kankyo.cpp index 32c8ee37c..4ea772e77 100644 --- a/src/d/d_kankyo.cpp +++ b/src/d/d_kankyo.cpp @@ -22,7 +22,7 @@ #include "m_Do/m_Do_printf.h" #include "math.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep class sub_kankyo__class : public kankyo_class { }; diff --git a/src/d/d_magma.cpp b/src/d/d_magma.cpp index 14a2e8446..487ab31e7 100644 --- a/src/d/d_magma.cpp +++ b/src/d/d_magma.cpp @@ -13,7 +13,7 @@ // #pragma sym on #include "weak_bss_3569.h" // IWYU pragma: keep -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep Mtx l_kuroOrthoMtx; Mtx l_colOrthoMtx; diff --git a/src/d/d_npc.cpp b/src/d/d_npc.cpp index 531189d81..fa0154461 100644 --- a/src/d/d_npc.cpp +++ b/src/d/d_npc.cpp @@ -12,7 +12,7 @@ #include "m_Do/m_Do_mtx.h" #include "d/d_item_data.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep /* 8021A7B4-8021A858 .text angCalcS__14dNpc_JntCtrl_cFPssss */ bool dNpc_JntCtrl_c::angCalcS(s16* out, s16 targetY, s16 speed, s16 maxVel) { diff --git a/src/d/d_particle.cpp b/src/d/d_particle.cpp index c72cf764a..1da76a0e1 100644 --- a/src/d/d_particle.cpp +++ b/src/d/d_particle.cpp @@ -24,7 +24,7 @@ #include "stdio.h" #include "weak_bss_3569.h" // IWYU pragma: keep -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep /* 8007A4D8-8007A514 .text __ct__18dPa_modelEmitter_cFv */ dPa_modelEmitter_c::dPa_modelEmitter_c() { diff --git a/src/d/d_s_name.cpp b/src/d/d_s_name.cpp index eedccd673..14deed751 100644 --- a/src/d/d_s_name.cpp +++ b/src/d/d_s_name.cpp @@ -31,7 +31,7 @@ #include "JSystem/J2DGraph/J2DScreen.h" #include "JSystem/JKernel/JKRExpHeap.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep dSn_HIO_c g_snHIO; diff --git a/src/d/d_tree.cpp b/src/d/d_tree.cpp index f61565e2f..d5d77414e 100644 --- a/src/d/d_tree.cpp +++ b/src/d/d_tree.cpp @@ -6,7 +6,7 @@ #include "d/d_tree.h" #include "dolphin/types.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep #include "assets/l_Txa_swood_aTEX.h" const u16 l_Txa_swood_aTEX__width = 64; diff --git a/src/d/d_wood.cpp b/src/d/d_wood.cpp index 2c54e43b0..8469e529c 100644 --- a/src/d/d_wood.cpp +++ b/src/d/d_wood.cpp @@ -24,7 +24,7 @@ #include "m_Do/m_Do_lib.h" #include "m_Do/m_Do_mtx.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep //----------------------------------------- // Types diff --git a/src/m_Do/m_Do_main.cpp b/src/m_Do/m_Do_main.cpp index 8fa32230c..ca27c4270 100644 --- a/src/m_Do/m_Do_main.cpp +++ b/src/m_Do/m_Do_main.cpp @@ -26,7 +26,7 @@ #include "m_Do/m_Do_machine.h" #include "m_Do/m_Do_printf.h" -#include "weak_data_2100_2080.h" // IWYU pragma: keep +#include "weak_data_1811.h" // IWYU pragma: keep class JUTGamePad;