https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119386
--- Comment #18 from Ard Biesheuvel <ardb at kernel dot org> --- (In reply to Michael Matz from comment #17) > (In reply to Ard Biesheuvel from comment #16) > > OK, so in summary, the fallthrough for CM_SMALL_PIC/CM_MEDIUM_PIC should be > > removed, and instead, a 'call mcount@PLT' should be emitted. > > That crucially depends on the answer to Alexanders question. Does the PLT > need > to be avoided in all cases, or not? I can't imagine why it would be so, but > the code before r14-811 explicitly went out of its way to ensure that no PLT > would > be used. Perhaps there was a reason for that? > Yes there was, this is documented in the patch commit bde21de1205c0456f6df68c950fb7ee631fcfa93 Author: Ard Biesheuvel <a...@kernel.org> Date: Sun May 14 18:18:38 2023 +0200 i386: Honour -mdirect-extern-access when calling __fentry__ TL;DR in the Linux kernel, we don't want to be forced to deal with the longer opcode and/or the need to perform linker relaxation. (Linux kernel modules are partially linked ELF objects) But looking at the code again, I wonder if -mno-direct-extern-access is a red herring, and this logic should be testing flag_plt instead.