[all-commits] [llvm/llvm-project] 6f6321: [lld-macho] Extend SyntheticSections to cover all ...

Jez Ng via All-commits all-commits at lists.llvm.org
Mon Apr 27 12:58:39 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 6f63216c3d6450c885e40b6a67e46563ce3d9746
      https://github.com/llvm/llvm-project/commit/6f63216c3d6450c885e40b6a67e46563ce3d9746
  Author: Jez Ng <jezng at fb.com>
  Date:   2020-04-27 (Mon, 27 Apr 2020)

  Changed paths:
    M lld/MachO/Driver.cpp
    M lld/MachO/InputSection.cpp
    M lld/MachO/InputSection.h
    M lld/MachO/OutputSegment.cpp
    M lld/MachO/OutputSegment.h
    M lld/MachO/SyntheticSections.cpp
    M lld/MachO/SyntheticSections.h
    M lld/MachO/Writer.cpp
    M lld/MachO/Writer.h
    M lld/test/MachO/segments.s
    R lld/test/MachO/text-segment.s

  Log Message:
  -----------
  [lld-macho] Extend SyntheticSections to cover all segment load commands

Previously, the special segments `__PAGEZERO` and `__LINKEDIT` were
implemented as special LoadCommands. This diff implements them using
special sections instead which have an `isHidden()` attribute. We do not
emit section headers for hidden sections, but we use their addresses and
file offsets to determine that of their containing segments. In addition
to allowing us to share more segment-related code, this refactor is also
important for the next step of emitting dylibs:

1) dylibs don't have segments like __PAGEZERO, so we need an easy way of
   omitting them w/o messing up segment indices
2) Unlike the kernel, which is happy to run an executable with
   out-of-order segments, dyld requires dylibs to have their segment
   load commands arranged in increasing address order. The refactor
   makes it easier to implement sorting of sections and segments.

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




More information about the All-commits mailing list