This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libc.so, dynamic and executable?


On Monday 12 May 2008, Nathan Weyer wrote:
> I am curious if anyone can explain how glibc manages the trick of being
> both a executable binary and a loadable module at the same time? I was
> under the impression that dlopen didn't work on anything that could run on
> it's own.

there isnt any magic here in the ELF world.  dlopen() only requires the ELF 
type be a shared object file.  in order to execute an ELF, it just needs a 
valid entry point.  there's nothing in the spec that you cant have an ELF be 
both a shared object and have a valid entry point (although generally the 
entry point isnt set as such when creating shared libraries).  when linking 
libc.so, glibc sets the entry point to a valid location.

for example, just create an application with -pie and you can dlopen() it just 
fine.  or create a shared library and set the entry point to a valid 
function.
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]