Bug 65057 - Broken shared library if created with -fuse-ld=gold -shared -Wl,--dynamic-list
Summary: Broken shared library if created with -fuse-ld=gold -shared -Wl,--dynamic-list
Status: RESOLVED MOVED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-13 21:19 UTC by Sandro Mani
Modified: 2015-02-16 12:57 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
testcase (1.56 KB, application/gzipped-tar)
2015-02-13 21:19 UTC, Sandro Mani
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sandro Mani 2015-02-13 21:19:59 UTC
Created attachment 34752 [details]
testcase

What follows is with gcc-5.0.0-0.10.fc22.x86_64 (Fedora rawhide).

See test case attached, build and run with the provided build.sh script.

Overview:

- A base class in a shared library (base.h, base.cpp)
- The shared library is linked with  -fuse-ld=gold -shared -Wl,--dynamic-list, the contents of the actual list provided to --dynamic-list does not seem to matter (in the provided testcase, the name of the symbol is made up).

- A derived class in an application linking with the library (derived.h, derived.cpp)
- Some random class which uses the derived class

Problem:
- The assertion at derived.h:25 fails
=> Derived::Derived calls Base::Base passing a DerivedPrivate instance to the base class, then Derived::Derived calls Base::init, which sets Base::self to the instance pointer this and calls DerivedPrivate::foo on the passed DerivedPrivate instance, which tests that Base::self is not null. This incorrectly fails.


Background:
This is causing Qt5 applications to crash in various ways.
Comment 1 Andrew Pinski 2015-02-13 21:38:19 UTC
Does this work without -fuse-ld=gold ?
Comment 2 Markus Trippelsdorf 2015-02-13 21:58:08 UTC
This is a known gold issue, see:
https://sourceware.org/bugzilla/show_bug.cgi?id=16992

Unfortunately nothing is being done about it.
Comment 3 Sandro Mani 2015-02-13 22:12:12 UTC
Yes, without -fuse-ld=gold it works.

What I forgot to mention: qt worked with gcc 4.9 (and the options passed to the Qt configure script haven't changed). The build log of a qt5-qtbase build built with gcc 4.9 shows that it was also built using the gold linker.

So this really appears to be a gcc 5.0 regression.