pub enum CodeModel {
Small,
Kernel,
}Expand description
Where the program’s code and static data are promised to be, which is -mcmodel=.
The model is a promise about addresses that the code generator is allowed to believe. It says
nothing about which link is coming, which is -fPIC and friends, and it decides only how an
address is written into an instruction. x86-64 is the only machine with more than one here.
Design: spec/11-asm-objects-debug.md section 11.3.
Variants§
Small
Everything within 2 GiB of everything else, reached from the instruction pointer. The default on every target and every hosted program’s model.
Kernel
The top 2 GiB of the address space, from 0xffffffff80000000 up, which is where every
x86-64 Linux kernel is linked. An address there is a 32 bit number sign extended, so an
instruction may carry it as an immediate (movq $sym, %rax) or as the displacement of an
indexed address (sym(,%rdi,8)), both with R_X86_64_32S.