aboutsummaryrefslogtreecommitdiffstats
path: root/ldid.cpp
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2021-04-12 11:54:53 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2021-04-12 11:54:53 -0700
commit2edb2a9307f1bd3909dadc20e80857c6e40c00c5 (patch)
tree29e1529aa8a0c493d9973cb32efb93dcbd84e9a3 /ldid.cpp
parentd4a4dbe847733d55834ebc60f0678c350fa3ebd5 (diff)
downloadldid-2edb2a9307f1bd3909dadc20e80857c6e40c00c5.tar.gz
ldid-2edb2a9307f1bd3909dadc20e80857c6e40c00c5.tar.zst
ldid-2edb2a9307f1bd3909dadc20e80857c6e40c00c5.zip
Fix regression on FAT files (from 64-bit support).v2.1.4
Diffstat (limited to 'ldid.cpp')
-rw-r--r--ldid.cpp19
1 files changed, 16 insertions, 3 deletions
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);