summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Freeman (saurik) <saurik@saurik.com>2015-06-29 12:04:31 -0700
committerJay Freeman (saurik) <saurik@saurik.com>2015-06-29 12:04:31 -0700
commite4b7adc1e02c9f0e16cc9ae2841192b386f6d4ea (patch)
tree6af8ad58111a0d95ef378bd8d7e8e3af4423a455
parent1b7da752c83d8adfc849b723caa4c51c2fe8343f (diff)
downloadldid-e4b7adc1e02c9f0e16cc9ae2841192b386f6d4ea.tar.gz
ldid-e4b7adc1e02c9f0e16cc9ae2841192b386f6d4ea.tar.zst
ldid-e4b7adc1e02c9f0e16cc9ae2841192b386f6d4ea.zip
Maintain fat_arch.align when allocating fat files.v1.2.1
-rw-r--r--ldid.cpp15
1 files changed, 10 insertions, 5 deletions
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;
}