From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sam Gendler To: gcc-help@gcc.gnu.org, gcc-bugs@gcc.gnu.org Subject: broken -rdynamic flag? Date: Tue, 28 Aug 2001 16:36:00 -0000 Message-id: <3B8C2AF0.C7C95A72@akamai.com> X-SW-Source: 2001-08/msg00235.html I have been trying for 24 hours to get a couple of functions defined in an archive file and linked into an application, to be available to a dso after it is loaded. No matter what I try (-rdynamic, -Xlinker --export-dynamic, -X -E, and others), the symbols that are confirmed to exist with nm in the library do not exist in the final executable, and the loading of the dso always fails as a result. I can workaround this by loading up a buncf of void* pointers with pointers to the relevant functions, which tricks the linker into leaving the symbols intact, or else I can link directly against all of the .o files that are contained by the archive (but that won't work on the actual project, only in my little dummy debugging application). Either method allows the dso to load and function correctly. Is there something I am missing, or is there a bug in my version of gcc? Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release) Incidentally, I believe that I am working with a standard RdHat 6.2 release of linux for x86. Examples of the problem are as follows: [564] ...sgendler/ex>nm libcpptest.a class.o: U PyInt_FromLong 00000000 T __9TestClass 00000000 ? __FRAME_BEGIN__ U __throw 00000010 T doSomething__9TestClassi U printf cwrapper.o: 00000020 T NewTestClass 00000000 T TestClassDoSomething U __9TestClass 00000000 ? __EXCEPTION_TABLE__ 00000000 ? __FRAME_BEGIN__ U __builtin_delete U __builtin_new U __throw U doSomething__9TestClassi U terminate__Fv cpplib.o: U PyErr_Print U PyImport_ImportModule U Py_Initialize 00000000 ? __FRAME_BEGIN__ U __throw 00000000 T cpplibFunc U printf The application is built with: gcc -g -O2 -Wall -Wpointer-arith -Wswitch -D_REENTRANT -Werror -I. -c -o main.o main.c gcc -v -rdynamic -Xlinker -E -o ghost -g main.o -L. -lcpptest -L/usr/lib/python2.0/config -lpython2.0 -L/usr/lib -lieee -ldl -lnsl -lreadline -ltermcap -lm -ldb -lutil And seaching for the 'TestClassDoSomething' function (a global wrapper around TestClass::doSomething()) in the final executable reveals nothing: [567] ...sgendler/ex>nm ghost | grep TestClass [568] ...sgendler/ex> Attempting to load the module (using python's module loading mechanism) reveals: [568] ...sgendler/ex>./ghost cpptest Hello, World entered cpplibFunc() ImportError: /usr/lib/python2.0/site-packages/cpptestmodule.so: undefined symbol: TestClassDoSomething exiting cpplibFunc()