Commit 19738b58 authored by q66's avatar q66
Browse files

internal: add a wrapper for __libc_start_main for PowerPC(64(le))

This is necessary because the musl and glibc function signatures
differ significantly.
parent 289a455f
......@@ -2,6 +2,47 @@
#include <stdio.h>
#include <stdlib.h>
#if defined(__powerpc__)
/* On PowerPC as well as ppc64, we need to fix up __libc_start_main as the
* glibc and musl versions have wildly different signatures, which would
* result in the arguments to __libc_start_main being completely wrong.
* Using dlsym in this context is mildly questionable as this is before
* the full initialization has been done, but there is no better way.
#include <dlfcn.h>
struct startup_info {
void *sda_base;
void *f_main;
void *f_init;
void *f_fini;
typedef int (*start_main_t)(void *mf, int argc, char **argv);
* ref:
* ref:
* ref:
int __libc_start_main(void *argc, void *argv, void *ev, void *auxv, void *fini,
struct startup_info *si, long *p)
/* argc/argv from the stack, main from startup_info */
start_main_t mainf = (start_main_t)dlsym(RTLD_NEXT, "__libc_start_main");
return mainf(si->f_main, *p, (void *)(p + 1));
#endif /* defined(__powerpc__) */
void GCOMPAT__panic(const char *fmt, ...)
va_list va;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment