llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Prevent R_X86_64_REX_GOTPCRELX relocations for kernel modules referencing __stack_chk_guard

Open justincady opened this issue 2 years ago • 4 comments

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

justincady avatar Mar 21 '24 20:03 justincady

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.

justincady avatar Mar 21 '24 20:03 justincady

Duplicate of #50932

justincady avatar Mar 25 '24 15:03 justincady

@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 avatar Mar 27 '24 13:03 justincady

@justincady: Proper way for duplicates is "Close as not planned" which is accessible from context menu on the right of close button.

EugeneZelenko avatar Mar 27 '24 13:03 EugeneZelenko