MachO::Binary::shift does not respect alignment of sections if alignment value is larger than size of a page.
I thought that it could be fixed by a simple patch Zimperium@a63a470
// Take into account sections that may have alignment larger than a size of a page.
auto it_maxa = std::max_element(sections_.begin(), sections_.end(),
[](const Section* a, const Section* b) {
return a->alignment() < b->alignment();
});
const size_t max_alignment = 1 << (*it_maxa)->alignment();
value = align(value, max_alignment);
However, this causes other bugs in layout checker:
- LINKEDIT overlap of DYSYMTAB_INDIRECT_SYM and SYMTAB_STR
- LINKEDIT segment does not wrap the end of the binary