X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FLinker.c;h=69b21a2098b3645bbb3cd983e3fe7fd4039c3b57;hb=8ef97aa30a33fb3b536252b2c0459cdf0fd5236f;hp=1a99f12d007ce22bebfaf4bfcc18fa6d3b7d05fc;hpb=4f4dd70fd10ab13e41cb0f541bbfee2330d149da;p=ghc-hetmet.git diff --git a/rts/Linker.c b/rts/Linker.c index 1a99f12..69b21a2 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -27,6 +27,7 @@ #include "Schedule.h" #include "Sparks.h" #include "RtsTypeable.h" +#include "Timer.h" #ifdef HAVE_SYS_TYPES_H #include @@ -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) \ @@ -1064,14 +1066,19 @@ addDLL( char *dll_name ) sprintf(buf, "%s.DLL", dll_name); instance = LoadLibrary(buf); if (instance == NULL) { - sprintf(buf, "%s.DRV", dll_name); // KAA: allow loading of drivers (like winspool.drv) - instance = LoadLibrary(buf); - if (instance == NULL) { - stgFree(buf); - - /* LoadLibrary failed; return a ptr to the error msg. */ - return "addDLL: unknown error"; - } + if (GetLastError() != ERROR_MOD_NOT_FOUND) goto error; + // KAA: allow loading of drivers (like winspool.drv) + sprintf(buf, "%s.DRV", dll_name); + instance = LoadLibrary(buf); + if (instance == NULL) { + if (GetLastError() != ERROR_MOD_NOT_FOUND) goto error; + // #1883: allow loading of unix-style libfoo.dll DLLs + sprintf(buf, "lib%s.DLL", dll_name); + instance = LoadLibrary(buf); + if (instance == NULL) { + goto error; + } + } } stgFree(buf); @@ -1084,6 +1091,14 @@ addDLL( char *dll_name ) opened_dlls = o_dll; return NULL; + +error: + stgFree(buf); + sysErrorBelch(dll_name); + + /* LoadLibrary failed; return a ptr to the error msg. */ + return "addDLL: could not load DLL"; + # else barf("addDLL: not implemented on this platform"); # endif @@ -1598,47 +1613,36 @@ static int ocAllocateSymbolExtras( ObjectCode* oc, int count, int first ) aligned = (oc->fileSize + 3) & ~3; #ifdef USE_MMAP - #ifndef linux_HOST_OS /* mremap is a linux extension */ - #error ocAllocateSymbolExtras doesnt want USE_MMAP to be defined - #endif - pagesize = getpagesize(); n = ROUND_UP( oc->fileSize, pagesize ); m = ROUND_UP( aligned + sizeof (SymbolExtra) * count, pagesize ); - /* If we have a half-page-size file and map one page of it then - * the part of the page after the size of the file remains accessible. - * If, however, we map in 2 pages, the 2nd page is not accessible - * and will give a "Bus Error" on access. To get around this, we check - * if we need any extra pages for the jump islands and map them in - * anonymously. We must check that we actually require extra pages - * otherwise the attempt to mmap 0 pages of anonymous memory will - * fail -EINVAL. + /* we try to use spare space at the end of the last page of the + * image for the jump islands, but if there isn't enough space + * then we have to map some (anonymously, remembering MAP_32BIT). */ - - if( m > n ) + if( m > n ) // we need to allocate more pages { - /* The effect of this mremap() call is only the ensure that we have - * a sufficient number of virtually contiguous pages. As returned from - * mremap, the pages past the end of the file are not backed. We give - * them a backing by using MAP_FIXED to map in anonymous pages. - */ - oc->image = mremap( oc->image, n, m, MREMAP_MAYMOVE ); - - if( oc->image == MAP_FAILED ) - { - errorBelch( "Unable to mremap for Jump Islands\n" ); - return 0; - } - - if( mmap( oc->image + n, m - n, PROT_READ | PROT_WRITE | PROT_EXEC, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, 0, 0 ) == MAP_FAILED ) - { - errorBelch( "Unable to mmap( MAP_FIXED ) for Jump Islands\n" ); - return 0; - } + oc->symbol_extras = mmap (NULL, sizeof(SymbolExtra) * count, + PROT_EXEC|PROT_READ|PROT_WRITE, + MAP_PRIVATE|MAP_ANONYMOUS|EXTRA_MAP_FLAGS, + 0, 0); + if (oc->symbol_extras == MAP_FAILED) + { + errorBelch( "Unable to mmap() for jump islands\n" ); + return 0; + } +#ifdef x86_64_HOST_ARCH + if ((StgWord)oc->symbol_extras > 0x80000000) + { + barf("mmap() returned memory outside 2Gb"); + } +#endif + } + else + { + oc->symbol_extras = (SymbolExtra *) (oc->image + aligned); } - #else oc->image -= misalignment; oc->image = stgReallocBytes( oc->image, @@ -1646,9 +1650,10 @@ static int ocAllocateSymbolExtras( ObjectCode* oc, int count, int first ) aligned + sizeof (SymbolExtra) * count, "ocAllocateSymbolExtras" ); oc->image += misalignment; -#endif /* USE_MMAP */ oc->symbol_extras = (SymbolExtra *) (oc->image + aligned); +#endif /* USE_MMAP */ + memset( oc->symbol_extras, 0, sizeof (SymbolExtra) * count ); } else @@ -2507,13 +2512,9 @@ ocResolve_PEi386 ( ObjectCode* oc ) + sym->Value); } else { copyName ( sym->Name, strtab, symbol, 1000-1 ); - S = (UInt32) lookupLocalSymbol( oc, symbol ); - if ((void*)S != NULL) goto foundit; S = (UInt32) lookupSymbol( symbol ); if ((void*)S != NULL) goto foundit; zapTrailingAtSign ( symbol ); - S = (UInt32) lookupLocalSymbol( oc, symbol ); - if ((void*)S != NULL) goto foundit; S = (UInt32) lookupSymbol( symbol ); if ((void*)S != NULL) goto foundit; /* Newline first because the interactive linker has printed "linking..." */