link executor

This commit is contained in:
Prakxo
2023-08-21 16:34:39 +02:00
parent 1faf96890a
commit 5756e35dfd
5 changed files with 62 additions and 7 deletions
+4
View File
@@ -1,3 +1,7 @@
executor.c:
.text: [0x803702A8, 0x803703F8]
.data: [0x8064D500, 0x8064D580]
.bss: [0x8125A7C0, 0x8125A7C8]
sys_vimgr.c:
.text: [0x803703F8, 0x80370418]
c_keyframe.c:
+10
View File
@@ -0,0 +1,10 @@
#ifndef EXECUTOR_H
#define EXECUTOR_H
#include "types.h"
void _prolog();
void _epilog();
void _unresolved();
#endif
+2
View File
@@ -20,6 +20,8 @@ extern int ScreenHeight;
extern OSThread graphThread;
extern u8 SegmentBaseAddress[0x40];
void foresta_main();
#ifdef __cplusplus
}
#endif
+44
View File
@@ -0,0 +1,44 @@
#include "executor.h"
#include "dolphin/os/__ppc_eabi_init.h"
#include "dolphin/os.h"
#include "dolphin/os/OSContext.h"
#include "terminal.h"
#include "main.h"
BOOL construct_skip;
void _prolog() {
voidfunctionptr *constructor;
/* call static initializers */
if (!construct_skip) {
for (constructor = _ctors; *constructor; constructor++) {
(*constructor)();
}
}
foresta_main();
}
void _epilog() {
voidfunctionptr *destructor;
/* call static destructors */
for (destructor = _dtors; *destructor; destructor++) {
(*destructor)();
}
}
void _unresolved() {
u32 i;
u32* p;
OSReport(VT_COL(RED, WHITE) "\nError: A called an unlinked function.\n");
OSReport("Address: Back Chain LR Save\n");
for (i = 0, p = (u32*)OSGetStackPointer(); p && (u32)p != 0xffffffff && i++ < 16; p = (u32*)*p) {
OSReport("0x%08x: 0x%08x 0x%08x\n", p, p[0], p[1]);
}
OSReport("\n" VT_RST "\n");
}
+2 -7
View File
@@ -1,17 +1,13 @@
#include "types.h"
#include "dolphin/os.h"
#include "dolphin/PPCArch.h"
#include "dolphin/os/__ppc_eabi_init.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef void (*voidfunctionptr)(void); // pointer to function returning void
__declspec(section ".ctors") extern voidfunctionptr _ctors[];
__declspec(section ".dtors") extern voidfunctionptr _dtors[];
static void __init_cpp(void);
// clang-format off
__declspec(section ".init") asm void __init_hardware(void) {
nofralloc
mfmsr r0
@@ -24,7 +20,7 @@ __declspec(section ".init") asm void __init_hardware(void) {
blr
}
__declspec(section ".init") asm void __flush_cache(void) {
__declspec(section ".init") asm void __flush_cache(void*, size_t) {
nofralloc
lis r5, 0xFFFFFFF1@h
ori r5, r5, 0xFFFFFFF1@l
@@ -41,7 +37,6 @@ loop:
isync
blr
}
// clang-format on
void __init_user(void) { __init_cpp(); }