GCC 编译错误 relocation truncated to fit: R_X86_64_32S against `.bss'
2018-02-01 14:49
676 查看
问题如下图所示:(.text+0x53a): relocation truncated to fit: R_X86_64_32S against `.bss'
以前在Linux中编译程序,从来没有遇到过这种问题,今天第一次遇到。查了一些资料发现时内存的限制,自己还有些疑问,以前编译内存大小是4G的程序都没出现过这种错误。
看到一些博文中说是内存超过2G会出现问题。需要添加编译选项:-mcmodel
调整编译时的对静态数组要求的大小:-mcmodel=medium(中级) -mcmodel=large(高级)
具体编译选项添加位置:
gcc -mcmodel=medium -o stream2g_10 stream.c
或者在makefile文件中对应位置添加即可。
找了以前编译的命令 gcc -O stream.c -o stream 就顺利通过了,-O这个优化参数也好神奇。
但是-O失效的时候,还是-mcmodel 比较实用,当单个数组大小为2G,这个代码占用内存6G时,-O已经解决不了问题。
以前在Linux中编译程序,从来没有遇到过这种问题,今天第一次遇到。查了一些资料发现时内存的限制,自己还有些疑问,以前编译内存大小是4G的程序都没出现过这种错误。
看到一些博文中说是内存超过2G会出现问题。需要添加编译选项:-mcmodel
调整编译时的对静态数组要求的大小:-mcmodel=medium(中级) -mcmodel=large(高级)
具体编译选项添加位置:
gcc -mcmodel=medium -o stream2g_10 stream.c
或者在makefile文件中对应位置添加即可。
找了以前编译的命令 gcc -O stream.c -o stream 就顺利通过了,-O这个优化参数也好神奇。
但是-O失效的时候,还是-mcmodel 比较实用,当单个数组大小为2G,这个代码占用内存6G时,-O已经解决不了问题。
相关文章推荐
- GCC 编译错误 relocation truncated to fit: R_X86_64_32S against `.bss'
- GCC 编译错误 relocation truncated to fit: R_X86_64_32S against `.bss'
- GCC 编译错误 relocation truncated to fit: R_X86_64_32S against `.bss'
- relocation truncated to fit: R_X86_64_PC32错误排除
- relocation truncated to fit: R_X86_64_PC32 against symbolXXX
- Linux:编译动态库时遇到的错误relocation R_X86_64_32 against `a local symbol'
- live555 编译动态库时遇到relocation R_X86_64_32 against `a local symbol'的错误
- 编译动态库时遇到relocation R_X86_64_32 against `a local symbol'的错误
- relocation truncated to fit: R_X86_64_PC32
- relocation truncated to fit: R_X86_64_32
- Building Error: relocation truncated to fit: R_X86_64_32S against symbol 'XXX'
- bl跳转指令使用错误导致编译出现错误--relocation truncated to fit: R_ARM_PC24 init_irq
- 编译程序遇到问题 relocation R_X86_64_32 against `.rodata' can not be used when making a shared object;
- 编译动态库出现问题relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object
- 编译so动态库出现relocation R_X86_64_32 against `a local symbol
- relocation R_X86_64_32S against -fPIC
- relocation R_X86_64_32S against `_nc_globals' can not be used when making a shared object; recompile
- 编译u-boot:_udivsi3.S:67: relocation truncated to fit: R_ARM_PLT32 __div0
- CentOS-6.3 编译erlang-otp 17.0 报relocation R_X86_64_32 against `OPENSSL_ia32cap_P' can not be used when making a shared object; recompile with -fPIC错误
- Linking fails : relocation truncated to fit: R_X86_程序占用内存大于2GB所导致的问题