Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 284659
Collapse All | Expand All

(-)utils/org/eclipse/cdt/utils/macho/MachO.java (-7 / +19 lines)
Lines 54-60 Link Here
54
	    public final static int MH_MAGIC = 0xfeedface;      /* the mach magic number */
54
	    public final static int MH_MAGIC = 0xfeedface;      /* the mach magic number */
55
	    public final static int MH_CIGAM = 0xcefaedfe;
55
	    public final static int MH_CIGAM = 0xcefaedfe;
56
	    public final static int MH_UNIVERSAL = 0xcafebabe;
56
	    public final static int MH_UNIVERSAL = 0xcafebabe;
57
57
	    public final static int MH_MAGIC_64 = 0xfeedfacf;      /* the mach magic number 64*/
58
	    public final static int MH_CIGAM_64 = 0xcffaedfe;
59
	    
58
	    /* values of cputype */
60
	    /* values of cputype */
59
	    public final static int CPU_TYPE_ANY = -1;
61
	    public final static int CPU_TYPE_ANY = -1;
60
	    public final static int CPU_TYPE_VAX = 1;
62
	    public final static int CPU_TYPE_VAX = 1;
Lines 66-72 Link Here
66
	    public final static int CPU_TYPE_SPARC = 14;
68
	    public final static int CPU_TYPE_SPARC = 14;
67
	    public final static int CPU_TYPE_I860 = 15;
69
	    public final static int CPU_TYPE_I860 = 15;
68
	    public final static int CPU_TYPE_POWERPC = 18;
70
	    public final static int CPU_TYPE_POWERPC = 18;
69
71
	    public final static int CPU_TYPE_x86_64 = (0x01000000 | CPU_TYPE_I386);
72
	    
70
	    /* values of cpusubtype */
73
	    /* values of cpusubtype */
71
	    public final static int CPU_SUBTYPE_MULTIPLE = -1;
74
	    public final static int CPU_SUBTYPE_MULTIPLE = -1;
72
	    public final static int CPU_SUBTYPE_LITTLE_ENDIAN = 0;
75
	    public final static int CPU_SUBTYPE_LITTLE_ENDIAN = 0;
Lines 166-172 Link Here
166
			efile.seek(0);
169
			efile.seek(0);
167
			efile.setEndian(false);
170
			efile.setEndian(false);
168
			magic = efile.readIntE();
171
			magic = efile.readIntE();
169
			if ( magic == MH_CIGAM )
172
			if ( magic == MH_CIGAM || magic == MH_CIGAM_64)
170
				efile.setEndian(true);
173
				efile.setEndian(true);
171
			else
174
			else
172
			if ( magic == MH_UNIVERSAL)
175
			if ( magic == MH_UNIVERSAL)
Lines 193-199 Link Here
193
					}
196
					}
194
				}
197
				}
195
			}
198
			}
196
			else if ( magic != MH_MAGIC )
199
			else if ( magic != MH_MAGIC  && magic != MH_MAGIC_64)
197
				throw new IOException(CCorePlugin.getResourceString("Util.exception.notMACHO")); //$NON-NLS-1$
200
				throw new IOException(CCorePlugin.getResourceString("Util.exception.notMACHO")); //$NON-NLS-1$
198
			cputype = efile.readIntE();
201
			cputype = efile.readIntE();
199
			cpusubtype = efile.readIntE();
202
			cpusubtype = efile.readIntE();
Lines 207-213 Link Here
207
			boolean isle = false;
210
			boolean isle = false;
208
			int offset = 0;
211
			int offset = 0;
209
			magic = makeInt(bytes, offset, isle); offset += 4;
212
			magic = makeInt(bytes, offset, isle); offset += 4;
210
			if ( magic == MH_CIGAM )
213
			if ( magic == MH_CIGAM || magic == MH_CIGAM_64)
211
				isle = true;
214
				isle = true;
212
			else
215
			else
213
				if ( magic == MH_UNIVERSAL)
216
				if ( magic == MH_UNIVERSAL)
Lines 234-240 Link Here
234
						}
237
						}
235
					}
238
					}
236
				}
239
				}
237
			else if ( magic != MH_MAGIC )
240
			else if ( magic != MH_MAGIC  && magic != MH_MAGIC_64 )
238
				throw new IOException(CCorePlugin.getResourceString("Util.exception.notMACHO")); //$NON-NLS-1$
241
				throw new IOException(CCorePlugin.getResourceString("Util.exception.notMACHO")); //$NON-NLS-1$
239
			cputype = makeInt(bytes, offset, isle); offset += 4;
242
			cputype = makeInt(bytes, offset, isle); offset += 4;
240
			cpusubtype = makeInt(bytes, offset, isle); offset += 4;
243
			cpusubtype = makeInt(bytes, offset, isle); offset += 4;
Lines 1054-1059 Link Here
1054
			case MachO.MachOhdr.CPU_TYPE_I860:
1057
			case MachO.MachOhdr.CPU_TYPE_I860:
1055
				attrib.cpu = "i860"; //$NON-NLS-1$
1058
				attrib.cpu = "i860"; //$NON-NLS-1$
1056
				break;
1059
				break;
1060
			case MachO.MachOhdr.CPU_TYPE_x86_64:
1061
				attrib.cpu = "x86_64"; //$NON-NLS-1$
1062
				break;
1057
			case MachO.MachOhdr.CPU_TYPE_ANY:
1063
			case MachO.MachOhdr.CPU_TYPE_ANY:
1058
			default:
1064
			default:
1059
				attrib.cpu = "any"; //$NON-NLS-1$
1065
				attrib.cpu = "any"; //$NON-NLS-1$
Lines 1096-1102 Link Here
1096
	public static boolean isMachOHeader(byte[] bytes) {
1102
	public static boolean isMachOHeader(byte[] bytes) {
1097
		try {
1103
		try {
1098
			int magic = makeInt(bytes, 0, false);
1104
			int magic = makeInt(bytes, 0, false);
1099
			return (magic == MachO.MachOhdr.MH_MAGIC || magic == MachO.MachOhdr.MH_CIGAM || magic == MachO.MachOhdr.MH_UNIVERSAL);
1105
			boolean match = (magic == MachO.MachOhdr.MH_MAGIC ||magic == MachO.MachOhdr.MH_CIGAM || magic == MachO.MachOhdr.MH_UNIVERSAL);
1106
			if(match)
1107
				return true;
1108
			match = (match || magic == MachO.MachOhdr.MH_MAGIC_64  ||magic == MachO.MachOhdr.MH_CIGAM_64);
1109
			if(match)
1110
				return true;
1111
			return match;
1100
		} catch (IOException e) {
1112
		} catch (IOException e) {
1101
			return false;
1113
			return false;
1102
		}
1114
		}

Return to bug 284659