Date: Sun, 12 Jan 2003 06:08:14 -0800 From: Terry Lambert <tlambert2@mindspring.com> To: Aurelien Nephtali <aurelien.nephtali@wanadoo.fr> Cc: hackers@freebsd.org Subject: Re: dlopen()/dlsym()/etc sources ? Message-ID: <3E2176CE.DAFE9A24@mindspring.com> References: <20030112130901.GA16913@nebula.wanadoo.fr>
index | next in thread | previous in thread | raw e-mail
Aurelien Nephtali wrote: > I would like to know where are the dlopen()/dlsym()/etc sources ? > There's nothing in the libc sources :/ > > (I'm using the HEAD tree) src/lib/csu/common/crtbegin.c src/lib/csu/i386/crt0.c src/lib/csu/i386-elf/crt1.c That's the glue. The actual functions are mapped in from a known symbol offset from the entrypoint in the ld.so (src/libexec/rtld-elf/). This is "you are not expected to understand this" code. If you are trying for a static libdlopen.a, then you should look at the way that constructors (ctor's) are handled, and the code that is "#ifdef DYNAMIC". Basically, you will need to change the ctor functions to pass a void * instead of nothing (void), and make it the base address of the context structure that used in the initialization phase in the crt0 code. Then make a static library with a constructor that mmap's in the ld.so, and then knows the offset of the .entry, and passes the main arg vector (the base address of the context structure) to the constructor there, which will let you resolve the dlopen/dlclose/etc. symbols. It's a bit of work, because of the compiler changes needed for the constructors modifies the way C++ handles them (particularly, you will shoot your foot off with --callee-pop, if you don't expect the void * as an argument, but there are other dangers, too...). -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the messagehome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E2176CE.DAFE9A24>
