summaryrefslogtreecommitdiff
path: root/magic/Magdir/cafebabe
blob: ea4846d86685383799be2d386ba88607e90915d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

#------------------------------------------------------------------------------
# $File: cafebabe,v 1.12 2013/01/11 16:45:23 christos Exp $
# Cafe Babes unite!
#
# Since Java bytecode and Mach-O universal binaries 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 universal binary 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...
#
### JAVA START ###
0	belong		0xcafebabe
!:mime	application/x-java-applet
>4	belong		>30		compiled Java class data,
>>6	beshort		x	        version %d.
>>4	beshort		x       	\b%d
# Which is which?
#>>4	belong		0x032d		(Java 1.0)
#>>4	belong		0x032d		(Java 1.1)
>>4	belong		0x002e		(Java 1.2)
>>4	belong		0x002f		(Java 1.3)
>>4	belong		0x0030		(Java 1.4)
>>4	belong		0x0031		(Java 1.5)
>>4	belong		0x0032		(Java 1.6)

0	belong		0xcafed00d	JAR compressed with pack200,
>5	byte		x		version %d.
>4	byte		x		\b%d
!:mime	application/x-java-pack200


0	belong		0xcafed00d	JAR compressed with pack200,
>5	byte		x		version %d.
>4	byte		x		\b%d
!:mime	application/x-java-pack200

### JAVA END ###
### MACH-O START ###

# 16777216 = 0x01000000
0	name		mach-o		\b [ 
>0	belong		0xffffffff	\bAny
>0	belong		1		\bVax
>0	belong		6		\bMC680x0
>0	belong		7		\bI386
>0	belong		8		\bMIPS
>0	belong		10		\bMC98000
>0	belong		11		\bHPPA
>0	belong		12		\bARM
>0	belong		13		\bMC88000
>0	belong		14		\bSPARC
>0	belong		15		\bI860
>0	belong		16		\bALPHA
>0	belong		17		\bPOWERPC
>0	belong		16777223	\bX86_64
>0	belong		16777233	\bPOWERPC64
>&(8.L)	indirect			: 
>0	belong		x		\b]

0	belong		0xcafebabe
>4	belong		1		Mach-O universal binary with 1 architecture:
>>8	use		mach-o
>4	belong		>1
>>4	belong		<20		Mach-O universal binary with %ld architectures:
>>>8	use		mach-o
>>>28	use		mach-o
>>>4	belong		>2
>>>>48	use		mach-o
>>>>>4	belong		>3
>>>>>68	use		mach-o

### MACH-O END ###