交叉编译出错之:reloaction truncated to fit : R_MIPS_CALL16

交叉编译工具链:cross-gcc-4.9.3-n64-loongson-rc6.1
交叉编译出错的日志:

/home/loongson/work/common/3rd/lib//3gpp.o: In function `asn1Init_ngap_GUAMI':
/home/loongson/work/common/3rd/src/3gpp.c:1441:(.text+0x536c): relocation truncated to fit: R_MIPS_CALL16 against `asn1Init_ngap_AMFRegionID'
/home/loongson/work/common/3rd/lib//3gpp.o: In function `asn1PE_ngap_SliceSupportItem':
/home/loongson/work/common/3rd/src/3gpp.c:2898:(.text+0xaf04): relocation truncated to fit: R_MIPS_CALL16 against `asn1PE_ngap_SliceSupportItem_iE_Extensions'
/home/loongson/work/common/3rd/lib//3gpp.o: In function `asn1PD_ngap_SliceSupportItem':
/home/loongson/work/common/3rd/src/3gpp.c:2961:(.text+0xb430): relocation truncated to fit: R_MIPS_CALL16 against `asn1PD_ngap_S_NSSAI'
/home/loongson/work/common/3rd/lib//3gpp.o: In function `asn1PD_ngap_PLMNSupportItem':
/home/loongson/work/common/3rd/src/3gpp.c:3446:(.text+0xd348): relocation truncated to fit: R_MIPS_CALL16 against `asn1PD_ngap_SliceSupportList'
/home/loongson/work/common/3rd/src/3gpp.c:3457:(.text+0xd3f8): relocation truncated to fit: R_MIPS_CALL16 against `asn1PD_ngap_PLMNSupportItem_iE_Extensions'
/home/loongson/work/common/3rd/lib//3gpp.o: In function `asn1PD_ngap_EndpointIPAddressAndPort':
/home/loongson/work/common/3rd/src/3gpp.c:3978:(.text+0xf458): relocation truncated to fit: R_MIPS_CALL16 against `asn1PD_ngap_TransportLayerAddress'
/home/loongson/work/common/3rd/src/3gpp.c:3986:(.text+0xf4e8): relocation truncated to fit: R_MIPS_CALL16 against `asn1PD_ngap_PortNumber'
/home/loongson/work/common/3rd/src/3gpp.c:3997:(.text+0xf598): relocation truncated to fit: R_MIPS_CALL16 against `asn1PD_ngap_EndpointIPAddressAndPort_iE_Extensions'
/home/loongson/work/common/3rd/lib//3gpp.o: In function `asn1PD_ngap_CPTransportLayerInformation':
/home/loongson/work/common/3rd/src/3gpp.c:4322:(.text+0x107d4): relocation truncated to fit: R_MIPS_CALL16 against `asn1PD_ngap_TransportLayerAddress'
/home/loongson/work/common/3rd/lib//3gpp.o: In function `asn1PE_ngap_AMF_TNLAssociationToRemoveItem_iE_Extensions':
/home/loongson/work/common/3rd/src/3gpp.c:5309:(.text+0x142f8): relocation truncated to fit: R_MIPS_CALL16 against `asn1PE_ngap_AMF_TNLAssociationToRemoveItem_iE_Extensions_element'
/home/loongson/work/common/3rd/lib//3gpp.o: In function `asn1PD_ngap_AMF_TNLAssociationToUpdateItem_iE_Extensions':
/home/loongson/work/common/3rd/src/3gpp.c:5820:(.text+0x1637c): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
Makefile:28: recipe for target '/home/loongson/work/common/3rd/lib/libasn.so' failed
make: *** [/home/loongson/work/common/3rd/lib/libasn.so] Error 1
build failed
build failed

解决方法:
这个mips平台才有的问题,使用-mxgot, 重新编译即可。需要确保每个*.c*.o 的过程都使用 -mxgot 参数。

gcc 中关于 mxgot的参数说明:
https://gcc.gnu.org/onlinedocs/gcc-4.9.4/gcc/MIPS-Options.html#MIPS-Options

-mxgot
-mno-xgot
Lift (do not lift) the usual restrictions on the size of the global offset table.
GCC normally uses a single instruction to load values from the GOT. While this is relatively efficient, it only works if the GOT is smaller than about 64k. Anything larger causes the linker to report an error such as:


          relocation truncated to fit: R_MIPS_GOT16 foobar
If this happens, you should recompile your code with -mxgot. This works with very large GOTs, although the code is also less efficient, since it takes three instructions to fetch the value of a global symbol.

Note that some linkers can create multiple GOTs. If you have such a linker, you should only need to use -mxgot when a single object file accesses more than 64k's worth of GOT entries. Very few do.

These options have no effect unless GCC is generating position independent code.
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页