projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
LLVM: Use mangler to fix up stack alignment issues on OSX
[ghc-hetmet.git]
/
rts
/
Linker.c
diff --git
a/rts/Linker.c
b/rts/Linker.c
index
0624081
..
78bdc8f
100644
(file)
--- a/
rts/Linker.c
+++ b/
rts/Linker.c
@@
-71,16
+71,14
@@
#include <sys/wait.h>
#endif
#include <sys/wait.h>
#endif
-#if defined(ia64_HOST_ARCH) || defined(linux_HOST_OS) || defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS) || defined(netbsd_HOST_OS) || defined(openbsd_HOST_OS)
+#if defined(linux_HOST_OS) || defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS) || defined(netbsd_HOST_OS) || defined(openbsd_HOST_OS) || defined(darwin_HOST_OS)
#define USE_MMAP
#include <fcntl.h>
#include <sys/mman.h>
#define USE_MMAP
#include <fcntl.h>
#include <sys/mman.h>
-#if defined(linux_HOST_OS) || defined(freebsd_HOST_OS) || defined(dragonfly_HOST_OS) || defined(netbsd_HOST_OS) || defined(openbsd_HOST_OS)
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#endif
#endif
#endif
@@
-136,7
+134,9
@@
static int ocVerifyImage_MachO ( ObjectCode* oc );
static int ocGetNames_MachO ( ObjectCode* oc );
static int ocResolve_MachO ( ObjectCode* oc );
static int ocGetNames_MachO ( ObjectCode* oc );
static int ocResolve_MachO ( ObjectCode* oc );
+#ifndef USE_MMAP
static int machoGetMisalignment( FILE * );
static int machoGetMisalignment( FILE * );
+#endif
#if defined(powerpc_HOST_ARCH) || defined(x86_64_HOST_ARCH)
static int ocAllocateSymbolExtras_MachO ( ObjectCode* oc );
#endif
#if defined(powerpc_HOST_ARCH) || defined(x86_64_HOST_ARCH)
static int ocAllocateSymbolExtras_MachO ( ObjectCode* oc );
#endif
@@
-457,7
+457,7
@@
typedef struct _RtsSymbolVal {
SymI_NeedsProto(closedir)
#endif
SymI_NeedsProto(closedir)
#endif
-#if defined(darwin_TARGET_OS) && HAVE_PRINTF_LDBLSTUB
+#if defined(darwin_HOST_OS) && HAVE_PRINTF_LDBLSTUB
#define RTS_DARWIN_ONLY_SYMBOLS \
SymI_NeedsProto(asprintf$LDBLStub) \
SymI_NeedsProto(err$LDBLStub) \
#define RTS_DARWIN_ONLY_SYMBOLS \
SymI_NeedsProto(asprintf$LDBLStub) \
SymI_NeedsProto(err$LDBLStub) \
@@
-743,8
+743,9
@@
typedef struct _RtsSymbolVal {
SymI_HasProto(debugBelch) \
SymI_HasProto(errorBelch) \
SymI_HasProto(sysErrorBelch) \
SymI_HasProto(debugBelch) \
SymI_HasProto(errorBelch) \
SymI_HasProto(sysErrorBelch) \
- SymI_HasProto(stg_asyncExceptionsBlockedzh) \
- SymI_HasProto(stg_blockAsyncExceptionszh) \
+ SymI_HasProto(stg_getMaskingStatezh) \
+ SymI_HasProto(stg_maskAsyncExceptionszh) \
+ SymI_HasProto(stg_maskUninterruptiblezh) \
SymI_HasProto(stg_catchzh) \
SymI_HasProto(stg_catchRetryzh) \
SymI_HasProto(stg_catchSTMzh) \
SymI_HasProto(stg_catchzh) \
SymI_HasProto(stg_catchRetryzh) \
SymI_HasProto(stg_catchSTMzh) \
@@
-950,7
+951,7
@@
typedef struct _RtsSymbolVal {
SymI_HasProto(stg_threadStatuszh) \
SymI_HasProto(stg_tryPutMVarzh) \
SymI_HasProto(stg_tryTakeMVarzh) \
SymI_HasProto(stg_threadStatuszh) \
SymI_HasProto(stg_tryPutMVarzh) \
SymI_HasProto(stg_tryTakeMVarzh) \
- SymI_HasProto(stg_unblockAsyncExceptionszh) \
+ SymI_HasProto(stg_unmaskAsyncExceptionszh) \
SymI_HasProto(unloadObj) \
SymI_HasProto(stg_unsafeThawArrayzh) \
SymI_HasProto(stg_waitReadzh) \
SymI_HasProto(unloadObj) \
SymI_HasProto(stg_unsafeThawArrayzh) \
SymI_HasProto(stg_waitReadzh) \
@@
-1003,7
+1004,7
@@
typedef struct _RtsSymbolVal {
/* entirely bogus claims about types of these symbols */
#define SymI_NeedsProto(vvv) extern void vvv(void);
/* entirely bogus claims about types of these symbols */
#define SymI_NeedsProto(vvv) extern void vvv(void);
-#if defined(__PIC__) && defined(mingw32_TARGET_OS)
+#if defined(__PIC__) && defined(mingw32_HOST_OS)
#define SymE_HasProto(vvv) SymE_HasProto(vvv);
#define SymE_NeedsProto(vvv) extern void _imp__ ## vvv (void);
#else
#define SymE_HasProto(vvv) SymE_HasProto(vvv);
#define SymE_NeedsProto(vvv) extern void _imp__ ## vvv (void);
#else
@@
-1230,11
+1231,12
@@
static OpenedDLL* opened_dlls = NULL;
# if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO)
# if defined(OBJFORMAT_ELF) || defined(OBJFORMAT_MACHO)
-static char *
+static const char *
internal_dlopen(const char *dll_name)
{
void *hdl;
internal_dlopen(const char *dll_name)
{
void *hdl;
- char *errmsg, *errmsg_copy;
+ const char *errmsg;
+ char *errmsg_copy;
// omitted: RTLD_NOW
// see http://www.haskell.org/pipermail/cvs-ghc/2007-September/038570.html
// omitted: RTLD_NOW
// see http://www.haskell.org/pipermail/cvs-ghc/2007-September/038570.html
@@
-1274,7
+1276,7
@@
addDLL( char *dll_name )
#define NMATCH 5
regmatch_t match[NMATCH];
#define NMATCH 5
regmatch_t match[NMATCH];
- char *errmsg;
+ const char *errmsg;
FILE* fp;
size_t match_length;
#define MAXLINE 1000
FILE* fp;
size_t match_length;
#define MAXLINE 1000
@@
-2015,7
+2017,7
@@
static SymbolExtra* makeSymbolExtra( ObjectCode* oc,
* PowerPC specifics (instruction cache flushing)
* ------------------------------------------------------------------------*/
* PowerPC specifics (instruction cache flushing)
* ------------------------------------------------------------------------*/
-#ifdef powerpc_TARGET_ARCH
+#ifdef powerpc_HOST_ARCH
/*
ocFlushInstructionCache
/*
ocFlushInstructionCache
@@
-2953,10
+2955,18
@@
ocResolve_PEi386 ( ObjectCode* oc )
#define Elf_Sym Elf64_Sym
#define Elf_Rel Elf64_Rel
#define Elf_Rela Elf64_Rela
#define Elf_Sym Elf64_Sym
#define Elf_Rel Elf64_Rel
#define Elf_Rela Elf64_Rela
+#ifndef ELF_ST_TYPE
#define ELF_ST_TYPE ELF64_ST_TYPE
#define ELF_ST_TYPE ELF64_ST_TYPE
+#endif
+#ifndef ELF_ST_BIND
#define ELF_ST_BIND ELF64_ST_BIND
#define ELF_ST_BIND ELF64_ST_BIND
+#endif
+#ifndef ELF_R_TYPE
#define ELF_R_TYPE ELF64_R_TYPE
#define ELF_R_TYPE ELF64_R_TYPE
+#endif
+#ifndef ELF_R_SYM
#define ELF_R_SYM ELF64_R_SYM
#define ELF_R_SYM ELF64_R_SYM
+#endif
#else
#define ELFCLASS ELFCLASS32
#define Elf_Addr Elf32_Addr
#else
#define ELFCLASS ELFCLASS32
#define Elf_Addr Elf32_Addr
@@
-4011,7
+4021,7
@@
static int ocVerifyImage_MachO(ObjectCode* oc)
char *image = (char*) oc->image;
struct mach_header *header = (struct mach_header*) image;
char *image = (char*) oc->image;
struct mach_header *header = (struct mach_header*) image;
-#if x86_64_TARGET_ARCH || powerpc64_TARGET_ARCH
+#if x86_64_HOST_ARCH || powerpc64_HOST_ARCH
if(header->magic != MH_MAGIC_64)
return 0;
#else
if(header->magic != MH_MAGIC_64)
return 0;
#else
@@
-4203,6
+4213,9
@@
static int relocateSection(
thing += value;
break;
case X86_64_RELOC_SIGNED:
thing += value;
break;
case X86_64_RELOC_SIGNED:
+ case X86_64_RELOC_SIGNED_1:
+ case X86_64_RELOC_SIGNED_2:
+ case X86_64_RELOC_SIGNED_4:
ASSERT(reloc->r_pcrel);
thing += value - baseValue;
break;
ASSERT(reloc->r_pcrel);
thing += value - baseValue;
break;
@@
-4266,7
+4279,8
@@
static int relocateSection(
else if(scat->r_type == PPC_RELOC_SECTDIFF
|| scat->r_type == PPC_RELOC_LO16_SECTDIFF
|| scat->r_type == PPC_RELOC_HI16_SECTDIFF
else if(scat->r_type == PPC_RELOC_SECTDIFF
|| scat->r_type == PPC_RELOC_LO16_SECTDIFF
|| scat->r_type == PPC_RELOC_HI16_SECTDIFF
- || scat->r_type == PPC_RELOC_HA16_SECTDIFF)
+ || scat->r_type == PPC_RELOC_HA16_SECTDIFF
+ || scat->r_type == PPC_RELOC_LOCAL_SECTDIFF)
#else
else if(scat->r_type == GENERIC_RELOC_SECTDIFF
|| scat->r_type == GENERIC_RELOC_LOCAL_SECTDIFF)
#else
else if(scat->r_type == GENERIC_RELOC_SECTDIFF
|| scat->r_type == GENERIC_RELOC_LOCAL_SECTDIFF)
@@
-4785,6
+4799,7
@@
static void machoInitSymbolsWithoutUnderscore()
}
#endif
}
#endif
+#ifndef USE_MMAP
/*
* Figure out by how much to shift the entire Mach-O file in memory
* when loading so that its single segment ends up 16-byte-aligned
/*
* Figure out by how much to shift the entire Mach-O file in memory
* when loading so that its single segment ends up 16-byte-aligned
@@
-4797,7
+4812,7
@@
static int machoGetMisalignment( FILE * f )
fread(&header, sizeof(header), 1, f);
rewind(f);
fread(&header, sizeof(header), 1, f);
rewind(f);
-#if x86_64_TARGET_ARCH || powerpc64_TARGET_ARCH
+#if x86_64_HOST_ARCH || powerpc64_HOST_ARCH
if(header.magic != MH_MAGIC_64)
return 0;
#else
if(header.magic != MH_MAGIC_64)
return 0;
#else
@@
-4810,6
+4825,7
@@
static int machoGetMisalignment( FILE * f )
return misalignment ? (16 - misalignment) : 0;
}
return misalignment ? (16 - misalignment) : 0;
}
+#endif
#endif
#endif