Skip to content

Commit

Permalink
Match most of runtime (#49)
Browse files Browse the repository at this point in the history
* match some runtime functions

* match the last non-c++ file
  • Loading branch information
Yanis002 authored Sep 8, 2024
1 parent 783f23e commit 92a0220
Show file tree
Hide file tree
Showing 10 changed files with 1,365 additions and 58 deletions.
2 changes: 2 additions & 0 deletions config/oot-j/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ runtime/ptmf.c:

runtime/runtime.c:
.text start:0x80152D30 end:0x80153618
.rodata start:0x8016E3C0 end:0x8016E3D8

runtime/__init_cpp_exceptions.cpp:
.text start:0x80153618 end:0x80153688
Expand All @@ -650,6 +651,7 @@ runtime/Gecko_ExceptionPPC.cpp:

runtime/GCN_mem_alloc.c:
.text start:0x80154FE4 end:0x80155154
.rodata start:0x8016E440 end:0x8016E4B0

libc/alloc.c:
extab start:0x80006770 end:0x800067A8
Expand Down
98 changes: 49 additions & 49 deletions config/oot-j/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ fn_80063910 = .text:0x80063910; // type:function size:0xC4
fn_800639D4 = .text:0x800639D4; // type:function size:0x128
fn_80063AFC = .text:0x80063AFC; // type:function size:0x12C
fn_80063C28 = .text:0x80063C28; // type:function size:0x2C
fn_80063C54 = .text:0x80063C54; // type:function size:0x28
OSFreeToHeap = .text:0x80063C54; // type:function size:0x28
fn_80063C7C = .text:0x80063C7C; // type:function size:0xFC
fn_80063D78 = .text:0x80063D78; // type:function size:0x1B8
fn_80063F30 = .text:0x80063F30; // type:function size:0x18C
Expand Down Expand Up @@ -4261,7 +4261,7 @@ __register_global_object = .text:0x801525DC; // type:function size:0x18 scope:gl
__destroy_global_chain = .text:0x801525F4; // type:function size:0x48 scope:global
fn_8015263C = .text:0x8015263C; // type:function size:0xA8
fn_801526E4 = .text:0x801526E4; // type:function size:0x40
delete = .text:0x80152724; // type:function size:0x10
__dl__FPv = .text:0x80152724; // type:function size:0x10
fn_80152734 = .text:0x80152734; // type:function size:0xC
fn_80152740 = .text:0x80152740; // type:function size:0x4
fn_80152744 = .text:0x80152744; // type:function size:0x4
Expand Down Expand Up @@ -4380,8 +4380,8 @@ fn_80154A68 = .text:0x80154A68; // type:function size:0x400
fn_80154E68 = .text:0x80154E68; // type:function size:0x144
fn_80154FAC = .text:0x80154FAC; // type:function size:0x2C
fn_80154FD8 = .text:0x80154FD8; // type:function size:0xC
fn_80154FE4 = .text:0x80154FE4; // type:function size:0xB8
fn_8015509C = .text:0x8015509C; // type:function size:0xB8
Init = .text:0x80154FE4; // type:function size:0xB8
__sys_free = .text:0x8015509C; // type:function size:0xB8 scope:weak
fn_80155154 = .text:0x80155154; // type:function size:0x204
Block_link = .text:0x80155358; // type:function size:0x150
fn_801554A8 = .text:0x801554A8; // type:function size:0xA8
Expand Down Expand Up @@ -4935,10 +4935,10 @@ lbl_8016E368 = .rodata:0x8016E368; // type:object size:0x14
lbl_8016E37C = .rodata:0x8016E37C; // type:object size:0x10
lbl_8016E38C = .rodata:0x8016E38C; // type:object size:0x10
lbl_8016E39C = .rodata:0x8016E39C; // type:object size:0x24
lbl_8016E3C0 = .rodata:0x8016E3C0; // type:object size:0x18 data:double
__constants = .rodata:0x8016E3C0; // type:object size:0x18 scope:local data:double
lbl_8016E3D8 = .rodata:0x8016E3D8; // type:object size:0x14
lbl_8016E3EC = .rodata:0x8016E3EC; // type:object size:0x54
lbl_8016E440 = .rodata:0x8016E440; // type:object size:0x70
@stringBase0 = .rodata:0x8016E440; // type:object size:0x6F scope:local data:string_table
lbl_8016E4B0 = .rodata:0x8016E4B0; // type:object size:0x18 data:4byte
lbl_8016E4C8 = .rodata:0x8016E4C8; // type:object size:0xE0
lbl_8016E5A8 = .rodata:0x8016E5A8; // type:object size:0x200
Expand Down Expand Up @@ -4978,24 +4978,24 @@ lbl_8016F660 = .rodata:0x8016F660; // type:object size:0x28 data:4byte
EndofProgramInstruction$159 = .rodata:0x8016F688; // type:object size:0x4 scope:local
lbl_8016F68C = .rodata:0x8016F68C; // type:object size:0x104
...data.0 = .data:0x8016F7A0; // type:label scope:local
@1614 = .data:0x8016F7A0; // type:object size:0xD8 scope:local
@1692 = .data:0x8016F878; // type:object size:0x4B scope:local data:string
@1693 = .data:0x8016F8C4; // type:object size:0xB scope:local data:string
@1694 = .data:0x8016F8D0; // type:object size:0x4B scope:local data:string
@1615 = .data:0x8016F7A0; // type:object size:0xD8 scope:local
@1693 = .data:0x8016F878; // type:object size:0x4B scope:local data:string
@1694 = .data:0x8016F8C4; // type:object size:0xB scope:local data:string
@1695 = .data:0x8016F8D0; // type:object size:0x4B scope:local data:string
contMap = .data:0x8016F920; // type:object size:0x190 scope:local
...data.0 = .data:0x8016F920; // type:label scope:local
gaSystemDevice = .data:0x8016FAB0; // type:object size:0x3F0 scope:local data:4byte
lbl_8016FEA0 = .data:0x8016FEA0; // type:object size:0x300
@2499 = .data:0x801701A0; // type:object size:0xC scope:local data:string
@2500 = .data:0x801701AC; // type:object size:0xB scope:local data:string
@2502 = .data:0x801701B8; // type:object size:0xD scope:local data:string
@2505 = .data:0x801701C8; // type:object size:0x40 scope:local data:string
@2500 = .data:0x801701A0; // type:object size:0xC scope:local data:string
@2501 = .data:0x801701AC; // type:object size:0xB scope:local data:string
@2503 = .data:0x801701B8; // type:object size:0xD scope:local data:string
@2506 = .data:0x801701C8; // type:object size:0x40 scope:local data:string
gClassSystem = .data:0x80170208; // type:object size:0x10
@799 = .data:0x80170218; // type:object size:0x54 scope:local
@847 = .data:0x8017026C; // type:object size:0x54 scope:local
gClassAI = .data:0x801702C0; // type:object size:0x10
@1510 = .data:0x801702D0; // type:object size:0xD4 scope:local
@1557 = .data:0x801703A4; // type:object size:0xD4 scope:local
@1511 = .data:0x801702D0; // type:object size:0xD4 scope:local
@1558 = .data:0x801703A4; // type:object size:0xD4 scope:local
gClassVI = .data:0x80170478; // type:object size:0x10
@740 = .data:0x80170488; // type:object size:0x64 scope:local
@781 = .data:0x801704EC; // type:object size:0x64 scope:local
Expand Down Expand Up @@ -6798,32 +6798,32 @@ TRK_Use_BBA = .bss:0x8025C188; // type:object size:0x1 scope:global data:byte
lbl_8025C190 = .bss:0x8025C190; // type:object size:0x8 data:byte
lbl_8025C198 = .bss:0x8025C198; // type:object size:0x500
lbl_8025C698 = .bss:0x8025C698; // type:object size:0x1C
@1695 = .sdata:0x8025C6C0; // type:object size:0x4 scope:local data:string
@2487 = .sdata:0x8025C6C8; // type:object size:0x1 scope:local
@2488 = .sdata:0x8025C6CC; // type:object size:0x4 scope:local data:string
@2489 = .sdata:0x8025C6D0; // type:object size:0x4 scope:local data:string
@2490 = .sdata:0x8025C6D4; // type:object size:0x5 scope:local data:string
@2491 = .sdata:0x8025C6E0; // type:object size:0x8 scope:local data:string
@2492 = .sdata:0x8025C6E8; // type:object size:0x4 scope:local data:string
@2493 = .sdata:0x8025C6EC; // type:object size:0x3 scope:local data:string
@2494 = .sdata:0x8025C6F0; // type:object size:0x3 scope:local data:string
@2495 = .sdata:0x8025C6F4; // type:object size:0x3 scope:local data:string
@2496 = .sdata:0x8025C6F8; // type:object size:0x3 scope:local data:string
@2497 = .sdata:0x8025C6FC; // type:object size:0x3 scope:local data:string
@2498 = .sdata:0x8025C700; // type:object size:0x3 scope:local data:string
@2501 = .sdata:0x8025C704; // type:object size:0x6 scope:local data:string
@2503 = .sdata:0x8025C70C; // type:object size:0x7 scope:local data:string
@3016 = .sdata:0x8025C714; // type:object size:0x7 scope:local data:string
@1696 = .sdata:0x8025C6C0; // type:object size:0x4 scope:local data:string
@2488 = .sdata:0x8025C6C8; // type:object size:0x1 scope:local
@2489 = .sdata:0x8025C6CC; // type:object size:0x4 scope:local data:string
@2490 = .sdata:0x8025C6D0; // type:object size:0x4 scope:local data:string
@2491 = .sdata:0x8025C6D4; // type:object size:0x5 scope:local data:string
@2492 = .sdata:0x8025C6E0; // type:object size:0x8 scope:local data:string
@2493 = .sdata:0x8025C6E8; // type:object size:0x4 scope:local data:string
@2494 = .sdata:0x8025C6EC; // type:object size:0x3 scope:local data:string
@2495 = .sdata:0x8025C6F0; // type:object size:0x3 scope:local data:string
@2496 = .sdata:0x8025C6F4; // type:object size:0x3 scope:local data:string
@2497 = .sdata:0x8025C6F8; // type:object size:0x3 scope:local data:string
@2498 = .sdata:0x8025C6FC; // type:object size:0x3 scope:local data:string
@2499 = .sdata:0x8025C700; // type:object size:0x3 scope:local data:string
@2502 = .sdata:0x8025C704; // type:object size:0x6 scope:local data:string
@2504 = .sdata:0x8025C70C; // type:object size:0x7 scope:local data:string
@3017 = .sdata:0x8025C714; // type:object size:0x7 scope:local data:string
@891 = .sdata:0x8025C720; // type:object size:0x3 scope:local data:string
@1598 = .sdata:0x8025C728; // type:object size:0x3 scope:local data:string
@1599 = .sdata:0x8025C728; // type:object size:0x3 scope:local data:string
@811 = .sdata:0x8025C730; // type:object size:0x3 scope:local data:string
@891 = .sdata:0x8025C738; // type:object size:0x3 scope:local data:string
@851 = .sdata:0x8025C740; // type:object size:0x3 scope:local data:string
@665 = .sdata:0x8025C748; // type:object size:0x3 scope:local data:string
lbl_8025C750 = .sdata:0x8025C750; // type:object size:0x4 data:string
@1097 = .sdata:0x8025C758; // type:object size:0x4 scope:local data:string
@1053 = .sdata:0x8025C760; // type:object size:0x4 scope:local data:string
@1466 = .sdata:0x8025C768; // type:object size:0x4 scope:local data:string
@1467 = .sdata:0x8025C768; // type:object size:0x4 scope:local data:string
@875 = .sdata:0x8025C770; // type:object size:0x4 scope:local data:string
@1196 = .sdata:0x8025C778; // type:object size:0x4 scope:local data:string
@1168 = .sdata:0x8025C780; // type:object size:0x4 scope:local data:string
Expand All @@ -6832,18 +6832,18 @@ lbl_8025C750 = .sdata:0x8025C750; // type:object size:0x4 data:string
@1302 = .sdata:0x8025C794; // type:object size:0x6 scope:local data:string
sOrder = .sdata:0x8025C7A0; // type:object size:0x5 scope:local data:byte
sReplace = .sdata:0x8025C7A8; // type:object size:0x5 scope:local
@1374 = .sdata:0x8025C7B0; // type:object size:0x7 scope:local data:string
@1375 = .sdata:0x8025C7B8; // type:object size:0x7 scope:local data:string
@1376 = .sdata:0x8025C7C0; // type:object size:0x7 scope:local data:string
@1377 = .sdata:0x8025C7C8; // type:object size:0x7 scope:local data:string
@1378 = .sdata:0x8025C7D0; // type:object size:0x7 scope:local data:string
@1379 = .sdata:0x8025C7D8; // type:object size:0x7 scope:local data:string
@1380 = .sdata:0x8025C7E0; // type:object size:0x7 scope:local data:string
@1381 = .sdata:0x8025C7E8; // type:object size:0x7 scope:local data:string
@1382 = .sdata:0x8025C7F0; // type:object size:0x6 scope:local data:string
@1383 = .sdata:0x8025C7F8; // type:object size:0x6 scope:local data:string
@1384 = .sdata:0x8025C800; // type:object size:0x6 scope:local data:string
@1385 = .sdata:0x8025C808; // type:object size:0x6 scope:local data:string
@1375 = .sdata:0x8025C7B0; // type:object size:0x7 scope:local data:string
@1376 = .sdata:0x8025C7B8; // type:object size:0x7 scope:local data:string
@1377 = .sdata:0x8025C7C0; // type:object size:0x7 scope:local data:string
@1378 = .sdata:0x8025C7C8; // type:object size:0x7 scope:local data:string
@1379 = .sdata:0x8025C7D0; // type:object size:0x7 scope:local data:string
@1380 = .sdata:0x8025C7D8; // type:object size:0x7 scope:local data:string
@1381 = .sdata:0x8025C7E0; // type:object size:0x7 scope:local data:string
@1382 = .sdata:0x8025C7E8; // type:object size:0x7 scope:local data:string
@1383 = .sdata:0x8025C7F0; // type:object size:0x6 scope:local data:string
@1384 = .sdata:0x8025C7F8; // type:object size:0x6 scope:local data:string
@1385 = .sdata:0x8025C800; // type:object size:0x6 scope:local data:string
@1386 = .sdata:0x8025C808; // type:object size:0x6 scope:local data:string
lbl_8025C810 = .sdata:0x8025C810; // type:object size:0x8
lbl_8025C818 = .sdata:0x8025C818; // type:object size:0x6 data:string
lbl_8025C820 = .sdata:0x8025C820; // type:object size:0x2 data:string
Expand Down Expand Up @@ -7946,14 +7946,14 @@ lbl_8025DD08 = .sbss:0x8025DD08; // type:object size:0x8 data:double
lbl_8025DD10 = .sbss:0x8025DD10; // type:object size:0x8 data:double
gTRKInputPendingPtr = .sbss:0x8025DD18; // type:object size:0x4 scope:global data:4byte
lbl_8025DD20 = .sbss:0x8025DD20; // type:object size:0x4 data:4byte
@2825 = .sdata2:0x8025DD40; // type:object size:0x4 scope:local data:float
@2828 = .sdata2:0x8025DD48; // type:object size:0x8 scope:local data:double
@2826 = .sdata2:0x8025DD40; // type:object size:0x4 scope:local data:float
@2829 = .sdata2:0x8025DD48; // type:object size:0x8 scope:local data:double
lbl_8025DD50 = .sdata2:0x8025DD50; // type:object size:0x8 data:double
lbl_8025DD58 = .sdata2:0x8025DD58; // type:object size:0x4 data:float
lbl_8025DD60 = .sdata2:0x8025DD60; // type:object size:0x8 data:double
lbl_8025DD68 = .sdata2:0x8025DD68; // type:object size:0x8 data:double
lbl_8025DD70 = .sdata2:0x8025DD70; // type:object size:0x8 data:double
@1910 = .sdata2:0x8025DD78; // type:object size:0x8 scope:local data:double
@1911 = .sdata2:0x8025DD78; // type:object size:0x8 scope:local data:double
lbl_8025DD80 = .sdata2:0x8025DD80; // type:object size:0x4 data:float
lbl_8025DD84 = .sdata2:0x8025DD84; // type:object size:0x4 data:float
lbl_8025DD88 = .sdata2:0x8025DD88; // type:object size:0x4 data:float
Expand Down
18 changes: 9 additions & 9 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def RuntimeLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
return {
"lib": lib_name,
"mw_version": "GC/3.0a3",
"cflags": [*cflags_base, "-Cpp_exceptions off", "-O4,p", "-rostr", "-use_lmw_stmw on", "-lang c", "-enc SJIS"],
"cflags": [*cflags_base, "-Cpp_exceptions off", "-O4,p", "-rostr", "-use_lmw_stmw on", "-enc SJIS"],
"host": False,
"objects": objects,
}
Expand Down Expand Up @@ -483,16 +483,16 @@ def LinkedFor(*versions):
"runtime",
[
Object(LinkedFor("oot-j"), "runtime/__mem.c"),
Object(NotLinked, "runtime/__va_arg.c"),
Object(LinkedFor("oot-j"), "runtime/__va_arg.c"),
Object(LinkedFor("oot-j"), "runtime/global_destructor_chain.c"),
Object(NotLinked, "runtime/New.cpp"),
Object(NotLinked, "runtime/NMWException.cpp"),
Object(NotLinked, "runtime/ptmf.c"),
Object(NotLinked, "runtime/runtime.c"),
Object(NotLinked, "runtime/New.cpp", extra_cflags=["-Cpp_exceptions on"]),
Object(NotLinked, "runtime/NMWException.cpp", extra_cflags=["-Cpp_exceptions on"]),
Object(LinkedFor("oot-j"), "runtime/ptmf.c"),
Object(LinkedFor("oot-j"), "runtime/runtime.c"),
Object(LinkedFor("oot-j"), "runtime/__init_cpp_exceptions.cpp"),
Object(NotLinked, "runtime/Gecko_setjmp.c"),
Object(NotLinked, "runtime/Gecko_ExceptionPPC.cpp"),
Object(NotLinked, "runtime/GCN_mem_alloc.c"),
Object(LinkedFor("oot-j"), "runtime/Gecko_setjmp.c"),
Object(NotLinked, "runtime/Gecko_ExceptionPPC.cpp", extra_cflags=["-Cpp_exceptions on"]),
Object(LinkedFor("oot-j"), "runtime/GCN_mem_alloc.c"),
]
),
LibC(
Expand Down
27 changes: 27 additions & 0 deletions include/runtime/Gecko_setjmp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef RUNTIME_GECKO_SETJMP_H
#define RUNTIME_GECKO_SETJMP_H

#ifdef __cplusplus
extern "C" {
#endif

struct __jmp_buf {
unsigned long lr;
unsigned long cr;
unsigned long sp;
unsigned long toc;
unsigned long _padding1;
unsigned long gprs[32 - 13];
double fprs[(32 - 14) * 2];
double fpscr;
double _padding2;
};

int __setjmp(struct __jmp_buf* env);
void longjmp(struct __jmp_buf* env, int status);

#ifdef __cplusplus
}
#endif

#endif
35 changes: 35 additions & 0 deletions src/runtime/GCN_mem_alloc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "revolution/os.h"
#include "macros.h"

//! TODO: document
fn_80063C28(s32 handle, void *p);

static inline void InitInline(void) {
void* arenaLo;
void* arenaHi;

if (__OSCurrHeap == -1) {
OSReport("GCN_Mem_Alloc.c : InitDefaultHeap. No Heap Available\n");
OSReport("Metrowerks CW runtime library initializing default heap\n");

arenaLo = OSGetArenaLo();
arenaHi = OSGetArenaHi();
arenaLo = OSInitAlloc(arenaLo, arenaHi, 1);
OSSetArenaLo(arenaLo);

arenaLo = (void*)OSRoundUp32B(arenaLo);
arenaHi = (void*)OSRoundDown32B(arenaHi);
OSSetCurrentHeap(OSCreateHeap(arenaLo, arenaHi));
OSSetArenaLo(arenaLo = arenaHi);
}
}

void Init(void *ptr) {
InitInline();
fn_80063C28(__OSCurrHeap, ptr);
}

WEAK void __sys_free(void *ptr) {
InitInline();
OSFreeToHeap(__OSCurrHeap, ptr);
}
Loading

0 comments on commit 92a0220

Please sign in to comment.