From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13470 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Question regarding dynamic loader Date: Wed, 21 Nov 2018 11:14:00 -0500 Message-ID: <20181121161400.GC23599@brightrain.aerifal.cx> References: <20181121142550.GA23599@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1542816730 21246 195.159.176.226 (21 Nov 2018 16:12:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 21 Nov 2018 16:12:10 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-13486-gllmg-musl=m.gmane.org@lists.openwall.com Wed Nov 21 17:12:06 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1gPV6h-0005PH-VZ for gllmg-musl@m.gmane.org; Wed, 21 Nov 2018 17:12:04 +0100 Original-Received: (qmail 6058 invoked by uid 550); 21 Nov 2018 16:14:13 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 6040 invoked from network); 21 Nov 2018 16:14:12 -0000 Content-Disposition: inline In-Reply-To: <20181121142550.GA23599@brightrain.aerifal.cx> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:13470 Archived-At: On Wed, Nov 21, 2018 at 09:25:50AM -0500, Rich Felker wrote: > On Wed, Nov 21, 2018 at 02:55:19PM +0100, Gernot Reisinger wrote: > > I wonder if calling constructor functions from crt code is an intended musl > > libc behavior. My personal - non expert - gut feeling considers glibc > > behavior "more correct". Is there a chance that musl will change this > > behavior? > > The musl behavior here is intentional. For FDPIC targets, it's > impossible to run *any* application code, in the main application or > shared libraries, before the main application's crt1 has executed, > because there are (essentially -- the equivalent of) self-relocations > performed at that stage that the dynamic linker can't see. If any > ctors were invoked directly by the dynamic linker before passing > control the the main application's entry point, they would run without > these relocations in the main application having been performed, > possibly resulting in runaway-wrong execution. For reference, this was initially done in commit c87a52103399135d2f57a91a8bcc749d8cb2ca83. Of course these code paths have changed significantly since then, but it gives some historical context. Rich