git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Usermode/libc++ - Implement map::insert and map::erase
[tpg/acess2.git]
/
Usermode
/
Libraries
/
ld-acess.so_src
/
main.c
diff --git
a/Usermode/Libraries/ld-acess.so_src/main.c
b/Usermode/Libraries/ld-acess.so_src/main.c
index
0eb28d1
..
976ceec
100644
(file)
--- a/
Usermode/Libraries/ld-acess.so_src/main.c
+++ b/
Usermode/Libraries/ld-acess.so_src/main.c
@@
-5,16
+5,17
@@
#include <stdint.h>
\r
#include <stddef.h>
\r
#include "common.h"
\r
#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
int CallUser(void *Entry, void *SP);
\r
\r
// === PROTOTYPES ===
\r
void *DoRelocate(void *base, char **envp, const char *Filename);
\r
int CallUser(void *Entry, void *SP);
\r
-void *ElfRelocate(void *Base, char **envp, const char *Filename);
\r
-void *PE_Relocate(void *Base, char **envp, const char *Filename);
\r
\r
// === Imports ===
\r
\r
// === Imports ===
\r
-extern void gLinkedBase;
\r
-extern tLoadedLib gLoadedLibraries[];
\r
+extern char gLinkedBase[];
\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
\r
// === CODE ===
\r
/**
\r
@@
-22,10
+23,12
@@
extern tLoadedLib gLoadedLibraries[];
\brief Library entry point
\r
\note This is the entrypoint for the library
\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
{
\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
// - 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
@@
-39,12
+42,7
@@
void *SoMain(void *base)
for(;;);
\r
}
\r
\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
// 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
ret = DoRelocate( base, NULL, "Executable" );
\r
if( ret == 0 ) {
\r
SysDebug("ld-acess - SoMain: Relocate failed, base=0x%x\n", base);
\r
@@
-52,7
+50,10
@@
void *SoMain(void *base)
for(;;);
\r
}
\r
\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
return ret;
\r
}
\r
\r
@@
-62,7
+63,7
@@
void *SoMain(void *base)
*/
\r
void *DoRelocate(void *base, char **envp, const char *Filename)
\r
{
\r
*/
\r
void *DoRelocate(void *base, char **envp, const char *Filename)
\r
{
\r
-
Uint8
*hdr = base;
\r
+
uint8_t
*hdr = base;
\r
// Load Executable
\r
if(memcmp(base, "\x7F""ELF", 4) == 0)
\r
return ElfRelocate(base, envp, Filename);
\r
// Load Executable
\r
if(memcmp(base, "\x7F""ELF", 4) == 0)
\r
return ElfRelocate(base, envp, Filename);
\r
@@
-99,3
+100,13
@@
int CallUser(void *entry, void *sp)
#endif
\r
for(;;);
\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
UCC
git Repository :: git.ucc.asn.au