summaryrefslogtreecommitdiff
path: root/rts/Linker.c
diff options
context:
space:
mode:
authorKyrill Briantsev <kyrab@mail.ru>2014-01-30 16:49:57 -0600
committerAustin Seipp <austin@well-typed.com>2014-01-30 16:49:57 -0600
commitfda9bebc61cab7235123b50dc70dbf30f0140dad (patch)
tree88231b0e221607373e3ebe5baf7b2a1eb0760f39 /rts/Linker.c
parent1dd38a54bb29387d9e9c549dbb020bc9ed4ecb91 (diff)
downloadhaskell-fda9bebc61cab7235123b50dc70dbf30f0140dad.tar.gz
Fix some edge cases in 8f8bd88c (#7134)
Signed-off-by: Austin Seipp <austin@well-typed.com>
Diffstat (limited to 'rts/Linker.c')
-rw-r--r--rts/Linker.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index bdd4746bbc..9bb377c492 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++;