Ticket #7134: ghc-7.6.3-w64fix.patch

File ghc-7.6.3-w64fix.patch, 1.5 KB (added by awson, 5 years ago)
  • rts/Linker.c

    diff -urN ghc-7.6.3/rts/Linker.c ghc-7.6.3.w64fix/rts/Linker.c
    old new  
    33163316#  undef my_isdigit
    33173317}
    33183318
     3319#if defined(x86_64_HOST_ARCH)
     3320static void*
     3321thunkifyFarCode( void *s )
     3322{
     3323    char *thunk;
     3324
     3325    if ((UInt64)s >> 32) {
     3326       thunk = (char*) VirtualAlloc(NULL, 14, MEM_RESERVE | MEM_COMMIT,
     3327                                               PAGE_EXECUTE_READWRITE);
     3328       *(UInt16*)thunk = 0x25ff;             // These bytes encode
     3329       *(UInt32*)(thunk+2) = 0x0;            // direct jump
     3330       *((FARPROC *)(thunk+6)) = (FARPROC)s; // to the address 's'
     3331       return thunk;
     3332    }
     3333    return s;
     3334}
     3335#endif
     3336
    33193337static void *
    33203338lookupSymbolInDLLs ( UChar *lbl )
    33213339{
     
    33323350               stripped off when mapping from import lib name to the DLL name.
    33333351            */
    33343352            sym = GetProcAddress(o_dll->instance, (char*)(lbl+1));
     3353#if defined(x86_64_HOST_ARCH)
     3354            sym = thunkifyFarCode(sym);
     3355#endif
    33353356            if (sym != NULL) {
    33363357                /*debugBelch("found %s in %s\n", lbl+1,o_dll->name);*/
    33373358                return sym;
    33383359            }
    33393360        }
    33403361        sym = GetProcAddress(o_dll->instance, (char*)lbl);
     3362#if defined(x86_64_HOST_ARCH)
     3363        sym = thunkifyFarCode(sym);
     3364#endif
    33413365        if (sym != NULL) {
    33423366            /*debugBelch("found %s in %s\n", lbl,o_dll->name);*/
    33433367            return sym;