From 2e000654704ccc02cbffa49a879e1da46f7bb231 Mon Sep 17 00:00:00 2001 From: Ted Mielczarek Date: Wed, 17 Mar 2010 11:55:56 -0400 Subject: [PATCH] bug 551941 - fix 'unify' to recognize 64-bit Mach-O files. r=bsmedberg --HG-- extra : rebase_source : 5b9ae5f47929f69d8c0627ed694b6c4354ca995e --- build/Makefile.in | 20 ++++++++++++++++++++ build/macosx/universal/unify | 12 ++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/build/Makefile.in b/build/Makefile.in index deb20252eee5..d28900e36362 100644 --- a/build/Makefile.in +++ b/build/Makefile.in @@ -134,6 +134,26 @@ check:: else \ echo "TEST-PASS | build/ | unify produced a universal binary!"; \ fi +# try building an x86-64 binary. if that succeeds, try unifying it +# with an i386 binary + -$(HOST_CC) -arch x86_64 $(srcdir)/unify-test.c -o unify-test-x86_64 + @if test -f ./unify-test-x86_64; then \ + if ! $(srcdir)/macosx/universal/unify ./unify-test-x86_64 ./unify-test-i386 \ + ./unify-test-universal-64; then \ + echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to produce a universal binary with a 64-bit input!"; \ + false; \ + fi; \ + if test ! -f ./unify-test-universal-64; then \ + echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to produce a universal binary with a 64-bit input!"; \ + false; \ + fi; \ + if ! file -b ./unify-test-universal-64 | head -n1 | grep -q "^Mach-O universal binary"; then \ + echo "TEST-UNEXPECTED-FAIL | build/ | unify failed to produce a universal binary with a 64-bit input!"; \ + false; \ + else \ + echo "TEST-PASS | build/ | unify produced a universal binary with a 64-bit input!"; \ + fi \ + fi # try unifying two identical Java class files rm -f unifytesta.class unifytestb.class unifytestc.class cp $(srcdir)/unifytest.class ./unifytesta.class diff --git a/build/macosx/universal/unify b/build/macosx/universal/unify index 4730e6cc1bdf..dafd06d1a53f 100755 --- a/build/macosx/universal/unify +++ b/build/macosx/universal/unify @@ -1165,6 +1165,12 @@ sub readZipCRCs($) { package FileAttrCache; + # from /usr/include/mach-o/loader.h + use constant MH_MAGIC => 0xfeedface; + use constant MH_CIGAM => 0xcefaedfe; + use constant MH_MAGIC_64 => 0xfeedfacf; + use constant MH_CIGAM_64 => 0xcffaedfe; + use Fcntl(':DEFAULT', ':mode'); # FileAttrCache->new($path) @@ -1243,8 +1249,10 @@ sub readZipCRCs($) { } # Accept Mach-O fat files or Mach-O thin files of either endianness. - if ($magic == 0xfeedface || - $magic == 0xcefaedfe || + if ($magic == MH_MAGIC || + $magic == MH_CIGAM || + $magic == MH_MAGIC_64 || + $magic == MH_CIGAM_64 || $this->isFat()) { return 1; }