diff --git a/source/crt.c b/source/crt.c new file mode 100644 index 0000000..c61ae0b --- /dev/null +++ b/source/crt.c @@ -0,0 +1,30 @@ +void __init_wut_malloc(); +void __init_wut_newlib(); +void __init_wut_stdcpp(); +void __init_wut_devoptab(); +void __attribute__((weak)) __init_wut_socket(); + +void __fini_wut_malloc(); +void __fini_wut_newlib(); +void __fini_wut_stdcpp(); +void __fini_wut_devoptab(); +void __attribute__((weak)) __fini_wut_socket(); + +void __attribute__((weak)) +__init_wut_() +{ + __init_wut_malloc(); + __init_wut_newlib(); + __init_wut_stdcpp(); + __init_wut_devoptab(); + if (&__init_wut_socket) __init_wut_socket(); +} + +void __attribute__((weak)) +__fini_wut_() +{ + __fini_wut_devoptab(); + __fini_wut_stdcpp(); + __fini_wut_newlib(); + __fini_wut_malloc(); +} diff --git a/source/crt0.s b/source/crt0.s index 595a028..318de30 100644 --- a/source/crt0.s +++ b/source/crt0.s @@ -1,7 +1,7 @@ .extern main .extern exit -.extern __init_wut -.extern __fini_wut +.extern __init_wut_ +.extern __fini_wut_ .global _start _start: @@ -12,13 +12,13 @@ _start: or 31, 1, 1 stw 3, 0x18(31) stw 4, 0x1C(31) - bl __init_wut + bl __init_wut_ lwz 4, 0x1C(31) lwz 3, 0x18(31) bl main or 9, 3, 3 stw 9, 0x8(31) - bl __fini_wut + bl __fini_wut_ lwz 9, 0x8(31) or 3, 9, 9 addi 11, 31, 0x28