From 2edb2a9307f1bd3909dadc20e80857c6e40c00c5 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 12 Apr 2021 11:54:53 -0700 Subject: Fix regression on FAT files (from 64-bit support). --- ldid.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'ldid.cpp') diff --git a/ldid.cpp b/ldid.cpp index d6b1573..da4c0c7 100644 --- a/ldid.cpp +++ b/ldid.cpp @@ -1096,7 +1096,7 @@ struct Baton { struct CodesignAllocation { FatMachHeader mach_header_; - uint32_t offset_; + uint64_t offset_; uint32_t size_; uint64_t limit_; uint32_t alloc_; @@ -1361,14 +1361,27 @@ static void Allocate(const void *idata, size_t isize, std::streambuf &output, co put(output, &fat_header, sizeof(fat_header)); position += sizeof(fat_header); + // XXX: support fat_arch_64 (not in my toolchain) + // probably use C++14 generic lambda (not in my toolchain) + + _assert_(![&]() { + _foreach (allocation, allocations) { + const auto offset(allocation.offset_); + const auto size(allocation.limit_ + allocation.alloc_); + if (uint32_t(offset) != offset || uint32_t(size) != size) + return true; + } + return false; + }(), "FAT slice >=4GiB not currently supported"); + _foreach (allocation, allocations) { auto &mach_header(allocation.mach_header_); fat_arch fat_arch; fat_arch.cputype = Swap(mach_header->cputype); fat_arch.cpusubtype = Swap(mach_header->cpusubtype); - fat_arch.offset = Swap(allocation.offset_); - fat_arch.size = Swap(allocation.limit_ + allocation.alloc_); + fat_arch.offset = Swap(uint32_t(allocation.offset_)); + fat_arch.size = Swap(uint32_t(allocation.limit_ + allocation.alloc_)); fat_arch.align = Swap(allocation.align_); put(output, &fat_arch, sizeof(fat_arch)); position += sizeof(fat_arch); -- cgit v1.2.3-56-ge451