X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Usermode%2FLibraries%2Fld-acess.so_src%2Fmain.c;h=976ceec445a3c6483d3020ca50129d93d14290a5;hb=6274aaa8894e14462a36c69090e2f9235f130e31;hp=6ccdc0c1250cf8138cfd51ea4b909f5990753e9a;hpb=c43c05ef3234d6118ce601d299df60383d54ac7b;p=tpg%2Facess2.git diff --git a/Usermode/Libraries/ld-acess.so_src/main.c b/Usermode/Libraries/ld-acess.so_src/main.c index 6ccdc0c1..976ceec4 100644 --- a/Usermode/Libraries/ld-acess.so_src/main.c +++ b/Usermode/Libraries/ld-acess.so_src/main.c @@ -5,16 +5,17 @@ #include #include #include "common.h" +#undef SoMain // === PROTOTYPES === void *DoRelocate(void *base, char **envp, const char *Filename); int CallUser(void *Entry, void *SP); -void *ElfRelocate(void *Base, char **envp, const char *Filename); -void *PE_Relocate(void *Base, char **envp, const char *Filename); // === Imports === extern char gLinkedBase[]; -extern tLoadedLib gLoadedLibraries[]; +char **gEnvP; +extern int memcmp(const void *m1, const void *m2, size_t size); +extern void CallQueuedEntrypoints(char **EnvP); // === CODE === /** @@ -22,10 +23,12 @@ extern tLoadedLib gLoadedLibraries[]; \brief Library entry point \note This is the entrypoint for the library */ -void *SoMain(void *base) +void *SoMain(void *base, int argc, char **argv, char **envp) { void *ret; + gEnvP = envp; + // - Assume that the file pointer will be less than 4096 if((intptr_t)base < 0x1000) { SysDebug("ld-acess - SoMain: Passed file pointer %i\n", base); @@ -39,12 +42,7 @@ void *SoMain(void *base) for(;;); } - gLoadedLibraries[0].Base = &gLinkedBase; - // 'libld-acess.so' because that is what applications link against - gLoadedLibraries[0].Name = "/Acess/Libs/libld-acess.so"; - // Otherwise do relocations - //ret = DoRelocate( base, envp, "Executable" ); ret = DoRelocate( base, NULL, "Executable" ); if( ret == 0 ) { SysDebug("ld-acess - SoMain: Relocate failed, base=0x%x\n", base); @@ -52,7 +50,10 @@ void *SoMain(void *base) for(;;); } - SysDebug("ld-acess - SoMain: ret = %p", ret); + // Call queued entry points (from libraries) + CallQueuedEntrypoints(envp); + + SysDebug("ld-acess - SoMain: Program entry %p", ret); return ret; } @@ -99,3 +100,13 @@ int CallUser(void *entry, void *sp) #endif for(;;); } + +void exit(int val) +{ + _exit(val); +} + +void abort(void) +{ + _exit(-4); +}