Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MachO::Binary::shift does not respect alignment of sections if alignment value is larger than size of a page #1144

Open
DzenIsRich opened this issue Dec 23, 2024 · 0 comments

Comments

@DzenIsRich
Copy link
Contributor

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants