/*
* C/C++ runtime start for GCC-built Xbox 360 titles (newlib + libstdc++).
*
* The toolchain uses .ctors (not .init_array) and no crtbegin/crtend, so
* the link script provides the bounds and we run the constructors here.
* .eh_frame is registered with libgcc's unwinder so C++ exceptions work.
*/
#include <stdlib.h>
typedef void (*ctor_fn)(void);
extern ctor_fn __CTOR_LIST__[];
extern ctor_fn __CTOR_END__[];
extern char __eh_frame_start[];
extern void __register_frame(void *);
extern void xex_mount_devices(void);
extern int main(int argc, char **argv);
static char *argv_empty[] = { "game:\\default.xex", 0 };
int __xex_crt_main(void)
{
__register_frame(__eh_frame_start);
xex_mount_devices();
/* GCC runs .ctors from the end towards the start */
for (ctor_fn *p = __CTOR_END__; p > __CTOR_LIST__; ) {
(*--p)();
}
int ret = main(1, argv_empty);
exit(ret);
return ret;
}