public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Fengkai Sun <qcloud1014@gmail.com>
To: libc-help@sourceware.org
Subject: Can LD_PRELOAD set different symbol definitions for shared objects and executable?
Date: Tue, 25 May 2021 10:35:20 +0800	[thread overview]
Message-ID: <CAF6YOcORWWnW8EvCskAmDf3shEBvP8Lo_irBcG7y2+_U0bSZBQ@mail.gmail.com> (raw)

Hi list,

I've done some research on elf/rtld.c, and found that the dynamic linker
only handles the preload list in dl_main, that is, there is no other way to
change it later.

Does that mean there is no way to give different symbol definitions to
shared objects and executable?

For example, if I set LD_PRELOAD="./mymalloc.so", then all references to
malloc will be interposed. There is no way to specify a custom allocator
only for shared objects(maybe I can make a difference in the source code of
custom malloc, but that's off topic).

I wonder if there is any way to do this, or if I missed out some
fundamental ideas.


Best,
Fengkai

             reply	other threads:[~2021-05-25  2:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25  2:35 Fengkai Sun [this message]
2021-05-25  8:41 ` Florian Weimer
2021-05-25 16:03   ` Fengkai Sun
2021-05-25 17:50     ` Florian Weimer

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=CAF6YOcORWWnW8EvCskAmDf3shEBvP8Lo_irBcG7y2+_U0bSZBQ@mail.gmail.com \
    --to=qcloud1014@gmail.com \
    --cc=libc-help@sourceware.org \
    /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).