From e4b7adc1e02c9f0e16cc9ae2841192b386f6d4ea Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 29 Jun 2015 12:04:31 -0700 Subject: Maintain fat_arch.align when allocating fat files. --- ldid.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'ldid.cpp') diff --git a/ldid.cpp b/ldid.cpp index 1795d34..7998ede 100644 --- a/ldid.cpp +++ b/ldid.cpp @@ -728,12 +728,14 @@ struct CodesignAllocation { uint32_t offset_; uint32_t size_; uint32_t alloc_; + uint32_t align_; - CodesignAllocation(FatMachHeader mach_header, size_t offset, size_t size, size_t alloc) : + CodesignAllocation(FatMachHeader mach_header, size_t offset, size_t size, size_t alloc, size_t align) : mach_header_(mach_header), offset_(offset), size_(size), - alloc_(alloc) + alloc_(alloc), + align_(align) { } }; @@ -1006,8 +1008,11 @@ int main(int argc, const char *argv[]) { size_t normal((size + 0x1000 - 1) / 0x1000); alloc = Align(alloc + (special + normal) * 0x14, 16); - offset = Align(offset, 4096); - allocations.push_back(CodesignAllocation(mach_header, offset, size, alloc)); + 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); } @@ -1041,7 +1046,7 @@ int main(int argc, const char *argv[]) { fat_arch->cpusubtype = Swap(source->cpusubtype); fat_arch->offset = Swap(allocation.offset_); fat_arch->size = Swap(align + allocation.alloc_); - fat_arch->align = Swap(0xc); + fat_arch->align = Swap(allocation.align_); ++fat_arch; } -- cgit v1.2.3-56-ge451