Prevent R_X86_64_REX_GOTPCRELX relocations for kernel modules referencing __stack_chk_guard
Building FreeBSD kernel modules with a standard LLVM 17.0.6 toolchain and -fstack-protector results in them containing R_X86_64_REX_GOTPCRELX relocations (for __stack_chk_guard). These are unloadable, because this relocation type isn't handled by the FreeBSD kernel loader.
This was addressed internally within FreeBSD already via https://github.com/freebsd/freebsd-src/commit/9a4d48a645a7a.
There has been discussion about upstreaming this into LLVM in D113443. It appears there was a consensus to submit once a comment was added. I'm filing this issue so we can get that patch submitted in some appropriate form.
cc @DimitryAndric @adalava
Also, please see https://github.com/llvm/llvm-project/issues/60116, but note that the current !TM.getTargetTriple().isOSFreeBSD() condition in TargetLoweringBase::insertSSPDeclarations still overrules that fix. Thus, -fdirect-access-external-data is not a solution here.
Duplicate of #50932
@EugeneZelenko Is there a better way to close a duplicate issue when the original is fixed? I just clicked "Close" after merging the fix for #50932 .
@justincady: Proper way for duplicates is "Close as not planned" which is accessible from context menu on the right of close button.