From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11323 Path: news.gmane.org!.POSTED!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: Static PIE with musl and clang Date: Tue, 16 May 2017 11:02:09 +0200 Message-ID: <20170516090209.GC9350@port70.net> References: <1450280459.2314.1488678451062.JavaMail.zimbra@computervoice.com> <20170305024403.GK1520@brightrain.aerifal.cx> <640524050.2626.1488685284594.JavaMail.zimbra@computervoice.com> <20170305122118.GG2082@port70.net> <1432352279.548091.1494876298089.JavaMail.zimbra@computervoice.com> 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 1494925345 12739 195.159.176.226 (16 May 2017 09:02:25 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 16 May 2017 09:02:25 +0000 (UTC) User-Agent: Mutt/1.6.0 (2016-04-01) To: musl@lists.openwall.com Original-X-From: musl-return-11338-gllmg-musl=m.gmane.org@lists.openwall.com Tue May 16 11:02:21 2017 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 1dAYN1-0003Cp-Vu for gllmg-musl@m.gmane.org; Tue, 16 May 2017 11:02:20 +0200 Original-Received: (qmail 5569 invoked by uid 550); 16 May 2017 09:02:22 -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 5547 invoked from network); 16 May 2017 09:02:22 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <1432352279.548091.1494876298089.JavaMail.zimbra@computervoice.com> Xref: news.gmane.org gmane.linux.lib.musl.general:11323 Archived-At: * Paul Sturm [2017-05-15 14:24:58 -0500]: > I decided to take a step back and try to make this work first with gcc (7.1) and ld (2.28). Both tools were built statically and musl (1.16+) is also built as a static libc.a. > > Test program is aslr.c: > > #include > > int main() { > printf("%p\n", main); > return 0; > } > > gcc aslr.c -fPIE -pie -static-libgcc -Wl,-static -Wl,--no-dynamic-linker > > ./a.out > Segementation fault there is no -static passed to the compiler so it cannot possibly select the right crt file. you need to patch gcc for static pie support, or pass all the necessary linker flags manually (including the crt files). https://github.com/richfelker/musl-cross-make/blob/master/patches/gcc-6.3.0/0010-static-pie-support.diff