Generate RelocatableReadOnlyData as .data
authorClemens Fruhwirth <clemens@endorphin.org>
Wed, 27 Jun 2007 16:06:40 +0000 (16:06 +0000)
committerClemens Fruhwirth <clemens@endorphin.org>
Wed, 27 Jun 2007 16:06:40 +0000 (16:06 +0000)
The GNU linker expects read-only sections to be relocation
free. Presumably because the dynamic linker maps all read-only
sections as read-only mmaps and hence can't do relocations.

If we want text-relocation-free shared libraries we have to put all
relocations into writable sections, hence .data.  See
http://www.mail-archive.com/cvs-all@haskell.org/msg15119.html

compiler/nativeGen/PprMach.hs

index e7c0e97..29cd23e 100644 (file)
@@ -646,9 +646,9 @@ pprSectionHeader RelocatableReadOnlyData
         IF_ARCH_alpha(SLIT("\t.data\n\t.align 3")
        ,IF_ARCH_sparc(SLIT(".data\n\t.align 8") {-<8 will break double constants -}
        ,IF_ARCH_i386(IF_OS_darwin(SLIT(".const_data\n.align 2"),
-                                   SLIT(".section .rodata\n\t.align 4"))
+                                   SLIT(".section .data\n\t.align 4"))
        ,IF_ARCH_x86_64(IF_OS_darwin(SLIT(".const_data\n.align 3"),
-                                     SLIT(".section .rodata\n\t.align 8"))
+                                     SLIT(".section .data\n\t.align 8"))
         ,IF_ARCH_powerpc(IF_OS_darwin(SLIT(".const_data\n.align 2"),
                                       SLIT(".data\n\t.align 2"))
        ,)))))