Build fixes
[tpg/acess2.git] / Usermode / Libraries / ld-acess.so_src / main.c
index fb9cd35..4f2ef88 100644 (file)
@@ -12,6 +12,7 @@
 \r
 // === Imports ===\r
 extern void    gLinkedBase;\r
+extern tLoadedLib      gLoadedLibraries[];\r
  \r
 // === CODE ===\r
 /**\r
@@ -22,29 +23,29 @@ extern void gLinkedBase;
 int SoMain(Uint base, int arg1)\r
 {\r
         int    ret;\r
-       \r
-       SysDebug("SoMain: base = 0x%x", base);\r
-       SysDebug("SoMain: arg1 = 0x%x", arg1);\r
         \r
        // - Assume that the file pointer will be less than 4096\r
        if(base < 0x1000) {\r
                SysDebug("ld-acess - SoMain: Passed file pointer %i\n", base);\r
-               SysExit();\r
+               _exit(-1);\r
                for(;;);\r
        }\r
        // Check if we are being called directly\r
        if(base == (Uint)&gLinkedBase) {\r
                SysDebug("ld-acess should not be directly called\n");\r
-               SysExit();\r
+               _exit(1);\r
                for(;;);\r
        }\r
+\r
+       gLoadedLibraries[0].Base = (Uint)&gLinkedBase;\r
+       gLoadedLibraries[0].Name = "ld-acess.so";\r
        \r
        // Otherwise do relocations\r
        //ret = DoRelocate( base, envp, "Executable" );\r
        ret = DoRelocate( base, NULL, "Executable" );\r
        if( ret == 0 ) {\r
                SysDebug("ld-acess - SoMain: Relocate failed, base=0x%x\n", base);\r
-               SysExit();\r
+               _exit(-1);\r
                for(;;);\r
        }\r
        \r
@@ -70,7 +71,7 @@ int DoRelocate( Uint base, char **envp, char *Filename )
        SysDebug("ld-acess - DoRelocate: Unkown file format '0x%x 0x%x 0x%x 0x%x'\n",\r
                *(Uint8*)(base), *(Uint8*)(base+1), *(Uint8*)(base+2), *(Uint8*)(base+3) );\r
        SysDebug("ld-acess - DoRelocate: File '%s'\n", Filename);\r
-       SysExit();\r
+       _exit(-1);\r
        for(;;);\r
 }\r
 \r
@@ -79,11 +80,11 @@ int DoRelocate( Uint base, char **envp, char *Filename )
 */\r
 int CallUser(Uint entry, Uint sp)\r
 {\r
-       SysDebug("CallUser: (entry=0x%x, sp=0x%x)", entry, sp);\r
+       //SysDebug("CallUser: (entry=0x%x, sp=0x%x)", entry, sp);\r
        *(Uint*)(sp-4) = 0;     // Clear return address\r
        __asm__ __volatile__ (\r
        "mov %%eax, %%esp;\n\t"\r
        "jmp *%%ecx"\r
-       : : "a"(sp-4), "c"(entry));\r
+       : : "a"(sp), "c"(entry));\r
        for(;;);\r
 }\r

UCC git Repository :: git.ucc.asn.au