summaryrefslogtreecommitdiff
path: root/ghc/compiler/nativeGen/PprMach.hs
diff options
context:
space:
mode:
authorwolfgang <unknown>2005-01-14 22:12:55 +0000
committerwolfgang <unknown>2005-01-14 22:12:55 +0000
commitacea64ed203f2e1b340e5a42bbb5fab4fc240baf (patch)
tree66d5a1982164fc5ba19a095c46d9cc9f63ef9a38 /ghc/compiler/nativeGen/PprMach.hs
parentc464eda3010831d8e5fb97c950aef953a1217db6 (diff)
downloadhaskell-acea64ed203f2e1b340e5a42bbb5fab4fc240baf.tar.gz
[project @ 2005-01-14 22:12:54 by wolfgang]
When -dynamic is specified but -fPIC is not, generate code that works around the ELF dynamic linker's misguided attempts to keep the main program unaware of dynamic linking. This involves generating indirect references and computed jumps for position dependent code, too, and making all constant data sections writable in order to persuade ld to not use "COPY" relocations. Tested on powerpc-linux; in theory, it also applies to i386-linux, but other parts of the PIC story are missing there. Note that the writable-const-data hack could be improved a bit by distinguishing between "really" constant data and "relocatable" constant data, which would be a nice thing to do anyway.
Diffstat (limited to 'ghc/compiler/nativeGen/PprMach.hs')
-rw-r--r--ghc/compiler/nativeGen/PprMach.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/ghc/compiler/nativeGen/PprMach.hs b/ghc/compiler/nativeGen/PprMach.hs
index 846a855508..a807cc2a05 100644
--- a/ghc/compiler/nativeGen/PprMach.hs
+++ b/ghc/compiler/nativeGen/PprMach.hs
@@ -34,7 +34,7 @@ import Pretty
import FastString
import qualified Outputable
-import CmdLineOpts ( opt_PIC )
+import CmdLineOpts ( opt_PIC, opt_Static )
#if __GLASGOW_HASKELL__ >= 504
import Data.Array.ST
@@ -512,6 +512,15 @@ pprAddr (AddrRegImm r1 imm) = hcat [ pprImm imm, char '(', pprReg r1, char ')' ]
-- -----------------------------------------------------------------------------
-- pprData: print a 'CmmStatic'
+#if defined(linux_TARGET_OS)
+#if defined(powerpc_TARGET_ARCH) || defined(i386_TARGET_ARCH)
+ -- Hack to make dynamic linking work
+pprSectionHeader ReadOnlyData
+ | not opt_PIC && not opt_Static
+ = pprSectionHeader Data
+#endif
+#endif
+
pprSectionHeader Text
= ptext
IF_ARCH_alpha(SLIT("\t.text\n\t.align 3") {-word boundary-}