Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Sep 1998 15:20:45 -0400 (EDT)
From:      Brian Feldman <green@unixhelp.org>
To:        John Polstra <jdp@polstra.com>
Cc:        current@FreeBSD.ORG
Subject:   Re: E-day problems: rtld-elf dlsym() broken?
Message-ID:  <Pine.BSF.4.02.9809011511060.28074-100000@zone.syracuse.net>
In-Reply-To: <199809011801.LAA14263@austin.polstra.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Actually, no. The program does no munging of the input at all, it looks up
with or without the _, whichever you input by typing "lookup
whatever\n"... it's not my program's fault, watch:

green@feldman:/home/green/C$ cc -aout -O3 dl.c -o dl -lreadline
green@feldman:/home/green/C$ echo lookup main | ./dl
(dl) lookup main
main: 0x15ac
green@feldman:/home/green/C$ cc -O3 dl.c -o dl -lreadline      dline
green@feldman:/home/green/C$ echo lookup main | ./dl           
(dl) lookup main
main: not found
(dl) green@feldman:/home/green/C$ 
Look at my source, it should work fine.

-Brian

On Tue, 1 Sep 1998, John Polstra wrote:

> In article <Pine.BSD.4.00.9809010729170.18315-200000@feldman.dyn.ml.org>,
> Brian Feldman  <green@unixhelp.org> wrote:
> 
> > there is a problem now: dlsym, for me, seems to have stopped working.
> > Entirely.... Returning NULL always it seems.
> 
> I bet you're adding a leading '_' to symbols you're passing to
> dlsym(), right?  That used to be necessary for a.out, but it doesn't
> work for ELF.  It hasn't been necessary even for a.out since August,
> 1997 in -current (September, 1997 in -stable).  I'd recommend ditching
> the underscores unconditionally.
> 
> Here's the test program I tried, which worked:
> 
>     #include <dlfcn.h>
>     #include <err.h>
>     #include <stdio.h>
> 
>     typedef int (*prf)(const char *, ...);
> 
>     int
>     main(int argc, char *argv[])
>     {
> 	void *h;
> 	void *fp1;
> 
> 	if ((h = dlopen("/usr/lib/libc.so.3", RTLD_LAZY)) == NULL)
> 	    errx(1, "dlopen: %s", dlerror());
> 	if ((fp1 = dlsym(h, "printf")) == NULL)
> 	    errx(1, "dlsym: %s", dlerror());
> 	(*(prf)fp1)("Hooray!  It worked!\n");
> 	dlclose(h);
> 	return 0;
>     }
> 
> John
> --
>    John Polstra                                       jdp@polstra.com
>    John D. Polstra & Co., Inc.                Seattle, Washington USA
>    "Self-knowledge is always bad news."                 -- John Barth
> 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.02.9809011511060.28074-100000>