[commit: ghc] ghc-7.8: Fix some edge cases in 8f8bd88c (#7134) (65d05d7)

git at git.haskell.org git at git.haskell.org
Thu Jan 30 22:51:22 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-7.8
Link       : http://ghc.haskell.org/trac/ghc/changeset/65d05d7334fb765db8d01fc1097225f9a9049521/ghc

>---------------------------------------------------------------

commit 65d05d7334fb765db8d01fc1097225f9a9049521
Author: Kyrill Briantsev <kyrab at mail.ru>
Date:   Thu Jan 30 16:49:57 2014 -0600

    Fix some edge cases in 8f8bd88c (#7134)
    
    Signed-off-by: Austin Seipp <austin at well-typed.com>
    
    (cherry picked from commit fda9bebc61cab7235123b50dc70dbf30f0140dad)


>---------------------------------------------------------------

65d05d7334fb765db8d01fc1097225f9a9049521
 rts/Linker.c |   19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/rts/Linker.c b/rts/Linker.c
index bdd4746..9bb377c 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -3491,9 +3491,9 @@ allocateImageAndTrampolines (
    /* For 32-bit case we don't need this, hence we use macro PEi386_IMAGE_OFFSET,
       which equals to 4 for 64-bit case and 0 for 32-bit case. */
    /* We allocate trampolines area for all symbols right behind
-      image data, aligned on pointer size. */
-   size = ((PEi386_IMAGE_OFFSET + size + sizeof(void*)) & ~sizeof(void*))
-              + hdr.NumberOfSymbols * sizeof(void*);
+      image data, aligned on 16. */
+   size = ((PEi386_IMAGE_OFFSET + size + 0xf) & ~0xf)
+              + hdr.NumberOfSymbols * sizeof(SymbolExtra);
 #endif
    image = VirtualAlloc(NULL, size,
                         MEM_RESERVE | MEM_COMMIT,
@@ -4146,8 +4146,8 @@ ocGetNames_PEi386 ( ObjectCode* oc )
 static int
 ocAllocateSymbolExtras_PEi386 ( ObjectCode* oc )
 {
-   /* Remember allocated memory starts at -4 offset from image pointer */
-   oc->symbol_extras = (SymbolExtra*)(oc->image - 4 + ((4 + oc->fileSize + sizeof(void*)) & ~sizeof(void*)));
+   oc->symbol_extras = (SymbolExtra*)(oc->image - PEi386_IMAGE_OFFSET
+                                      + ((PEi386_IMAGE_OFFSET + oc->fileSize + 0xf) & ~0xf));
    oc->first_symbol_extra = 0;
    oc->n_symbol_extras = ((COFF_header*)oc->image)->NumberOfSymbols;
 
@@ -4172,8 +4172,13 @@ makeSymbolExtra_PEi386( ObjectCode* oc, size_t s, char* symbol )
     extra->addr = (uint64_t)s;
     memcpy(extra->jumpIsland, jmp, 6);
 
-    ghciInsertSymbolTable(oc->fileName, symhash, symbol, extra->jumpIsland,
-            HS_BOOL_FALSE, oc);
+    /* DLL-imported symbols are inserted here.
+       Others are inserted in ocGetNames_PEi386.
+     */
+    if(lookupStrHashTable(symhash, symbol) == NULL) {
+       ghciInsertSymbolTable(oc->fileName, symhash, symbol, extra->jumpIsland,
+               HS_BOOL_FALSE, oc);
+    }
 
     oc->first_symbol_extra++;
 



More information about the ghc-commits mailing list