
Hardened gentoo patches gcc to default to -fPIC -fPIE -pie. Defaults
#9007: fails to build with hardening flags enabled (relocation R_X86_64_32 against `stg_CHARLIKE_closure'...) -------------------------------------+------------------------------------- Reporter: nomeata | Owner: nomeata Type: bug | Status: infoneeded Priority: high | Milestone: 7.12.1 Component: Compiler | Version: 7.9 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Building GHC | Unknown/Multiple failed | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by kgardas): Replying to [comment:19 slyfox]: there:
{{{ # gcc -dM -E - < /dev/null | grep -E -i 'pic|pie' #define __pie__ 2 #define __PIE__ 2 #define __pic__ 2 #define __PIC__ 2 }}}
What bothers me is -optl-pie seems not to work even for -split-objs case on vanilla gcc/ghc: {{{ $ echo 'main = print "hello"' > a.hs $ ghc --make -optl-pie -fPIC -optc-fPIC -dynamic a.hs -fforce-recomp [1 of 1] Compiling Main ( a.hs, a.o ) Linking a ... $ ghc --make -optl-pie -fPIC -optc-fPIC -dynamic a.hs -fforce-recomp -split-objs [1 of 1] Compiling Main ( a.hs, a.o ) /usr/lib/gcc/x86_64-pc-linux-gnu/5.1.0/../../../../x86_64-pc-linux- gnu/bin/ld: -r and -shared may not be used together collect2: error: ld returned 1 exit status }}} An evil corner case as we use ld for partial linking. Can be an argument for native fPIE/pie support in ghc.
I'm curious but isn't -split-objs purely static library thing? IMHO it's not usable for -shared nor -dynamic nor -fPIC etc. Please correct me if I'm wrong here... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9007#comment:21 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler