链接器失败:.gnu.linkonce.t
我在使用 GCC 3.2.3 与 binutils 2.18 链接共享库时遇到问题。 当我尝试链接库时出现以下错误:
.gnu.linkonce.t_...在 .rodata 节中引用:在废弃的 .gnu.linkonce.t... 节中定义
我已经对此进行了大量的谷歌搜索,大多数地方似乎表明它是一个回归引入在 binutils 2.17 中,后来在 2.18.50 中修复,但我很好奇是否有人知道是否有任何特定的解决方法可以解决这个问题,而不必接触 binutils 和 GCC。
I'm having trouble linking a shared library using GCC 3.2.3 with binutils 2.18. When I try to link the library I get the following error:
.gnu.linkonce.t_... referenced in section .rodata: defined in discarded section .gnu.linkonce.t...
I've done a fair amount of googling on this and most places seem to indicate it is a regression introduce in binutils 2.17 and later fixed in 2.18.50, but I was curious if anybody knew if there were any particular workarounds for the issue without having to touch binutils and GCC.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实证明,这是一个奇怪的结果,系统将 gcc 与不同的 binutils 不匹配。 /usr/bin/gcc 正在被使用(3.2.3),并且 /usr/local/bin/ld 正在与它一起使用,因为 /usr/local/bin 位于路径中 /usr/bin 的前面。 当我们切换到 /usr/bin 位于路径的前面时,相应的 /usr/bin/ld 被调用(binutils 2.14),这似乎已经解决了问题。
This turned out to be a strange result where the system was mismatching gcc with a different binutils. /usr/bin/gcc was being used (3.2.3) and /usr/local/bin/ld was being used with it due to /usr/local/bin being in front of /usr/bin in the path. When we switched so that /usr/bin was at the front of the path, the appropriate /usr/bin/ld was called (binutils 2.14) and this seems to have resolved the problem.
此错误已被发现并GCC Bugzilla 站点进行了报告。 评论中提供了一个专注于该错误的小测试用例,我发现它非常有帮助,不浪费时间。 从 GCC 3.4.6 开始,此错误已得到修复。
我在使用 GCC 3.3.1 与 binutils 2.15.92 和 binutils 2.17.50 时遇到了这个问题,但两者都不起作用。 所以,对我来说,显然不是 GCC 和 binutils 版本的混合造成了问题。
如果您必须使用较旧的 GCC 版本,您可以使用 HJ 提供的此补丁并手动执行此操作,然后再次重建旧的 GCC。
无需 COMDAT 组即可修复
使用 COMDAT 组修复
检查提供的链接中显示确切差异的附件为了修复。
我自己做了并测试了它,它成功地工作了,用第一个修复“没有 COMDAT 组”修补了 GCC 3.3.1,重建它并与 binutils 2.15.92 和 binutils 2.17.50 一起使用。
This bug was found and was reported at the GCC Bugzilla site. A small test case that focuses on the bug was provided in the comments which I found it to be really helpful not to waste time. This bug was fixed starting with GCC 3.4.6.
I have had this issue while using GCC 3.3.1 with binutils 2.15.92 and binutils 2.17.50 and both didn't work. So, for me it clearly wasn't the mix of GCC and binutils versions that made the problem.
If you must use an older GCC version you may use this patch provided by H.J. and do it manually then rebuild your old GCC again.
Fix without COMDAT group
Fix with COMDAT group
Check the attachments in the provided links that shows the exact diff for the fix.
I have did it myself and tested it and it worked successfully, patching GCC 3.3.1 with the first fix "without COMDAT group", rebuilt it and used it with binutils 2.15.92 and binutils 2.17.50.