[all-commits] [llvm/llvm-project] c3e4f3: [lld-macho] Fix alignment & layout to match ld64 a...

Greg McGary via All-commits all-commits at lists.llvm.org
Fri Feb 5 16:23:03 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c3e4f3b231db1ee31668b2e06047cf2a1e89455e
      https://github.com/llvm/llvm-project/commit/c3e4f3b231db1ee31668b2e06047cf2a1e89455e
  Author: Greg McGary <gkm at fb.com>
  Date:   2021-02-05 (Fri, 05 Feb 2021)

  Changed paths:
    M lld/MachO/SyntheticSections.cpp
    M lld/MachO/SyntheticSections.h
    M lld/MachO/UnwindInfoSection.cpp
    M lld/MachO/Writer.cpp
    M lld/test/MachO/dylib-stub.yaml
    M lld/test/MachO/entry-symbol.s
    M lld/test/MachO/indirect-symtab.s
    M lld/test/MachO/lc-build-version.s
    A lld/test/MachO/load-command-sequence.s
    M lld/test/MachO/symtab.s
    M lld/test/MachO/weak-binding.s
    M lld/test/MachO/weak-reference.s

  Log Message:
  -----------
  [lld-macho] Fix alignment & layout to match ld64 and satisfy kernel & codesign

The Mach kernel & codesign on arm64 macOS has strict requirements for alignment and sequence of segments and sections. Dyld probably is just as picky, though kernel & codesign reject malformed Mach-O files before dyld ever has a chance.

I developed this diff by incrementally changing alignments & sequences to match the output of ld64. I stopped when my hello-world test program started working: `codesign --verify` succeded, and `execve(2)` didn't immediately fail with `errno == EBADMACHO` = `"Malformed Mach-O file"`.

Differential Revision: https://reviews.llvm.org/D94935




More information about the All-commits mailing list