unrecognized relocation (0x2a) in section `.text`

解决unrecognized relocation (0x2a) in section .text

问题:

/usr/bin/ld: …/deps/zw/lib/libdmsdk.a(http.o): unrecognized relocation (0x2a) in section `.text’
/usr/bin/ld: final link failed: 错误的值
collect2: 错误:ld 返回 1
make: *** [thermometry] 错误 1

解决方案:

查看ld 版本 ,使用命令:ld -v

GNU ld version 2.25.1-22.base.el7
  • 1

通过网上搜素可知,是ld版本过低,因此使用更高版本

GNU ld version 2.27-28.base.el7_5.1
  • 1

使用高版本ld,就编译通过了。

问题

今天使用的一个库更新了,升级新的版本之后,在服务器上编译linux-x86-64版本的时候会出现错误:
/usr/bin/ld: libsdk.a(Imagexxx.cpp.o): unrecognized relocation (0x2a) in section .text
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

随后在自己的电脑测试了一下,结果可以编译。

结合在stack overflow上看到的相关信息:
https://stackoverflow.com/questions/46058050/unable-to-compile-unrecognized-relocation

很可能是ld版本不对

确定了版本信息:
pc上ld版本:
GNU ld(GNU Binutils for Ubuntu) 2.26
服务器上ld版本:
GNU ld(GNU Binutils for Ubuntu) 2.24

解决

有root权限

$ sudo apt-get update
$ sudo apt-get install binutils-2.26

export PATH="/usr/lib/binutils-2.26/bin:$PATH"
posted @ 2021-01-17 14:38  Raymone1125  阅读(5508)  评论(0编辑  收藏  举报