From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8489 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: musl/SH-FDPIC progress Date: Thu, 10 Sep 2015 21:48:50 -0400 Message-ID: <20150911014850.GA18775@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1441936154 3379 80.91.229.3 (11 Sep 2015 01:49:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 11 Sep 2015 01:49:14 +0000 (UTC) Cc: 0pf@nommu.org To: musl@lists.openwall.com Original-X-From: musl-return-8501-gllmg-musl=m.gmane.org@lists.openwall.com Fri Sep 11 03:49:13 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ZaDSi-0008Oa-3Y for gllmg-musl@m.gmane.org; Fri, 11 Sep 2015 03:49:12 +0200 Original-Received: (qmail 29968 invoked by uid 550); 11 Sep 2015 01:49:09 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 29874 invoked from network); 11 Sep 2015 01:49:03 -0000 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:8489 Archived-At: I now have a working prototype of static-linked FDPIC binary support in musl libc using gcc 5.2 (with the forward-ported SH-FDPIC patch) and binutils 2.25.1. I've tested simple example programs and some non-trivial examples with threads and they work both under qemu-sh4eb with FDPIC support added (needs a small patch) and on real J2 hardware, where they successfully share text/execute-in-place. The gcc patch is presently against gcc with all the other patches from my musl-cross-make repo applied, so some refactoring will be needed to propose it upstream, but I think it's ready for initial review. After a little bit more cleanup (mainly bad specs logic) I'll go ahead and put a version of this patch in the toolchain repo. On the musl side, the changes are not ready for upstream. Adding FDPIC revealed that the way we're bootstrapping the dynamic linker and PIE entry point does not make sense, but I already knew that anyway -- having to use -export-dynamic for static-linked PIE was already a problem. I might however be able to get just the non-PIE, static linking only version of FDPIC support upstreamable in the next few days and go ahead and commit that before working on the bigger upstream changes that will be needed to make full FDPIC support (including dynamic linking) possible. On the kernel side, a really ugly issue is blocking FDPIC deployment: the kernel interprets an ELF header bit the opposite of how it's specified and how ld sets it. Details are in this thread: http://www.spinics.net/lists/linux-sh/msg44965.html Until that's resolved, it's impossible to make future-proof FDPIC binaries that will reliably share text. (They'll work regardless, but won't share text.) I'll follow up soon with details on patches needed to make this all work. Rich