Commit a6f9ebc5 authored by Ian Lynagh's avatar Ian Lynagh

Add "have subsections via symbols" to the Platform type

parent 7ef5b293
......@@ -225,6 +225,20 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS],
esac
}
dnl ** check for Apple-style dead-stripping support
dnl (.subsections-via-symbols assembler directive)
AC_MSG_CHECKING(for .subsections_via_symbols)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [__asm__ (".subsections_via_symbols");])],
[AC_MSG_RESULT(yes)
HaskellHaveSubsectionsViaSymbols=True
AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
[Define to 1 if Apple-style dead-stripping is supported.])
],
[HaskellHaveSubsectionsViaSymbols=False
AC_MSG_RESULT(no)])
checkArch "$BuildArch" ""
checkVendor "$BuildVendor"
checkOS "$BuildOS" ""
......@@ -239,6 +253,7 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS],
AC_SUBST(HaskellTargetArch)
AC_SUBST(HaskellTargetOs)
AC_SUBST(HaskellHaveSubsectionsViaSymbols)
])
......
......@@ -1103,37 +1103,38 @@ asmTempLabelPrefix platform =
pprDynamicLinkerAsmLabel :: Platform -> DynamicLinkerLabelInfo -> CLabel -> SDoc
pprDynamicLinkerAsmLabel platform dllInfo lbl
= if platform == Platform ArchX86_64 OSDarwin
then case dllInfo of
CodeStub -> char 'L' <> pprCLabel platform lbl <> text "$stub"
SymbolPtr -> char 'L' <> pprCLabel platform lbl <> text "$non_lazy_ptr"
GotSymbolPtr -> pprCLabel platform lbl <> text "@GOTPCREL"
GotSymbolOffset -> pprCLabel platform lbl
else if platformOS platform == OSDarwin
then case dllInfo of
CodeStub -> char 'L' <> pprCLabel platform lbl <> text "$stub"
SymbolPtr -> char 'L' <> pprCLabel platform lbl <> text "$non_lazy_ptr"
_ -> panic "pprDynamicLinkerAsmLabel"
else if platformArch platform == ArchPPC && osElfTarget (platformOS platform)
then case dllInfo of
CodeStub -> pprCLabel platform lbl <> text "@plt"
SymbolPtr -> text ".LC_" <> pprCLabel platform lbl
_ -> panic "pprDynamicLinkerAsmLabel"
else if platformArch platform == ArchX86_64 && osElfTarget (platformOS platform)
then case dllInfo of
CodeStub -> pprCLabel platform lbl <> text "@plt"
GotSymbolPtr -> pprCLabel platform lbl <> text "@gotpcrel"
GotSymbolOffset -> pprCLabel platform lbl
SymbolPtr -> text ".LC_" <> pprCLabel platform lbl
= if platformOS platform == OSDarwin
then if platformArch platform == ArchX86_64
then case dllInfo of
CodeStub -> char 'L' <> pprCLabel platform lbl <> text "$stub"
SymbolPtr -> char 'L' <> pprCLabel platform lbl <> text "$non_lazy_ptr"
GotSymbolPtr -> pprCLabel platform lbl <> text "@GOTPCREL"
GotSymbolOffset -> pprCLabel platform lbl
else case dllInfo of
CodeStub -> char 'L' <> pprCLabel platform lbl <> text "$stub"
SymbolPtr -> char 'L' <> pprCLabel platform lbl <> text "$non_lazy_ptr"
_ -> panic "pprDynamicLinkerAsmLabel"
else if osElfTarget (platformOS platform)
then case dllInfo of
CodeStub -> pprCLabel platform lbl <> text "@plt"
SymbolPtr -> text ".LC_" <> pprCLabel platform lbl
GotSymbolPtr -> pprCLabel platform lbl <> text "@got"
GotSymbolOffset -> pprCLabel platform lbl <> text "@gotoff"
then if platformArch platform == ArchPPC
then case dllInfo of
CodeStub -> pprCLabel platform lbl <> text "@plt"
SymbolPtr -> text ".LC_" <> pprCLabel platform lbl
_ -> panic "pprDynamicLinkerAsmLabel"
else if platformArch platform == ArchX86_64
then case dllInfo of
CodeStub -> pprCLabel platform lbl <> text "@plt"
GotSymbolPtr -> pprCLabel platform lbl <> text "@gotpcrel"
GotSymbolOffset -> pprCLabel platform lbl
SymbolPtr -> text ".LC_" <> pprCLabel platform lbl
else case dllInfo of
CodeStub -> pprCLabel platform lbl <> text "@plt"
SymbolPtr -> text ".LC_" <> pprCLabel platform lbl
GotSymbolPtr -> pprCLabel platform lbl <> text "@got"
GotSymbolOffset -> pprCLabel platform lbl <> text "@gotoff"
else if platformOS platform == OSMinGW32
then case dllInfo of
SymbolPtr -> text "__imp_" <> pprCLabel platform lbl
_ -> panic "pprDynamicLinkerAsmLabel"
then case dllInfo of
SymbolPtr -> text "__imp_" <> pprCLabel platform lbl
_ -> panic "pprDynamicLinkerAsmLabel"
else panic "pprDynamicLinkerAsmLabel"
......@@ -191,6 +191,7 @@ initSysTools mbMinusB
Nothing -> pgmError ("No entry for " ++ show key ++ " in " ++ show settingsFile)
; targetArch <- readSetting "target arch"
; targetOS <- readSetting "target os"
; targetHasSubsectionsViaSymbols <- readSetting "target has subsections via symbols"
; myExtraGccViaCFlags <- getSetting "GCC extra via C opts"
-- On Windows, mingw is distributed with GHC,
-- so we look in TopDir/../mingw/bin
......@@ -252,7 +253,8 @@ initSysTools mbMinusB
; return $ Settings {
sTargetPlatform = Platform {
platformArch = targetArch,
platformOS = targetOS
platformOS = targetOS,
platformHasSubsectionsViaSymbols = targetHasSubsectionsViaSymbols
},
sTmpDir = normalise tmpdir,
sGhcUsagePath = ghc_usage_msg_path,
......
......@@ -510,7 +510,7 @@ pprGotDeclaration _ _
-- the splitter in driver/split/ghc-split.lprl recognizes the new output
pprImportedSymbol :: Platform -> CLabel -> Doc
pprImportedSymbol platform@(Platform ArchPPC OSDarwin) importedLbl
pprImportedSymbol platform@(Platform { platformArch = ArchPPC, platformOS = OSDarwin }) importedLbl
| Just (CodeStub, lbl) <- dynamicLinkerLabelInfo importedLbl
= case opt_PIC of
False ->
......@@ -564,7 +564,7 @@ pprImportedSymbol platform@(Platform ArchPPC OSDarwin) importedLbl
= empty
pprImportedSymbol platform@(Platform ArchX86 OSDarwin) importedLbl
pprImportedSymbol platform@(Platform { platformArch = ArchX86, platformOS = OSDarwin }) importedLbl
| Just (CodeStub, lbl) <- dynamicLinkerLabelInfo importedLbl
= case opt_PIC of
False ->
......@@ -617,7 +617,7 @@ pprImportedSymbol platform@(Platform ArchX86 OSDarwin) importedLbl
= empty
pprImportedSymbol (Platform _ OSDarwin) _
pprImportedSymbol (Platform { platformOS = OSDarwin }) _
= empty
......@@ -650,12 +650,12 @@ pprImportedSymbol (Platform _ OSDarwin) _
-- the NCG will keep track of all DynamicLinkerLabels it uses
-- and output each of them using pprImportedSymbol.
pprImportedSymbol (Platform ArchPPC_64 os) _
| osElfTarget os
pprImportedSymbol platform@(Platform { platformArch = ArchPPC_64 }) _
| osElfTarget (platformOS platform)
= empty
pprImportedSymbol platform@(Platform _ os) importedLbl
| osElfTarget os
pprImportedSymbol platform importedLbl
| osElfTarget (platformOS platform)
= case dynamicLinkerLabelInfo importedLbl of
Just (SymbolPtr, lbl)
-> let symbolSize = case wordWidth of
......
......@@ -19,9 +19,11 @@ import Panic
-- | Contains enough information for the native code generator to emit
-- code for this platform.
data Platform
= Platform
{ platformArch :: Arch
, platformOS :: OS }
= Platform {
platformArch :: Arch,
platformOS :: OS,
platformHasSubsectionsViaSymbols :: Bool
}
deriving (Read, Show, Eq)
......
......@@ -703,19 +703,6 @@ FP_PROG_LD_X
FP_PROG_LD_IS_GNU
FP_PROG_LD_BUILD_ID
dnl ** check for Apple-style dead-stripping support
dnl (.subsections-via-symbols assembler directive)
AC_MSG_CHECKING(for .subsections_via_symbols)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [__asm__ (".subsections_via_symbols");])],
[AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
[Define to 1 if Apple-style dead-stripping is supported.])
],
[AC_MSG_RESULT(no)])
dnl *** check for GNU non-executable stack note support (ELF only)
dnl (.section .note.GNU-stack,"",@progbits)
......
......@@ -9,6 +9,7 @@
("windres command", "@SettingsWindresCommand@"),
("perl command", "@SettingsPerlCommand@"),
("target os", "@HaskellTargetOs@"),
("target arch", "@HaskellTargetArch@")
("target arch", "@HaskellTargetArch@"),
("target has subsections via symbols", "@HaskellHaveSubsectionsViaSymbols@")
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment