Help with linker failer: .gnu.linkonce.t

旧街凉风 提交于 2019-12-23 08:55:28

问题


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.

Thanks.


回答1:


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.




回答2:


This bug was found and was reported here GCC bugzilla, a small testcase 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 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 attachements 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.



来源:https://stackoverflow.com/questions/1239730/help-with-linker-failer-gnu-linkonce-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!