From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1BEB03858C27; Tue, 31 Aug 2021 17:41:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BEB03858C27 From: "amonakov at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: dynamic-link X-Bugzilla-Version: 2.33 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: amonakov at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Aug 2021 17:41:24 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28248 Alexander Monakov changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amonakov at gmail dot com --- Comment #1 from Alexander Monakov --- You're mixing up two separate library orderings: the symbol lookup order (w= hich 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 lib= c.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 --=20 You are receiving this mail because: You are on the CC list for the bug.=