Date: Tue, 01 Sep 1998 11:01:28 -0700 From: John Polstra <jdp@polstra.com> To: green@unixhelp.org Cc: current@FreeBSD.ORG Subject: Re: E-day problems: rtld-elf dlsym() broken? Message-ID: <199809011801.LAA14263@austin.polstra.com> In-Reply-To: <Pine.BSD.4.00.9809010729170.18315-200000@feldman.dyn.ml.org> References: <Pine.BSD.4.00.9809010729170.18315-200000@feldman.dyn.ml.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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?199809011801.LAA14263>
