Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Mar 1999 23:23:17 -0700
From:      Nate Williams <nate@mt.sri.com>
To:        Steve Price <sprice@hiwaay.net>
Cc:        freebsd-hackers@FreeBSD.ORG, jdp@FreeBSD.ORG
Subject:   Re: dladdr(3) question
Message-ID:  <199903240623.XAA17580@mt.sri.com>
In-Reply-To: <Pine.OSF.4.02.9903232035020.150-100000@fly.HiWAAY.net>
References:  <Pine.OSF.4.02.9903232035020.150-100000@fly.HiWAAY.net>

next in thread | previous in thread | raw e-mail | index | archive | help
> 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 <dlfcn.h>
> #include <stdio.h>
> #include <stdlib.h>
> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199903240623.XAA17580>