diff options
author | Tamar Christina <tamar@zhox.com> | 2017-03-26 19:05:46 +0100 |
---|---|---|
committer | Tamar Christina <tamar@zhox.com> | 2017-07-08 00:02:36 +0100 |
commit | bd4fdc6aa34a85268f3e9a2bd3f4142a97724ce4 (patch) | |
tree | 984a144a47f4045b226a1511442bb13fd3a8a3cb /compiler/nativeGen | |
parent | 99adcc8804e91161b35ff1d0e5f718d18fcaa66a (diff) | |
download | haskell-bd4fdc6aa34a85268f3e9a2bd3f4142a97724ce4.tar.gz |
Implement split-sections support for windows.
Summary:
Initial implementation of split-section on Windows.
This also corrects section namings and uses the platform
convention of `$` instead of `.` to separate sections.
Implementation is based on @awson's patches to binutils.
Binutils requires some extra help when compiling the libraries
for GHCi usage. We drop the `-T` and use implicit scripts to amend
the linker scripts instead of replacing it.
Because of these very large GHCi object files, we need big-obj support,
which will be added by another patch.
Test Plan: ./validate
Reviewers: awson, austin, bgamari
Subscribers: dfeuer, rwbarton, thomie, snowleopard, #ghc_windows_task_force
GHC Trac Issues: #12913
Differential Revision: https://phabricator.haskell.org/D3383
Diffstat (limited to 'compiler/nativeGen')
-rw-r--r-- | compiler/nativeGen/PprBase.hs | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/compiler/nativeGen/PprBase.hs b/compiler/nativeGen/PprBase.hs index e05b2b5cb1..76ac13ef4b 100644 --- a/compiler/nativeGen/PprBase.hs +++ b/compiler/nativeGen/PprBase.hs @@ -93,14 +93,15 @@ doubleToBytes d pprSectionHeader :: Platform -> Section -> SDoc pprSectionHeader platform (Section t suffix) = case platformOS platform of - OSAIX -> pprXcoffSectionHeader t - OSDarwin -> pprDarwinSectionHeader t - _ -> pprGNUSectionHeader t suffix + OSAIX -> pprXcoffSectionHeader t + OSDarwin -> pprDarwinSectionHeader t + OSMinGW32 -> pprGNUSectionHeader (char '$') t suffix + _ -> pprGNUSectionHeader (char '.') t suffix -pprGNUSectionHeader :: SectionType -> CLabel -> SDoc -pprGNUSectionHeader t suffix = sdocWithDynFlags $ \dflags -> +pprGNUSectionHeader :: SDoc -> SectionType -> CLabel -> SDoc +pprGNUSectionHeader sep t suffix = sdocWithDynFlags $ \dflags -> let splitSections = gopt Opt_SplitSections dflags - subsection | splitSections = char '.' <> ppr suffix + subsection | splitSections = sep <> ppr suffix | otherwise = empty in text ".section " <> ptext (header dflags) <> subsection <> flags dflags @@ -108,20 +109,28 @@ pprGNUSectionHeader t suffix = sdocWithDynFlags $ \dflags -> header dflags = case t of Text -> sLit ".text" Data -> sLit ".data" - ReadOnlyData -> sLit ".rodata" - RelocatableReadOnlyData -> sLit ".data.rel.ro" + ReadOnlyData | OSMinGW32 <- platformOS (targetPlatform dflags) + -> sLit ".rdata" + | otherwise -> sLit ".rodata" + RelocatableReadOnlyData | OSMinGW32 <- platformOS (targetPlatform dflags) + -- Concept does not exist on Windows, + -- So map these to R/O data. + -> sLit ".rdata$rel.ro" + | otherwise -> sLit ".data.rel.ro" UninitialisedData -> sLit ".bss" - ReadOnlyData16 -> sLit ".rodata.cst16" + ReadOnlyData16 | OSMinGW32 <- platformOS (targetPlatform dflags) + -> sLit ".rdata$cst16" + | otherwise -> sLit ".rodata.cst16" CString | OSMinGW32 <- platformOS (targetPlatform dflags) - -> sLit ".rdata" + -> sLit ".rdata" | otherwise -> sLit ".rodata.str" OtherSection _ -> panic "PprBase.pprGNUSectionHeader: unknown section type" flags dflags = case t of CString | OSMinGW32 <- platformOS (targetPlatform dflags) - -> text ",\"dr\"" + -> empty | otherwise -> text ",\"aMS\",@progbits,1" _ -> empty |