mirror of
https://github.com/zeldaret/oot.git
synced 2024-11-25 09:45:02 +00:00
Add pad_text to mkldscript and update progress.py (#1024)
* Add pad_text to mkldscript and update progress.py Implements `pad_text` from MM and uses it instead of asm nops for the padding in ucode_disas. Also updates `progress.py` to account for the change (RIP 1000000 code size), and to have a green badge for 100%. * Remove 1.00mb comment in progress.py Co-authored-by: Anghelo Carvajal <angheloalf95@gmail.com> Co-authored-by: Anghelo Carvajal <angheloalf95@gmail.com>
This commit is contained in:
parent
a497f33bda
commit
8d4828a3be
5 changed files with 46 additions and 37 deletions
|
@ -1,5 +0,0 @@
|
|||
glabel pad_800DACB0
|
||||
/* B51E50 800DACB0 00000000 */ nop
|
||||
/* B51E54 800DACB4 00000000 */ nop
|
||||
/* B51E58 800DACB8 00000000 */ nop
|
||||
/* B51E5C 800DACBC 00000000 */ nop
|
|
@ -95,7 +95,7 @@ boot -= nonMatchingASMBoot
|
|||
ovl -= nonMatchingASMOvl
|
||||
|
||||
bootSize = 31408 # decompilable code only
|
||||
codeSize = 1000000 # decompilable code only (1.00mb)
|
||||
codeSize = 999984 # decompilable code only
|
||||
ovlSize = 2812000 # .text sections
|
||||
|
||||
total = src + nonMatchingASM
|
||||
|
@ -119,7 +119,7 @@ elif args.format == 'shield-json':
|
|||
"schemaVersion": 1,
|
||||
"label": "progress",
|
||||
"message": f"{srcPct:.3g}%",
|
||||
"color": 'yellow',
|
||||
"color": 'yellow' if srcPct < 100 else 'brightgreen',
|
||||
}))
|
||||
elif args.format == 'text':
|
||||
adjective = "decompiled" if not args.matching else "matched"
|
||||
|
|
1
spec
1
spec
|
@ -406,6 +406,7 @@ beginseg
|
|||
include "build/src/code/fault_drawer.o"
|
||||
include "build/asm/code_800D71F0.o"
|
||||
include "build/src/code/ucode_disas.o"
|
||||
pad_text // audio library aligned to 32 bytes?
|
||||
include "build/src/code/audio_data.o"
|
||||
include "build/src/code/audio_synthesis.o"
|
||||
include "build/src/code/audio_heap.o"
|
||||
|
|
|
@ -1356,8 +1356,3 @@ void UCodeDisas_RegisterUCode(UCodeDisas* this, s32 count, UCodeInfo* ucodeArray
|
|||
void UCodeDisas_SetCurUCode(UCodeDisas* this, void* ptr) {
|
||||
UCodeDisas_SetCurUCodeImpl(this, ptr);
|
||||
}
|
||||
|
||||
// 4 bytes of nops, separating this file from audio_synthesis and padding .text
|
||||
// to a 32-byte boundary. Unclear what this comes from... maybe the audio
|
||||
// library was built separately and aligned to 32 bytes?
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/ucode_disas/pad_800DACB0.s")
|
||||
|
|
|
@ -28,6 +28,7 @@ enum
|
|||
STMT_romalign,
|
||||
STMT_stack,
|
||||
STMT_increment,
|
||||
STMT_pad_text,
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -37,6 +38,13 @@ enum
|
|||
FLAG_RAW = (1 << 2),
|
||||
};
|
||||
|
||||
struct Include
|
||||
{
|
||||
char *fpath;
|
||||
int linkerPadding;
|
||||
uint8_t dataWithRodata;
|
||||
};
|
||||
|
||||
struct Segment
|
||||
{
|
||||
uint32_t fields;
|
||||
|
@ -50,8 +58,7 @@ struct Segment
|
|||
uint32_t increment;
|
||||
uint32_t entry;
|
||||
uint32_t number;
|
||||
char **includes;
|
||||
uint8_t *data_with_rodata;
|
||||
struct Include *includes;
|
||||
int includesCount;
|
||||
};
|
||||
|
||||
|
@ -184,6 +191,7 @@ static const char *const stmtNames[] =
|
|||
[STMT_romalign] = "romalign",
|
||||
[STMT_stack] = "stack",
|
||||
[STMT_increment] = "increment",
|
||||
[STMT_pad_text] = "pad_text",
|
||||
};
|
||||
|
||||
static void parse_rom_spec(char *spec)
|
||||
|
@ -217,8 +225,9 @@ static void parse_rom_spec(char *spec)
|
|||
|
||||
if (currSeg != NULL)
|
||||
{
|
||||
// ensure no duplicates (except for 'include')
|
||||
if (stmt != STMT_include && stmt != STMT_include_data_with_rodata && (currSeg->fields & (1 << stmt)))
|
||||
// ensure no duplicates (except for 'include' or 'pad_text')
|
||||
if (stmt != STMT_include && stmt != STMT_include_data_with_rodata && stmt != STMT_pad_text &&
|
||||
(currSeg->fields & (1 << stmt)))
|
||||
util_fatal_error("line %i: duplicate '%s' statement", lineNum, stmtName);
|
||||
|
||||
currSeg->fields |= 1 << stmt;
|
||||
|
@ -273,15 +282,20 @@ static void parse_rom_spec(char *spec)
|
|||
case STMT_include_data_with_rodata:
|
||||
currSeg->includesCount++;
|
||||
currSeg->includes = realloc(currSeg->includes, currSeg->includesCount * sizeof(*currSeg->includes));
|
||||
currSeg->data_with_rodata = realloc(currSeg->data_with_rodata, currSeg->includesCount * sizeof(*currSeg->data_with_rodata));
|
||||
currSeg->data_with_rodata[currSeg->includesCount - 1] = (stmt == STMT_include_data_with_rodata);
|
||||
if (!parse_quoted_string(args, &currSeg->includes[currSeg->includesCount - 1]))
|
||||
|
||||
if (!parse_quoted_string(args, &currSeg->includes[currSeg->includesCount - 1].fpath))
|
||||
util_fatal_error("line %i: invalid filename", lineNum);
|
||||
|
||||
currSeg->includes[currSeg->includesCount - 1].linkerPadding = 0;
|
||||
currSeg->includes[currSeg->includesCount - 1].dataWithRodata = (stmt == STMT_include_data_with_rodata);
|
||||
break;
|
||||
case STMT_increment:
|
||||
if (!parse_number(args, &currSeg->increment))
|
||||
util_fatal_error("line %i: expected number after 'increment'", lineNum);
|
||||
break;
|
||||
case STMT_pad_text:
|
||||
currSeg->includes[currSeg->includesCount - 1].linkerPadding += 0x10;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "warning: '%s' is not implemented\n", stmtName);
|
||||
break;
|
||||
|
@ -356,7 +370,11 @@ static void write_ld_script(void)
|
|||
fprintf(fout, " . = ALIGN(0x%X);\n", seg->align);
|
||||
|
||||
for (j = 0; j < seg->includesCount; j++)
|
||||
fprintf(fout, " %s (.text)\n", seg->includes[j]);
|
||||
{
|
||||
fprintf(fout, " %s (.text)\n", seg->includes[j].fpath);
|
||||
if (seg->includes[j].linkerPadding != 0)
|
||||
fprintf(fout, " . += 0x%X;\n", seg->includes[j].linkerPadding);
|
||||
}
|
||||
|
||||
fprintf(fout, " _%sSegmentTextEnd = .;\n", seg->name);
|
||||
|
||||
|
@ -366,16 +384,16 @@ static void write_ld_script(void)
|
|||
|
||||
for (j = 0; j < seg->includesCount; j++)
|
||||
{
|
||||
if (!seg->data_with_rodata[j])
|
||||
fprintf(fout, " %s (.data)\n", seg->includes[j]);
|
||||
if (!seg->includes[j].dataWithRodata)
|
||||
fprintf(fout, " %s (.data)\n", seg->includes[j].fpath);
|
||||
}
|
||||
|
||||
/*
|
||||
for (j = 0; j < seg->includesCount; j++)
|
||||
fprintf(fout, " %s (.rodata)\n", seg->includes[j]);
|
||||
fprintf(fout, " %s (.rodata)\n", seg->includes[j].fpath);
|
||||
|
||||
for (j = 0; j < seg->includesCount; j++)
|
||||
fprintf(fout, " %s (.sdata)\n", seg->includes[j]);
|
||||
fprintf(fout, " %s (.sdata)\n", seg->includes[j].fpath);
|
||||
*/
|
||||
|
||||
//fprintf(fout, " . = ALIGN(0x10);\n");
|
||||
|
@ -387,9 +405,9 @@ static void write_ld_script(void)
|
|||
|
||||
for (j = 0; j < seg->includesCount; j++)
|
||||
{
|
||||
if (seg->data_with_rodata[j])
|
||||
fprintf(fout, " %s (.data)\n", seg->includes[j]);
|
||||
fprintf(fout, " %s (.rodata)\n", seg->includes[j]);
|
||||
if (seg->includes[j].dataWithRodata)
|
||||
fprintf(fout, " %s (.data)\n", seg->includes[j].fpath);
|
||||
fprintf(fout, " %s (.rodata)\n", seg->includes[j].fpath);
|
||||
// Compilers other than IDO, such as GCC, produce different sections such as
|
||||
// the ones named directly below. These sections do not contain values that
|
||||
// need relocating, but we need to ensure that the base .rodata section
|
||||
|
@ -398,9 +416,9 @@ static void write_ld_script(void)
|
|||
// the beginning of the entire rodata area in order to remain consistent.
|
||||
// Inconsistencies will lead to various .rodata reloc crashes as a result of
|
||||
// either missing relocs or wrong relocs.
|
||||
fprintf(fout, " %s (.rodata.str1.4)\n", seg->includes[j]);
|
||||
fprintf(fout, " %s (.rodata.cst4)\n", seg->includes[j]);
|
||||
fprintf(fout, " %s (.rodata.cst8)\n", seg->includes[j]);
|
||||
fprintf(fout, " %s (.rodata.str1.4)\n", seg->includes[j].fpath);
|
||||
fprintf(fout, " %s (.rodata.cst4)\n", seg->includes[j].fpath);
|
||||
fprintf(fout, " %s (.rodata.cst8)\n", seg->includes[j].fpath);
|
||||
}
|
||||
|
||||
//fprintf(fout, " . = ALIGN(0x10);\n");
|
||||
|
@ -412,7 +430,7 @@ static void write_ld_script(void)
|
|||
fprintf(fout, " _%sSegmentSDataStart = .;\n", seg->name);
|
||||
|
||||
for (j = 0; j < seg->includesCount; j++)
|
||||
fprintf(fout, " %s (.sdata)\n", seg->includes[j]);
|
||||
fprintf(fout, " %s (.sdata)\n", seg->includes[j].fpath);
|
||||
|
||||
fprintf(fout, " . = ALIGN(0x10);\n");
|
||||
|
||||
|
@ -421,7 +439,7 @@ static void write_ld_script(void)
|
|||
fprintf(fout, " _%sSegmentOvlStart = .;\n", seg->name);
|
||||
|
||||
for (j = 0; j < seg->includesCount; j++)
|
||||
fprintf(fout, " %s (.ovl)\n", seg->includes[j]);
|
||||
fprintf(fout, " %s (.ovl)\n", seg->includes[j].fpath);
|
||||
|
||||
fprintf(fout, " . = ALIGN(0x10);\n");
|
||||
|
||||
|
@ -453,13 +471,13 @@ static void write_ld_script(void)
|
|||
if (seg->fields & (1 << STMT_align))
|
||||
fprintf(fout, " . = ALIGN(0x%X);\n", seg->align);
|
||||
for (j = 0; j < seg->includesCount; j++)
|
||||
fprintf(fout, " %s (.sbss)\n", seg->includes[j]);
|
||||
fprintf(fout, " %s (.sbss)\n", seg->includes[j].fpath);
|
||||
for (j = 0; j < seg->includesCount; j++)
|
||||
fprintf(fout, " %s (.scommon)\n", seg->includes[j]);
|
||||
fprintf(fout, " %s (.scommon)\n", seg->includes[j].fpath);
|
||||
for (j = 0; j < seg->includesCount; j++)
|
||||
fprintf(fout, " %s (.bss)\n", seg->includes[j]);
|
||||
fprintf(fout, " %s (.bss)\n", seg->includes[j].fpath);
|
||||
for (j = 0; j < seg->includesCount; j++)
|
||||
fprintf(fout, " %s (COMMON)\n", seg->includes[j]);
|
||||
fprintf(fout, " %s (COMMON)\n", seg->includes[j].fpath);
|
||||
fprintf(fout, " . = ALIGN(0x10);\n"
|
||||
" _%sSegmentBssEnd = .;\n"
|
||||
" _%sSegmentEnd = .;\n"
|
||||
|
@ -478,7 +496,7 @@ static void write_ld_script(void)
|
|||
//fprintf(fout, " _%sSegmentOvlStart = .;\n", seg->name);
|
||||
|
||||
//for (j = 0; j < seg->includesCount; j++)
|
||||
// fprintf(fout, " %s (.ovl)\n", seg->includes[j]);
|
||||
// fprintf(fout, " %s (.ovl)\n", seg->includes[j].fpath);
|
||||
|
||||
////fprintf(fout, " . = ALIGN(0x10);\n");
|
||||
|
||||
|
|
Loading…
Reference in a new issue