Skip to content

Commit

Permalink
wutcrt: Fix the trap instruction and move it directly into __rpx_start
Browse files Browse the repository at this point in the history
  • Loading branch information
Maschell committed Feb 17, 2023
1 parent 8b68eeb commit 543fe4d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 11 additions & 0 deletions libraries/wutcrt/crt0_rpx.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.extern __init_wut
.extern __fini_wut
.extern __preinit_user
.extern OSIsDebuggerInitialized

.section .crt0, "ax", @progbits
.global __rpx_start
Expand All @@ -12,6 +13,16 @@ __rpx_start:
stw 0, 0x14(1)
stw 3, 0x8(1)
stw 4, 0xC(1)
bl OSIsDebuggerInitialized
cmpwi 3,0x0
beq init_wut
li 3, 2 # DBGCTL_INIT_BREAKPOINT
lis 4, main@h # Used for the initial bp if (((appFlags & 0x40) != 0) || ((appFlags & 0x10) != 0))
ori 4,4, main@l
lis 5, __init_wut@h # Used for the initial bp if ((appFlags & 0x20) == 0)
ori 5,5, __init_wut@l
tw 0x1f, 30, 0 # DBGCTL_INSTRUCTION
init_wut:
bl __init_wut
lwz 3, 0x8(1)
lwz 4, 0xC(1)
Expand Down
3 changes: 0 additions & 3 deletions libraries/wutcrt/wut_crt.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ void __attribute__((weak)) __fini_wut_socket();
void __attribute__((weak))
__init_wut()
{
if (OSIsDebuggerInitialized()) {
__asm__ __volatile__("tw 0x1f, 30, 0");
}
__init_wut_newlib();
__init_wut_stdcpp();
__init_wut_devoptab();
Expand Down

0 comments on commit 543fe4d

Please sign in to comment.