According to the ELFv2 ABI
This relocation type is used to specify a function call where the TOC pointer is not initialized. It is similar to R_PPC64_REL24 in that it specifies a symbol to be resolved. If the symbol resolves to a function that requires a TOC pointer (as determined by st_other bits) then a link editor must arrange for the call to be via the global entry point of the called function. Any stub code must not rely on a valid TOC base address in r2.
This patch fixes handling of R_PPC64_REL24_NOTOC by using the same stub code sequence as lld.
You could further unify some of the code paths using a pair of template variables:
pickStub's cases then look like:
If other clients are likely to use the stub content arrays this may be worth it. If everyone is going to use pickStub then I think it's fine either way.