X86-64: Difference between revisions

-mcmodel=kernel affects codegen. Using a linker script has nothing to do with codegen, since only the linker looks at the script, not the compiler. Recommending not to use it, is just plain wrong.
[unchecked revision][unchecked revision]
m (Undo revision 25151 by Nullplan (talk) Nullplan was wrong, quoted GNU gcc manual.)
(-mcmodel=kernel affects codegen. Using a linker script has nothing to do with codegen, since only the linker looks at the script, not the compiler. Recommending not to use it, is just plain wrong.)
Line 191:
|}
It worth noting that code models are different for architectures, as they are tied with the instruction encoding. For example, AArch64 has a "-mcmodel=tiny" too, which allows 1M addressing, unknown to x86_64. And for AArch64 "-mcmodel=small" has a 4G limitation, not 2G as for the x86_64.
 
From experience, you should not use "-mcmodel=kernel". According to the [https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html GNU gcc manual] "this model has to be used for Linux kernel code". It is not available for other architectures, and it might change any time to suit the Linux kernel needs. It is better if you use a proper linker script with explicit higher-half addresses to place your kernel into the negative address range.
 
== See Also ==
Anonymous user