public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Fengkai Sun via Libc-help <libc-help@sourceware.org>
Cc: Fengkai Sun <qcloud1014@gmail.com>
Subject: Re: Is writing a dynamic linker/loader to load glibc a bad idea?
Date: Tue, 05 Jan 2021 10:58:06 +0100	[thread overview]
Message-ID: <87ble3hfip.fsf@oldenburg2.str.redhat.com> (raw)
In-Reply-To: <CAF6YOcO1WHNrhrmzfsHiNzRNdc7soMSUpQQd0jYXE8mLU_vH9Q@mail.gmail.com> (Fengkai Sun via Libc-help's message of "Tue, 5 Jan 2021 11:25:04 +0800")

* Fengkai Sun via Libc-help:

> Sorry in advance if this question is a bit unclear and confusing.
>
> Recently I want to implement an ld.so myself, that is, a DSO that allows me
> to load other DSOs into memory.
>
> I've tried my best to finish all the steps that I discovered: loading
> PT_LOAD segments with mmap, loading dependencies, relocating, and calling
> DT_INIT and DT_INITARRAY in the right order.
>
> It works all right when the DSO is simple, e.g. using a few printfs and
> other libc functions. But it fails when I'm using some(not all) DSOs in the
> real world.

At present, this isn't really possible because among other things, the
dynamic loader needs to provide the _rtld_global and and _rtld_global_ro
variable to libc.so.6, and the layout of these variables changes fairly
rapidly.

glibc's ld.so also knows about unusal initialization requirements for
libc.so.6 (see __libc_early_init, _dl_var_init).

It may be interesting to come up with the absolut minimum set of ld.so
interfaces, and try to move the rest into libc.so.6, and then stabilize
the interface between the two.

But today, glibc's hooking mechanism for ld.so is the audit (LD_AUDIT)
interface, not replacing ld.so completely.

Thanks,
Florian
-- 
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill


      reply	other threads:[~2021-01-05  9:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05  3:25 Fengkai Sun
2021-01-05  9:58 ` Florian Weimer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ble3hfip.fsf@oldenburg2.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-help@sourceware.org \
    --cc=qcloud1014@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).