From 7094734970645d7c26504a531dc2ba390148c44b Mon Sep 17 00:00:00 2001 From: Ian Darwin Date: Thu, 1 Jun 2006 18:49:35 +0000 Subject: [PATCH] Centralized java and mach-o common; leave non-shared in each --- magic/Magdir/cafebabe | 21 +++++++++++++++++++++ magic/Magdir/java | 9 +++------ magic/Magdir/mach | 29 ++++++----------------------- 3 files changed, 30 insertions(+), 29 deletions(-) create mode 100644 magic/Magdir/cafebabe diff --git a/magic/Magdir/cafebabe b/magic/Magdir/cafebabe new file mode 100644 index 00000000..233411c8 --- /dev/null +++ b/magic/Magdir/cafebabe @@ -0,0 +1,21 @@ +#------------------------------------------------------------------------------ +# Cafe Babes unite! +# +# Since Java bytecode and Mach-O fat-files have the same magic number, the test +# must be performed in the same "magic" sequence to get both right. The long +# at offset 4 in a mach-O fat file tells the number of architectures; the short at +# offset 4 in a Java bytecode file is the JVM minor version and the +# short at offset 6 is the JVM major version. Since there are only +# only 18 labeled Mach-O architectures at current, and the first released +# Java class format was version 43.0, we can safely choose any number +# between 18 and 39 to test the number of architectures against +# (and use as a hack). Let's not use 18, because the Mach-O people +# might add another one or two as time goes by... +# +0 belong 0xcafebabe +>4 belong >30 compiled Java class data, +>>6 beshort x version %d. +>>4 beshort x \b%d +>4 belong 1 Mach-O fat file with 1 architecture +>4 belong >1 +>>4 belong <20 Mach-O fat file with %ld architectures diff --git a/magic/Magdir/java b/magic/Magdir/java index f9b70915..7aa22a6a 100644 --- a/magic/Magdir/java +++ b/magic/Magdir/java @@ -1,10 +1,7 @@ #------------------------------------------------------------ -# Java ByteCode -# From Larry Schwimmer (schwim@cs.stanford.edu) -# Handled in Mach now -#0 belong 0xcafebabe compiled Java class data, -#>6 beshort x version %d. -#>4 beshort x \b%d +# Java ByteCode and Mach-O binaries (e.g., Mac OS X) use the +# same magic number, 0xcafebabe, so they are both handled +# in the entry called "cafebabe". #------------------------------------------------------------ # Java serialization # From Martin Pool (m.pool@pharos.com.au) diff --git a/magic/Magdir/mach b/magic/Magdir/mach index 6289a2da..cced3a58 100644 --- a/magic/Magdir/mach +++ b/magic/Magdir/mach @@ -1,26 +1,9 @@ -#------------------------------------------------------------------------------ -# mach file description -# -# Since Java bytecode and Mach-O fat-files have the same magic number the test -# must be preformed in the same "magic" sequence to get both right. The long -# at offset 4 in a fat file tells the number of architectures. The short at -# offset 4 in a Java bytecode file is the compiler minor version and the -# short at offset 6 is the compiler major version. Since there are only -# only 18 labeled Mach-O architectures at current, and the first released -# Java class format was version 43.0, we can safely choose any number -# between 18 and 39 to test the number of architectures against -# (and use as a hack). -# -0 belong 0xcafebabe ->4 belong >19 compiled Java class data, ->>6 beshort x version %d. ->>4 beshort x \b%d ->4 belong 1 Mach-O fat file with 1 architecture ->4 belong >1 -# The following is necessary to support java class files. ->>4 belong <20 Mach-O fat file with %ld architectures -#>>4 belong <0xffff Mach-O fat file with %ld architectures -# +#------------------------------------------------------------ +# Mach has two magic numbers, 0xcafebabe and 0xfeedface. +# Unfortunately the first, cafebabe, is shared with +# Java ByteCode, so they are both handled in the file "cafebabe". +# The "feedface" ones are handled herein. +#------------------------------------------------------------ 0 lelong&0xfeffffff 0xfeedface Mach-O >0 byte 0xcf 64-bit >12 lelong 1 object -- 2.40.0