From 353d31af7514ae29788414ea2411e1856b691495 Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Sun, 4 Oct 2026 21:41:31 -0500 Subject: [PATCH] fix(cdb): unify date helper signatures without code changes --- libs/RevoEX/include/private/cdb/CDBConv.h | 4 -- libs/RevoEX/include/revolution/cdb/CDBDate.h | 9 --- libs/RevoEX/src/cdb/CDBConv.c | 16 +++-- libs/RevoEX/src/cdb/CDBDatabase.c | 1 - .../decomp-assist/cdb-unify-arity.attempts.md | 67 +++++++++++++++++++ 5 files changed, 76 insertions(+), 21 deletions(-) create mode 100644 tools/decomp-assist/cdb-unify-arity.attempts.md diff --git a/libs/RevoEX/include/private/cdb/CDBConv.h b/libs/RevoEX/include/private/cdb/CDBConv.h index 8c73d818..27f1ba6a 100644 --- a/libs/RevoEX/include/private/cdb/CDBConv.h +++ b/libs/RevoEX/include/private/cdb/CDBConv.h @@ -34,11 +34,7 @@ void CDBConvTypeStrToFullPath(char* fullPath, char* yearStr, char* monthStr, cha void CDBConvFileNameStrToFullPath(char* fullPath, char* yearStr, char* monthStr, char* dayStr, char* hourStr, char* minuteStr, char* codeStr, char* typeStr, char* fileStr, CDBLocation location, u64* wiiId); -#ifdef CDB_DATABASE_IMPLEMENTATION CDBDate CDBConvDirStrToCDBDate(char* yearStr, char* monthStr, char* dayStr, char* hourStr, char* minuteStr); -#else -CDBDate CDBConvDirStrToCDBDate(char* yearStr, char* monthStr, char* dayStr, char* hourStr, char* minuteStr, CDBLocation location, u64* wiiId); -#endif void CDBConvGCStrToGCValue(char* gcStr, u32* gcValue); void CDBConvGCValueToGCStr(u32 gcValue, char* gcStr); diff --git a/libs/RevoEX/include/revolution/cdb/CDBDate.h b/libs/RevoEX/include/revolution/cdb/CDBDate.h index d23292eb..9e65ed83 100644 --- a/libs/RevoEX/include/revolution/cdb/CDBDate.h +++ b/libs/RevoEX/include/revolution/cdb/CDBDate.h @@ -13,21 +13,12 @@ void CDBClampCDBDate(CDBDate* cdbDate); CDBDate CDBMakeCDBDate(int year, int month, int day, int hour, int min, int sec); -#ifdef CDB_DATABASE_IMPLEMENTATION CDBDate CDBMakeCDBDateDayBegin(int year, int month, int day); CDBDate CDBMakeCDBDateDayEnd(int year, int month, int day); CDBDate CDBMakeCDBDateMonthBegin(int year, int month); CDBDate CDBMakeCDBDateMonthEnd(int year, int month); CDBDate CDBMakeCDBDateYearBegin(int year); CDBDate CDBMakeCDBDateYearEnd(int year); -#else -CDBDate CDBMakeCDBDateDayBegin(int year, int month, int day, int hour, int min, int sec); -CDBDate CDBMakeCDBDateDayEnd(int year, int month, int day, int hour, int min, int sec); -CDBDate CDBMakeCDBDateMonthBegin(int year, int month, int day, int hour, int min, int sec); -CDBDate CDBMakeCDBDateMonthEnd(int year, int month, int day, int hour, int min, int sec); -CDBDate CDBMakeCDBDateYearBegin(int year, int month, int day, int hour, int min, int sec); -CDBDate CDBMakeCDBDateYearEnd(int year, int month, int day, int hour, int min, int sec); -#endif #ifdef __cplusplus } diff --git a/libs/RevoEX/src/cdb/CDBConv.c b/libs/RevoEX/src/cdb/CDBConv.c index e1de530a..fce3e196 100644 --- a/libs/RevoEX/src/cdb/CDBConv.c +++ b/libs/RevoEX/src/cdb/CDBConv.c @@ -58,19 +58,21 @@ CDBDate CDBMakeCDBDate(int year, int month, int day, int hour, int min, int sec) return OSTicksToSeconds(OSCalendarTimeToTicks(&calendar)); } -CDBDate CDBMakeCDBDateDayBegin(int year, int month, int day, int hour, int min, int sec) { +CDBDate CDBMakeCDBDateDayBegin(int year, int month, int day) { return CDBMakeCDBDate(year, month, day, MIN_HOUR, MIN_MINUTE, MIN_SECOND); } -CDBDate CDBMakeCDBDateDayEnd(int year, int month, int day, int hour, int min, int sec) { +CDBDate CDBMakeCDBDateDayEnd(int year, int month, int day) { return CDBMakeCDBDate(year, month, day, MAX_HOUR, MAX_MINUTE, MAX_SECOND); } -CDBDate CDBMakeCDBDateMonthBegin(int year, int month, int day, int hour, int min, int sec) { +CDBDate CDBMakeCDBDateMonthBegin(int year, int month) { return CDBMakeCDBDate(year, month, MIN_DAY, MIN_HOUR, MIN_MINUTE, MIN_SECOND); } -CDBDate CDBMakeCDBDateMonthEnd(int year, int month, int day, int hour, int min, int sec) { +CDBDate CDBMakeCDBDateMonthEnd(int year, int month) { + int day; + switch (month) { case 1: { day = 28; @@ -101,11 +103,11 @@ CDBDate CDBMakeCDBDateMonthEnd(int year, int month, int day, int hour, int min, return CDBMakeCDBDate(year, month, day, MAX_HOUR, MAX_MINUTE, MAX_SECOND); } -CDBDate CDBMakeCDBDateYearBegin(int year, int month, int day, int hour, int min, int sec) { +CDBDate CDBMakeCDBDateYearBegin(int year) { return CDBMakeCDBDate(year, MIN_MONTH - 1, MIN_DAY, MIN_HOUR, MIN_MINUTE, MIN_SECOND); } -CDBDate CDBMakeCDBDateYearEnd(int year, int month, int day, int hour, int min, int sec) { +CDBDate CDBMakeCDBDateYearEnd(int year) { return CDBMakeCDBDate(year, MAX_MONTH - 1, MAX_DAY, MAX_HOUR, MAX_MINUTE, MAX_SECOND); } @@ -231,7 +233,7 @@ void CDBConvFileNameStrToFullPath(char* fullPath, char* yearStr, char* monthStr, CDBFSConcatenatePath(fullPath, fileNameStr); } -CDBDate CDBConvDirStrToCDBDate(char* yearStr, char* monthStr, char* dayStr, char* hourStr, char* minuteStr, CDBLocation location, u64* wiiId) { +CDBDate CDBConvDirStrToCDBDate(char* yearStr, char* monthStr, char* dayStr, char* hourStr, char* minuteStr) { return CDBMakeCDBDate(atoi(yearStr), atoi(monthStr), atoi(dayStr), atoi(hourStr), atoi(minuteStr), 0); } diff --git a/libs/RevoEX/src/cdb/CDBDatabase.c b/libs/RevoEX/src/cdb/CDBDatabase.c index da91c029..8b418342 100644 --- a/libs/RevoEX/src/cdb/CDBDatabase.c +++ b/libs/RevoEX/src/cdb/CDBDatabase.c @@ -1,4 +1,3 @@ -#define CDB_DATABASE_IMPLEMENTATION #include #include #include diff --git a/tools/decomp-assist/cdb-unify-arity.attempts.md b/tools/decomp-assist/cdb-unify-arity.attempts.md new file mode 100644 index 00000000..58c4a5c3 --- /dev/null +++ b/tools/decomp-assist/cdb-unify-arity.attempts.md @@ -0,0 +1,67 @@ +# Unify CDB helper signatures + +Base: f8957ca95be0ca4b35a281fa9a5d59f7f1787a41. +Branch: agent/fix/cdb-unify-arity. +Scope: CDBDate.h, CDBConv.h, CDBConv.c, CDBDatabase.c. + +## Reason and consumer audit + +PR #1167 introduced shorter declarations visible only to CDBDatabase.c while +CDBConv.c retained the old, longer definitions. Unused trailing machine +arguments do not make these incompatible C function types valid. + +Unify declarations and definitions around the arguments used by the target: +DayBegin/DayEnd take three ints, MonthBegin/MonthEnd two, YearBegin/YearEnd +one, and CDBConvDirStrToCDBDate five character pointers. Remove the +CDB_DATABASE_IMPLEMENTATION guard. MonthEnd's former day parameter becomes +a local assigned in every switch arm, including default, before any read. +All seven external names, linkage, return types, and linked bytes are retained. + +The complete original 43U object relocation audit found 13 call relocations, +all in CDBDatabase: one directory conversion and two calls to each of the six +date boundary helpers. The only additional 12 relocations were MonthEnd's +internal switch destinations. Decoding direct branches throughout the original +DOL confirmed the same 13 calls. No literal entry-address references, dynamic +ELF sections, relevant export list, or REL/RSO modules were found. These checks +cover observed 43U consumers, not hypothetical external fixed-address callers. +None of the removed trailing arguments is read by the helper implementations. + +## One bounded source attempt + +Applied the four-file signature correction directly, with no code-generation +tuning, new assembly, volatile casts, dummy arguments, or unrelated source edits. +Configured only 43U with the existing local compiler, binutils and wrapper paths. +Ran the complete default build, then progress, report and build/43U/ok targets. + +Fresh results: + +- CDBConv: 39/39 original functions, 4676/4676 code bytes, 232/232 data bytes; + matched and linked code/data all 100%. +- CDBDatabase: 33/33 original functions, 12152/12152 code bytes, 312/312 data + bytes; matched and linked code/data all 100%. +- All 72 exact-name original functions have identical raw instruction bytes, + position-normalized Capstone instructions and normalized relocation targets. +- Every allocated section and compiled function body is identical to the + pre-edit source-object baseline. Existing line-number-derived FORCEACTIVE + helper names move from 132/313 to 134/315; their bodies do not change. +- String pools: CDBConv 5/5, CDBDatabase 7/7, both identical. +- Literal audit: 31 arguments, 72 functions, zero skipped functions, candidates + or errors. +- MonthEnd jump table: 12/12 destinations identical. +- All 1027 report units retain identical measures and section results versus + the preserved baseline; global measures are identical. +- Full build and build/43U/ok pass. +- Original and rebuilt DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d. +- git diff --check passes. + +Global completion was also checked. It still fails the pre-existing incomplete +project totals (2778928/2995176 matched code, 2312404/2995176 linked code, +1832576/1832684 matched data, 1545364/1832684 linked data). This correction +makes no new decompilation or completion-percentage claim. + +GATE PASS: bounded signature correction; no exact, data, function or link +regression. Independent parent verification is still required before landing. + +Transient validation evidence is in build/cdb-arity-review/: the preserved +baseline report/objects, full-build.log, final-gates.log, check_objects.py, +object-gates.log, status.json, status.md and completion.log. -- 2.49.1