Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 01 Sep 1998 18:17:47 -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:  <199809020117.SAA16605@austin.polstra.com>
In-Reply-To: <Pine.BSF.4.02.9809011511060.28074-100000@zone.syracuse.net>
References:  <Pine.BSF.4.02.9809011511060.28074-100000@zone.syracuse.net>

next in thread | previous in thread | raw e-mail | index | archive | help
OK, I believe I've fixed this in src/libexec/rtld-elf/rtld.c
revision 1.4.  It now does what the documentation says it does.
Namely:

    dlopen(NULL, ...)

returns a handle which, if passed to dlsym(), will cause the main
executable and all of its needed shared objects to be searched for
the symbol.

And:

    dlsym(NULL, ...)

will search for the symbol in the caller's shared object.  N.B.,
that's the caller's shared object _only_.  It doesn't include any
needed shared objects.

Also, your particular test case of trying to look up "main" still
isn't going to work.  The reason is that ELF doesn't put "main" into
the dynamic symbol table, because it's not needed there.  If you are
looking up symbols defined in shared libraries or called from shared
libraries, it should work fine.  But symbols in the main executable
that don't meet those criteria probably won't be found.

There is a linker option "-E" that puts all global symbols into the
dynamic symbol table.  That will cause it to do what you want.  But
of course you have to specify it when you're building the program
(LDFLAGS+=-Wl,-E).

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?199809020117.SAA16605>