summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2010-08-05 12:06:00 +0000
committerIan Lynagh <igloo@earth.li>2010-08-05 12:06:00 +0000
commit948c175539ddd954d56e82c902274c9d0e4de858 (patch)
tree77b3c93edaac92fe69db44a0fb2287a7b986e760 /rts
parentfd8a24fdce1ff65c4d8f89955b8dd0dc4511ccc8 (diff)
downloadhaskell-948c175539ddd954d56e82c902274c9d0e4de858.tar.gz
On amd64/OSX we don't need to be given memory in the first 31bits
as PIC is always on
Diffstat (limited to 'rts')
-rw-r--r--rts/Linker.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/rts/Linker.c b/rts/Linker.c
index beaf19e4a5..67e5b56050 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -107,6 +107,10 @@
#endif
#endif
+#if defined(x86_64_HOST_ARCH) && defined(darwin_HOST_OS)
+#define ALWAYS_PIC
+#endif
+
/* Hash table mapping symbol names to Symbol */
static /*Str*/HashTable *symhash;
@@ -208,7 +212,7 @@ static void machoInitSymbolsWithoutUnderscore( void );
* We pick a default address based on the OS, but also make this
* configurable via an RTS flag (+RTS -xm)
*/
-#if defined(x86_64_HOST_ARCH)
+#if !defined(ALWAYS_PIC) && defined(x86_64_HOST_ARCH)
#if defined(MAP_32BIT)
// Try to use MAP_32BIT
@@ -1164,7 +1168,7 @@ initLinker( void )
ASSERT( compileResult == 0 );
# endif
-#if defined(x86_64_HOST_ARCH)
+#if !defined(ALWAYS_PIC) && defined(x86_64_HOST_ARCH)
if (RtsFlags.MiscFlags.linkerMemBase != 0) {
// User-override for mmap_32bit_base
mmap_32bit_base = (void*)RtsFlags.MiscFlags.linkerMemBase;
@@ -1533,7 +1537,7 @@ mmapForLinker (size_t bytes, nat flags, int fd)
pagesize = getpagesize();
size = ROUND_UP(bytes, pagesize);
-#if defined(x86_64_HOST_ARCH)
+#if !defined(ALWAYS_PIC) && defined(x86_64_HOST_ARCH)
mmap_again:
if (mmap_32bit_base != 0) {
@@ -1550,7 +1554,7 @@ mmap_again:
stg_exit(EXIT_FAILURE);
}
-#if defined(x86_64_HOST_ARCH)
+#if !defined(ALWAYS_PIC) && defined(x86_64_HOST_ARCH)
if (mmap_32bit_base != 0) {
if (result == map_addr) {
mmap_32bit_base = (StgWord8*)map_addr + size;
@@ -3777,6 +3781,9 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
case R_X86_64_PC32:
{
+#if defined(ALWAYS_PIC)
+ barf("R_X86_64_PC32 relocation, but ALWAYS_PIC.");
+#else
StgInt64 off = value - P;
if (off >= 0x7fffffffL || off < -0x80000000L) {
#if X86_64_ELF_NONPIC_HACK
@@ -3789,6 +3796,7 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
#endif
}
*(Elf64_Word *)P = (Elf64_Word)off;
+#endif
break;
}
@@ -3800,6 +3808,9 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
}
case R_X86_64_32:
+#if defined(ALWAYS_PIC)
+ barf("R_X86_64_32 relocation, but ALWAYS_PIC.");
+#else
if (value >= 0x7fffffffL) {
#if X86_64_ELF_NONPIC_HACK
StgInt64 pltAddress = (StgInt64) &makeSymbolExtra(oc, ELF_R_SYM(info), S)
@@ -3811,9 +3822,13 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
#endif
}
*(Elf64_Word *)P = (Elf64_Word)value;
+#endif
break;
case R_X86_64_32S:
+#if defined(ALWAYS_PIC)
+ barf("R_X86_64_32S relocation, but ALWAYS_PIC.");
+#else
if ((StgInt64)value > 0x7fffffffL || (StgInt64)value < -0x80000000L) {
#if X86_64_ELF_NONPIC_HACK
StgInt64 pltAddress = (StgInt64) &makeSymbolExtra(oc, ELF_R_SYM(info), S)
@@ -3825,6 +3840,7 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
#endif
}
*(Elf64_Sword *)P = (Elf64_Sword)value;
+#endif
break;
case R_X86_64_GOTPCREL:
@@ -3837,6 +3853,9 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
case R_X86_64_PLT32:
{
+#if defined(ALWAYS_PIC)
+ barf("R_X86_64_PLT32 relocation, but ALWAYS_PIC.");
+#else
StgInt64 off = value - P;
if (off >= 0x7fffffffL || off < -0x80000000L) {
StgInt64 pltAddress = (StgInt64) &makeSymbolExtra(oc, ELF_R_SYM(info), S)
@@ -3844,6 +3863,7 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
off = pltAddress + A - P;
}
*(Elf64_Word *)P = (Elf64_Word)off;
+#endif
break;
}
#endif