[commit: ghc] master: rts: Fix LoadArchive on OS X (ec0bf81)
git at git.haskell.org
git at git.haskell.org
Fri Nov 11 18:17:27 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/ec0bf8117d1aefd20711a6152ebbca63f3bd0774/ghc
>---------------------------------------------------------------
commit ec0bf8117d1aefd20711a6152ebbca63f3bd0774
Author: Ben Gamari <ben at smart-cactus.org>
Date: Fri Nov 11 10:58:08 2016 -0500
rts: Fix LoadArchive on OS X
>---------------------------------------------------------------
ec0bf8117d1aefd20711a6152ebbca63f3bd0774
rts/Linker.c | 9 +++------
rts/LinkerInternals.h | 9 +++++++++
rts/linker/LoadArchive.c | 9 ++++++++-
3 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/rts/Linker.c b/rts/Linker.c
index ede5654..eba9821 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -57,17 +57,14 @@
#include <dlfcn.h>
#endif
-#if defined(linux_HOST_OS) || defined(solaris2_HOST_OS) || defined(freebsd_HOST_OS) || defined(kfreebsdgnu_HOST_OS) || defined(dragonfly_HOST_OS) || defined(netbsd_HOST_OS) || defined(openbsd_HOST_OS) || defined(gnu_HOST_OS)
-# define OBJFORMAT_ELF
+#if defined(OBJFORMAT_ELF)
# include "linker/Elf.h"
# include <regex.h> // regex is already used by dlopen() so this is OK
// to use here without requiring an additional lib
-#elif defined (mingw32_HOST_OS)
-# define OBJFORMAT_PEi386
+#elif defined(OBJFORMAT_PEi386)
# include "linker/PEi386.h"
# include <windows.h>
-#elif defined(darwin_HOST_OS)
-# define OBJFORMAT_MACHO
+#elif defined(OBJFORMAT_MACHO)
# include "linker/MachO.h"
# include <regex.h>
# include <mach/machine.h>
diff --git a/rts/LinkerInternals.h b/rts/LinkerInternals.h
index 1093435..ce5c5eb 100644
--- a/rts/LinkerInternals.h
+++ b/rts/LinkerInternals.h
@@ -293,4 +293,13 @@ char *cstring_from_section_name(
UChar* strtab);
#endif /* mingw32_HOST_OS */
+/* Which object file format are we targetting? */
+#if defined(linux_HOST_OS) || defined(solaris2_HOST_OS) || defined(freebsd_HOST_OS) || defined(kfreebsdgnu_HOST_OS) || defined(dragonfly_HOST_OS) || defined(netbsd_HOST_OS) || defined(openbsd_HOST_OS) || defined(gnu_HOST_OS)
+# define OBJFORMAT_ELF
+#elif defined (mingw32_HOST_OS)
+# define OBJFORMAT_PEi386
+#elif defined(darwin_HOST_OS)
+# define OBJFORMAT_MACHO
+#endif
+
#endif /* LINKERINTERNALS_H */
diff --git a/rts/linker/LoadArchive.c b/rts/linker/LoadArchive.c
index 6e1fb29..a5af719 100644
--- a/rts/linker/LoadArchive.c
+++ b/rts/linker/LoadArchive.c
@@ -9,8 +9,15 @@
#include "PathUtils.h"
#include "LinkerInternals.h"
#include "linker/M32Alloc.h"
+
+/* Platform specific headers */
#if defined(OBJFORMAT_PEi386)
-#include "linkers/PEi386.h"
+# include "linkers/PEi386.h"
+#elif defined(darwin_HOST_OS)
+# include "linker/MachO.h"
+# include <regex.h>
+# include <mach/machine.h>
+# include <mach-o/fat.h>
#endif
#include <ctype.h>
More information about the ghc-commits
mailing list