diff options
author | Gabor Greif <ggreif@gmail.com> | 2014-08-08 18:01:19 +0200 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2014-08-08 18:01:19 +0200 |
commit | 5f003d228340c3ce8e500f9053f353c58dc1dc94 (patch) | |
tree | a855b0f173ff635b48354e1136ef6cbb2a1214a4 /rts/Linker.c | |
parent | ff9c5570395bcacf8963149b3a8475f5644ce694 (diff) | |
parent | dff0623d5ab13222c06b3ff6b32793e05b417970 (diff) | |
download | haskell-wip/generics-propeq.tar.gz |
Merge branch 'master' into wip/generics-propeqwip/generics-propeq
Conflicts:
compiler/typecheck/TcGenGenerics.lhs
Diffstat (limited to 'rts/Linker.c')
-rw-r--r-- | rts/Linker.c | 52 |
1 files changed, 17 insertions, 35 deletions
diff --git a/rts/Linker.c b/rts/Linker.c index f7f554ce6c..480dc2a967 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -1186,7 +1186,6 @@ typedef struct _RtsSymbolVal { SymI_HasProto(stg_newBCOzh) \ SymI_HasProto(stg_newByteArrayzh) \ SymI_HasProto(stg_casIntArrayzh) \ - SymI_HasProto(stg_fetchAddIntArrayzh) \ SymI_HasProto(stg_newMVarzh) \ SymI_HasProto(stg_newMutVarzh) \ SymI_HasProto(stg_newTVarzh) \ @@ -1798,7 +1797,7 @@ internal_dlopen(const char *dll_name) // (see POSIX also) ACQUIRE_LOCK(&dl_mutex); - hdl = dlopen(dll_name, RTLD_LAZY|RTLD_LOCAL); /* see Note [RTLD_LOCAL] */ + hdl = dlopen(dll_name, RTLD_LAZY | RTLD_GLOBAL); errmsg = NULL; if (hdl == NULL) { @@ -1808,12 +1807,11 @@ internal_dlopen(const char *dll_name) errmsg_copy = stgMallocBytes(strlen(errmsg)+1, "addDLL"); strcpy(errmsg_copy, errmsg); errmsg = errmsg_copy; - } else { - o_so = stgMallocBytes(sizeof(OpenedSO), "addDLL"); - o_so->handle = hdl; - o_so->next = openedSOs; - openedSOs = o_so; } + o_so = stgMallocBytes(sizeof(OpenedSO), "addDLL"); + o_so->handle = hdl; + o_so->next = openedSOs; + openedSOs = o_so; RELEASE_LOCK(&dl_mutex); //--------------- End critical section ------------------- @@ -1821,39 +1819,14 @@ internal_dlopen(const char *dll_name) return errmsg; } -/* - Note [RTLD_LOCAL] - - In GHCi we want to be able to override previous .so's with newly - loaded .so's when we recompile something. This further implies that - when we look up a symbol in internal_dlsym() we have to iterate - through the loaded libraries (in order from most recently loaded to - oldest) looking up the symbol in each one until we find it. - - However, this can cause problems for some symbols that are copied - by the linker into the executable image at runtime - see #8935 for a - lengthy discussion. To solve that problem we need to look up - symbols in the main executable *first*, before attempting to look - them up in the loaded .so's. But in order to make that work, we - have to always call dlopen with RTLD_LOCAL, so that the loaded - libraries don't populate the global symbol table. -*/ - static void * -internal_dlsym(const char *symbol) { +internal_dlsym(void *hdl, const char *symbol) { OpenedSO* o_so; void *v; // We acquire dl_mutex as concurrent dl* calls may alter dlerror ACQUIRE_LOCK(&dl_mutex); dlerror(); - // look in program first - v = dlsym(dl_prog_handle, symbol); - if (dlerror() == NULL) { - RELEASE_LOCK(&dl_mutex); - return v; - } - for (o_so = openedSOs; o_so != NULL; o_so = o_so->next) { v = dlsym(o_so->handle, symbol); if (dlerror() == NULL) { @@ -1861,6 +1834,7 @@ internal_dlsym(const char *symbol) { return v; } } + v = dlsym(hdl, symbol); RELEASE_LOCK(&dl_mutex); return v; } @@ -2028,7 +2002,7 @@ lookupSymbol( char *lbl ) if (!ghciLookupSymbolTable(symhash, lbl, &val)) { IF_DEBUG(linker, debugBelch("lookupSymbol: symbol not found\n")); # if defined(OBJFORMAT_ELF) - return internal_dlsym(lbl); + return internal_dlsym(dl_prog_handle, lbl); # elif defined(OBJFORMAT_MACHO) # if HAVE_DLFCN_H /* On OS X 10.3 and later, we use dlsym instead of the old legacy @@ -2042,7 +2016,7 @@ lookupSymbol( char *lbl ) */ IF_DEBUG(linker, debugBelch("lookupSymbol: looking up %s with dlsym\n", lbl)); ASSERT(lbl[0] == '_'); - return internal_dlsym(lbl + 1); + return internal_dlsym(dl_prog_handle, lbl + 1); # else if (NSIsSymbolNameDefined(lbl)) { NSSymbol symbol = NSLookupAndBindSymbol(lbl); @@ -7189,3 +7163,11 @@ machoGetMisalignment( FILE * f ) #endif #endif + +// Local Variables: +// mode: C +// fill-column: 80 +// indent-tabs-mode: nil +// c-basic-offset: 4 +// buffer-file-coding-system: utf-8-unix +// End: |