Bug 18596

Summary: hidden symbol warnings may fire even if a visible symbol is available
Product: binutils Reporter: Dan Albert <danalbert>
Component: goldAssignee: Cary Coutant <ccoutant>
Status: RESOLVED DUPLICATE    
Severity: normal CC: dimitry, ian, jsweval
Priority: P2    
Version: 2.24   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Attachments: minimized test case

Description Dan Albert 2015-06-24 20:52:28 UTC
Created attachment 8391 [details]
minimized test case

Test case attached. Essentially the problem occurs when there is a symbol `foo` that is hidden in the main executable, used in liba, and public in libb when liba is linked before libb. Note that this does actually only occur for the main executable; it won't happen when linking a library.

    $ make
    clang++ -fuse-ld=gold -fPIC -shared -o libbar.so bar.cpp
    clang++ -fuse-ld=gold -fPIC -shared -o libfoo.so foo.cpp -L. -lbar
    clang++ -fuse-ld=gold -Wl,--fatal-warnings -shared -o baz baz.cpp -L. -lfoo -lbar
    /usr/bin/ld.gold: warning: hidden symbol 'foo()' in /tmp/baz-6c2f17.o is  referenced by DSO ./libfoo.so
    /usr/bin/ld.gold: error: treating warnings as errors
    clang-3.6: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [baz] Error 1

`foo` is hidden in the main executable, but is public in libbar.so.
Comment 1 Cary Coutant 2015-07-20 15:34:03 UTC
Duplicate of PR 15574.

*** This bug has been marked as a duplicate of bug 15574 ***