This is the mail archive of the
cygwin@sources.redhat.com
mailing list for the Cygwin project.
Re: dlopen a.exe
- To: "Brian D. Carlstrom" <bdc at ai dot mit dot edu>
- Subject: Re: dlopen a.exe
- From: Chris Faylor <cgf at cygnus dot com>
- Date: Mon, 7 Aug 2000 00:01:50 -0400
- Cc: cookj at cs dot man dot ac dot uk, cygwin at sourceware dot cygnus dot com
- References: <E13Ldqn-0008PJ-00@nestle.ai.mit.edu>
- Reply-To: cygwin at sources dot redhat dot com
On Sun, Aug 06, 2000 at 08:45:17PM -0700, Brian D. Carlstrom wrote:
>This is from a while back, I haven't been on the list for a while, but
>I'm trying to upgrade a tool called scsh from cygwin-b20 and I came
>across this:
>
>Chris Faylor wrote:
>> On Wed, May 31, 2000 at 11:32:36AM +0100, Jon Cook wrote:
>> > Can you use dlopen with the pathname set to 0 to open a.exe?
>> No.
>> cgf
>
>huh? This used to work, and is required for my tool unless I want to
>totally rework it. I copied all sorts of crap with dlltool and gcc
>-Wl,scshvm.exp from the tcl port, as well as hacking my autocong
>configure script.
Perhaps I misunderstood the question. Take a look at the source code
for dlopen. If you pass a NULL as the first parameter it returns a handle
to the current program, not an arbitrary program called "a.exe".
Regardless, you won't be able to retrieve anything with dlsym() unless
either the function/variable has been defined with the __declspec(dllexport)
attribute or you've included it in a linker .def file.
cgf
>This small program used to work. The mesage was old. Is there any way to
>do this now or am I going to have to stay with cygwin-b20 indefinitely?
>
>-bri
>
>#include <dlfcn.h>
>#include <stdio.h>
>fnord()
>{
> int i=42;
>}
>main()
>{
> void *self, *ptr1, *ptr2;
> self=dlopen(NULL,RTLD_LAZY);
> if (self) {
> printf("foo\n");
> ptr1=dlsym(self,"fnord");
> ptr2=dlsym(self,"_fnord");
> printf("ptr1 %x\n", ptr1);
> printf("ptr2 %x\n", ptr2);
> if(ptr1 && !ptr2) {
> printf("bar\n");
> exit(0);
> }
> printf("qux\n");
> }
> printf("baz\n");
> exit(1);
>}
--
cgf@cygnus.com Cygnus Solutions, a Red Hat company
http://sourceware.cygnus.com/ http://www.redhat.com/
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com