[PATCH] D128108: [WIP][lld-macho] Add support for objc_msgSend stubs

Keith Smiley via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 17 16:32:59 PDT 2022


keith created this revision.
Herald added projects: lld-macho, All.
Herald added a reviewer: lld-macho.
keith requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Apple Clang in Xcode 14 introduced a new feature for reducing the
overhead of objc_msgSend calls by deduplicating the setup calls for each
individual selector. This works by clang adding undefined symbols for
each selector called in a translation unit, such as `_objc_msgSend$foo`
for calling the `foo` method on any `NSObject`. There are 2
different modes for this behavior, the default directly does the setup
for `_objc_msgSend` and calls it, and the smaller option does the
selector setup, and then calls the standard `_objc_msgSend` stub
function.

Here's an overview of how ld64 seems to work: first it resolves these
undefined references and inserts some specific instructions in the
`__TEXT,__objc_stubs` section. ld64 stores the selector names in the
`__TEXT,__objc_methname` section, and then creates a pointer to these in
the `__DATA,__objc_selrefs` section (previously lld did not use
`__objc_methname`, or `__objc_selrefs`).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128108

Files:
  lld/MachO/Arch/ARM.cpp
  lld/MachO/Arch/ARM64.cpp
  lld/MachO/Arch/ARM64_32.cpp
  lld/MachO/Arch/X86_64.cpp
  lld/MachO/InputSection.h
  lld/MachO/SyntheticSections.cpp
  lld/MachO/SyntheticSections.h
  lld/MachO/Target.h
  lld/MachO/Writer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128108.438066.patch
Type: text/x-patch
Size: 14180 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220617/f8571558/attachment.bin>


More information about the llvm-commits mailing list