- mh = (struct mach_header *) header;
- ms = &machine_slot[cpu_number()];
- mh->magic = MH_MAGIC;
- mh->cputype = ms->cpu_type;
- mh->cpusubtype = ms->cpu_subtype;
- mh->filetype = MH_CORE;
- mh->ncmds = segment_count + thread_count;
- mh->sizeofcmds = command_size;
-
- hoffset = sizeof(struct mach_header); /* offset into header */
- foffset = round_page_32(header_size); /* offset into file */
- vmoffset = VM_MIN_ADDRESS; /* offset into VM */
+ if (is_64) {
+ mh64 = (struct mach_header_64 *)header;
+ mh64->magic = MH_MAGIC_64;
+ mh64->cputype = process_cpu_type(core_proc);
+ mh64->cpusubtype = process_cpu_subtype(core_proc);
+ mh64->filetype = MH_CORE;
+ mh64->ncmds = segment_count + thread_count;
+ mh64->sizeofcmds = command_size;
+ mh64->reserved = 0; /* 8 byte alignment */
+ } else {
+ mh = (struct mach_header *)header;
+ mh->magic = MH_MAGIC;
+ mh->cputype = process_cpu_type(core_proc);
+ mh->cpusubtype = process_cpu_subtype(core_proc);
+ mh->filetype = MH_CORE;
+ mh->ncmds = segment_count + thread_count;
+ mh->sizeofcmds = command_size;
+ }
+
+ hoffset = mach_header_sz; /* offset into header */
+ foffset = round_page(header_size); /* offset into file */
+ vmoffset = MACH_VM_MIN_ADDRESS; /* offset into VM */
+