https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119386
--- Comment #37 from Ard Biesheuvel <ardb at kernel dot org> --- (In reply to Alexander Monakov from comment #36) > Today, gcc rejects -fpic -mcmodel=kernel on the command line though, and it > doesn't look like you can drop -mcmodel=kernel, so... was there some plan > for dealing with that? > Yes, we can drop -mcmodel=kernel, and use -mcmodel=small instead. This is why I'm not keen on relying on that - it is ill-defined and there is really no need to have this special case. In the kernel, we are trying to move away from all the special sauce in the toolchain - x86 especially is affected by this, whereas arm64 and other architectures just use -mcmodel=small. The primary sticking point is the relative cost of RIP-relative LEA vs 32-bit absolute MOV but that gap appears to have been closing in recent designs. > (considering new flags to cover such use case, it would be nice to have > -fstatic-pie, i.e. generate PIE for subsequent link with -static-pie where > no PLT is necessary and all calls can be direct) I'm not sure what that would solve. When linking the kernel, all R_X86_64_PLT32 can be resolved directly, and so there is never the need for a PLT in practice. The compiler does not have to care about this distinction. Relaxing a CALL via a PLT into a direct one is much easier than relaxing a GOT based data reference into a direct one.