What is the right way to initialize GLibc?

Paul Pluzhnikov ppluzhnikov@gmail.com
Sun Aug 3 15:58:00 GMT 2014

On Sun, Aug 3, 2014 at 6:06 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Fri 14 Mar 2014 23:13:40 Steven Stewart-Gallus wrote:
> > Suppose I'm experimenting with making an executable shared library
> > like GLibc itself is.

Please see http://stackoverflow.com/a/1451482/50617

TL;DR: building a PIE binary gives you ET_DYN that can be used as a
stand-alone binary, or as a shared library, and requires no hacks.

> I can get something simple like that working but
> > I want to do more and to do that I need to initialize libc. I think
> > the right way to do this is to call __libc_start_main manually in my
> > libraries start function but I don't know how to do that. What is the
> > right way to initialize GLibc?
> i'm afraid we've never speced this out and most likely never will.  there's so
> many little pieces spread over the crt/ldso/libc/etc...  that i'm not sure
> this is worthwhile.
> note that the way a shared app initializes is not the same as a static app.
> it is actually the ldso which starts execution when the app is shared and
> takes care of doing initialization before calling the app's main.
> -mike

Paul Pluzhnikov

More information about the Libc-help mailing list