xref: /freebsd/contrib/file/magic/Magdir/cafebabe (revision ef36b3f75658d201edb495068db5e1be49593de5)
1
2#------------------------------------------------------------------------------
3# $File: cafebabe,v 1.23 2017/05/25 20:07:23 christos Exp $
4# Cafe Babes unite!
5#
6# Since Java bytecode and Mach-O universal binaries have the same magic number,
7# the test must be performed in the same "magic" sequence to get both right.
8# The long at offset 4 in a Mach-O universal binary tells the number of
9# architectures; the short at offset 4 in a Java bytecode file is the JVM minor
10# version and the short at offset 6 is the JVM major version.  Since there are only
11# only 18 labeled Mach-O architectures at current, and the first released
12# Java class format was version 43.0, we can safely choose any number
13# between 18 and 39 to test the number of architectures against
14# (and use as a hack). Let's not use 18, because the Mach-O people
15# might add another one or two as time goes by...
16#
17### JAVA START ###
180	belong		0xcafebabe
19>4	belong		>30		compiled Java class data,
20!:mime	application/x-java-applet
21>>6	beshort		x	        version %d.
22>>4	beshort		x       	\b%d
23# Which is which?
24#>>4	belong		0x032d		(Java 1.0)
25#>>4	belong		0x032d		(Java 1.1)
26>>4	belong		0x002e		(Java 1.2)
27>>4	belong		0x002f		(Java 1.3)
28>>4	belong		0x0030		(Java 1.4)
29>>4	belong		0x0031		(Java 1.5)
30>>4	belong		0x0032		(Java 1.6)
31>>4	belong		0x0033		(Java 1.7)
32>>4	belong		0x0034		(Java 1.8)
33
340	belong		0xcafed00d	JAR compressed with pack200,
35>5	byte		x		version %d.
36>4	byte		x		\b%d
37!:mime	application/x-java-pack200
38
39
400	belong		0xcafed00d	JAR compressed with pack200,
41>5	byte		x		version %d.
42>4	byte		x		\b%d
43!:mime	application/x-java-pack200
44
45### JAVA END ###
46### MACH-O START ###
47
480	name		mach-o		\b [
49>0	use		mach-o-cpu	\b
50>(8.L)	indirect	x		\b:
51>0	belong		x		\b]
52
530	belong		0xcafebabe
54>4	belong		1		Mach-O universal binary with 1 architecture:
55!:mime application/x-mach-binary
56>>8	use		mach-o		\b
57>4	belong		>1
58>>4	belong		<20		Mach-O universal binary with %d architectures:
59!:mime application/x-mach-binary
60>>>8	use		mach-o		\b
61>>4	belong		2
62>>>28	use		mach-o		\b
63>>4	belong		3
64>>>48	use		mach-o		\b
65>>4	belong		4
66>>>68	use		mach-o		\b
67>>4	belong		5
68>>>88	use		mach-o		\b
69>>4	belong		6
70>>>108	use		mach-o		\b
71
72### MACH-O END ###
73