Bug 12488 - plugins don't support linkonce
Summary: plugins don't support linkonce
Status: RESOLVED WONTFIX
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-14 01:22 UTC by Rafael Ávila de Espíndola
Modified: 2016-03-27 17:32 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
foo.o (344 bytes, application/octet-stream)
2011-02-14 01:23 UTC, Rafael Ávila de Espíndola
Details
bar.o (238 bytes, application/octet-stream)
2011-02-14 01:23 UTC, Rafael Ávila de Espíndola
Details
bar.syms (214 bytes, application/octet-stream)
2011-02-14 01:24 UTC, Rafael Ávila de Espíndola
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Ávila de Espíndola 2011-02-14 01:22:37 UTC
This works:

$ ./gold/ld-new -plugin ./gold/testsuite/plugin_test.so --no-demangle -shared -o test.so bar.o  foo.o
API version:   1
gold version:  111
bar.o: claim file hook called (offset = 0, size = 936)
foo.o: claim file hook called (offset = 0, size = 1176)
all symbols read hook called
cleanup hook called

But this fails:

$ ./gold/ld-new -plugin ./gold/testsuite/plugin_test.so --no-demangle -shared -o test.so bar.syms  foo.o
API version:   1
gold version:  111
bar.syms: claim file hook called (offset = 0, size = 596)
bar.syms: claiming file, adding 1 symbols
foo.o: claim file hook called (offset = 0, size = 1176)
all symbols read hook called
bar.syms: xyz: PREVAILING_DEF_REG
bar.o: adding new input file
./gold/ld-new: error: foo.o: requires dynamic reloc which may overflow at runtime; recompile with -fPIC
./gold/ld-new: foo.o: in function bar:foo.ll(.text+0x4): warning: relocation refers to discarded section
./gold/ld-new: error: hidden symbol 'xyz' is not defined locally
cleanup hook called
Comment 1 Rafael Ávila de Espíndola 2011-02-14 01:23:25 UTC
Created attachment 5237 [details]
foo.o
Comment 2 Rafael Ávila de Espíndola 2011-02-14 01:23:44 UTC
Created attachment 5238 [details]
bar.o
Comment 3 Rafael Ávila de Espíndola 2011-02-14 01:24:00 UTC
Created attachment 5239 [details]
bar.syms
Comment 4 Rafael Ávila de Espíndola 2011-02-14 06:36:37 UTC
I noticed that the real problem is that plugins don't support linkonce. We select the symbol from the IL file but the section from the elf file :-)

Shouldn't be too hard to add support, but I will try to get LLVM to use comdat instead.

Should I close as wontfix?
Comment 5 H.J. Lu 2011-02-14 14:48:24 UTC
Is this related to

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47247
Comment 6 Vincenzo Innocente 2012-05-10 07:14:48 UTC
with
GNU gold (GNU Binutils 2.21.1) 1.11
and
gcc-4_7-branch revision 187326

with linker-plugin enabled I get this type of errors
ld: error: hidden symbol '_ZThn16_N5boost16exception_detail10clone_implINS0_19error_info_injectorISt11logic_errorEEED0Ev' is not defined locally
ld: /tmp/innocent/ccggD26x.ltrans8.ltrans.o: in function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorISt11logic_errorEEEE.local.4390:ccggD26x.ltrans8.o(.data.rel.ro+0x1558): warning: relocation refers to discarded section
does not occur w/o linker-plugin

is the problem on gcc or gold side?
(posted also on http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47247)
Comment 7 Ian Lance Taylor 2012-05-11 03:59:50 UTC
This bug report is specifically about plugins and linkonce.  Please don't add separate bug reports to this one.  Instead, open a new bug report.  Thanks.

Without a test case it's impossible to be sure, but I think "hidden symbol is not defined locally" is more likely to be a GCC problem.
Comment 8 Cary Coutant 2016-03-27 17:32:04 UTC
> I noticed that the real problem is that plugins don't support linkonce. We
> select the symbol from the IL file but the section from the elf file :-)
> 
> Shouldn't be too hard to add support, but I will try to get LLVM to use
> comdat instead.
> 
> Should I close as wontfix?

Yeah, I think comdat is the right way to go.

BTW, with plugin_test.so, it doesn't recognize comdat symbols from the .syms file, but if you add the comdat key as a --plugin-opt, it will special-case a symbol of the same name. Limited use, but sufficient for the test cases.