public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amonakov at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug dynamic-link/28248] is there a way to LD_PRELOAD library before other dynamic libraries?
Date: Tue, 31 Aug 2021 17:41:23 +0000	[thread overview]
Message-ID: <bug-28248-131-9GTyLfOFrb@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-28248-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=28248

Alexander Monakov <amonakov at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amonakov at gmail dot com

--- Comment #1 from Alexander Monakov <amonakov at gmail dot com> ---
You're mixing up two separate library orderings: the symbol lookup order (which
is what the man page implicitly refers to, it's breadth-first order over
DT_NEEDED links, with LD_PRELOAD modules appearing just after the main
executable and before its first DT_NEEDED library), and initialization order
(which is reverse topological order over DT_NEEDED links, assuming lack of
cycles).

To interpose malloc and the like, your library needs to appear prior to libc.so
in the former; also, your library in all likelihood depends on libc.so, so it
will appear after libc.so in the latter.

The log you've shown confirms this: preload_dump.so is loaded prior to
libtinfo.so.5, but its constructors are invoked last.

ELF gABI document explains this, please have a look:
http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#init_fini

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  reply	other threads:[~2021-08-31 17:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-19 12:57 [Bug dynamic-link/28248] New: " mail at milianw dot de
2021-08-31 17:41 ` amonakov at gmail dot com [this message]
2021-09-06  8:19 ` [Bug dynamic-link/28248] " mail at milianw dot de
2021-09-06  8:32 ` fweimer at redhat dot com
2021-09-09  8:35 ` mail at milianw dot de
2021-09-09  8:54 ` mail at milianw dot de
2022-08-29  9:53 ` fweimer at redhat dot com

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=bug-28248-131-9GTyLfOFrb@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@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).