From owner-freebsd-hackers Tue Mar 23 22:23:40 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from ns.mt.sri.com (sri-gw.MT.net [206.127.105.141]) by hub.freebsd.org (Postfix) with ESMTP id 7CC1815121; Tue, 23 Mar 1999 22:23:37 -0800 (PST) (envelope-from nate@mt.sri.com) Received: from mt.sri.com (rocky.mt.sri.com [206.127.76.100]) by ns.mt.sri.com (8.8.8/8.8.8) with SMTP id XAA11340; Tue, 23 Mar 1999 23:23:18 -0700 (MST) (envelope-from nate@rocky.mt.sri.com) Received: by mt.sri.com (SMI-8.6/SMI-SVR4) id XAA17580; Tue, 23 Mar 1999 23:23:17 -0700 Date: Tue, 23 Mar 1999 23:23:17 -0700 Message-Id: <199903240623.XAA17580@mt.sri.com> From: Nate Williams MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: Steve Price Cc: freebsd-hackers@FreeBSD.ORG, jdp@FreeBSD.ORG Subject: Re: dladdr(3) question In-Reply-To: References: X-Mailer: VM 6.34 under 19.16 "Lille" XEmacs Lucid Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > I know I'm probably doing something stupid here, but I > seem to be having a problem getting dladdr(3) to work. I just researched this (since I'm as interested in Steve as to why this doesn't work. :) It appears to me that dladdr is *NOT* supported in ELF in the current code. However, it is supported in a.out (in 3.* only). The functionality is missing in /usr/src/libexec/rtld-elf, although I suspect it's an oversight and not intentional. I'm not *real* familiar with the loader code, but given it's already implemented for a.out I suspect it should be easy to add to the elf loader. John would know more (hope he's feeling better). Nate -------------------- > Here's the code ... > > #include > #include > #include > int foo() { > return 0; > } > int main() { > Dl_info dlinfo; > if (dladdr(foo, &dlinfo) == 0) { > printf("dladdr failed: %s\n", dlerror()); > exit(1); > } > printf("dli_fname = %s\n", dlinfo.dli_fname); > return 0; > } > > ... and a couple of sample runs. > > bsd[~]$ ./a.out > dladdr failed: Service unavailable > bsd[~]$ uname -rs > FreeBSD 4.0-CURRENT > > pepito[~]$ ./a.out > dli_fname = a.out > pepito[~]$ uname -rs > SunOS 5.7 > > Anyone have any ideas where I'm missing the boat? > > -steve > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message