X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=Usermode%2FLibraries%2Fld-acess.so_src%2Fmain.c;h=976ceec445a3c6483d3020ca50129d93d14290a5;hb=5cab4c07bc13888dc7956194ef9595508072a4eb;hp=0eb28d14ddf5a1cc8fdbf9d5f0d7609a6b7a395a;hpb=11686aa86bc0adae2555aa7796fe229770bb02f7;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 0eb28d14..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 void gLinkedBase; -extern tLoadedLib gLoadedLibraries[]; +extern char gLinkedBase[]; +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; } @@ -62,7 +63,7 @@ void *SoMain(void *base) */ void *DoRelocate(void *base, char **envp, const char *Filename) { - Uint8 *hdr = base; + uint8_t *hdr = base; // Load Executable if(memcmp(base, "\x7F""ELF", 4) == 0) return ElfRelocate(base, envp, Filename); @@ -99,3 +100,13 @@ int CallUser(void *entry, void *sp) #endif for(;;); } + +void exit(int val) +{ + _exit(val); +} + +void abort(void) +{ + _exit(-4); +}