Clean up the weak data fakematches to be slightly closer to the real code

This commit is contained in:
LagoLunatic 2024-11-20 16:38:29 -05:00
parent ba31450171
commit 3bdcd42944
23 changed files with 61 additions and 38 deletions

View File

@ -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 */

View File

@ -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 */

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -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 {

View File

@ -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[] = {

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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";

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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] = {

View File

@ -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 {
};

View File

@ -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;

View File

@ -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) {

View File

@ -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() {

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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;