X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Fld-acess_src%2Fbinary.c;h=738c6e819c77966fd36e33647af012883c3ab399;hb=5b487e31cf5145372e9777e9f82a8cd661d4f1b4;hp=d04ac6d2504026c0f93de0ae832cb2793e543f46;hpb=b519c413b534ab831a0fcb6228b8a49d4a491279;p=tpg%2Facess2.git diff --git a/AcessNative/ld-acess_src/binary.c b/AcessNative/ld-acess_src/binary.c index d04ac6d2..738c6e81 100644 --- a/AcessNative/ld-acess_src/binary.c +++ b/AcessNative/ld-acess_src/binary.c @@ -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 #include @@ -65,9 +66,9 @@ char *Binary_LocateLibrary(const char *Name) strcat(tmp, "/"); strcat(tmp, Name); - fd = acess_open(tmp, 4); // OPENFLAG_EXEC + fd = acess__SysOpen(tmp, 4); // OPENFLAG_EXEC if(fd != -1) { - acess_close(fd); + acess__SysClose(fd); return strdup(tmp); } } @@ -84,9 +85,9 @@ char *Binary_LocateLibrary(const char *Name) printf("Binary_LocateLibrary: tmp = '%s'\n", tmp); #endif - fd = acess_open(tmp, 4); // OPENFLAG_EXEC + fd = acess__SysOpen(tmp, 4); // OPENFLAG_EXEC if(fd != -1) { - acess_close(fd); + acess__SysClose(fd); return strdup(tmp); } } @@ -156,22 +157,22 @@ void *Binary_Load(const char *Filename, uintptr_t *EntryPoint) } } - fd = acess_open(Filename, 2|1); // Execute and Read + fd = acess__SysOpen(Filename, 2|1); // Execute and Read if( fd == -1 ) { // TODO: Handle libary directories perror("Opening binary"); return NULL; } - acess_read(fd, &dword, 4); - acess_seek(fd, 0, ACESS_SEEK_SET); + acess__SysRead(fd, &dword, 4); + acess__SysSeek(fd, 0, ACESS_SEEK_SET); if( memcmp(&dword, "\x7F""ELF", 4) == 0 ) { fmt = &gElf_FormatDef; } else { fprintf(stderr, "Unknown executable format (0x%08x)\n", dword); - acess_close(fd); + acess__SysClose(fd); return NULL; } @@ -179,7 +180,7 @@ void *Binary_Load(const char *Filename, uintptr_t *EntryPoint) printf("fmt->Load(0x%x)...\n", fd); #endif ret = fmt->Load(fd); - acess_close(fd); + acess__SysClose(fd); #if DEBUG printf("fmt->Load(0x%x): %p\n", fd, ret); #endif @@ -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) )