public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* broken -rdynamic flag?
@ 2001-08-28 16:36 Sam Gendler
  2001-08-31  2:23 ` Alexandre Oliva
  0 siblings, 1 reply; 2+ messages in thread
From: Sam Gendler @ 2001-08-28 16:36 UTC (permalink / raw)
  To: gcc-help, gcc-bugs

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()

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: broken -rdynamic flag?
  2001-08-28 16:36 broken -rdynamic flag? Sam Gendler
@ 2001-08-31  2:23 ` Alexandre Oliva
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2001-08-31  2:23 UTC (permalink / raw)
  To: Sam Gendler; +Cc: gcc-help, gcc-bugs

On Aug 28, 2001, Sam Gendler <sgendler@akamai.com> wrote:

> the symbols that are confirmed to exist with nm in the library do
> not exist in the final executable

If the symbols in the library are not referenced in object files used
to build the executable, they're not going to be imported into the
executable.  Anyway, this is a linker issue, so it doesn't belong in
these mailing lists.  Look for --whole-archive in the GNU ld manual.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-08-31  2:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-28 16:36 broken -rdynamic flag? Sam Gendler
2001-08-31  2:23 ` Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).