rts: Fix LoadArchive on OS X
authorBen Gamari <ben@smart-cactus.org>
Fri, 11 Nov 2016 15:58:08 +0000 (10:58 -0500)
committerBen Gamari <ben@smart-cactus.org>
Fri, 11 Nov 2016 16:10:47 +0000 (11:10 -0500)
rts/Linker.c
rts/LinkerInternals.h
rts/linker/LoadArchive.c

index ede5654..eba9821 100644 (file)
 #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>
index 1093435..ce5c5eb 100644 (file)
@@ -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 */
index 6e1fb29..a5af719 100644 (file)
@@ -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>