[commit: ghc] master: Big-obj support for the Windows runtime linker (81377e9)
git at git.haskell.org
git at git.haskell.org
Sat Jul 8 16:00:40 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/81377e9e4bd52256946114d9c1dd966d5e3e7692/ghc
>---------------------------------------------------------------
commit 81377e9e4bd52256946114d9c1dd966d5e3e7692
Author: Tamar Christina <tamar at zhox.com>
Date: Sat Jul 8 09:57:55 2017 +0100
Big-obj support for the Windows runtime linker
Summary:
The normal object file on Windows has a limit of `2^16`
sections that can be in an object-file.
The `big-obj` format raises this to `2^32` sections.
The implementation is made difficult because we now need to support
two header formats and two section formats that differ only by a single
element size within each. The element that's different is in the middle
of the structs and since the structs are used to map regions of memory
directly, it means we need to know which struct it is when we do the
mapping or pointer arithmetics.
This is the final Object-Code format which Windows compilers can generate
which we do not support yet in GHCI. All other major compilers on the platforms
can produce it and all linkers consume it (bfd and lld).
See http://tinyurl.com/bigobj
This patch abstracts away retrieving the fields to functions which all take
an struct which describes which object format is currently being parsed.
These functions are always in-lined as they're small but would looks messy
being copy-pasted everywhere.
Test Plan:
./validate and new test `big-obj`
```
Tamar at Rage MINGW64 /r
$ gcc -c -Wa,-mbig-obj foo.c -o foo.o
Tamar at Rage MINGW64 /r
$ objdump -h foo.o
foo.o: file format pe-bigobj-x86-64
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000010 0000000000000000 0000000000000000 00000128 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 0000000000000000 0000000000000000 00000000 2**4
ALLOC, LOAD, DATA
2 .bss 00000000 0000000000000000 0000000000000000 00000000 2**4
ALLOC
3 .xdata 00000008 0000000000000000 0000000000000000 00000138 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .pdata 0000000c 0000000000000000 0000000000000000 00000140 2**2
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA
5 .rdata$zzz 00000030 0000000000000000 0000000000000000 0000014c 2**4
CONTENTS, ALLOC, LOAD, READONLY, DATA
Tamar at Rage MINGW64 /r
$ echo main | ~/ghc/inplace/bin/ghc-stage2.exe --interactive bar.hs foo.o
GHCi, version 8.3.20170430: http://www.haskell.org/ghc/ :? for help
[1 of 1] Compiling Main ( bar.hs, interpreted )
Ok, modules loaded: Main.
*Main> 17
*Main> Leaving GHCi.
```
Reviewers: austin, bgamari, erikd, simonmar
Subscribers: awson, rwbarton, thomie, #ghc_windows_task_force
GHC Trac Issues: #13815
Differential Revision: https://phabricator.haskell.org/D3523
>---------------------------------------------------------------
81377e9e4bd52256946114d9c1dd966d5e3e7692
docs/users_guide/8.4.1-notes.rst | 2 +
rts/linker/PEi386.c | 624 ++++++++++++++++-----
rts/linker/PEi386.h | 52 +-
testsuite/tests/ghci/linking/dyn/Makefile | 5 +
testsuite/tests/ghci/linking/dyn/all.T | 4 +
.../foo_dll.c => ghci/linking/dyn/big-obj-c.c} | 2 +-
testsuite/tests/ghci/linking/dyn/big-obj.hs | 3 +
.../linking/dyn/big-obj.stdout} | 0
8 files changed, 539 insertions(+), 153 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 81377e9e4bd52256946114d9c1dd966d5e3e7692
More information about the ghc-commits
mailing list