winegcc: Add Macho-o lib detection support

André Hentschel nerv at dawncrow.de
Mon Nov 8 11:52:01 CST 2010


---
 tools/winegcc/winegcc.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c
index bec4be3..8dfa14a 100644
--- a/tools/winegcc/winegcc.c
+++ b/tools/winegcc/winegcc.c
@@ -321,7 +321,8 @@ static int check_platform( struct options *opts, const char *file )
         unsigned char header[16];
         if (read( fd, header, sizeof(header) ) == sizeof(header))
         {
-            /* FIXME: only ELF is supported, platform is not checked beyond 32/64 */
+            /* FIXME: only ELF and Macho-o is supported, platform is not checked beyond 32/64 */
+            /* ELF */
             if (!memcmp( header, "\177ELF", 4 ))
             {
                 if (header[4] == 2)  /* 64-bit */
@@ -331,6 +332,15 @@ static int check_platform( struct options *opts, const char *file )
                     ret = (opts->force_pointer_size == 4 ||
                            (!opts->force_pointer_size && opts->target_cpu != CPU_x86_64));
             }
+            /* Big Endian or Little Endian Mach-o File */
+            else if (!memcmp( header, "\376\355\372\316", 4 ) || !memcmp( header, "\316\372\355\376", 4 ))
+            {
+                unsigned int *cputype = (unsigned int *)&header[4];
+                if ((*cputype >> 24) == 1)  /* 64-bit */
+                    ret = (opts->force_pointer_size == 8);
+                else
+                    ret = (opts->force_pointer_size == 4);
+            }
         }
         close( fd );
     }
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list