[commit: ghc] master: Updated PE linker, section alignment and cleanup. (5840734)

git at git.haskell.org git at git.haskell.org
Mon Sep 17 21:31:09 UTC 2018


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/5840734379da5d494a368d0b8a6edf1b1216a7f4/ghc

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

commit 5840734379da5d494a368d0b8a6edf1b1216a7f4
Author: Tamar Christina <tamar at zhox.com>
Date:   Mon Sep 17 22:06:05 2018 +0100

    Updated PE linker, section alignment and cleanup.
    
    Summary:
    This patch is to address a couple of short comings of the PE linker.
    
    The first thing it does is properly honor section alignments, so SSE code
    will work reliably.
    
    While doing this I've also changed how it reads and stores ObjectFile
    information. Previously the entire object file was read in and treated
    as one blob, including headers, symbol tables etc.
    
    Now the ObjectFile is read in but stored in chunks, tables go into a temporary
    info struct and code/data into a new private heap. This allows me to free all
    meta data once we're done relocating. Which means we can reclaim this memory.
    
    As I've mentioned above I've also moved from using VirtualAlloc to HeapAlloc.
    The reason is VirtualAlloc is meant to be used for more low level memory
    allocation, it's very fast because it can only allocate whole blocks,
    (64k) by default, and the memory must be paged (4k) aligned.
    
    So when you ask for e.g. 30k of memory, you're given a whole block where 34k
    will be wasted memory. Nothing else can ever access that untill you free the 30k.
    
    One downside of HeapAlloc is that you're not in control of how the heap grows,
    and heap memory is always committed. So it's harder to tell how much we're
    actually using now.
    
    Another big upside of splitting off the ObjectCode tables to info structs
    is that I can adjust them, so that later addressings can just use array
    subscripts to index into them. This simplifies the code a lot and a lot of
    complicated casts and indexing can be removed. Leaving less and more simple
    code.
    
    This patch doesn't fix the memprotection but it doesn't regress it either.
    It does however make the next changes smaller and fixes the alignments.
    
    Test Plan: ./validate , new test T13617
    
    Reviewers: bgamari, erikd, simonmar, hvr, angerman
    
    Reviewed By: angerman
    
    Subscribers: nickkuk, carter, RyanGlScott, rwbarton, thomie
    
    GHC Trac Issues: #13617
    
    Differential Revision: https://phabricator.haskell.org/D3915


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

5840734379da5d494a368d0b8a6edf1b1216a7f4
 docs/users_guide/8.8.1-notes.rst  |    5 +
 rts/Linker.c                      |   65 ++-
 rts/LinkerInternals.h             |   31 +-
 rts/linker/LoadArchive.c          |    9 +-
 rts/linker/PEi386.c               | 1146 +++++++++++++++++++------------------
 rts/linker/PEi386.h               |   39 +-
 rts/linker/PEi386Types.h          |   35 ++
 testsuite/tests/rts/Makefile      |    5 +
 testsuite/tests/rts/T13617.c      |    8 +
 testsuite/tests/rts/T13617.hs     |   15 +
 testsuite/tests/rts/T13617.stdout |    1 +
 testsuite/tests/rts/all.T         |    3 +
 12 files changed, 741 insertions(+), 621 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 5840734379da5d494a368d0b8a6edf1b1216a7f4


More information about the ghc-commits mailing list