I have the following: - A library called toto.so where the object Toto is implemented: class Toto { public: Toto(); static Toto *instance() { return self; } private: static Toto *self; }; - A main.cpp linked against toto.so: int main() { Toto tmp; std::cout << "Main: Toto::instance() == " << tmp.instance() << std::endl; return 0; } If I build everything like this: g++ -shared -fPIC -Wl,--dynamic-list-cpp-typeinfo toto.cpp -o libtoto.so g++ -Wl,--dynamic-list-cpp-typeinfo main.cpp -L. -ltoto The toto::instance() function returns 0 in the main function. However, if I build without --dynamic-list-cpp-typeinfo, the toto::instance() function returns the correct value. I compiled natively on Linux I386 and I cross compiled for ARM. I got the same results on both architectures.
Created attachment 1461 [details] A small example to reproduce the bug
As documented, --dynamic-list-cpp-typeinfo only does "Provide the builtin dynamic list for C++ runtime type identification". You need to use --dynamic-list= to add additional symbols to dynamic list.
Is there a way to automatically include all symbols in a list file for --dynamic-list for which the linker of a separate program would generate copy relocations? If not would you accept an enhancement request for the linker to support something like that? Because as it stands right now --dynamic-list-typeinfo is not very useful for C++ libraries (such as Qt or KDE) because of this very problem, which is a pity since the --dynamic-list feature is otherwise very attractive.
(In reply to comment #3) > Is there a way to automatically include all symbols in a list file > for --dynamic-list for which the linker of a separate program would generate > copy relocations? > > If not would you accept an enhancement request for the linker to support > something like that? > Yes, please be specific about what you want.
Thanks for the quick reply. I have tried to elaborate on the problem now in bug #3831 .