go unrecognized relocation (0x2a) in section `.text‘问题

11 篇文章 0 订阅
本文档描述了遇到ld链接错误`unrecognized relocation (0x2a)`和`Bad value`的问题,原因是ld版本过低。解决方法是在CentOS系统上通过`yum install binutils`命令升级ld版本。升级过程包括检查依赖、下载更新和验证安装,最终成功升级并解决了问题。
摘要由CSDN通过智能技术生成

问题现象

[root@localhost main]# go run -race mrsequential.go wc.so pg*.txt
# command-line-arguments
/root/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-3541234412/000010.o: unrecognized relocation (0x2a) in section `.text'
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

问题原因

由于ld的版本过低导致的。

解决办法

升级ld版本即可,升级方法如下,对应centos系统

[root@localhost main]# yum install binutils
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base                                                                                                                      | 3.6 kB  00:00:00     
epel/x86_64/metalink                                                                                                      | 6.6 kB  00:00:00     
https://mirror.sjtu.edu.cn/fedora/epel/7/x86_64/repodata/repomd.xml: [Errno 14] curl#60 - "Peer's Certificate issuer is not recognized."
Trying other mirror.
It was impossible to connect to the CentOS servers.
This could mean a connectivity issue in your environment, such as the requirement to configure a proxy,
or a transparent proxy that tampers with TLS security, or an incorrect system clock.
Please collect information about the specific failure that occurs in your environment,
using the instructions in: https://access.redhat.com/solutions/1527033 and create a bug on https://bugs.centos.org/

epel                                                                                                                      | 4.7 kB  00:00:00     
extras                                                                                                                    | 2.9 kB  00:00:00     
updates                                                                                                                   | 2.9 kB  00:00:00     
(1/7): epel/x86_64/group_gz                                                                                               |  96 kB  00:00:00     
(2/7): base/7/x86_64/group_gz                                                                                             | 153 kB  00:00:00     
(3/7): extras/7/x86_64/primary_db                                                                                         | 243 kB  00:00:00     
epel/x86_64/updateinfo         FAILED                                                                          ] 4.5 MB/s | 5.4 MB  00:00:04 ETA 
https://repo.extreme-ix.org/epel/7/x86_64/repodata/d96a5371f4668273e30e45b84bc5ed65c73d01c86c09f96c70612709824c4765-updateinfo.xml.bz2: [Errno 14] curl#60 - "The certificate issuer's certificate has expired. Check your system date and time."
Trying other mirror.
(4/7): base/7/x86_64/primary_db                                                                                           | 6.1 MB  00:00:01     
(5/7): epel/x86_64/updateinfo                                                                                             | 1.0 MB  00:00:00     
(6/7): epel/x86_64/primary_db                                                                                             | 7.0 MB  00:00:05     
(7/7): updates/7/x86_64/primary_db                                                                                        |  13 MB  00:00:06     
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * epel: mirror.sjtu.edu.cn
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.cn99.com
Resolving Dependencies
--> Running transaction check
---> Package binutils.x86_64 0:2.23.52.0.1-55.el7 will be updated
---> Package binutils.x86_64 0:2.27-44.base.el7_9.1 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================
 Package                         Arch                          Version                                      Repository                      Size
=================================================================================================================================================
Updating:
 binutils                        x86_64                        2.27-44.base.el7_9.1                         updates                        5.9 M

Transaction Summary
=================================================================================================================================================
Upgrade  1 Package

Total download size: 5.9 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for updates
binutils-2.27-44.base.el7_9.1.x86_64.rpm                                                                                  | 5.9 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : binutils-2.27-44.base.el7_9.1.x86_64                                                                                          1/2 
  Cleanup    : binutils-2.23.52.0.1-55.el7.x86_64                                                                                            2/2 
  Verifying  : binutils-2.27-44.base.el7_9.1.x86_64                                                                                          1/2 
  Verifying  : binutils-2.23.52.0.1-55.el7.x86_64                                                                                            2/2 

Updated:
  binutils.x86_64 0:2.27-44.base.el7_9.1                                                                                                         

Complete!

#再运行没有问题了
[root@localhost main]# go run -race mrsequential.go wc.so pg*.txt
[root@localhost main]# 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值