Usermode/ld-acess - Reworked build structure and syscall files
authorJohn Hodge <[email protected]>
Thu, 24 Mar 2011 02:28:28 +0000 (10:28 +0800)
committerJohn Hodge <[email protected]>
Thu, 24 Mar 2011 02:28:28 +0000 (10:28 +0800)
- Fixed up many places that used Uint in place of a pointer
- Converted the *.asm files into common and architecture-dependent parts
 > Some hackery with $(CPP) was used :)

13 files changed:
Usermode/Libraries/ld-acess.so_src/Makefile
Usermode/Libraries/ld-acess.so_src/arch/syscalls.s.h [new file with mode: 0644]
Usermode/Libraries/ld-acess.so_src/arch/x86.asm.h [new file with mode: 0644]
Usermode/Libraries/ld-acess.so_src/common.h
Usermode/Libraries/ld-acess.so_src/core.asm [deleted file]
Usermode/Libraries/ld-acess.so_src/elf.c
Usermode/Libraries/ld-acess.so_src/export.c
Usermode/Libraries/ld-acess.so_src/loadlib.c
Usermode/Libraries/ld-acess.so_src/main.c
Usermode/Libraries/ld-acess.so_src/mm.asm [deleted file]
Usermode/Libraries/ld-acess.so_src/pe.c
Usermode/Libraries/ld-acess.so_src/syscalls.inc.asm [deleted file]
Usermode/Libraries/ld-acess.so_src/vfs.asm [deleted file]

index 668460a..64a120c 100644 (file)
@@ -5,7 +5,7 @@
 -include ../Makefile.cfg
 
 OBJ := main.o lib.o loadlib.o export.o elf.o pe.o
-OBJ += core.ao vfs.ao mm.ao
+OBJ += arch/$(ARCHDIR).ao
 BIN = ld-acess.so
 EXTRABIN := libld-acess.so
 
@@ -16,7 +16,20 @@ LDFLAGS  = -T link.ld -Map map.txt --export-dynamic
 
 include ../Makefile.tpl
 
+# create libld-acess.so
 $(_XBIN): $(_BIN)
        @echo [LD] -o -shared libld-acess.so
        @$(LD) $(LDFLAGS) -shared -o $@ $(OBJ)
 
+# Override .ao to look in the object prefix for the source
+%.ao: %.asm
+       @echo [AS] -o $@
+       @mkdir -p $(dir $@)
+       @$(AS) $(ASFLAGS) -o $@ $<
+
+# Preprocessing objects if needed
+$(_OBJPREFIX)%: %.h
+       @echo [CPP] -o $@
+       @mkdir -p $(dir $@)
+       @$(CPP) $(CPPFLAGS) -P -D_ASM_ $< -o $@
+
diff --git a/Usermode/Libraries/ld-acess.so_src/arch/syscalls.s.h b/Usermode/Libraries/ld-acess.so_src/arch/syscalls.s.h
new file mode 100644 (file)
index 0000000..1c7a5bb
--- /dev/null
@@ -0,0 +1,52 @@
+// --- Process Control ---
+SYSCALL1(_exit, SYS_EXIT)
+
+SYSCALL2(clone, SYS_CLONE)
+SYSCALL2(kill, SYS_KILL)
+SYSCALL0(yield, SYS_YIELD)
+SYSCALL0(sleep, SYS_SLEEP)
+SYSCALL2(waittid, SYS_WAITTID)
+
+SYSCALL0(gettid, SYS_GETTID)
+SYSCALL0(getpid, SYS_GETPID)
+SYSCALL0(getuid, SYS_GETUID)
+SYSCALL0(getgid, SYS_GETGID)
+
+SYSCALL1(setuid, SYS_SETUID)
+SYSCALL1(setgid, SYS_SETGID)
+
+SYSCALL1(SysSetName, SYS_SETNAME)
+SYSCALL2(SysGetName, SYS_GETNAME)
+
+SYSCALL1(SysSetPri, SYS_SETPRI)
+
+SYSCALL3(SysSendMessage, SYS_SENDMSG)
+SYSCALL3(SysGetMessage, SYS_GETMSG)
+
+SYSCALL3(SysSpawn, SYS_SPAWN)
+SYSCALL3(execve, SYS_EXECVE)
+SYSCALL2(SysLoadBin, SYS_LOADBIN)
+SYSCALL1(SysUnloadBin, SYS_UNLOADBIN)
+
+SYSCALL1(_SysSetFaultHandler, SYS_SETFAULTHANDLER)
+
+SYSCALL6(_SysDebug, 0x100)
+SYSCALL1(_SysGetPhys, SYS_GETPHYS)     // uint64_t _SysGetPhys(uint addr)
+SYSCALL1(_SysAllocate, SYS_ALLOCATE)   // uint64_t _SysAllocate(uint addr)
+// VFS System calls
+SYSCALL2(open, SYS_OPEN)       // char*, int
+SYSCALL3(reopen, SYS_REOPEN)   // int, char*, int
+SYSCALL1(close, SYS_CLOSE)     // int
+SYSCALL3(read, SYS_READ)       // int, uint, void*
+SYSCALL3(write, SYS_WRITE)     // int, uint, void*
+SYSCALL4(seek, SYS_SEEK)       // int, uint64_t, int
+SYSCALL1(tell, SYS_TELL)       // int
+SYSCALL3(finfo, SYS_FINFO)     // int, void*, int
+SYSCALL2(readdir, SYS_READDIR) // int, char*
+SYSCALL2(_SysGetACL,SYS_GETACL)        // int, void*
+SYSCALL1(chdir, SYS_CHDIR)     // char*
+SYSCALL3(ioctl, SYS_IOCTL)     // int, int, void*
+SYSCALL4(_SysMount, SYS_MOUNT) // char*, char*, char*, char*
+SYSCALL5(select, SYS_SELECT)   // int, fd_set*, fd_set*, fd_set*, tTime*
+
+SYSCALL3(_SysOpenChild, SYS_OPENCHILD)
diff --git a/Usermode/Libraries/ld-acess.so_src/arch/x86.asm.h b/Usermode/Libraries/ld-acess.so_src/arch/x86.asm.h
new file mode 100644 (file)
index 0000000..282ff40
--- /dev/null
@@ -0,0 +1,191 @@
+; ========================
+; AcssMicro - System Calls
+; ========================
+
+%include "../../../Kernel/include/syscalls.inc.asm"
+
+[bits 32]
+[section .data]
+_errno:        dw      0
+
+[section .text]
+; DEST
+; SRC
+_memcpy:
+       push ebp
+       mov ebp, esp
+       push edi
+       push esi        ; // DI and SI must be maintained, CX doesn't
+       
+       mov ecx, [ebp+16]
+       mov esi, [ebp+12]
+       mov edi, [ebp+8]
+       rep movsb
+       
+       pop esi
+       pop edi
+       pop ebp
+       ret
+
+#define SYSCALL0(_name,_num)   SYSCALL0 _name, _num
+#define SYSCALL1(_name,_num)   SYSCALL1 _name, _num
+#define SYSCALL2(_name,_num)   SYSCALL2 _name, _num
+#define SYSCALL3(_name,_num)   SYSCALL3 _name, _num
+#define SYSCALL4(_name,_num)   SYSCALL4 _name, _num
+#define SYSCALL5(_name,_num)   SYSCALL5 _name, _num
+#define SYSCALL6(_name,_num)   SYSCALL6 _name, _num
+
+;%define SYSCALL_OP    jmp 0xCFFF0000
+%define SYSCALL_OP     int 0xAC
+
+; System Call - No Arguments
+%macro SYSCALL0        2
+[global %1:func]
+%1:
+       push ebx
+       mov eax, %2
+       SYSCALL_OP
+       mov [_errno], ebx
+       pop ebx
+       ret
+%endmacro
+
+%macro _SYSCALL_HEAD 2
+[global %1:func]
+%1:
+       push ebp
+       mov ebp, esp
+       push ebx
+       mov eax, %2
+%endmacro
+%macro _SYSCALL_TAIL 0
+       mov [_errno], ebx
+       pop ebx
+       pop ebp
+       ret
+%endmacro
+
+; System Call - 1 Argument
+%macro SYSCALL1        2
+_SYSCALL_HEAD %1, %2
+       mov ebx, [ebp+8]
+       SYSCALL_OP
+_SYSCALL_TAIL
+%endmacro
+
+; System Call - 2 Arguments
+%macro SYSCALL2        2
+_SYSCALL_HEAD %1, %2
+       mov eax, %2
+       mov ebx, [ebp+8]
+       mov ecx, [ebp+12]
+       SYSCALL_OP
+_SYSCALL_TAIL
+%endmacro
+
+; System Call - 3 Arguments
+%macro SYSCALL3        2
+_SYSCALL_HEAD %1, %2
+       mov ebx, [ebp+8]
+       mov ecx, [ebp+12]
+       mov edx, [ebp+16]
+       SYSCALL_OP
+_SYSCALL_TAIL
+%endmacro
+
+; System Call - 4 Arguments
+%macro SYSCALL4        2
+_SYSCALL_HEAD %1, %2
+       push edi
+       mov ebx, [ebp+8]
+       mov ecx, [ebp+12]
+       mov edx, [ebp+16]
+       mov edi, [ebp+20]
+       SYSCALL_OP
+       pop edi
+_SYSCALL_TAIL
+%endmacro
+
+; System Call - 5 Arguments
+%macro SYSCALL5        2
+_SYSCALL_HEAD %1, %2
+       push edi
+       push esi
+       mov ebx, [ebp+8]
+       mov ecx, [ebp+12]
+       mov edx, [ebp+16]
+       mov edi, [ebp+20]
+       mov esi, [ebp+24]
+       SYSCALL_OP
+       pop esi
+       pop edi
+_SYSCALL_TAIL
+%endmacro
+
+; System Call - 6 Arguments
+%macro SYSCALL6        2
+_SYSCALL_HEAD %1, %2
+       push edi
+       push esi
+       mov ebx, [ebp+8]
+       mov ecx, [ebp+12]
+       mov edx, [ebp+16]
+       mov edi, [ebp+20]
+       mov esi, [ebp+24]
+       mov ebp, [ebp+28]
+       SYSCALL_OP
+       pop esi
+       pop edi
+_SYSCALL_TAIL
+%endmacro
+
+; // Override the clone syscall
+#define clone  _clone_raw
+#include "syscalls.s.h"
+#undef clone
+
+[global clone:func]
+clone:
+       push ebp
+       mov ebp, esp
+       push ebx
+       
+       mov ebx, [ebp+12]       ; Get new stack pointer
+       
+       ; Check if the new stack is being used
+       test ebx, ebx
+       jz .doCall
+       ; Modify it to include the calling function (and this)
+       %if 0
+       mov eax, [ebp]  ; Get old stack frame
+       sub eax, ebp    ; Get size
+       sub ebx, eax    ; Alter new stack pointer
+       push eax        ; < Size
+       push DWORD [ebp]        ; < Source
+       push ebx        ; < Dest
+       call _memcpy
+       add esp, 4*3    ; Restore stack
+       ; EBX should still be the new stack pointer
+       mov eax, [ebp]  ; Save old stack frame pointer in new stack
+       mov [ebx-4], eax
+       mov eax, [ebp-4]        ; Save EBX there too
+       mov [ebx-8], eax
+       sub ebx, 8      ; Update stack pointer for system
+       %else
+       ; Quick hack, just this stack frame
+       mov eax, [ebp+4]
+       mov [ebx-4], eax        ; Return
+       mov [ebx-8], ebx        ; EBP
+       mov DWORD [ebx-12], 0   ; EBX
+       sub ebx, 12
+       %endif
+.doCall:
+       mov eax, SYS_CLONE
+       mov ecx, ebx    ; Stack
+       mov ebx, [ebp+8]        ; Flags
+       SYSCALL_OP
+       mov [_errno], ebx
+       pop ebx
+       pop ebp
+       ret
+
index fad0344..3eef946 100644 (file)
@@ -29,7 +29,7 @@ typedef signed short  Sint16;
 typedef signed long            Sint32;
 
 typedef struct {
-       Uint    Base;
+       void    *Base;
        char    *Name;
 }      tLoadedLib;
 
@@ -37,13 +37,13 @@ typedef struct {
 extern tLoadedLib      gLoadedLibraries[MAX_LOADED_LIBRARIES];
 
 // === Main ===
-extern int     DoRelocate( Uint base, char **envp, char *Filename );
+extern void    *DoRelocate(void *Base, char **envp, char *Filename);
 
 // === Library/Symbol Manipulation ==
-extern Uint    LoadLibrary(char *filename, char *SearchDir, char **envp);
-extern void    AddLoaded(char *File, Uint base);
-extern Uint    GetSymbol(char *name);
-extern int     GetSymbolFromBase(Uint base, char *name, Uint *ret);
+extern void    *LoadLibrary(char *filename, char *SearchDir, char **envp);
+extern void    AddLoaded(char *File, void *base);
+extern void    *GetSymbol(char *name);
+extern int     GetSymbolFromBase(void *base, char *name, void **ret);
 
 // === Library Functions ===
 extern char    *strcpy(char *dest, const char *src);
@@ -56,16 +56,16 @@ extern int  file_exists(char *filename);
 extern void    _exit(int retval);
 extern void    SysDebug(const char *fmt, ...); //!< Now implemented in main.c
 extern void    SysDebugV(const char *fmt, ...);
-extern Uint    SysLoadBin(const char *path, Uint *entry);
-extern Uint    SysUnloadBin(Uint Base);
+extern void    *SysLoadBin(const char *path, void **entry);
+extern int     SysUnloadBin(void *Base);
 extern void    SysSetFaultHandler(int (*Hanlder)(int));
 extern int     open(const char *filename, int flags);
 extern void    close(int fd);
 
 // === ELF Loader ===
-extern int     ElfGetSymbol(Uint Base, char *name, Uint *ret);
+extern int     ElfGetSymbol(void *Base, char *name, void **ret);
 
 // === PE Loader ===
-extern int     PE_GetSymbol(Uint Base, char *Name, Uint *ret);
+extern int     PE_GetSymbol(void *Base, char *Name, void **ret);
 
 #endif
diff --git a/Usermode/Libraries/ld-acess.so_src/core.asm b/Usermode/Libraries/ld-acess.so_src/core.asm
deleted file mode 100644 (file)
index 0bf80c1..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-;
-; Acess2 System Interface
-;
-%include "syscalls.inc.asm"
-
-[BITS 32]
-[section .data]
-[global _errno:data (4)]
-_errno:
-       dd      0
-
-[section .text]
-; DEST
-; SRC
-_memcpy:
-       push ebp
-       mov ebp, esp
-       push edi
-       push esi        ; DI and SI must be maintained, CX doesn't
-       
-       mov ecx, [ebp+16]
-       mov esi, [ebp+12]
-       mov edi, [ebp+8]
-       rep movsb
-       
-       pop esi
-       pop edi
-       pop ebp
-       ret
-
-; --- Process Control ---
-SYSCALL1       _exit, SYS_EXIT
-
-%if 0
-SYSCALL2       clone, SYS_CLONE
-%else
-[global clone:func]
-clone:
-       push ebp
-       mov ebp, esp
-       push ebx
-       
-       mov ebx, [ebp+12]       ; Get new stack pointer
-       
-       ; Check if the new stack is being used
-       test ebx, ebx
-       jz .doCall
-       ; Modify it to include the calling function (and this)
-       %if 0
-       mov eax, [ebp]  ; Get old stack frame
-       sub eax, ebp    ; Get size
-       sub ebx, eax    ; Alter new stack pointer
-       push eax        ; < Size
-       push DWORD [ebp]        ; < Source
-       push ebx        ; < Dest
-       call _memcpy
-       add esp, 4*3    ; Restore stack
-       ; EBX should still be the new stack pointer
-       mov eax, [ebp]  ; Save old stack frame pointer in new stack
-       mov [ebx-4], eax
-       mov eax, [ebp-4]        ; Save EBX there too
-       mov [ebx-8], eax
-       sub ebx, 8      ; Update stack pointer for system
-       %else
-       ; Quick hack, just this stack frame
-       mov eax, [ebp+4]
-       mov [ebx-4], eax        ; Return
-       mov [ebx-8], ebx        ; EBP
-       mov DWORD [ebx-12], 0   ; EBX
-       sub ebx, 12
-       %endif
-.doCall:
-       mov eax, SYS_CLONE
-       mov ecx, ebx    ; Stack
-       mov ebx, [ebp+8]        ; Flags
-       SYSCALL_OP
-       mov [_errno], ebx
-       pop ebx
-       pop ebp
-       ret
-%endif
-
-SYSCALL2       kill, SYS_KILL
-SYSCALL0       yield, SYS_YIELD
-SYSCALL0       sleep, SYS_SLEEP
-SYSCALL2       waittid, SYS_WAITTID
-
-SYSCALL0       gettid, SYS_GETTID
-SYSCALL0       getpid, SYS_GETPID
-SYSCALL0       getuid, SYS_GETUID
-SYSCALL0       getgid, SYS_GETGID
-
-SYSCALL1       setuid, SYS_SETUID
-SYSCALL1       setgid, SYS_SETGID
-
-SYSCALL1       SysSetName, SYS_SETNAME
-SYSCALL2       SysGetName, SYS_GETNAME
-
-SYSCALL1       SysSetPri, SYS_SETPRI
-
-SYSCALL3       SysSendMessage, SYS_SENDMSG
-SYSCALL3       SysGetMessage, SYS_GETMSG
-
-SYSCALL3       SysSpawn, SYS_SPAWN
-SYSCALL3       execve, SYS_EXECVE
-SYSCALL2       SysLoadBin, SYS_LOADBIN
-SYSCALL1       SysUnloadBin, SYS_UNLOADBIN
-
-SYSCALL1       _SysSetFaultHandler, SYS_SETFAULTHANDLER
-
-SYSCALL6       _SysDebug, 0x100
index dcde746..bcec1dc 100644 (file)
-/*\r
- * AcessOS 1 - Dynamic Loader\r
- * By thePowersGang\r
- */\r
-#include "common.h"\r
-#include "elf32.h"\r
+/*
+ * AcessOS 1 - Dynamic Loader
+ * By thePowersGang
+ */
+#include "common.h"
+#include <stdint.h>
+#include "elf32.h"
 
 #define DEBUG  0
 
-#if DEBUG\r
-# define       DEBUGS(v...)    SysDebug(v)\r
+#if DEBUG
+# define       DEBUGS(v...)    SysDebug(v)
 #else
 # define       DEBUGS(...)     
 #endif
-\r
+
 // === CONSTANTS ===
-#if DEBUG\r
-//static const char    *csaDT_NAMES[] = {"DT_NULL", "DT_NEEDED", "DT_PLTRELSZ", "DT_PLTGOT", "DT_HASH", "DT_STRTAB", "DT_SYMTAB", "DT_RELA", "DT_RELASZ", "DT_RELAENT", "DT_STRSZ", "DT_SYMENT", "DT_INIT", "DT_FINI", "DT_SONAME", "DT_RPATH", "DT_SYMBOLIC", "DT_REL", "DT_RELSZ", "DT_RELENT", "DT_PLTREL", "DT_DEBUG", "DT_TEXTREL", "DT_JMPREL"};\r
+#if DEBUG
+//static const char    *csaDT_NAMES[] = {"DT_NULL", "DT_NEEDED", "DT_PLTRELSZ", "DT_PLTGOT", "DT_HASH", "DT_STRTAB", "DT_SYMTAB", "DT_RELA", "DT_RELASZ", "DT_RELAENT", "DT_STRSZ", "DT_SYMENT", "DT_INIT", "DT_FINI", "DT_SONAME", "DT_RPATH", "DT_SYMBOLIC", "DT_REL", "DT_RELSZ", "DT_RELENT", "DT_PLTREL", "DT_DEBUG", "DT_TEXTREL", "DT_JMPREL"};
 static const char      *csaR_NAMES[] = {"R_386_NONE", "R_386_32", "R_386_PC32", "R_386_GOT32", "R_386_PLT32", "R_386_COPY", "R_386_GLOB_DAT", "R_386_JMP_SLOT", "R_386_RELATIVE", "R_386_GOTOFF", "R_386_GOTPC", "R_386_LAST"};
-#endif\r
-\r
-// === PROTOTYPES ===\r
-void elf_doRelocate(Uint r_info, Uint32 *ptr, Uint32 addend, Elf32_Sym *symtab, Uint base);\r
-Uint ElfHashString(char *name);\r
-\r
-// === CODE ===\r
-/**\r
- \fn int ElfRelocate(void *Base, char **envp, char *Filename)\r
- \brief Relocates a loaded ELF Executable\r
-*/\r
-int ElfRelocate(void *Base, char **envp, char *Filename)\r
-{\r
-       Elf32_Ehdr      *hdr = Base;\r
-       Elf32_Phdr      *phtab;\r
-        int    i, j;   // Counters\r
-       char    *libPath;\r
-       Uint    iRealBase = -1;\r
-       Uint    iBaseDiff;\r
-        int    iSegmentCount;\r
-        int    iSymCount;\r
-       Elf32_Rel       *rel = NULL;\r
-       Elf32_Rela      *rela = NULL;\r
-       Uint32  *pltgot = NULL;\r
-       void    *plt = NULL;\r
-        int    relSz=0, relEntSz=8;\r
-        int    relaSz=0, relaEntSz=8;\r
-        int    pltSz=0, pltType=0;\r
-       Elf32_Dyn       *dynamicTab = NULL;     // Dynamic Table Pointer\r
-       char    *dynstrtab = NULL;      // .dynamic String Table\r
-       Elf32_Sym       *dynsymtab;\r
-       \r
-       DEBUGS("ElfRelocate: (Base=0x%x)\n", Base);\r
-       \r
-       // Check magic header\r
-       \r
-       \r
-       // Parse Program Header to get Dynamic Table\r
-       phtab = Base + hdr->phoff;\r
-       iSegmentCount = hdr->phentcount;\r
-       for(i=0;i<iSegmentCount;i++)\r
-       {\r
-               // Determine linked base address\r
-               if(phtab[i].Type == PT_LOAD && iRealBase > phtab[i].VAddr)\r
-                       iRealBase = phtab[i].VAddr;\r
-               \r
-               // Find Dynamic Section\r
-               if(phtab[i].Type == PT_DYNAMIC) {\r
-                       if(dynamicTab) {\r
-                               DEBUGS(" WARNING - elf_relocate: Multiple PT_DYNAMIC segments\n");\r
-                               continue;\r
-                       }\r
-                       dynamicTab = (void *) phtab[i].VAddr;\r
-                       j = i;  // Save Dynamic Table ID\r
-               }\r
-       }\r
-       \r
-       // Page Align real base\r
-       iRealBase &= ~0xFFF;\r
-       DEBUGS(" elf_relocate: True Base = 0x%x, Compiled Base = 0x%x\n", Base, iRealBase);\r
-       \r
-       // Adjust "Real" Base\r
-       iBaseDiff = (Uint)Base - iRealBase;\r
-       \r
-       hdr->entrypoint += iBaseDiff;   // Adjust Entrypoint\r
-       \r
-       // Check if a PT_DYNAMIC segement was found\r
-       if(!dynamicTab) {\r
-               SysDebug(" elf_relocate: No PT_DYNAMIC segment in image, returning\n");\r
-               return hdr->entrypoint;\r
-       }\r
-       \r
-       // Adjust Dynamic Table\r
-       dynamicTab = (void *) ((Uint)dynamicTab + iBaseDiff);\r
+#endif
+
+// === PROTOTYPES ===
+void elf_doRelocate(Uint r_info, Uint32 *ptr, Uint32 addend, Elf32_Sym *symtab, Uint base);
+Uint ElfHashString(char *name);
+
+// === CODE ===
+/**
+ \fn int ElfRelocate(void *Base, char **envp, char *Filename)
+ \brief Relocates a loaded ELF Executable
+*/
+void *ElfRelocate(void *Base, char **envp, char *Filename)
+{
+       Elf32_Ehdr      *hdr = Base;
+       Elf32_Phdr      *phtab;
+        int    i, j;   // Counters
+       char    *libPath;
+       Uint    iRealBase = -1;
+       Uint    iBaseDiff;
+        int    iSegmentCount;
+        int    iSymCount;
+       Elf32_Rel       *rel = NULL;
+       Elf32_Rela      *rela = NULL;
+       Uint32  *pltgot = NULL;
+       void    *plt = NULL;
+        int    relSz=0, relEntSz=8;
+        int    relaSz=0, relaEntSz=8;
+        int    pltSz=0, pltType=0;
+       Elf32_Dyn       *dynamicTab = NULL;     // Dynamic Table Pointer
+       char    *dynstrtab = NULL;      // .dynamic String Table
+       Elf32_Sym       *dynsymtab;
+       
+       DEBUGS("ElfRelocate: (Base=0x%x)\n", Base);
+       
+       // Check magic header
+       
+       
+       // Parse Program Header to get Dynamic Table
+       phtab = Base + hdr->phoff;
+       iSegmentCount = hdr->phentcount;
+       for(i=0;i<iSegmentCount;i++)
+       {
+               // Determine linked base address
+               if(phtab[i].Type == PT_LOAD && iRealBase > phtab[i].VAddr)
+                       iRealBase = phtab[i].VAddr;
+               
+               // Find Dynamic Section
+               if(phtab[i].Type == PT_DYNAMIC) {
+                       if(dynamicTab) {
+                               DEBUGS(" WARNING - elf_relocate: Multiple PT_DYNAMIC segments\n");
+                               continue;
+                       }
+                       dynamicTab = (void *) (intptr_t) phtab[i].VAddr;
+                       j = i;  // Save Dynamic Table ID
+               }
+       }
+       
+       // Page Align real base
+       iRealBase &= ~0xFFF;
+       DEBUGS(" elf_relocate: True Base = 0x%x, Compiled Base = 0x%x\n", Base, iRealBase);
+       
+       // Adjust "Real" Base
+       iBaseDiff = (intptr_t)Base - iRealBase;
+       
+       hdr->entrypoint += iBaseDiff;   // Adjust Entrypoint
+       
+       // Check if a PT_DYNAMIC segement was found
+       if(!dynamicTab) {
+               SysDebug(" elf_relocate: No PT_DYNAMIC segment in image, returning\n");
+               return (void *)hdr->entrypoint;
+       }
        
-       // === Get Symbol table and String Table ===\r
-       for( j = 0; dynamicTab[j].d_tag != DT_NULL; j++)\r
+       // Adjust Dynamic Table
+       dynamicTab = (void *)( (intptr_t)dynamicTab + iBaseDiff );
+       
+       // === Get Symbol table and String Table ===
+       for( j = 0; dynamicTab[j].d_tag != DT_NULL; j++)
        {
                switch(dynamicTab[j].d_tag)
                {
-               // --- Symbol Table ---\r
-               case DT_SYMTAB:\r
-                       DEBUGS(" elf_relocate: DYNAMIC Symbol Table 0x%x (0x%x)\n",\r
-                               dynamicTab[j].d_val, dynamicTab[j].d_val + iBaseDiff);\r
-                       dynamicTab[j].d_val += iBaseDiff;\r
-                       dynsymtab = (void*)(dynamicTab[j].d_val);\r
-                       hdr->misc.SymTable = dynamicTab[j].d_val;       // Saved in unused bytes of ident\r
-                       break;\r
-               // --- String Table ---\r
-               case DT_STRTAB:\r
-                       DEBUGS(" elf_relocate: DYNAMIC String Table 0x%x (0x%x)\n",\r
-                               dynamicTab[j].d_val, dynamicTab[j].d_val + iBaseDiff);\r
-                       dynamicTab[j].d_val += iBaseDiff;\r
-                       dynstrtab = (void*)(dynamicTab[j].d_val);\r
-                       break;\r
-               // --- Hash Table --\r
-               case DT_HASH:\r
-                       dynamicTab[j].d_val += iBaseDiff;\r
-                       iSymCount = ((Uint*)(dynamicTab[j].d_val))[1];\r
-                       hdr->misc.HashTable = dynamicTab[j].d_val;      // Saved in unused bytes of ident\r
+               // --- Symbol Table ---
+               case DT_SYMTAB:
+                       DEBUGS(" elf_relocate: DYNAMIC Symbol Table 0x%x (0x%x)\n",
+                               dynamicTab[j].d_val, dynamicTab[j].d_val + iBaseDiff);
+                       dynamicTab[j].d_val += iBaseDiff;
+                       dynsymtab = (void*)(dynamicTab[j].d_val);
+                       hdr->misc.SymTable = dynamicTab[j].d_val;       // Saved in unused bytes of ident
+                       break;
+               // --- String Table ---
+               case DT_STRTAB:
+                       DEBUGS(" elf_relocate: DYNAMIC String Table 0x%x (0x%x)\n",
+                               dynamicTab[j].d_val, dynamicTab[j].d_val + iBaseDiff);
+                       dynamicTab[j].d_val += iBaseDiff;
+                       dynstrtab = (void*)(dynamicTab[j].d_val);
+                       break;
+               // --- Hash Table --
+               case DT_HASH:
+                       dynamicTab[j].d_val += iBaseDiff;
+                       iSymCount = ((Uint*)(dynamicTab[j].d_val))[1];
+                       hdr->misc.HashTable = dynamicTab[j].d_val;      // Saved in unused bytes of ident
                        break;
                }
        }
-\r
-       if(dynsymtab == NULL) {\r
-               SysDebug("ld-acess.so - WARNING: No Dynamic Symbol table, returning\n");\r
-               return hdr->entrypoint;\r
-       }\r
-       \r
-       // Alter Symbols to true base\r
-       for(i=0;i<iSymCount;i++)\r
-       {\r
+
+       if(dynsymtab == NULL) {
+               SysDebug("ld-acess.so - WARNING: No Dynamic Symbol table, returning\n");
+               return (void *) hdr->entrypoint;
+       }
+       
+       // Alter Symbols to true base
+       for(i=0;i<iSymCount;i++)
+       {
                dynsymtab[i].value += iBaseDiff;
-               dynsymtab[i].nameOfs += (Uint)dynstrtab;\r
-               //DEBUGS("elf_relocate: Sym '%s' = 0x%x (relocated)\n", dynsymtab[i].name, dynsymtab[i].value);\r
-       }\r
+               dynsymtab[i].nameOfs += (intptr_t)dynstrtab;
+               //DEBUGS("elf_relocate: Sym '%s' = 0x%x (relocated)\n", dynsymtab[i].name, dynsymtab[i].value);
+       }
        
        // === Add to loaded list (can be imported now) ===
-       AddLoaded( Filename, (Uint)Base );
+       AddLoaded( Filename, Base );
 
-       // === Parse Relocation Data ===\r
-       DEBUGS(" elf_relocate: dynamicTab = 0x%x\n", dynamicTab);\r
-       for( j = 0; dynamicTab[j].d_tag != DT_NULL; j++)\r
-       {\r
-               switch(dynamicTab[j].d_tag)\r
-               {\r
-               // --- Shared Library Name ---\r
-               case DT_SONAME:\r
-                       DEBUGS(" elf_relocate: .so Name '%s'\n", dynstrtab+dynamicTab[j].d_val);\r
-                       break;\r
-               // --- Needed Library ---\r
-               case DT_NEEDED:\r
-                       libPath = dynstrtab + dynamicTab[j].d_val;\r
-                       DEBUGS(" Required Library '%s'\n", libPath);\r
-                       if(LoadLibrary(libPath, NULL, envp) == 0) {\r
-                               #if DEBUG\r
-                                       DEBUGS(" elf_relocate: Unable to load '%s'\n", libPath);\r
-                               #else\r
-                               SysDebug("Unable to load required library '%s'\n", libPath);\r
-                               #endif\r
-                               return 0;\r
-                       }\r
-                       break;\r
-               // --- PLT/GOT ---\r
-               case DT_PLTGOT: pltgot = (void*)iBaseDiff+(dynamicTab[j].d_val);        break;\r
-               case DT_JMPREL: plt = (void*)(iBaseDiff+dynamicTab[j].d_val);   break;\r
-               case DT_PLTREL: pltType = dynamicTab[j].d_val;  break;\r
-               case DT_PLTRELSZ:       pltSz = dynamicTab[j].d_val;    break;\r
-               \r
-               // --- Relocation ---\r
-               case DT_REL:    rel = (void*)(iBaseDiff + dynamicTab[j].d_val); break;\r
-               case DT_RELSZ:  relSz = dynamicTab[j].d_val;    break;\r
-               case DT_RELENT: relEntSz = dynamicTab[j].d_val; break;\r
-               case DT_RELA:   rela = (void*)(iBaseDiff + dynamicTab[j].d_val);        break;\r
-               case DT_RELASZ: relaSz = dynamicTab[j].d_val;   break;\r
-               case DT_RELAENT:        relaEntSz = dynamicTab[j].d_val;        break;\r
-               \r
-               // --- Symbol Table ---\r
-               case DT_SYMTAB:\r
-               // --- Hash Table ---\r
-               case DT_HASH:\r
-               // --- String Table ---\r
-               case DT_STRTAB:\r
-                       break;\r
-               \r
-               // --- Unknown ---\r
-               default:\r
-                       if(dynamicTab[j].d_tag > DT_JMPREL)     continue;\r
-                       //DEBUGS(" elf_relocate: %i-%i = %s,0x%x\n",\r
-                       //      i,j, csaDT_NAMES[dynamicTab[j].d_tag],dynamicTab[j].d_val);\r
-                       break;\r
-               }\r
-       }\r
-       \r
-       DEBUGS(" elf_relocate: Beginning Relocation\n");\r
-       \r
-       // Parse Relocation Entries\r
-       if(rel && relSz)\r
-       {\r
-               Uint32  *ptr;\r
-               DEBUGS(" elf_relocate: rel=0x%x, relSz=0x%x, relEntSz=0x%x\n", rel, relSz, relEntSz);\r
-               j = relSz / relEntSz;\r
-               for( i = 0; i < j; i++ )\r
+       // === Parse Relocation Data ===
+       DEBUGS(" elf_relocate: dynamicTab = 0x%x\n", dynamicTab);
+       for( j = 0; dynamicTab[j].d_tag != DT_NULL; j++)
+       {
+               switch(dynamicTab[j].d_tag)
+               {
+               // --- Shared Library Name ---
+               case DT_SONAME:
+                       DEBUGS(" elf_relocate: .so Name '%s'\n", dynstrtab+dynamicTab[j].d_val);
+                       break;
+               // --- Needed Library ---
+               case DT_NEEDED:
+                       libPath = dynstrtab + dynamicTab[j].d_val;
+                       DEBUGS(" Required Library '%s'\n", libPath);
+                       if(LoadLibrary(libPath, NULL, envp) == 0) {
+                               #if DEBUG
+                                       DEBUGS(" elf_relocate: Unable to load '%s'\n", libPath);
+                               #else
+                               SysDebug("Unable to load required library '%s'\n", libPath);
+                               #endif
+                               return 0;
+                       }
+                       break;
+               // --- PLT/GOT ---
+               case DT_PLTGOT: pltgot = (void*)(iBaseDiff + dynamicTab[j].d_val);      break;
+               case DT_JMPREL: plt = (void*)(iBaseDiff + dynamicTab[j].d_val); break;
+               case DT_PLTREL: pltType = dynamicTab[j].d_val;  break;
+               case DT_PLTRELSZ:       pltSz = dynamicTab[j].d_val;    break;
+               
+               // --- Relocation ---
+               case DT_REL:    rel = (void*)(iBaseDiff + dynamicTab[j].d_val); break;
+               case DT_RELSZ:  relSz = dynamicTab[j].d_val;    break;
+               case DT_RELENT: relEntSz = dynamicTab[j].d_val; break;
+               case DT_RELA:   rela = (void*)(iBaseDiff + dynamicTab[j].d_val);        break;
+               case DT_RELASZ: relaSz = dynamicTab[j].d_val;   break;
+               case DT_RELAENT:        relaEntSz = dynamicTab[j].d_val;        break;
+               
+               // --- Symbol Table ---
+               case DT_SYMTAB:
+               // --- Hash Table ---
+               case DT_HASH:
+               // --- String Table ---
+               case DT_STRTAB:
+                       break;
+               
+               // --- Unknown ---
+               default:
+                       if(dynamicTab[j].d_tag > DT_JMPREL)     continue;
+                       //DEBUGS(" elf_relocate: %i-%i = %s,0x%x\n",
+                       //      i,j, csaDT_NAMES[dynamicTab[j].d_tag],dynamicTab[j].d_val);
+                       break;
+               }
+       }
+       
+       DEBUGS(" elf_relocate: Beginning Relocation\n");
+       
+       // Parse Relocation Entries
+       if(rel && relSz)
+       {
+               Uint32  *ptr;
+               DEBUGS(" elf_relocate: rel=0x%x, relSz=0x%x, relEntSz=0x%x\n", rel, relSz, relEntSz);
+               j = relSz / relEntSz;
+               for( i = 0; i < j; i++ )
+               {
+                       //DEBUGS("  Rel %i: 0x%x+0x%x\n", i, iBaseDiff, rel[i].r_offset);
+                       ptr = (void*)(iBaseDiff + rel[i].r_offset);
+                       elf_doRelocate(rel[i].r_info, ptr, *ptr, dynsymtab, iBaseDiff);
+               }
+       }
+       // Parse Relocation Entries
+       if(rela && relaSz)
+       {
+               Uint32  *ptr;
+               DEBUGS(" elf_relocate: rela=0x%x, relaSz=0x%x, relaEntSz=0x%x\n", rela, relaSz, relaEntSz);
+               j = relaSz / relaEntSz;
+               for( i = 0; i < j; i++ )
+               {
+                       ptr = (void*)(iBaseDiff + rela[i].r_offset);
+                       elf_doRelocate(rel[i].r_info, ptr, rela[i].r_addend, dynsymtab, iBaseDiff);
+               }
+       }
+       
+       // === Process PLT (Procedure Linkage Table) ===
+       if(plt && pltSz)
+       {
+               Uint32  *ptr;
+               DEBUGS(" elf_relocate: Relocate PLT, plt=0x%x\n", plt);
+               if(pltType == DT_REL)
+               {
+                       Elf32_Rel       *pltRel = plt;
+                       j = pltSz / sizeof(Elf32_Rel);
+                       DEBUGS(" elf_relocate: PLT Reloc Type = Rel, %i entries\n", j);
+                       for(i=0;i<j;i++)
+                       {
+                               ptr = (void*)(iBaseDiff + pltRel[i].r_offset);
+                               elf_doRelocate(pltRel[i].r_info, ptr, *ptr, dynsymtab, iRealBase);
+                       }
+               }
+               else
                {
-                       //DEBUGS("  Rel %i: 0x%x+0x%x\n", i, iBaseDiff, rel[i].r_offset);\r
-                       ptr = (void*)(iBaseDiff + rel[i].r_offset);\r
-                       elf_doRelocate(rel[i].r_info, ptr, *ptr, dynsymtab, iBaseDiff);\r
-               }\r
-       }\r
-       // Parse Relocation Entries\r
-       if(rela && relaSz)\r
-       {\r
-               Uint32  *ptr;\r
-               DEBUGS(" elf_relocate: rela=0x%x, relaSz=0x%x, relaEntSz=0x%x\n", rela, relaSz, relaEntSz);\r
-               j = relaSz / relaEntSz;\r
-               for( i = 0; i < j; i++ )\r
-               {\r
-                       ptr = (void*)(iBaseDiff + rela[i].r_offset);\r
-                       elf_doRelocate(rel[i].r_info, ptr, rela[i].r_addend, dynsymtab, iBaseDiff);\r
-               }\r
-       }\r
-       \r
-       // === Process PLT (Procedure Linkage Table) ===\r
-       if(plt && pltSz)\r
-       {\r
-               Uint32  *ptr;\r
-               DEBUGS(" elf_relocate: Relocate PLT, plt=0x%x\n", plt);\r
-               if(pltType == DT_REL)\r
-               {\r
-                       Elf32_Rel       *pltRel = plt;\r
-                       j = pltSz / sizeof(Elf32_Rel);\r
-                       DEBUGS(" elf_relocate: PLT Reloc Type = Rel, %i entries\n", j);\r
-                       for(i=0;i<j;i++)\r
-                       {\r
-                               ptr = (void*)(iBaseDiff + pltRel[i].r_offset);\r
-                               elf_doRelocate(pltRel[i].r_info, ptr, *ptr, dynsymtab, iRealBase);\r
-                       }\r
-               }\r
-               else\r
-               {\r
-                       Elf32_Rela      *pltRela = plt;\r
-                       j = pltSz / sizeof(Elf32_Rela);\r
-                       DEBUGS(" elf_relocate: PLT Reloc Type = Rela, %i entries\n", j);\r
-                       for(i=0;i<j;i++)\r
-                       {\r
-                               ptr = (void*)(iRealBase + pltRela[i].r_offset);\r
-                               elf_doRelocate(pltRela[i].r_info, ptr, pltRela[i].r_addend, dynsymtab, iRealBase);\r
-                       }\r
-               }\r
-       }\r
-       \r
-       DEBUGS("ElfRelocate: RETURN 0x%x", hdr->entrypoint);\r
-       return hdr->entrypoint;\r
-}\r
-\r
-void elf_doRelocate(Uint r_info, Uint32 *ptr, Uint32 addend, Elf32_Sym *symtab, Uint base)\r
-{\r
-        int    type = ELF32_R_TYPE(r_info);\r
-        int    sym = ELF32_R_SYM(r_info);\r
-       Uint32  val;\r
-       switch( type )\r
-       {\r
-       // Standard 32 Bit Relocation (S+A)\r
-       case R_386_32:\r
-               val = GetSymbol( symtab[sym].name );\r
-               DEBUGS(" elf_doRelocate: R_386_32 *0x%x += 0x%x('%s')\n",\r
-                       ptr, val, symtab[sym].name);\r
-               *ptr = val + addend;\r
-               break;\r
-               \r
-       // 32 Bit Relocation wrt. Offset (S+A-P)\r
-       case R_386_PC32:\r
-               DEBUGS(" elf_doRelocate: #%i: '%s'\n", sym, symtab[sym].name);\r
-               val = GetSymbol( symtab[sym].name );\r
-               DEBUGS(" elf_doRelocate: R_386_PC32 *0x%x = 0x%x + 0x%x - 0x%x\n",\r
-                       ptr, *ptr, val, (Uint)ptr );\r
-               *ptr = val + addend - (Uint)ptr;\r
-               //*ptr = val + addend - ((Uint)ptr - base);\r
+                       Elf32_Rela      *pltRela = plt;
+                       j = pltSz / sizeof(Elf32_Rela);
+                       DEBUGS(" elf_relocate: PLT Reloc Type = Rela, %i entries\n", j);
+                       for(i=0;i<j;i++)
+                       {
+                               ptr = (void*)(iRealBase + pltRela[i].r_offset);
+                               elf_doRelocate(pltRela[i].r_info, ptr, pltRela[i].r_addend, dynsymtab, iRealBase);
+                       }
+               }
+       }
+       
+       DEBUGS("ElfRelocate: RETURN 0x%x", hdr->entrypoint);
+       return (void*)hdr->entrypoint;
+}
+
+void elf_doRelocate(Uint r_info, Uint32 *ptr, Uint32 addend, Elf32_Sym *symtab, Uint base)
+{
+        int    type = ELF32_R_TYPE(r_info);
+        int    sym = ELF32_R_SYM(r_info);
+       Uint32  val;
+       switch( type )
+       {
+       // Standard 32 Bit Relocation (S+A)
+       case R_386_32:
+               val = (intptr_t) GetSymbol( symtab[sym].name );
+               DEBUGS(" elf_doRelocate: R_386_32 *0x%x += 0x%x('%s')\n",
+                       ptr, val, symtab[sym].name);
+               *ptr = val + addend;
+               break;
+               
+       // 32 Bit Relocation wrt. Offset (S+A-P)
+       case R_386_PC32:
+               DEBUGS(" elf_doRelocate: #%i: '%s'\n", sym, symtab[sym].name);
+               val = (intptr_t) GetSymbol( symtab[sym].name );
+               DEBUGS(" elf_doRelocate: R_386_PC32 *0x%x = 0x%x + 0x%x - 0x%x\n",
+                       ptr, *ptr, val, (Uint)ptr );
+               *ptr = val + addend - (intptr_t)ptr;
+               //*ptr = val + addend - ((Uint)ptr - base);
                break;
-\r
-       // Absolute Value of a symbol (S)\r
-       case R_386_GLOB_DAT:\r
+
+       // Absolute Value of a symbol (S)
+       case R_386_GLOB_DAT:
        case R_386_JMP_SLOT:
-               DEBUGS(" elf_doRelocate: #%i: '%s'\n", sym, symtab[sym].name);\r
-               val = GetSymbol( symtab[sym].name );\r
-               DEBUGS(" elf_doRelocate: %s *0x%x = 0x%x\n", csaR_NAMES[type], ptr, val);\r
-               *ptr = val;\r
-               break;\r
-\r
-       // Base Address (B+A)\r
-       case R_386_RELATIVE:\r
-               DEBUGS(" elf_doRelocate: R_386_RELATIVE *0x%x = 0x%x + 0x%x\n", ptr, base, addend);\r
-               *ptr = base + addend;\r
-               break;\r
-               \r
-       default:\r
-               DEBUGS(" elf_doRelocate: Rel 0x%x: 0x%x,%s\n", ptr, sym, csaR_NAMES[type]);\r
-               break;\r
-       }\r
-       \r
+               DEBUGS(" elf_doRelocate: #%i: '%s'\n", sym, symtab[sym].name);
+               val = (intptr_t) GetSymbol( symtab[sym].name );
+               DEBUGS(" elf_doRelocate: %s *0x%x = 0x%x\n", csaR_NAMES[type], ptr, val);
+               *ptr = val;
+               break;
+
+       // Base Address (B+A)
+       case R_386_RELATIVE:
+               DEBUGS(" elf_doRelocate: R_386_RELATIVE *0x%x = 0x%x + 0x%x\n", ptr, base, addend);
+               *ptr = base + addend;
+               break;
+               
+       default:
+               DEBUGS(" elf_doRelocate: Rel 0x%x: 0x%x,%s\n", ptr, sym, csaR_NAMES[type]);
+               break;
+       }
+       
 }
-\r
-/**\r
- * \fn int ElfGetSymbol(Uint Base, char *name, Uint *ret)\r
+
+/**
+ * \fn int ElfGetSymbol(Uint Base, char *name, void **ret)
  */
-int ElfGetSymbol(Uint Base, char *Name, Uint *ret)
+int ElfGetSymbol(void *Base, char *Name, void **ret)
 {
-       Elf32_Ehdr      *hdr = (void*)Base;\r
+       Elf32_Ehdr      *hdr = Base;
        Elf32_Sym       *symtab;
-        int    nbuckets = 0;\r
+        int    nbuckets = 0;
         int    iSymCount = 0;
-        int    i;\r
-       Uint    *pBuckets;\r
-       Uint    *pChains;\r
+        int    i;
+       Uint    *pBuckets;
+       Uint    *pChains;
        Uint    iNameHash;
-\r
-       //DEBUGS("ElfGetSymbol: (Base=0x%x, Name='%s')\n", Base, Name);\r
-\r
-       // Catch the current executable\r
-       #if 0\r
-       if( !hdr->misc.HashTable )\r
-       {\r
-               Elf32_Phdr      *phtab;\r
-               Elf32_Dyn       *dynTab = NULL;\r
-                int    j;\r
-               \r
-               // Locate the tables\r
-               phtab = (void*)( Base + hdr->phoff );\r
-               for( i = 0; i < hdr->phentcount; i ++ )\r
-               {\r
-                       if( phtab[i].Type == PT_DYNAMIC ) {\r
-                               dynTab = (void*)phtab[i].VAddr;\r
-                               break ;\r
-                       }\r
-               }\r
-               if( !dynTab ) {\r
-                       SysDebug("ERROR - Unable to find DYNAMIC segment in %p", (void*)Base);\r
-                       return 0;\r
-               }\r
-               \r
-               for( j = 0; dynTab[j].d_tag != DT_NULL; j++)\r
-               {\r
-                       switch(dynTab[j].d_tag)\r
-                       {\r
-                       // --- Symbol Table ---\r
-                       case DT_SYMTAB:\r
-                               hdr->misc.SymTable = dynTab[j].d_val;\r
-                               break;\r
-                       // --- Hash Table --\r
-                       case DT_HASH:\r
-                               hdr->misc.HashTable = dynTab[j].d_val;\r
-                               break;\r
-                       }\r
-               }\r
-       }\r
-       #endif\r
-       \r
-       if( !hdr->misc.SymTable || !hdr->misc.HashTable ) {\r
-               return 0;\r
-       }\r
-\r
-       pBuckets = (void *) hdr->misc.HashTable;\r
-       symtab = (void *) hdr->misc.SymTable;\r
+
+       //DEBUGS("ElfGetSymbol: (Base=0x%x, Name='%s')\n", Base, Name);
+
+       // Catch the current executable
+       #if 0
+       if( !hdr->misc.HashTable )
+       {
+               Elf32_Phdr      *phtab;
+               Elf32_Dyn       *dynTab = NULL;
+                int    j;
+               
+               // Locate the tables
+               phtab = (void*)( Base + hdr->phoff );
+               for( i = 0; i < hdr->phentcount; i ++ )
+               {
+                       if( phtab[i].Type == PT_DYNAMIC ) {
+                               dynTab = (void*)phtab[i].VAddr;
+                               break ;
+                       }
+               }
+               if( !dynTab ) {
+                       SysDebug("ERROR - Unable to find DYNAMIC segment in %p", (void*)Base);
+                       return 0;
+               }
+               
+               for( j = 0; dynTab[j].d_tag != DT_NULL; j++)
+               {
+                       switch(dynTab[j].d_tag)
+                       {
+                       // --- Symbol Table ---
+                       case DT_SYMTAB:
+                               hdr->misc.SymTable = dynTab[j].d_val;
+                               break;
+                       // --- Hash Table --
+                       case DT_HASH:
+                               hdr->misc.HashTable = dynTab[j].d_val;
+                               break;
+                       }
+               }
+       }
+       #endif
+       
+       if( !hdr->misc.SymTable || !hdr->misc.HashTable ) {
+               return 0;
+       }
+
+       pBuckets = (void *) (intptr_t) hdr->misc.HashTable;
+       symtab = (void *) (intptr_t) hdr->misc.SymTable;
+       
+       nbuckets = pBuckets[0];
+       iSymCount = pBuckets[1];
+       pBuckets = &pBuckets[2];
+       pChains = &pBuckets[ nbuckets ];
        
-       nbuckets = pBuckets[0];\r
-       iSymCount = pBuckets[1];\r
-       pBuckets = &pBuckets[2];\r
-       pChains = &pBuckets[ nbuckets ];\r
-       \r
        // Get hash
-       iNameHash = ElfHashString(Name);\r
-       iNameHash %= nbuckets;\r
-       //DEBUGS(" ElfGetSymbol: iNameHash = 0x%x\n", iNameHash);\r
+       iNameHash = ElfHashString(Name);
+       iNameHash %= nbuckets;
+       //DEBUGS(" ElfGetSymbol: iNameHash = 0x%x\n", iNameHash);
 
-       // Walk Chain\r
-       i = pBuckets[ iNameHash ];\r
-       //DEBUGS(" ElfGetSymbol: strcmp(Name, \"%s\")\n", symtab[i].name);\r
-       if(symtab[i].shndx != SHN_UNDEF && strcmp(symtab[i].name, Name) == 0) {\r
-               *ret = symtab[ i ].value;\r
-               return 1;\r
-       }\r
-       \r
-       //DEBUGS(" ElfGetSymbol: Hash of first = 0x%x\n", ElfHashString( symtab[i].name ) % nbuckets);\r
-       while(pChains[i] != STN_UNDEF)\r
-       {\r
-               //DEBUGS(" pChains[%i] = %i\n", i, pChains[i]);\r
-               i = pChains[i];\r
-               //DEBUGS(" ElfGetSymbol: strcmp(Name, \"%s\")\n", symtab[ i ].name);\r
-               if(symtab[i].shndx != SHN_UNDEF && strcmp(symtab[ i ].name, Name) == 0) {\r
-                       //DEBUGS("ElfGetSymbol: RETURN 1, '%s' = 0x%x\n", symtab[ i ].name, symtab[ i ].value);\r
-                       *ret = symtab[ i ].value;\r
-                       return 1;\r
-               }\r
-       }\r
-       \r
+       // Walk Chain
+       i = pBuckets[ iNameHash ];
+       //DEBUGS(" ElfGetSymbol: strcmp(Name, \"%s\")\n", symtab[i].name);
+       if(symtab[i].shndx != SHN_UNDEF && strcmp(symtab[i].name, Name) == 0) {
+               *ret = (void*) (intptr_t) symtab[ i ].value;
+               return 1;
+       }
+       
+       //DEBUGS(" ElfGetSymbol: Hash of first = 0x%x\n", ElfHashString( symtab[i].name ) % nbuckets);
+       while(pChains[i] != STN_UNDEF)
+       {
+               //DEBUGS(" pChains[%i] = %i\n", i, pChains[i]);
+               i = pChains[i];
+               //DEBUGS(" ElfGetSymbol: strcmp(Name, \"%s\")\n", symtab[ i ].name);
+               if(symtab[i].shndx != SHN_UNDEF && strcmp(symtab[ i ].name, Name) == 0) {
+                       //DEBUGS("ElfGetSymbol: RETURN 1, '%s' = 0x%x\n", symtab[ i ].name, symtab[ i ].value);
+                       *ret = (void*)(intptr_t)symtab[ i ].value;
+                       return 1;
+               }
+       }
+       
        //DEBUGS("ElfGetSymbol: RETURN 0, Symbol '%s' not found\n", Name);
        return 0;
-}\r
-\r
-Uint ElfHashString(char *name)\r
-{\r
-       Uint    h = 0, g;\r
-       while(*name)\r
-       {\r
-               h = (h << 4) + *name++;\r
-               if( (g = h & 0xf0000000) )\r
-                       h ^= g >> 24;\r
-               h &= ~g;\r
-       }\r
-       return h;\r
-}\r
-\r
-#if 0\r
-unsigned long elf_hash(const unsigned char *name)\r
-{\r
-       unsigned long   h = 0, g;\r
-       while (*name)\r
-       {\r
-               h = (h << 4) + *name++;\r
-               if (g = h & 0xf0000000)\r
-                       h ^= g >> 24;\r
-               h &= ~g;\r
-       }\r
-       return h;\r
-}\r
-#endif\r
+}
+
+Uint ElfHashString(char *name)
+{
+       Uint    h = 0, g;
+       while(*name)
+       {
+               h = (h << 4) + *name++;
+               if( (g = h & 0xf0000000) )
+                       h ^= g >> 24;
+               h &= ~g;
+       }
+       return h;
+}
+
+#if 0
+unsigned long elf_hash(const unsigned char *name)
+{
+       unsigned long   h = 0, g;
+       while (*name)
+       {
+               h = (h << 4) + *name++;
+               if (g = h & 0xf0000000)
+                       h ^= g >> 24;
+               h &= ~g;
+       }
+       return h;
+}
+#endif
index 83a1c7a..d69c6d2 100644 (file)
@@ -6,11 +6,11 @@
 
 #define _STR(x)        #x
 #define STR(x) _STR(x)
-#define EXP(sym)       {(Uint)&sym, STR(sym)}
+#define EXP(sym)       {&sym, STR(sym)}
 
 // === CONSTANTS ===
 const struct {
-       Uint    Value;
+       void    *Value;
        char    *Name;
 }      caLocalExports[] = {
        EXP(gLoadedLibraries),
index a5f0bc2..da74b82 100644 (file)
 #endif
 
 // === PROTOTYPES ===
-Uint   IsFileLoaded(char *file);
- int   GetSymbolFromBase(Uint base, char *name, Uint *ret);
+void   *IsFileLoaded(char *file);
+ int   GetSymbolFromBase(void *base, char *name, void **ret);
 
 // === IMPORTS ===
 extern const struct {
-       Uint    Value;
+       void    *Value;
        char    *Name;
 }      caLocalExports[];
 extern const int       ciNumLocalExports;
@@ -54,12 +54,12 @@ char *FindLibrary(char *DestBuf, char *SoName, char *ExtraSearchDir)
 
 /**
  */
-Uint LoadLibrary(char *SoName, char *SearchDir, char **envp)
+void *LoadLibrary(char *SoName, char *SearchDir, char **envp)
 {
        char    sTmpName[1024];
        char    *filename;
-       Uint    iArg;
-       void    (*fEntry)(int, int, char *[], char**);
+       void    *base;
+       void    (*fEntry)(void *, int, char *[], char**);
        
        DEBUGS("LoadLibrary: (filename='%s', envp=0x%x)\n", filename, envp);
        
@@ -71,34 +71,34 @@ Uint LoadLibrary(char *SoName, char *SearchDir, char **envp)
        }
        DEBUGS(" LoadLibrary: filename='%s'\n", filename);
        
-       if( (iArg = IsFileLoaded(filename)) )
-               return iArg;
+       if( (base = IsFileLoaded(filename)) )
+               return base;
        
        // Load Library
-       iArg = SysLoadBin(filename, (Uint*)&fEntry);
-       if(iArg == 0) {
+       base = SysLoadBin(filename, (void**)&fEntry);
+       if(!base) {
                DEBUGS("LoadLibrary: RETURN 0\n");
                return 0;
        }
        
-       DEBUGS(" LoadLibrary: iArg=0x%x, iEntry=0x%x\n", iArg, fEntry);
+       DEBUGS(" LoadLibrary: iArg=%p, iEntry=0x%x\n", base, fEntry);
        
        // Load Symbols
-       fEntry = (void*)DoRelocate( iArg, envp, filename );
+       fEntry = DoRelocate( base, envp, filename );
        
        // Call Entrypoint
        DEBUGS(" LoadLibrary: '%s' Entry 0x%x\n", SoName, fEntry);
-       fEntry(iArg, 0, NULL, envp);
+       fEntry(base, 0, NULL, envp);
        
        DEBUGS("LoadLibrary: RETURN 1\n");
-       return iArg;
+       return base;
 }
 
 /**
  * \fn Uint IsFileLoaded(char *file)
  * \brief Determine if a file is already loaded
  */
-Uint IsFileLoaded(char *file)
+void *IsFileLoaded(char *file)
 {
         int    i;
        DEBUGS("IsFileLoaded: (file='%s')", file);
@@ -119,7 +119,7 @@ Uint IsFileLoaded(char *file)
  * \fn void AddLoaded(char *File, Uint base)
  * \brief Add a file to the loaded list
  */
-void AddLoaded(char *File, Uint base)
+void AddLoaded(char *File, void *base)
 {
         int    i, length;
        char    *name = gsNextAvailString;
@@ -155,7 +155,7 @@ void AddLoaded(char *File, Uint base)
 /**
  * \fn void Unload(Uint Base)
  */
-void Unload(Uint Base)
+void Unload(void *Base)
 {      
         int    i, j;
         int    id;
@@ -195,10 +195,10 @@ void Unload(Uint Base)
  \fn Uint GetSymbol(char *name)
  \brief Gets a symbol value from a loaded library
 */
-Uint GetSymbol(char *name)
+void *GetSymbol(char *name)
 {
         int    i;
-       Uint    ret;
+       void    *ret;
        
        //SysDebug("ciNumLocalExports = %i", ciNumLocalExports);
        for(i=0;i<ciNumLocalExports;i++)
@@ -223,7 +223,7 @@ Uint GetSymbol(char *name)
  \fn int GetSymbolFromBase(Uint base, char *name, Uint *ret)
  \breif Gets a symbol from a specified library
 */
-int GetSymbolFromBase(Uint base, char *name, Uint *ret)
+int GetSymbolFromBase(void *base, char *name, void **ret)
 {
        if(*(Uint32*)base == (0x7F|('E'<<8)|('L'<<16)|('F'<<24)))
                return ElfGetSymbol(base, name, ret);
index 85fbc74..dfb1b61 100644 (file)
@@ -2,13 +2,14 @@
  AcessOS 1 - Dynamic Loader\r
  By thePowersGang\r
 */\r
+#include <stdint.h>\r
 #include "common.h"\r
 \r
 // === PROTOTYPES ===\r
- int   DoRelocate( Uint base, char **envp, char *Filename );\r
- int   CallUser(Uint entry, Uint SP);\r
- int   ElfRelocate(void *Base, char *envp[], char *Filename);\r
- int   PE_Relocate(void *Base, char *envp[], char *Filename);\r
+void   *DoRelocate(void *base, char **envp, char *Filename);\r
+ int   CallUser(void *Entry, void *SP);\r
+void   *ElfRelocate(void *Base, char *envp[], char *Filename);\r
+void   *PE_Relocate(void *Base, char *envp[], char *Filename);\r
 \r
 // === Imports ===\r
 extern void    gLinkedBase;\r
@@ -20,24 +21,25 @@ extern tLoadedLib   gLoadedLibraries[];
  \brief Library entry point\r
  \note This is the entrypoint for the library\r
 */\r
-int SoMain(Uint base, int arg1)\r
+int SoMain(void *base, void *arg1)\r
 {\r
-        int    ret;\r
+       void    *ret;\r
         \r
        // - Assume that the file pointer will be less than 4096\r
-       if(base < 0x1000) {\r
+       if((intptr_t)base < 0x1000) {\r
                SysDebug("ld-acess - SoMain: Passed file pointer %i\n", base);\r
                _exit(-1);\r
                for(;;);\r
        }\r
        // Check if we are being called directly\r
-       if(base == (Uint)&gLinkedBase) {\r
+       if(base == &gLinkedBase) {\r
                SysDebug("ld-acess should not be directly called\n");\r
                _exit(1);\r
                for(;;);\r
        }\r
 \r
-       gLoadedLibraries[0].Base = (Uint)&gLinkedBase;\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
@@ -51,22 +53,22 @@ int SoMain(Uint base, int arg1)
        \r
        // And call user\r
        //SysDebug("Calling User at 0x%x\n", ret);\r
-       CallUser( ret, (Uint)&arg1 );\r
+       CallUser( ret, &arg1 );\r
        \r
        return 0;\r
 }\r
 \r
 /**\r
- \fn int DoRelocate(Uint base, char **envp)\r
+ \fn int DoRelocate(void *base, char **envp)\r
  \brief Relocates an in-memory image\r
 */\r
-int DoRelocate( Uint base, char **envp, char *Filename )\r
+void *DoRelocate(void *base, char **envp, char *Filename)\r
 {\r
        // Load Executable\r
-       if(*(Uint*)base == (0x7F|('E'<<8)|('L'<<16)|('F'<<24)))\r
-               return ElfRelocate((void*)base, envp, Filename);\r
+       if(*(Uint32*)base == (0x7F|('E'<<8)|('L'<<16)|('F'<<24)))\r
+               return ElfRelocate(base, envp, Filename);\r
        if(*(Uint16*)base == ('M'|('Z'<<8)))\r
-               return PE_Relocate((void*)base, envp, Filename);\r
+               return PE_Relocate(base, envp, Filename);\r
        \r
        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
@@ -78,13 +80,20 @@ int DoRelocate( Uint base, char **envp, char *Filename )
 /**\r
  \fn int CallUser(Uint entry, Uint sp)\r
 */\r
-int CallUser(Uint entry, Uint sp)\r
+int CallUser(void *entry, void *sp)\r
 {\r
-       //SysDebug("CallUser: (entry=0x%x, sp=0x%x)", entry, sp);\r
-       *(Uint*)(sp-4) = 0;     // Clear return address\r
+       #if ARCHDIR_IS_x86_64\r
+       ((void **)sp)[-1] = 0;  // Clear return address\r
+       __asm__ __volatile__ (\r
+       "mov %%rax, %%rsp;\n\t"\r
+       "jmp *%%rcx"\r
+       : : "a"(sp), "c"(entry));\r
+       #elif ARCHDIR_IS_x86\r
+       ((void **)sp)[-1] = 0;  // Clear return address\r
        __asm__ __volatile__ (\r
        "mov %%eax, %%esp;\n\t"\r
        "jmp *%%ecx"\r
        : : "a"(sp), "c"(entry));\r
+       #endif\r
        for(;;);\r
 }\r
diff --git a/Usermode/Libraries/ld-acess.so_src/mm.asm b/Usermode/Libraries/ld-acess.so_src/mm.asm
deleted file mode 100644 (file)
index bede9ae..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-;
-; Acess2 System Interface
-;
-%include "syscalls.inc.asm"
-
-[BITS 32]
-[extern _errno]
-
-[section .text]
-SYSCALL1       _SysGetPhys, SYS_GETPHYS        ; uint64_t _SysGetPhys(uint addr)
-SYSCALL1       _SysAllocate, SYS_ALLOCATE      ; uint64_t _SysAllocate(uint addr)
index ec3b6b8..afcb4ce 100644 (file)
@@ -3,6 +3,7 @@
  * Portable Executable Loader\r
  */\r
 #include "common.h"\r
+#include <stdint.h>\r
 #include "pe.h"\r
 \r
 #define PE_DEBUG       0\r
@@ -20,7 +21,7 @@
 // === PROTOTYPES ===\r
  int   PE_Relocate(void *Base, char **envp, char *Filename);\r
 char   *PE_int_GetTrueFile(char *file);\r
- int   PE_int_GetForwardSymbol(char *Fwd, Uint *Value);\r
+ int   PE_int_GetForwardSymbol(char *Fwd, void **Value);\r
 \r
 // === CODE ===\r
 int PE_Relocate(void *Base, char *envp[], char *Filename)\r
@@ -32,8 +33,8 @@ int PE_Relocate(void *Base, char *envp[], char *Filename)
        tPE_HINT_NAME   *name;\r
        Uint32  *importTab, *aIAT;\r
         int    i, j;\r
-       Uint    iBase = (Uint)Base;\r
-       Uint    iLibBase;\r
+       intptr_t        iBase = (intptr_t)Base;\r
+       void    *pLibBase;\r
        \r
        DEBUGS("PE_Relocate: (Base=0x%x)\n", Base);\r
        \r
@@ -49,12 +50,12 @@ int PE_Relocate(void *Base, char *envp[], char *Filename)
                impDir[i].ImportLookupTable += iBase/4;\r
                impDir[i].ImportAddressTable += iBase/4;\r
                DEBUGS(" PE_Relocate: DLL Required '%s'(0x%x)\n", impDir[i].DLLName, impDir[i].DLLName);\r
-               iLibBase = LoadLibrary(PE_int_GetTrueFile(impDir[i].DLLName), DLL_BASE_PATH, envp);\r
-               if(iLibBase == 0) {\r
+               pLibBase = LoadLibrary(PE_int_GetTrueFile(impDir[i].DLLName), DLL_BASE_PATH, envp);\r
+               if(pLibBase == 0) {\r
                        SysDebug("Unable to load required library '%s'\n", impDir[i].DLLName);\r
                        return 0;\r
                }\r
-               DEBUGS(" PE_Relocate: Loaded as 0x%x\n", iLibBase);\r
+               DEBUGS(" PE_Relocate: Loaded as 0x%x\n", pLibBase);\r
                importTab = impDir[i].ImportLookupTable;\r
                aIAT = impDir[i].ImportAddressTable;\r
                for( j = 0; importTab[j] != 0; j++ )\r
@@ -63,12 +64,14 @@ int PE_Relocate(void *Base, char *envp[], char *Filename)
                                DEBUGS(" PE_Relocate: Import Ordinal %i\n", importTab[j] & 0x7FFFFFFF);\r
                        else\r
                        {\r
+                               void    *symPtr = 0;\r
                                name = (void*)( iBase + importTab[j] );\r
                                DEBUGS(" PE_Relocate: Import Name '%s', Hint 0x%x\n", name->Name, name->Hint);\r
-                               if( GetSymbolFromBase(iLibBase, name->Name, (Uint*)&aIAT[j]) == 0 ) {\r
+                               if( GetSymbolFromBase(pLibBase, name->Name, symPtr) == 0 ) {\r
                                        SysDebug("Unable to find symbol '%s' in library '%s'\n", name->Name, impDir[i].DLLName);\r
                                        return 0;\r
                                }\r
+                               aIAT[j] = (intptr_t)symPtr;\r
                        }\r
                }\r
        }\r
@@ -88,9 +91,9 @@ int PE_Relocate(void *Base, char *envp[], char *Filename)
 /**\r
  * \fn int PE_GetSymbol(Uint Base, char *Name, Uint *Ret)\r
  */\r
-int PE_GetSymbol(Uint Base, char *Name, Uint *Ret)\r
+int PE_GetSymbol(void *Base, char *Name, void **Ret)\r
 {\r
-       tPE_DOS_HEADER          *dosHdr = (void*)Base;\r
+       tPE_DOS_HEADER          *dosHdr = Base;\r
        tPE_IMAGE_HEADERS       *peHeaders;\r
        tPE_DATA_DIR    *directory;\r
        tPE_EXPORT_DIR  *expDir;\r
@@ -99,7 +102,7 @@ int PE_GetSymbol(Uint Base, char *Name, Uint *Ret)
         int    i;\r
         int    symbolCount;\r
        char    *name;\r
-       Uint    retVal;\r
+       intptr_t        retVal;\r
        Uint    expLen;\r
        \r
        peHeaders = (void*)( Base + dosHdr->PeHdrOffs );\r
@@ -118,14 +121,14 @@ int PE_GetSymbol(Uint Base, char *Name, Uint *Ret)
                //DEBUGS(" PE_GetSymbol: '%s' = 0x%x\n", name, Base + addrTable[ ordTable[i] ]);\r
                if(strcmp(name, Name) == 0)\r
                {\r
-                       retVal = Base + addrTable[ ordTable[i] ];\r
+                       retVal = (intptr_t) Base + addrTable[ ordTable[i] ];\r
                        // Check for forwarding\r
-                       if((Uint)expDir < retVal && retVal < (Uint)expDir + expLen) {\r
+                       if( (intptr_t)expDir < retVal && retVal < (intptr_t)expDir + expLen) {\r
                                char *fwd = (char*)retVal;\r
                                DEBUGS(" PE_GetSymbol: '%s' forwards to '%s'\n", name, fwd);\r
                                return PE_int_GetForwardSymbol(fwd, Ret);\r
                        }\r
-                       *Ret = retVal;\r
+                       *Ret = (void*)retVal;\r
                        return 1;\r
                }\r
        }\r
@@ -149,12 +152,12 @@ char *PE_int_GetTrueFile(char *file)
        return &file[1];\r
 }\r
 \r
-int PE_int_GetForwardSymbol(char *Fwd, Uint *Value)\r
+int PE_int_GetForwardSymbol(char *Fwd, void **Value)\r
 {\r
        char    *libname;\r
        char    *sym;\r
         int    i;\r
-       Uint    libbase;\r
+       void    *libbase;\r
         int    ret;\r
        \r
        // -- Find seperator\r
diff --git a/Usermode/Libraries/ld-acess.so_src/syscalls.inc.asm b/Usermode/Libraries/ld-acess.so_src/syscalls.inc.asm
deleted file mode 100644 (file)
index eea5573..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-; ========================
-; AcssMicro - System Calls
-; ========================
-
-%include "../../../Kernel/include/syscalls.inc.asm"
-
-;%define SYSCALL_OP    jmp 0xCFFF0000
-%define SYSCALL_OP     int 0xAC
-
-; System Call - No Arguments
-%macro SYSCALL0        2
-[global %1:func]
-%1:
-       push ebx
-       mov eax, %2
-       SYSCALL_OP
-       mov [_errno], ebx
-       pop ebx
-       ret
-%endmacro
-
-; System Call - 1 Argument
-%macro SYSCALL1        2
-[global %1:func]
-%1:
-       push ebp
-       mov ebp, esp
-       push ebx
-       mov eax, %2
-       mov ebx, [ebp+8]
-       SYSCALL_OP
-       mov [_errno], ebx
-       pop ebx
-       pop ebp
-       ret
-%endmacro
-
-; System Call - 2 Arguments
-%macro SYSCALL2        2
-[global %1:func]
-%1:
-       push ebp
-       mov ebp, esp
-       push ebx
-       mov eax, %2
-       mov ebx, [ebp+8]
-       mov ecx, [ebp+12]
-       SYSCALL_OP
-       mov [_errno], ebx
-       pop ebx
-       pop ebp
-       ret
-%endmacro
-
-; System Call - 3 Arguments
-%macro SYSCALL3        2
-[global %1:func]
-%1:
-       push ebp
-       mov ebp, esp
-       push ebx
-       mov eax, %2
-       mov ebx, [ebp+8]
-       mov ecx, [ebp+12]
-       mov edx, [ebp+16]
-       SYSCALL_OP
-       mov [_errno], ebx
-       pop ebx
-       pop ebp
-       ret
-%endmacro
-
-; System Call - 4 Arguments
-%macro SYSCALL4        2
-[global %1:func]
-%1:
-       push ebp
-       mov ebp, esp
-       push ebx
-       push edi
-       mov eax, %2
-       mov ebx, [ebp+8]
-       mov ecx, [ebp+12]
-       mov edx, [ebp+16]
-       mov edi, [ebp+20]
-       SYSCALL_OP
-       mov [_errno], ebx
-       pop edi
-       pop ebx
-       pop ebp
-       ret
-%endmacro
-
-; System Call - 5 Arguments
-%macro SYSCALL5        2
-[global %1:func]
-%1:
-       push ebp
-       mov ebp, esp
-       push ebx
-       push edi
-       push esi
-       mov eax, %2
-       mov ebx, [ebp+8]
-       mov ecx, [ebp+12]
-       mov edx, [ebp+16]
-       mov edi, [ebp+20]
-       mov esi, [ebp+24]
-       SYSCALL_OP
-       mov [_errno], ebx
-       pop esi
-       pop edi
-       pop ebx
-       pop ebp
-       ret
-%endmacro
-
-; System Call - 6 Arguments
-%macro SYSCALL6        2
-[global %1:func]
-%1:
-       push ebp
-       mov ebp, esp
-       push ebx
-       push edi
-       push esi
-       mov eax, %2
-       mov ebx, [ebp+8]
-       mov ecx, [ebp+12]
-       mov edx, [ebp+16]
-       mov edi, [ebp+20]
-       mov esi, [ebp+24]
-       mov ebp, [ebp+28]
-       SYSCALL_OP
-       mov [_errno], ebx
-       pop esi
-       pop edi
-       pop ebx
-       pop ebp
-       ret
-%endmacro
diff --git a/Usermode/Libraries/ld-acess.so_src/vfs.asm b/Usermode/Libraries/ld-acess.so_src/vfs.asm
deleted file mode 100644 (file)
index 6afd7c7..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-;
-; Acess2 System Interface
-;
-%include "syscalls.inc.asm"
-
-[BITS 32]
-[extern _errno]
-
-[section .text]
-SYSCALL2       open, SYS_OPEN  ; char*, int
-SYSCALL3       reopen, SYS_REOPEN      ; int, char*, int
-SYSCALL1       close, SYS_CLOSE        ; int
-SYSCALL3       read, SYS_READ  ; int, uint, void*
-SYSCALL3       write, SYS_WRITE        ; int, uint, void*
-SYSCALL4       seek, SYS_SEEK          ; int, uint64_t, int
-SYSCALL1       tell, SYS_TELL          ; int
-SYSCALL3       finfo, SYS_FINFO        ; int, void*, int
-SYSCALL2       readdir, SYS_READDIR    ; int, char*
-SYSCALL2       _SysGetACL, SYS_GETACL  ; int, void*
-SYSCALL1       chdir, SYS_CHDIR        ; char*
-SYSCALL3       ioctl, SYS_IOCTL        ; int, int, void*
-SYSCALL4       _SysMount, SYS_MOUNT    ; char*, char*, char*, char*
-SYSCALL5       select, SYS_SELECT      ; int, fd_set*, fd_set*, fd_set*, tTime*
-
-SYSCALL3       _SysOpenChild, SYS_OPENCHILD

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