#include <stdint.h>\r
#include <stddef.h>\r
#include "common.h"\r
+#undef SoMain\r
\r
// === PROTOTYPES ===\r
void *DoRelocate(void *base, char **envp, const char *Filename);\r
\r
// === Imports ===\r
extern char gLinkedBase[];\r
-extern tLoadedLib gLoadedLibraries[];\r
+char **gEnvP;\r
+extern int memcmp(const void *m1, const void *m2, size_t size);\r
+extern void CallQueuedEntrypoints(char **EnvP);\r
\r
// === CODE ===\r
/**\r
\brief Library entry point\r
\note This is the entrypoint for the library\r
*/\r
-void *SoMain(void *base)\r
+void *SoMain(void *base, int argc, char **argv, char **envp)\r
{\r
void *ret;\r
\r
+ gEnvP = envp;\r
+\r
// - Assume that the file pointer will be less than 4096\r
if((intptr_t)base < 0x1000) {\r
SysDebug("ld-acess - SoMain: Passed file pointer %i\n", base);\r
for(;;);\r
}\r
\r
- gLoadedLibraries[0].Base = &gLinkedBase;\r
- // 'libld-acess.so' because that is what applications link against\r
- gLoadedLibraries[0].Name = "/Acess/Libs/libld-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
for(;;);\r
}\r
\r
- SysDebug("ld-acess - SoMain: ret = %p", ret); \r
+ // Call queued entry points (from libraries)\r
+ CallQueuedEntrypoints(envp);\r
+\r
+ SysDebug("ld-acess - SoMain: Program entry %p", ret); \r
return ret;\r
}\r
\r
#endif\r
for(;;);\r
}\r
+\r
+void exit(int val)\r
+{\r
+ _exit(val);\r
+}\r
+\r
+void abort(void)\r
+{\r
+ _exit(-4);\r
+}\r