From owner-freebsd-current Tue Sep 1 11:02:41 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA24449 for freebsd-current-outgoing; Tue, 1 Sep 1998 11:02:41 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from austin.polstra.com (austin.polstra.com [206.213.73.10]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id LAA24429 for ; Tue, 1 Sep 1998 11:02:31 -0700 (PDT) (envelope-from jdp@austin.polstra.com) Received: from austin.polstra.com (jdp@localhost) by austin.polstra.com (8.8.8/8.8.8) with ESMTP id LAA14263; Tue, 1 Sep 1998 11:01:28 -0700 (PDT) (envelope-from jdp) Message-Id: <199809011801.LAA14263@austin.polstra.com> To: green@unixhelp.org Subject: Re: E-day problems: rtld-elf dlsym() broken? In-Reply-To: References: Organization: Polstra & Co., Seattle, WA Cc: current@FreeBSD.ORG Date: Tue, 01 Sep 1998 11:01:28 -0700 From: John Polstra Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In article , Brian Feldman 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 #include #include 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