summaryrefslogtreecommitdiff
path: root/compiler/main/Elf.hs
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2017-07-11 15:41:55 -0400
committerBen Gamari <ben@smart-cactus.org>2017-07-11 16:32:43 -0400
commit9b9f978fdcd13ff7b2a9b7391e02dff06da622a0 (patch)
tree23221a07613b0866727026b201778eb5bc3d08b4 /compiler/main/Elf.hs
parent4befb415d7ee63d2b0ecdc2384310dc4b3ccc90a (diff)
downloadhaskell-9b9f978fdcd13ff7b2a9b7391e02dff06da622a0.tar.gz
Use correct section types syntax for architecture
Previously GHC would always assume that section types began with `@` while producing assembly, which is not true. For instance, in ARM assembly syntax section types begin with `%`. This abstracts out section type pretty-printing and adjusts it to correctly account for the target architectures assembly flavor. Reviewers: austin, hvr, Phyx Reviewed By: Phyx Subscribers: Phyx, rwbarton, thomie, erikd GHC Trac Issues: #13937 Differential Revision: https://phabricator.haskell.org/D3712
Diffstat (limited to 'compiler/main/Elf.hs')
-rw-r--r--compiler/main/Elf.hs14
1 files changed, 4 insertions, 10 deletions
diff --git a/compiler/main/Elf.hs b/compiler/main/Elf.hs
index 50f11a72a8..599d4d9160 100644
--- a/compiler/main/Elf.hs
+++ b/compiler/main/Elf.hs
@@ -14,9 +14,9 @@ module Elf (
makeElfNote
) where
+import AsmUtils
import Exception
import DynFlags
-import Platform
import ErrUtils
import Maybes (MaybeT(..),runMaybeT)
import Util (charToC)
@@ -415,12 +415,12 @@ readElfNoteAsString dflags path sectionName noteId = action `catchIO` \_ -> do
-- If we add new target platforms, we need to check that the generated words
-- are 32-bit long, otherwise we need to use platform specific directives to
-- force 32-bit .int in asWord32.
-makeElfNote :: DynFlags -> String -> String -> Word32 -> String -> SDoc
-makeElfNote dflags sectionName noteName typ contents = hcat [
+makeElfNote :: String -> String -> Word32 -> String -> SDoc
+makeElfNote sectionName noteName typ contents = hcat [
text "\t.section ",
text sectionName,
text ",\"\",",
- text elfSectionNote,
+ sectionType "note",
text "\n",
-- note name length (+ 1 for ending \0)
@@ -453,12 +453,6 @@ makeElfNote dflags sectionName noteName typ contents = hcat [
text (show x),
text "\n"]
- elfSectionNote :: String
- elfSectionNote = case platformArch (targetPlatform dflags) of
- ArchARM _ _ _ -> "%note"
- _ -> "@note"
-
-
------------------
-- Helpers