llvm-project/lld/MachO
Keith Smiley 3c24fae398
[lld-macho] Add support for objc_msgSend stubs
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.

The general overview of how this works is:

- Undefined symbols with the given prefix are collected
- The suffix of each matching undefined symbol is added as a string to
  `__objc_methname`
- A pointer is added for every method name in the `__objc_selrefs`
  section
- A `got` entry is emitted for `_objc_msgSend`
- Stubs are emitting pointing to the synthesized locations

Notes:

- Both `__objc_methname` and `__objc_selrefs` can also exist from object
  files, so their contents are merged with our synthesized contents
- The compiler emits method names for defined methods, but not for
  undefined symbols you call, but stubs are used for both
- This only implements the default "fast" mode currently just to reduce
  the diff, I also doubt many folks will care to swap modes
- This only implements this for arm64 and x86_64, we don't need to
  implement this for 32 bit iOS archs, but we should implement it for
  watchOS archs in a later diff

Differential Revision: https://reviews.llvm.org/D128108
2022-08-10 17:17:17 -07:00
..
Arch [lld-macho] Add support for objc_msgSend stubs 2022-08-10 17:17:17 -07:00
CMakeLists.txt [lld-macho][reland] Initial support for EH Frames 2022-06-13 07:45:16 -04:00
ConcatOutputSection.cpp Replace to_hexString by touhexstr [NFC] 2022-06-16 17:29:50 +02:00
ConcatOutputSection.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
Config.h [lld-macho] Add support for objc_msgSend stubs 2022-08-10 17:17:17 -07:00
Driver.cpp [lld-macho] Add support for objc_msgSend stubs 2022-08-10 17:17:17 -07:00
Driver.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
DriverUtils.cpp [lld/mac] Add support for $ld$previous symbols with explicit symbol name 2022-07-28 20:35:48 -04:00
Dwarf.cpp [lld-macho] Support creating N_SO stab for DWARF5 compile units 2022-07-28 09:58:26 +02:00
Dwarf.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
EhFrame.cpp [lld-macho] Support EH frame pointer encodings that use sdata4 2022-07-31 20:16:33 -04:00
EhFrame.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
ExportTrie.cpp
ExportTrie.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
ICF.cpp [lld-macho] Fold cfstrings with --deduplicate-literals 2022-07-20 11:11:09 -07:00
ICF.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
InputFiles.cpp [lld-macho] Add support for objc_msgSend stubs 2022-08-10 17:17:17 -07:00
InputFiles.h [lld/mac] Add support for $ld$previous symbols with explicit symbol name 2022-07-28 20:35:48 -04:00
InputSection.cpp [lld-macho] Add support for objc_msgSend stubs 2022-08-10 17:17:17 -07:00
InputSection.h [lld-macho] Add support for objc_msgSend stubs 2022-08-10 17:17:17 -07:00
LTO.cpp [lld-macho] Handle filename being passed in -lto_object_path 2022-07-16 21:46:47 +02:00
LTO.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
MachOStructs.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
MapFile.cpp [lld/mac] Use C++17 structured bindings 2022-08-08 07:21:28 -04:00
MapFile.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
MarkLive.cpp [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
MarkLive.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
ObjC.cpp
ObjC.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
Options.td [lld-macho] Add support for objc_msgSend stubs 2022-08-10 17:17:17 -07:00
OutputSection.cpp
OutputSection.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
OutputSegment.cpp
OutputSegment.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
Relocations.cpp
Relocations.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
SectionPriorities.cpp Use value instead of getValue (NFC) 2022-07-15 20:03:13 -07:00
SectionPriorities.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
SymbolTable.cpp [lld/mac] Use C++17 structured bindings in two more places 2022-08-08 11:09:44 -04:00
SymbolTable.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
Symbols.cpp [lld-macho] Use source information in duplicate symbol errors 2022-06-23 11:07:15 -04:00
Symbols.h [lld-macho] Use source information in duplicate symbol errors 2022-06-23 11:07:15 -04:00
SyntheticSections.cpp [lld-macho] Add support for objc_msgSend stubs 2022-08-10 17:17:17 -07:00
SyntheticSections.h [lld-macho] Add support for objc_msgSend stubs 2022-08-10 17:17:17 -07:00
Target.cpp
Target.h [lld-macho] Add support for objc_msgSend stubs 2022-08-10 17:17:17 -07:00
UnwindInfoSection.cpp [LLD] [MachO] Fix GCC build warnings 2022-08-03 00:14:39 +03:00
UnwindInfoSection.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
Writer.cpp [lld-macho] Add support for objc_msgSend stubs 2022-08-10 17:17:17 -07:00
Writer.h [lld/mac] Use C++17 nested namespace syntax in most places 2022-08-08 07:11:17 -04:00
ld64-vs-lld.rst