+ size_t normal((size + 0x1000 - 1) / 0x1000);
+ alloc = Align(alloc + (special + normal) * 0x14, 16);
+
+ auto *fat_arch(mach_header.GetFatArch());
+ uint32_t align(fat_arch == NULL ? 0 : source.Swap(fat_arch->align));
+ offset = Align(offset, 1 << align);
+
+ allocations.push_back(CodesignAllocation(mach_header, offset, size, alloc, align));
+ offset += size + alloc;
+ offset = Align(offset, 16);
+ }
+ }
+
+ asprintf(&temp, "%s.%s.cs", dir, base);
+ fclose(fopen(temp, "w+"));
+ _syscall(truncate(temp, offset));
+
+ void *file(map(temp, 0, offset, NULL, false));
+ memset(file, 0, offset);
+
+ fat_arch *fat_arch;
+ if (!source.IsFat())
+ fat_arch = NULL;
+ else {
+ auto *fat_header(reinterpret_cast<struct fat_header *>(file));
+ fat_header->magic = Swap(FAT_MAGIC);
+ fat_header->nfat_arch = Swap(source.Swap(source->nfat_arch));
+ fat_arch = reinterpret_cast<struct fat_arch *>(fat_header + 1);
+ }
+
+ _foreach (allocation, allocations) {
+ auto &source(allocation.mach_header_);