Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
target: properly fix weak aliasing of probe NOPs on macOS
@dragonmux got a report on Discord that the weak aliasing of probe functions caused a linking error on macOS. I was able to reproduce the issue by building BMP once with `-Dprobe=''`, then reconfiguring with `-Dprobe='native'` and rebuilding. Upon looking into the functions with Binary Ninja, I realised that the true issue was that AppleClang does not support aliases *at all*. Therefore, when saying "attribute weak" on the probe declaration, since the alias never takes effect, the linker would then expect a framework or library to supply the symbol [1]. The fix is to define a weak linkable pivot that will call the alias. If a strong definition appears later, the linker will emit just that definition. Otherwise, it'll emit an overridable pointer to the weak definition in the symbol table. This also lets us restore the visibility and inlining of the NOP probes. This partially reverts commit 5e98f30. [1]: https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/MachOTopics/1-Articles/executing_files.html#//apple_ref/doc/uid/TP40001829-98432-TPXREF120
- Loading branch information