[Git][ghc/ghc][wip/T22834] 2 commits: nativeGen: Explicitly set flags of text sections on Windows

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Wed Jan 25 17:12:54 UTC 2023



Ben Gamari pushed to branch wip/T22834 at Glasgow Haskell Compiler / GHC


Commits:
951bb80b by Ben Gamari at 2023-01-25T12:12:43-05:00
nativeGen: Explicitly set flags of text sections on Windows

The binutils documentation (for COFF) claims,

> If no flags are specified, the default flags depend upon the section
> name. If the section name is not recognized, the default will be for the
> section to be loaded and writable.

We previously assumed that this would do the right thing for split
sections (e.g. a section named `.text$foo` would be correctly inferred
to be a text section). However, we have observed that this is not the
case (at least under the clang toolchain used on Windows): when
split-sections is enabled, text sections are treated by the assembler as
data (matching the "default" behavior specified by the documentation).

Avoid this by setting section flags explicitly. This should fix split
sections on Windows.

Fixes #22834.

- - - - -
2416f607 by Ben Gamari at 2023-01-25T12:12:49-05:00
nativeGen: Explicitly set section types

TODO

- - - - -


2 changed files:

- .gitlab/gen_ci.hs
- compiler/GHC/CmmToAsm/Ppr.hs


Changes:

=====================================
.gitlab/gen_ci.hs
=====================================
@@ -196,9 +196,6 @@ vanilla = BuildConfig
   , noSplitSections = False
   }
 
-splitSectionsBroken :: BuildConfig -> BuildConfig
-splitSectionsBroken bc = bc { noSplitSections = True }
-
 nativeInt :: BuildConfig
 nativeInt = vanilla { bignumBackend = Native }
 
@@ -859,25 +856,25 @@ job_groups =
      , disableValidate (standardBuilds Amd64 (Linux Debian11))
      -- We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19
      -- not being at EOL until April 2023 and they still need tinfo5.
-     , disableValidate (standardBuildsWithConfig Amd64 (Linux Debian9) (splitSectionsBroken vanilla))
+     , disableValidate (standardBuildsWithConfig Amd64 (Linux Debian9) vanilla)
      , disableValidate (standardBuilds Amd64 (Linux Ubuntu2004))
      , disableValidate (standardBuilds Amd64 (Linux Rocky8))
-     , disableValidate (standardBuildsWithConfig Amd64 (Linux Centos7) (splitSectionsBroken vanilla))
+     , disableValidate (standardBuildsWithConfig Amd64 (Linux Centos7) vanilla)
      -- Fedora33 job is always built with perf so there's one job in the normal
      -- validate pipeline which is built with perf.
      , standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig
      -- This job is only for generating head.hackage docs
      , hackage_doc_job (disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig))
      , disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) dwarf)
-     , fastCI (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken vanilla))
-     , disableValidate (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken nativeInt))
+     , fastCI (standardBuildsWithConfig Amd64 Windows vanilla)
+     , disableValidate (standardBuildsWithConfig Amd64 Windows nativeInt)
      , standardBuilds Amd64 Darwin
      , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13))
      , standardBuilds AArch64 Darwin
-     , standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla)
+     , standardBuildsWithConfig AArch64 (Linux Debian10) vanilla
      , disableValidate (validateBuilds AArch64 (Linux Debian10) llvm)
-     , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla)
-     , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static)
+     , standardBuildsWithConfig I386 (Linux Debian9) vanilla
+     , standardBuildsWithConfig Amd64 (Linux Alpine) static
      , disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt))
      , validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing)
      , validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" NoEmulatorNeeded (Just "emconfigure")


=====================================
compiler/GHC/CmmToAsm/Ppr.hs
=====================================
@@ -245,6 +245,10 @@ pprGNUSectionHeader config t suffix =
       OtherSection _ ->
         panic "PprBase.pprGNUSectionHeader: unknown section type"
     flags = case t of
+      Text
+        | OSMinGW32 <- platformOS platform
+                    -> text ",\"xr\""
+        | otherwise -> text ",\"ax\"," <> sectionType platform "progbits"
       CString
         | OSMinGW32 <- platformOS platform
                     -> empty



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a7c0381a59ded7b875164eb6314d25ac2f085d4e...2416f607a1695c597e9bff91e78a637b7b413c80

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a7c0381a59ded7b875164eb6314d25ac2f085d4e...2416f607a1695c597e9bff91e78a637b7b413c80
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230125/f3d04e85/attachment-0001.html>


More information about the ghc-commits mailing list