This is the mail archive of the 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:, dynamic and executable?

On Mon, May 12, 2008 at 10:19 AM, Nathan Weyer <> wrote:
> Well, the list said any question....
>  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.

Which application and/or library provided by GLIBC are you referring to?

When a user application is compiled it has the program interpreter
(the dynamic linker/loader information [the path] embedded in
the program's ELF header.  Of course this isn't the case with
statically link applications since you don't need a dynamic linker and
no libraries are loaded after the fact.

As far as I understand, the kernel loads the application and the
indicated dynamic linker/loader into memory.  It passes control to the
loader which will load the library and resolve necessary early
symbols.  Control will pass to libc to execute the application init
code which will launch the application.

The library does have a 'main' entry point but it is compiled
as a shared object, not an executable.

Run readelf -l <executable or shared object> | grep "Elf file type"
against an executable and you'll see:
Elf file type is EXEC (Executable file)

For a shared object you'll see:
Elf file type is DYN (Shared object file)

Ryan S. Arnold

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