X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=AcessNative%2Fld-acess.so_src%2Fbinary.c;h=b8f6e71bbf8861467e4d814605a07b88ca889cd4;hb=4726431cb7e0bada749b32f9e51dedadf882d50b;hp=7f97eddaf6f53891449946ac56c8dde7e50d6822;hpb=381005a446e3f8c7c56bf4764b2e697dee203840;p=tpg%2Facess2.git diff --git a/AcessNative/ld-acess.so_src/binary.c b/AcessNative/ld-acess.so_src/binary.c index 7f97edda..b8f6e71b 100644 --- a/AcessNative/ld-acess.so_src/binary.c +++ b/AcessNative/ld-acess.so_src/binary.c @@ -45,6 +45,10 @@ char *Binary_LocateLibrary(const char *Name) int nameLen = strlen(Name); FILE *fp; + if( strcmp(Name, "libld-acess.so") == 0 ) { + return strdup("libld-acess.so"); + } + // Try the environment ACESS_LIBRARY_PATH if( envPath && envPath[0] != '\0' ) { @@ -103,6 +107,7 @@ void *Binary_LoadLibrary(const char *Name) printf("Binary_LoadLibrary: ret = %p, entry = %p\n", ret, entry); if( entry ) { char *argv[] = {NULL}; + printf("Calling '%s' entry point %p\n", Name, entry); entry(0, argv, NULL); } @@ -117,6 +122,12 @@ void *Binary_Load(const char *Filename, uintptr_t *EntryPoint) uintptr_t entry = 0; tBinFmt *fmt; + // Ignore loading ld-acess + if( strcmp(Filename, "libld-acess.so") == 0 ) { + *EntryPoint = 0; + return (void*)-1; + } + { tBinary *bin; for(bin = gLoadedBinaries; bin; bin = bin->Next) @@ -145,7 +156,8 @@ void *Binary_Load(const char *Filename, uintptr_t *EntryPoint) fclose(fp); return NULL; } - + + printf("fmt->Load(%p)...\n", fp); ret = fmt->Load(fp); printf("fmt->Load(%p): %p\n", fp, ret); if( !ret ) { @@ -199,16 +211,12 @@ int Binary_GetSymbol(const char *SymbolName, uintptr_t *Value) int i; tBinary *bin; - // TODO: Search list of loaded binaries - for(bin = gLoadedBinaries; bin; bin = bin->Next) - { - 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) ) - return 1; - } + printf("Binary_GetSymbol: (SymbolName='%s', Value=%p)\n", + SymbolName, Value); // Search builtins + // - Placed first to override smartarses that define their own versions + // of system calls for( i = 0; i < ciNumBuiltinSymbols; i ++ ) { if( strcmp(caBuiltinSymbols[i].Name, SymbolName) == 0 ) { @@ -216,6 +224,17 @@ int Binary_GetSymbol(const char *SymbolName, uintptr_t *Value) return 1; } } + + // TODO: Search list of loaded binaries + for(bin = gLoadedBinaries; bin; bin = bin->Next) + { + 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) ) + return 1; + } + printf("Binary_GetSymbol: RETURN 0, not found\n"); + return 0; }