AcessNative - Fix compile errors from API changes (and from compiler upgrade)
authorJohn Hodge (sonata) <[email protected]>
Wed, 5 Nov 2014 02:14:08 +0000 (10:14 +0800)
committerJohn Hodge (sonata) <[email protected]>
Wed, 5 Nov 2014 02:14:08 +0000 (10:14 +0800)
12 files changed:
AcessNative/acesskernel_src/Makefile
AcessNative/acesskernel_src/main.c
AcessNative/acesskernel_src/net_wrap.c
AcessNative/acesskernel_src/server.c
AcessNative/acesskernel_src/threads.c
AcessNative/acesskernel_src/threads_glue.c
AcessNative/acesskernel_src/vfs_handle.c
AcessNative/ld-acess_src/binary.c
AcessNative/ld-acess_src/common.h
AcessNative/ld-acess_src/elf_load.c
AcessNative/ld-acess_src/memory.c
AcessNative/ld-acess_src/request.c

index 9e8ce35..d2a22c6 100644 (file)
@@ -15,7 +15,7 @@ KERNEL_SRC = ../../KernelLand/Kernel/
 LDACESS_SRC = ../../Usermode/Libraries/ld-acess.so_src/\r
 \r
 # - Kernel objects (from KernelLand/Kernel)\r
-KERNEL_OBJ := logging.o adt.o lib.o debug.o messages.o drvutil_disk.o drvutil_video.o\r
+KERNEL_OBJ := logging.o adt.o lib.o debug.o messages.o drvutil_disk.o drvutil_video.o memfs_helpers.o\r
 KERNEL_OBJ += mutex.o semaphore.o rwlock.o workqueue.o events.o\r
 #KERNEL_OBJ += libc.o\r
 KERNEL_OBJ += vfs/main.o vfs/open.o vfs/acls.o vfs/io.o vfs/dir.o\r
index ead4f33..9ef49c9 100644 (file)
@@ -13,6 +13,7 @@
 #endif
 #include <unistd.h>
 #include <string.h>
+#include <stdbool.h>
 #include "../../KernelLand/Kernel/include/logdebug.h"
 
 #define VALGRIND_CLIENT        0
index 730eda0..33a5cf9 100644 (file)
@@ -8,6 +8,7 @@
 #define DEBUG  1
 #include <stdlib.h>
 #include <unistd.h>
+#include <stdbool.h>
 #include "../../KernelLand/Kernel/include/logdebug.h"
 #include "net_wrap.h"
 #include <string.h>
index f3826db..8de8ad3 100644 (file)
@@ -6,6 +6,7 @@
  */
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <string.h>
 #include <SDL/SDL.h>
 #ifdef __WIN32__
index 86b8a89..74d85fc 100644 (file)
@@ -199,9 +199,10 @@ int Threads_SetGID(tGID NewGID)
 }
 
 int *Threads_GetErrno(void) { return &gpCurrentThread->_errno; }
-char **Threads_GetCWD(void) { return &gpCurrentThread->Process->CWD; }
-char **Threads_GetChroot(void) { return &gpCurrentThread->Process->Chroot; }
-int *Threads_GetMaxFD(void) { return &gpCurrentThread->Process->MaxFD; };
+static tProcess *proc(tProcess *Proc) { return Proc ? Proc : gpCurrentThread->Process; }
+char **Threads_GetCWD   (tProcess *Proc) { return &proc(Proc)->CWD; }
+char **Threads_GetChroot(tProcess *Proc) { return &proc(Proc)->Chroot; }
+int *Threads_GetMaxFD   (tProcess *Proc) { return &proc(Proc)->MaxFD; };
 
 tTID Threads_WaitTID(int TID, int *Status)
 {
index fa83980..7c13780 100644 (file)
@@ -20,6 +20,7 @@ typedef void  **tShortSpinlock;
 #include <pthread.h>
 
 #define NORETURN       __attribute__((noreturn))
+#include <stdbool.h>
 #include <logdebug.h>  // Kernel land, but uses standards
 #include <errno.h>
 
index 6c3992f..93b6a9d 100644 (file)
@@ -79,7 +79,7 @@ void VFS_CloneHandleList(int PID)
        
        ent = VFS_int_GetUserHandles(PID, 1);
        
-       maxhandles = *Threads_GetMaxFD();
+       maxhandles = *Threads_GetMaxFD(NULL);
        memcpy(ent->Handles, cur->Handles, maxhandles*sizeof(tVFS_Handle));
        
        // Reference all
@@ -105,7 +105,7 @@ void VFS_CloneHandlesFromList(int PID, int nFD, int FDs[])
 
        LOG("Copying %i FDs from %i", nFD, PID);
 
-       maxhandles = *Threads_GetMaxFD();
+       maxhandles = *Threads_GetMaxFD(NULL);
        if( nFD > maxhandles )
                nFD = maxhandles;
        for( int i = 0; i < nFD; i ++ )
@@ -156,7 +156,7 @@ tVFS_Handle *VFS_GetHandle(int FD)
        else
        {
                 int    pid = Threads_GetPID();
-                int    maxhandles = *Threads_GetMaxFD();
+                int    maxhandles = *Threads_GetMaxFD(NULL);
                
                tUserHandles *ent = VFS_int_GetUserHandles(pid, 0);
                if(!ent) {
@@ -193,7 +193,7 @@ int VFS_SetHandle(int FD, tVFS_Node *Node, int Mode)
        else {
                tUserHandles    *ent;
                 int    pid = Threads_GetPID();
-                int    maxhandles = *Threads_GetMaxFD();
+                int    maxhandles = *Threads_GetMaxFD(NULL);
                
                ent = VFS_int_GetUserHandles(pid, 0);
                if(!ent) {
@@ -219,7 +219,7 @@ int VFS_AllocHandle(int bIsUser, tVFS_Node *Node, int Mode)
        if(bIsUser)
        {
                tUserHandles    *ent;
-                int    maxhandles = *Threads_GetMaxFD();
+                int    maxhandles = *Threads_GetMaxFD(NULL);
                // Find the PID's handle list
                ent = VFS_int_GetUserHandles(Threads_GetPID(), 1);
                // Get a handle
@@ -254,7 +254,7 @@ void VFS_ClearHandles(int PID)
        tUserHandles *ent = VFS_int_GetUserHandles(PID, 0);
        if( !ent )      return;
        // Get a handle
-        int    maxhandles = *Threads_GetMaxFD();
+        int    maxhandles = *Threads_GetMaxFD(NULL);
        for( int i = 0; i < maxhandles; i ++ )
        {
                if(ent->Handles[i].Node)        continue;
index 59be829..738c6e8 100644 (file)
@@ -6,6 +6,7 @@
  * - Provides binary loading and type abstraction
  */
 #define DEBUG  0
+#define _POSIX_C_SOURCE        200809L // needed for strdup
 #include "common.h"
 #include <stdint.h>
 #include <stdio.h>
@@ -228,7 +229,7 @@ void Binary_SetReadyToUse(void *Base)
        }
 }
 
-int Binary_GetSymbol(const char *SymbolName, uintptr_t *Value, size_t *Size)
+int Binary_GetSymbol(const char *SymbolName, uintptr_t *Value, size_t *Size, void *IgnoreBase)
 {
         int    i;
        tBinary *bin;
@@ -251,6 +252,7 @@ int Binary_GetSymbol(const char *SymbolName, uintptr_t *Value, size_t *Size)
        // Search list of loaded binaries
        for(bin = gLoadedBinaries; bin; bin = bin->Next)
        {
+               if( bin->Base == IgnoreBase )   continue ;
                if( !bin->Ready )       continue;
                //printf(" Binary_GetSymbol: bin = %p{%p, %s}\n", bin, bin->Base, bin->Path);
                if( bin->Format->GetSymbol(bin->Base, (char*)SymbolName, Value, Size) )
index 9f67e9c..0bdc40f 100644 (file)
@@ -8,16 +8,16 @@
 #include <stdint.h>
 #include <string.h>
 
-extern int     Binary_GetSymbol(const char *SymbolName, uintptr_t *Value, size_t *Size);
+extern int     Binary_GetSymbol(const char *SymbolName, uintptr_t *Value, size_t *Size, void *IgnoreBase);
 extern void    *Binary_LoadLibrary(const char *Path);
 extern void    *Binary_Load(const char *Path, uintptr_t *EntryPoint);
 extern void    Binary_SetReadyToUse(void *Base);
 
 // HACKS - So this can share the usermode elf.c
-static inline int GetSymbol(const char *sym, void **val, size_t *sz)
+static inline int GetSymbol(const char *sym, void **val, size_t *sz, void *IgnoreBase)
 {
        uintptr_t rv;
-       if( !Binary_GetSymbol(sym, &rv, sz) )
+       if( !Binary_GetSymbol(sym, &rv, sz, IgnoreBase) )
                return 0;
        *val = (void*)rv;
        return 1;
index 19a8c13..c5edc4a 100644 (file)
@@ -74,7 +74,7 @@ void *Elf32Load(int FD, Elf32_Ehdr *hdr)
        ENTER("iFD", FD);\r
        \r
        // Check for a program header\r
-       if(hdr->phoff == 0) {\r
+       if(hdr->e_phoff == 0) {\r
                #if DEBUG_WARN\r
                Warning("ELF File does not contain a program header\n");\r
                #endif\r
@@ -83,25 +83,25 @@ void *Elf32Load(int FD, Elf32_Ehdr *hdr)
        }\r
        \r
        // Read Program Header Table\r
-       phtab = malloc( sizeof(Elf32_Phdr) * hdr->phentcount );\r
+       phtab = malloc( sizeof(Elf32_Phdr) * hdr->e_phnum );\r
        if( !phtab ) {\r
                LEAVE('n');\r
                return NULL;\r
        }\r
-       LOG("hdr.phoff = 0x%08x\n", hdr->phoff);\r
-       acess__SysSeek(FD, hdr->phoff, ACESS_SEEK_SET);\r
-       acess__SysRead(FD, phtab, sizeof(Elf32_Phdr) * hdr->phentcount);\r
+       LOG("hdr.e_phoff = 0x%08x\n", hdr->e_phoff);\r
+       acess__SysSeek(FD, hdr->e_phoff, ACESS_SEEK_SET);\r
+       acess__SysRead(FD, phtab, sizeof(Elf32_Phdr) * hdr->e_phnum);\r
        \r
        // Count Pages\r
        iPageCount = 0;\r
-       LOG("hdr.phentcount = %i\n", hdr->phentcount);\r
-       for( i = 0; i < hdr->phentcount; i++ )\r
+       LOG("hdr.e_phnum = %i\n", hdr->e_phnum);\r
+       for( i = 0; i < hdr->e_phnum; i++ )\r
        {\r
                // Ignore Non-LOAD types\r
-               if(phtab[i].Type != PT_LOAD)\r
+               if(phtab[i].p_type != PT_LOAD)\r
                        continue;\r
-               iPageCount += ((phtab[i].VAddr&0xFFF) + phtab[i].MemSize + 0xFFF) >> 12;\r
-               LOG("phtab[%i] = {VAddr:0x%x, MemSize:0x%x}\n", i, phtab[i].VAddr, phtab[i].MemSize);\r
+               iPageCount += ((phtab[i].p_vaddr&0xFFF) + phtab[i].p_memsz + 0xFFF) >> 12;\r
+               LOG("phtab[%i] = {p_vaddr:0x%x, p_memsz:0x%x}\n", i, phtab[i].p_vaddr, phtab[i].MemSize);\r
        }\r
        \r
        LOG("iPageCount = %i\n", iPageCount);\r
@@ -117,14 +117,14 @@ void *Elf32Load(int FD, Elf32_Ehdr *hdr)
        // Prescan for base and size\r
        max = 0;\r
        base = 0xFFFFFFFF;\r
-       for( i = 0; i < hdr->phentcount; i ++)\r
+       for( i = 0; i < hdr->e_phnum; i ++)\r
        {\r
-               if( phtab[i].Type != PT_LOAD )\r
+               if( phtab[i].p_type != PT_LOAD )\r
                        continue;\r
-               if( phtab[i].VAddr < base )\r
-                       base = phtab[i].VAddr;\r
-               if( phtab[i].VAddr + phtab[i].MemSize > max )\r
-                       max = phtab[i].VAddr + phtab[i].MemSize;\r
+               if( phtab[i].p_vaddr < base )\r
+                       base = phtab[i].p_vaddr;\r
+               if( phtab[i].p_vaddr + phtab[i].p_memsz > max )\r
+                       max = phtab[i].p_vaddr + phtab[i].p_memsz;\r
        }\r
 \r
        LOG("base = %08x, max = %08x\n", base, max);\r
@@ -138,39 +138,39 @@ void *Elf32Load(int FD, Elf32_Ehdr *hdr)
        }\r
        \r
        // Load Pages\r
-       for( i = 0; i < hdr->phentcount; i++ )\r
+       for( i = 0; i < hdr->e_phnum; i++ )\r
        {\r
                // Get Interpreter Name\r
-               if( phtab[i].Type == PT_INTERP )\r
+               if( phtab[i].p_type == PT_INTERP )\r
                {\r
                        char *tmp;\r
                        //if(ret->Interpreter)  continue;\r
-                       tmp = malloc(phtab[i].FileSize);\r
-                       acess__SysSeek(FD, phtab[i].Offset, ACESS_SEEK_SET);\r
-                       acess__SysRead(FD, tmp, phtab[i].FileSize);\r
+                       tmp = malloc(phtab[i].p_filesz);\r
+                       acess__SysSeek(FD, phtab[i].p_offset, ACESS_SEEK_SET);\r
+                       acess__SysRead(FD, tmp, phtab[i].p_filesz);\r
                        //ret->Interpreter = Binary_RegInterp(tmp);\r
                        LOG("Interpreter '%s'\n", tmp);\r
                        free(tmp);\r
                        continue;\r
                }\r
                // Ignore non-LOAD types\r
-               if(phtab[i].Type != PT_LOAD)    continue;\r
+               if(phtab[i].p_type != PT_LOAD)  continue;\r
                \r
-               LOG("phtab[%i] = PT_LOAD {Adj VAddr:0x%x, Offset:0x%x, FileSize:0x%x, MemSize:0x%x}\n",\r
-                       i, phtab[i].VAddr+baseDiff, phtab[i].Offset, phtab[i].FileSize, phtab[i].MemSize);\r
+               LOG("phtab[%i] = PT_LOAD {Adj p_vaddr:0x%x, p_offset:0x%x, p_filesz:0x%x, p_memsz:0x%x}\n",\r
+                       i, phtab[i].p_vaddr+baseDiff, phtab[i].p_offset, phtab[i].p_filesz, phtab[i].p_memsz);\r
                \r
-               addr = phtab[i].VAddr + baseDiff;\r
+               addr = phtab[i].p_vaddr + baseDiff;\r
 \r
-               if( AllocateMemory( addr, phtab[i].MemSize ) ) {\r
+               if( AllocateMemory( addr, phtab[i].p_memsz ) ) {\r
                        fprintf(stderr, "Elf_Load: Unable to map memory at %x (0x%x bytes)\n",\r
-                               addr, phtab[i].MemSize);\r
+                               addr, phtab[i].p_memsz);\r
                        free( phtab );\r
                        return NULL;\r
                }\r
                \r
-               acess__SysSeek(FD, phtab[i].Offset, ACESS_SEEK_SET);\r
-               acess__SysRead(FD, PTRMK(void, addr), phtab[i].FileSize);\r
-               memset( PTRMK(char, addr) + phtab[i].FileSize, 0, phtab[i].MemSize - phtab[i].FileSize );\r
+               acess__SysSeek(FD, phtab[i].p_offset, ACESS_SEEK_SET);\r
+               acess__SysRead(FD, PTRMK(void, addr), phtab[i].p_filesz);\r
+               memset( PTRMK(char, addr) + phtab[i].p_filesz, 0, phtab[i].p_memsz - phtab[i].p_filesz );\r
        }\r
        \r
        // Clean Up\r
@@ -210,20 +210,20 @@ void *Elf64Load(int FD, Elf64_Ehdr *hdr)
                LEAVE('n');\r
                return NULL;\r
        }\r
-       LOG("hdr.phoff = 0x%08llx\n", (long long)hdr->e_phoff);\r
+       LOG("hdr.e_phoff = 0x%08llx\n", (long long)hdr->e_phoff);\r
        acess__SysSeek(FD, hdr->e_phoff, ACESS_SEEK_SET);\r
        acess__SysRead(FD, phtab, sizeof(Elf64_Phdr) * hdr->e_phnum);\r
        \r
        // Count Pages\r
        iPageCount = 0;\r
-       LOG("hdr.phentcount = %i\n", hdr->e_phnum);\r
+       LOG("hdr.e_phnum = %i\n", hdr->e_phnum);\r
        for( i = 0; i < hdr->e_phnum; i++ )\r
        {\r
                // Ignore Non-LOAD types\r
                if(phtab[i].p_type != PT_LOAD)\r
                        continue;\r
                iPageCount += ((phtab[i].p_vaddr&0xFFF) + phtab[i].p_memsz + 0xFFF) >> 12;\r
-               LOG("phtab[%i] = {VAddr:0x%llx, MemSize:0x%llx}\n",\r
+               LOG("phtab[%i] = {p_vaddr:0x%llx, p_memsz:0x%llx}\n",\r
                        i, (long long)phtab[i].p_vaddr, (long long)phtab[i].p_memsz);\r
        }\r
        \r
@@ -280,7 +280,7 @@ void *Elf64Load(int FD, Elf64_Ehdr *hdr)
                // Ignore non-LOAD types\r
                if(phtab[i].p_type != PT_LOAD)  continue;\r
                \r
-               LOG("phtab[%i] = PT_LOAD {Adj VAddr:0x%llx, Offset:0x%llx, FileSize:0x%llx, MemSize:0x%llx}\n",\r
+               LOG("phtab[%i] = PT_LOAD {Adj p_vaddr:0x%llx, p_offset:0x%llx, p_filesz:0x%llx, p_memsz:0x%llx}\n",\r
                        i,\r
                        (long long)phtab[i].p_vaddr+baseDiff, (long long)phtab[i].p_offset,\r
                        (long long)phtab[i].p_filesz, (long long)phtab[i].p_memsz\r
index c8166af..99238a5 100644 (file)
@@ -1,5 +1,6 @@
 /*
  */
+#define _GNU_SOURCE    // needed for MAP_ANONYMOUS to be avaliable
 #include "common.h"
 #include <stdio.h>
 #include <stdlib.h>
index fdf5748..c516a22 100644 (file)
@@ -25,6 +25,7 @@
 # include <unistd.h>
 # include <sys/socket.h>
 # include <netinet/in.h>
+# include <sys/select.h>
 #endif
 #include "request.h"
 #include "../syscalls.h"

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