2017年9月25日 星期一

GCC編譯錯誤: relocation truncated to fit: R_X86_64_32S against symbol `xxxxx` defined in `.bss' section in xxxxx



在GCC的編譯參數加入"-mcmodel=xxxx", 即可解決這個編譯錯誤的問題

-mcmodel=tiny
Generate code for the tiny code model. The program and its statically defined symbols must be within 1GB of each other. Pointers are 64 bits. Programs can be statically or dynamically linked. This model is not fully implemented and mostly treated as ‘small’.
-mcmodel=small
Generate code for the small code model. The program and its statically defined symbols must be within 4GB of each other. Pointers are 64 bits. Programs can be statically or dynamically linked. This is the default code model.
-mcmodel=large
Generate code for the large code model. This makes no assumptions about addresses and sizes of sections. Pointers are 64 bits. Programs can be statically linked only.