Bug 18596 - hidden symbol warnings may fire even if a visible symbol is available
Summary: hidden symbol warnings may fire even if a visible symbol is available
Status: RESOLVED DUPLICATE of bug 15574
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.24
: P2 normal
Target Milestone: ---
Assignee: Cary Coutant
Depends on:
Reported: 2015-06-24 20:52 UTC by Dan Albert
Modified: 2015-07-20 15:34 UTC (History)
3 users (show)

See Also:
Last reconfirmed:

minimized test case (501 bytes, application/x-bzip)
2015-06-24 20:52 UTC, Dan Albert

Note You need to log in before you can comment on or make changes to this bug.
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 ***