Usermode/libposix - Basic stat() emulation
[tpg/acess2.git] / Usermode / Libraries / ld-acess.so_src / loadlib.c
index dcacd8a..88aafc3 100644 (file)
@@ -24,6 +24,7 @@ extern const struct {
 }      caLocalExports[];
 extern const int       ciNumLocalExports;
 extern char    **gEnvP;
+extern char    gLinkedBase[];
 
 // === GLOABLS ===
 tLoadedLib     gLoadedLibraries[MAX_LOADED_LIBRARIES];
@@ -32,6 +33,18 @@ char *gsNextAvailString = gsLoadedStrings;
 //tLoadLib     *gpLoadedLibraries = NULL;
 
 // === CODE ===
+void ldacess_DumpLoadedLibraries(void)
+{
+       for( int i = 0; i < MAX_LOADED_LIBRARIES; i ++ )
+       {
+               if(gLoadedLibraries[i].Base == 0)       break;  // Last entry has Base set to NULL
+               _SysDebug("%p: %s",
+                       gLoadedLibraries[i].Base,
+                       gLoadedLibraries[i].Name
+                       );
+       }
+}
+
 const char *FindLibrary(char *DestBuf, const char *SoName, const char *ExtraSearchDir)
 {      
        // -- #1: Executable Specified
@@ -108,6 +121,15 @@ void *IsFileLoaded(const char *file)
 {
         int    i;
        DEBUGS("IsFileLoaded: (file='%s')", file);
+
+       // Applications link against either libld-acess.so or ld-acess.so
+       if( strcmp(file, "/Acess/Libs/libld-acess.so") == 0
+        || strcmp(file, "/Acess/Libs/ld-acess.so") == 0 )
+       {
+               DEBUGS("IsFileLoaded: Found local (%p)", &gLinkedBase);
+               return &gLinkedBase;
+       }
+
        for( i = 0; i < MAX_LOADED_LIBRARIES; i++ )
        {
                if(gLoadedLibraries[i].Base == 0)       break;  // Last entry has Base set to NULL
@@ -217,7 +239,7 @@ int GetSymbol(const char *name, void **Value, size_t *Size)
        }
        
        // Entry 0 is ld-acess, ignore it
-       for(i = 1; i < MAX_LOADED_LIBRARIES; i ++)
+       for(i = 0; i < MAX_LOADED_LIBRARIES; i ++)
        {
                if(gLoadedLibraries[i].Base == 0)
                        break;

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