From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <2b9e67caaea302d52915f9ae9764c6dc.axp-list@archive.invalid> X-Archive-Original-Message-ID: <199801111601.QAA18417@winksmith.com> Date: Sun, 11 Jan 1998 11:30:33 -0500 From: Richard Hadsell Subject: Re: Solution to --> Re: dlopen() bug on Linux/Alpha Stefan Traby wrote: > > Hi ! > > > ST: 'Try to link the main (!) program with "-export-dynamic -shared"' > > > > rather than the dynamic library only we got dlopen to work. This > > might be the solution to GNU glibc PR number 387. I am not going to > > say it is a fix, but it is working for us. > > To maintainers: I don't have an AXP-machine and currently don't use gibc. > Please check another special condition: Make a simple program > which does dlopen and dlsym (no, don't call main :-) on itself. > Simplified I mean dlopen(argv[0],...) but argv[0] may not contain > the full path... > Does it work ? > If and only if, why ? is (export == dlsym(, "export") in this special > case ? > > Of corse this is a hack and not a real-world solution. On a non glibc > GNU-Linux/i386 system, linking with "-shared" makes the > program dump core _before_ main is called. SIGSEGV "#0 0x4 in ?? ()" > > The hack is simply based on a special, simplified point of view: > A program is a special case of an dynamic library. > (it contains _start and main()). > This may not be true and is not portable. I fixed the problem by using "-export-dynamic" when linking the executable that calls dlopen(). I did not use "-shared". The man page for "ld" mentions that "-export-dynamic" is needed when using dlopen(), but it doesn't say where it is needed. I had incorrectly assumed it was needed when building the shared library that would be linked by dlopen(), because dlopen() and dlsym() would need to be able to see the symbols defined in the library. Instead, it seems to be equivalent to the "-E" option on the HP-UX linker. It would be nice for someone to improve the description of this option on the man page. Please pass this on to anyone who knows how to do that. Thanks for your help. -- Dick Hadsell 914-381-8400 Fax: 914-381-9790 Reply-to: hadsell@blueskystudios.com Blue Sky | VIFX http://www.blueskystudios.com 1 South Road, Harrison, NY 10528 -- To unsubscribe: send e-mail to axp-list-request@redhat.com with 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com