diff options
author | Simon Brenner <olsner@gmail.com> | 2016-12-16 12:14:36 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-12-16 12:14:38 -0500 |
commit | 4026b452817e9d4241691c58d131904bd0eb1fec (patch) | |
tree | 2b33e3beabfa6b92ac2d145d0bea5cb9211211e0 /compiler/nativeGen | |
parent | 222e99d9e6b24c17a67c07d24d05999701b83e96 (diff) | |
download | haskell-4026b452817e9d4241691c58d131904bd0eb1fec.tar.gz |
Fix string merging with -split-sections
The added flags for string literal merging ended up printed in the
middle of the section name when -split-sections was enabled. Break it up
to put the flags after the name.
Test Plan: validate with SplitSections=YES
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2865
GHC Trac Issues: #9577
Diffstat (limited to 'compiler/nativeGen')
-rw-r--r-- | compiler/nativeGen/PprBase.hs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/compiler/nativeGen/PprBase.hs b/compiler/nativeGen/PprBase.hs index 10ed2fb65d..e05b2b5cb1 100644 --- a/compiler/nativeGen/PprBase.hs +++ b/compiler/nativeGen/PprBase.hs @@ -85,6 +85,10 @@ doubleToBytes d -- If -split-section was specified, include the suffix label, otherwise just -- print the section type. For Darwin, where subsections-for-symbols are -- used instead, only print section type. +-- +-- For string literals, additional flags are specified to enable merging of +-- identical strings in the linker. With -split-sections each string also gets +-- a unique section to allow strings from unused code to be GC'd. pprSectionHeader :: Platform -> Section -> SDoc pprSectionHeader platform (Section t suffix) = @@ -98,7 +102,8 @@ pprGNUSectionHeader t suffix = sdocWithDynFlags $ \dflags -> let splitSections = gopt Opt_SplitSections dflags subsection | splitSections = char '.' <> ppr suffix | otherwise = empty - in text ".section " <> ptext (header dflags) <> subsection + in text ".section " <> ptext (header dflags) <> subsection <> + flags dflags where header dflags = case t of Text -> sLit ".text" @@ -109,10 +114,16 @@ pprGNUSectionHeader t suffix = sdocWithDynFlags $ \dflags -> ReadOnlyData16 -> sLit ".rodata.cst16" CString | OSMinGW32 <- platformOS (targetPlatform dflags) - -> sLit ".rdata,\"dr\"" - | otherwise -> sLit ".rodata.str1.1,\"aMS\",@progbits,1" + -> 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\"" + | otherwise -> text ",\"aMS\",@progbits,1" + _ -> empty -- XCOFF doesn't support relocating label-differences, so we place all -- RO sections into .text[PR] sections |