X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FnativeGen%2FAsmCodeGen.lhs;h=0e05fb8f51dd6635992150e64fb0b729ee5c962a;hb=3e83dfb21b2f2220dce97427fff5c19459ae68d1;hp=1576162167821bf6a47965725543b8531dbcb344;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/compiler/nativeGen/AsmCodeGen.lhs b/compiler/nativeGen/AsmCodeGen.lhs index 1576162..0e05fb8 100644 --- a/compiler/nativeGen/AsmCodeGen.lhs +++ b/compiler/nativeGen/AsmCodeGen.lhs @@ -10,7 +10,7 @@ module AsmCodeGen ( nativeCodeGen ) where #include "HsVersions.h" -#include "NCG.h" +#include "nativeGen/NCG.h" import MachInstrs import MachRegs @@ -39,6 +39,7 @@ import CLabel ( pprCLabel ) import ErrUtils ( dumpIfSet_dyn ) import DynFlags ( DynFlags, DynFlag(..), dopt ) import StaticFlags ( opt_Static, opt_PIC ) +import Config ( cProjectVersion ) import Digraph import qualified Pretty @@ -131,6 +132,23 @@ nativeCodeGen dflags cmms us -- There's a hack to make this work in PprMach.pprNatCmmTop. Pretty.$$ Pretty.text ".subsections_via_symbols" #endif +#if HAVE_GNU_NONEXEC_STACK + -- On recent GNU ELF systems one can mark an object file + -- as not requiring an executable stack. If all objects + -- linked into a program have this note then the program + -- will not use an executable stack, which is good for + -- security. GHC generated code does not need an executable + -- stack so add the note in: + Pretty.$$ Pretty.text ".section .note.GNU-stack,\"\",@progbits" +#endif +#if !defined(darwin_TARGET_OS) + -- And just because every other compiler does, lets stick in + -- an identifier directive: .ident "GHC x.y.z" + Pretty.$$ let compilerIdent = Pretty.text "GHC" Pretty.<+> + Pretty.text cProjectVersion + in Pretty.text ".ident" Pretty.<+> + Pretty.doubleQuotes compilerIdent +#endif ) } @@ -293,17 +311,17 @@ reorder id accum (b@(block,id',out) : rest) genMachCode :: CmmTop -> UniqSM ([NatCmmTop], [CLabel]) -genMachCode cmm_top initial_us - = let initial_st = mkNatM_State initial_us 0 - (new_tops, final_st) = initNat initial_st (cmmTopCodeGen cmm_top) - final_us = natm_us final_st - final_delta = natm_delta final_st - final_imports = natm_imports final_st - in - if final_delta == 0 - then ((new_tops, final_imports), final_us) - else pprPanic "genMachCode: nonzero final delta" - (int final_delta) +genMachCode cmm_top + = do { initial_us <- getUs + ; let initial_st = mkNatM_State initial_us 0 + (new_tops, final_st) = initNat initial_st (cmmTopCodeGen cmm_top) + final_us = natm_us final_st + final_delta = natm_delta final_st + final_imports = natm_imports final_st + ; if final_delta == 0 + then return (new_tops, final_imports) + else pprPanic "genMachCode: nonzero final delta" (int final_delta) + } -- ----------------------------------------------------------------------------- -- Fixup assignments to global registers so that they assign to