This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: What is the right way to initialize GLibc?
- From: Paul Pluzhnikov <ppluzhnikov at gmail dot com>
- To: Mike Frysinger <vapier at gentoo dot org>
- Cc: libc-help at sourceware dot org, Steven Stewart-Gallus <sstewartgallus00 at mylangara dot bc dot ca>
- Date: Sun, 3 Aug 2014 08:57:55 -0700
- Subject: Re: What is the right way to initialize GLibc?
- Authentication-results: sourceware.org; auth=none
- References: <facc9a2a1da91 dot 53238d24 at langara dot bc dot ca> <2143181 dot IzuyS1CTfW at vapier>
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