diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-03-21 18:56:42 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2022-04-06 16:25:25 -0400 |
commit | 7e8cc293702354bec350c4d3c784a70cd8f7ffe4 (patch) | |
tree | 611f581939fa6dfd9c5e0d03f64fa2c973897ff1 /rts/Linker.c | |
parent | 655e7d8f968eeaabfc02329d7ac9361678364c06 (diff) | |
download | haskell-7e8cc293702354bec350c4d3c784a70cd8f7ffe4.tar.gz |
rts/PEi386: Rework linker
This is a significant rework of the PEi386 linker, making the linker
compatible with high image base addresses. Specifically, we now use the
m32 allocator instead of `HeapAllocate`.
In addition I found a number of latent bugs in our handling of import
libraries and relocations. I've added quite a few comments describing
what I've learned about Windows import libraries while fixing these.
Thanks to Tamar Christina (@Phyx) for providing the address space search
logic, countless hours of help while debugging, and his boundless
Windows knowledge.
Co-Authored-By: Tamar Christina <tamar@zhox.com>
Diffstat (limited to 'rts/Linker.c')
-rw-r--r-- | rts/Linker.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/rts/Linker.c b/rts/Linker.c index c1918ecbba..823d58cc67 100644 --- a/rts/Linker.c +++ b/rts/Linker.c @@ -817,9 +817,8 @@ HsInt insertSymbol(pathchar* obj_name, SymbolName* key, SymbolAddr* data) #if defined(OBJFORMAT_PEi386) SymbolAddr* lookupDependentSymbol (SymbolName* lbl, ObjectCode *dependent, SymType *type) { - (void)dependent; // TODO ASSERT_LOCK_HELD(&linker_mutex); - return lookupSymbol_PEi386(lbl, type); + return lookupSymbol_PEi386(lbl, dependent, type); } #else @@ -1482,7 +1481,7 @@ HsInt loadOc (ObjectCode* oc) { int r; - IF_DEBUG(linker, debugBelch("loadOc: start (%s)\n", oc->fileName)); + IF_DEBUG(linker, debugBelch("loadOc: start (%" PATH_FMT ")\n", oc->fileName)); /* verify the in-memory image */ # if defined(OBJFORMAT_ELF) @@ -1513,8 +1512,7 @@ HsInt loadOc (ObjectCode* oc) symbol table. Allocating space for jump tables in ocAllocateExtras would just be a waste then as we'll be stopping further processing of the library in the next few steps. If necessary, the actual allocation - happens in `ocGetNames_PEi386` and `ocAllocateExtras_PEi386` simply - set the correct pointers. + happens in `ocGetNames_PEi386` simply set the correct pointers. */ #if defined(NEED_SYMBOL_EXTRAS) @@ -1550,12 +1548,6 @@ HsInt loadOc (ObjectCode* oc) return r; } -#if defined(NEED_SYMBOL_EXTRAS) -# if defined(OBJFORMAT_PEi386) - ocAllocateExtras_PEi386 ( oc ); -# endif -#endif - /* Loaded, but not resolved yet, ensure the OC is in a consistent state. If a target has requested the ObjectCode not to be resolved then honor this requests. Usually this means the ObjectCode has not been initialized @@ -1567,7 +1559,7 @@ HsInt loadOc (ObjectCode* oc) oc->status = OBJECT_LOADED; } } - IF_DEBUG(linker, debugBelch("loadOc: done (%s).\n", oc->fileName)); + IF_DEBUG(linker, debugBelch("loadOc: done (%" PATH_FMT ").\n", oc->fileName)); return 1; } |