UNDO: FIX #2375: remove oc->lochash completely, it apparently isn't used
[ghc-hetmet.git] / rts / Linker.c
index 1a99f12..0d56912 100644 (file)
@@ -27,6 +27,7 @@
 #include "Schedule.h"
 #include "Sparks.h"
 #include "RtsTypeable.h"
+#include "Timer.h"
 
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
@@ -703,6 +704,7 @@ typedef struct _RtsSymbolVal {
       SymX(stackOverflow)                      \
       SymX(stg_CAF_BLACKHOLE_info)             \
       SymX(awakenBlockedQueue)                 \
+      SymX(startTimer)                          \
       SymX(stg_CHARLIKE_closure)               \
       SymX(stg_MVAR_CLEAN_info)                        \
       SymX(stg_MVAR_DIRTY_info)                        \
@@ -1176,6 +1178,23 @@ lookupSymbol( char *lbl )
     }
 }
 
+static
+__attribute((unused))
+void *
+lookupLocalSymbol( ObjectCode* oc, char *lbl )
+{
+    void *val;
+    initLinker() ;
+    val = lookupStrHashTable(oc->lochash, lbl);
+
+    if (val == NULL) {
+        return NULL;
+    } else {
+       return val;
+    }
+}
+
+
 /* -----------------------------------------------------------------------------
  * Debugging aid: look in GHCi's object symbol tables for symbols
  * within DELTA bytes of the specified address, and show their names.
@@ -1197,7 +1216,11 @@ void ghci_enquire ( char* addr )
       for (i = 0; i < oc->n_symbols; i++) {
          sym = oc->symbols[i];
          if (sym == NULL) continue;
+         // debugBelch("enquire %p %p\n", sym, oc->lochash);
          a = NULL;
+         if (oc->lochash != NULL) {
+            a = lookupStrHashTable(oc->lochash, sym);
+        }
          if (a == NULL) {
             a = lookupStrHashTable(symhash, sym);
         }
@@ -1282,6 +1305,7 @@ loadObj( char *path )
    oc->fileSize          = st.st_size;
    oc->symbols           = NULL;
    oc->sections          = NULL;
+   oc->lochash           = allocStrHashTable();
    oc->proddables        = NULL;
 
    /* chain it onto the list of objects */
@@ -1490,6 +1514,9 @@ unloadObj( char *path )
            stgFree(oc->fileName);
            stgFree(oc->symbols);
            stgFree(oc->sections);
+           /* The local hash table should have been freed at the end
+               of the ocResolve_ call on it. */
+            ASSERT(oc->lochash == NULL);
            stgFree(oc);
            return 1;
        }
@@ -3603,6 +3630,10 @@ ocResolve_ELF ( ObjectCode* oc )
       }
    }
 
+   /* Free the local symbol table; we won't need it again. */
+   freeHashTable(oc->lochash, NULL);
+   oc->lochash = NULL;
+
 #if defined(powerpc_HOST_ARCH)
    ocFlushInstructionCache( oc );
 #endif
@@ -3881,6 +3912,8 @@ static int resolveImports(
        if((symbol->n_type & N_TYPE) == N_UNDF
            && (symbol->n_type & N_EXT) && (symbol->n_value != 0))
            addr = (void*) (symbol->n_value);
+       else if((addr = lookupLocalSymbol(oc,nm)) != NULL)
+           ;
        else
            addr = lookupSymbol(nm);
        if(!addr)
@@ -4527,6 +4560,10 @@ static int ocResolve_MachO(ObjectCode* oc)
            return 0;
     }
 
+    /* Free the local symbol table; we won't need it again. */
+    freeHashTable(oc->lochash, NULL);
+    oc->lochash = NULL;
+
 #if defined (powerpc_HOST_ARCH)
     ocFlushInstructionCache( oc );
 #endif