public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Fengkai Sun <qcloud1014@gmail.com>
Cc: libc-help@sourceware.org
Subject: Re: Can LD_PRELOAD set different symbol definitions for shared objects and executable?
Date: Tue, 25 May 2021 19:50:36 +0200	[thread overview]
Message-ID: <87im36vh1v.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <CAF6YOcPZKYDHbwGgheWJdHQ6MqAq7GR7iLGc1GrKeNzjEEgKpA@mail.gmail.com> (Fengkai Sun's message of "Wed, 26 May 2021 00:03:34 +0800")

* Fengkai Sun:

> Hi Florian,
>
> Thanks for your help as always.
>
> I've done some research on LD_AUDIT interfaces, and found it very useful to me. However, I
> had some problems when implementing a separate malloc for executable and shared
> objects:
>
> I use la_symbind64 to monitor symbol binding. The pseudocode is as follows:
> IF symname == "malloc" AND refcook == "shared objects"
>     RETURN custom_malloc
> ELSE
>     RETURN malloc
>
> Then I discovered I have no way to get the address of custom malloc in
> the audit library...

Hmm, malloc may be very special here because ld.so and libc.so in the
base namespace really must use the same malloc, or things will fall
apart.  In principle this code should work, and I expect with a lot of
care, it can be made to work for malloc as well.

Thanks,
Florian


      reply	other threads:[~2021-05-25 17:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25  2:35 Fengkai Sun
2021-05-25  8:41 ` Florian Weimer
2021-05-25 16:03   ` Fengkai Sun
2021-05-25 17:50     ` 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=87im36vh1v.fsf@oldenburg.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).