Since addesses in 64-bit higher half kernel are 64-bit, we need special compiler flags to handle the "relocation truncated to fit: R_X86_64_32S against symbol xxx" problem. Currently I know two flags: one is "-mcmodel=large", the other one is "-fPIC".
When compiled with flag "-mcmodel=large", all function calls are translated to 2 instructions:
Code: Select all
ffffff8000200051: 48 b8 10 00 20 00 80 movabs $0xffffff8000200010,%rax
ffffff8000200058: ff ff ff
ffffff800020005b: ff d0 callq *%rax
Because 64-bit CPU has IP-relative addessing support, when compiled with flag "-fPIC", all function calls are translated to 1 instruction:
Code: Select all
ffffff8000200071: e8 d1 ff ff ff callq 200047 <_start-0xffffff7fffffffb9>
My question is which flag will get better performance? Probably "-fPIC" beats "-mcmodel=large" in function calls. How about other situations, for example, memory copy, jump, etc. Anyone knows the flag used by linux/freebsd?
Thanks
torshie