mold icon indicating copy to clipboard operation
mold copied to clipboard

[MachO] - Add support for objc_msgSend stubs

Open erneestoc opened this issue 3 years ago • 1 comments
trafficstars

Support ObjC stubs:

[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

Source: https://reviews.llvm.org/D128108

erneestoc avatar Oct 05 '22 01:10 erneestoc

Issue at LLVM https://github.com/llvm/llvm-project/issues/56034

nevack avatar Oct 13 '22 15:10 nevack