From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/15054 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [BUG] Force to use a dynamic linker in musl-clang wapper cause a crash for static-pie c++ programs. Date: Tue, 24 Dec 2019 10:03:31 -0500 Message-ID: <20191224150331.GX1666@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="8773"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) Cc: musl@lists.openwall.com To: Youren Shen Original-X-From: musl-return-15070-gllmg-musl=m.gmane.org@lists.openwall.com Tue Dec 24 16:03:53 2019 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.89) (envelope-from ) id 1ijliz-00026m-9Y for gllmg-musl@m.gmane.org; Tue, 24 Dec 2019 16:03:53 +0100 Original-Received: (qmail 9369 invoked by uid 550); 24 Dec 2019 15:03:46 -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 9351 invoked from network); 24 Dec 2019 15:03:45 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:15054 Archived-At: On Tue, Dec 24, 2019 at 10:38:49PM +0800, Youren Shen wrote: > Hey, there, > Recently I'm trying to build a non-gnu toolchain with musl, clang, llvm, > libc++, compiler-rt. While static-pie feature is very useful in our > project, musl-clang force to link a dynamic linker into the binary. This > behavior will cause a crash in c++ programs with compiler-rt and libc++. > For more details and reproduction of this bug, you can read my previous > email to llvm-dev mail lists.[1] > I spend a few days to find the reason -- in function _dlstart_c, the > program will get a "base" of relocation in /lib/ld-musl-x86_64.so.1, which > is not right when it tries to relocate .rel.dyn section in the binary. > Overall, the static-pie program does not need a dynamic linker at all. So > maybe we should remove this argument in wrapper when static-pie is enabled. > > Thank you very much. > > [1]. https://groups.google.com/forum/#!msg/llvm-dev/XPrSPqD2zjM/YtH6Fi2YAgAJ I don't think the wrappers (gcc or clang one) have been updated with logic for static pie since it was added, and I'm not sure how easy it is to add. I'd welcome patches for review, though. Rich