From patchwork Fri Dec 1 04:18:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 24655 Received: (qmail 66205 invoked by alias); 1 Dec 2017 04:18:25 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 66196 invoked by uid 89); 1 Dec 2017 04:18:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-ot0-f169.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=DdeYeJ9LgDNw/naRBaO01gxYP+1fAndWw8yps99+mgg=; b=YaE+UzXoMyih82BOFZrk0sBErfGgl1U+jbfF4tObiMiWtY73HXQxLobEiMcmB5q940 6s7DHo+IzMTdDOy2EfhYmCZNi4qzVmShIfbop4/CzbrBNdkUFXqKz4irkcaXW24+nRsD K2FrH/19V87eJ1g0+RHn8dYtz91Z3v9Wr4FtPzinDbjoINyeD9zj8Xsa94KS5XYRTdp8 oSPRj72WohMPdTTZ8D8s7D3EmgT8deQLVKxJePz71rMg1PYphqGb0WQ9fYl1IcThpiyM FIXLDF1vrbtgOWM1STxJXdEaypTDnlVbDGZIF7HnR9rJOd9JIaVbWCaki0QE40CQvdUu RVHQ== X-Gm-Message-State: AJaThX729LxgWPA+Lmm3GQY/CjH/S7lGNjtxRw/FmuBnJi2G7anEmJ9a 6vSXbezqkmgEcKwdijvULRq7eUvC5JF9+Z+DfzR0Mg== X-Google-Smtp-Source: AGs4zMYXuJAGRY7+jnaIP5NzQ1xzzhDzKW92YSRev1cwKSLynOM1mbwNZLiwRGEWufmiLEmkNwMGX07KBxkv61kB4No= X-Received: by 10.157.65.213 with SMTP id v21mr7207746oti.392.1512101902406; Thu, 30 Nov 2017 20:18:22 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <5A12C781.3030700@arm.com> <5A18196C.90208@arm.com> <02278c7c-ade4-c8f2-c978-e66f77a101bd@redhat.com> From: "H.J. Lu" Date: Thu, 30 Nov 2017 20:18:21 -0800 Message-ID: Subject: Re: PING^N: [PATCH] Add --enable-static-pie to build static PIE [BZ #19574] To: "Maciej W. Rozycki" Cc: GNU C Library On Thu, Nov 30, 2017 at 5:57 PM, Maciej W. Rozycki wrote: > On Thu, 30 Nov 2017, H.J. Lu wrote: > >> > However overall all these MIPS relocations are strictly non-PIC ones, so >> > clearly this code has not been correctly built. >> >> That is MIPS specific issue. It could be bfd_link_pic vs bfd_link_executable >> in MIPS linker backend. > > Well, these relocations are produced by GAS, which obviously has nothing > to do with linking. You need to find a way for them not to be produced in > the first place, as they are not valid in a PIE executable link. > >> > AFAICT you need to pass -DPIC to GCC when assembling sysdeps/mips/start.S >> > to get a position-independent intermediate object. The same applies to >> > our other MIPS assembly sources. >> >> Everything is compiled with -fPIE -DPIC: >> >> +ifeq (yes,$(enable-static-pie)) >> +pic-default = -DPIC >> +pie-default = $(pie-ccflag) >> +ifeq (yes,$(have-static-pie)) >> +default-pie-ldflag = -static-pie >> +else >> +default-pie-ldflag = -Wl,-pie,--no-dynamic-linker,--eh-frame-hdr,-z,text >> +endif >> +endif > > Well, that doesn't prove that these options actually make it to the GCC > invocation line for say rcrt1.o. Quoting the actual line for rcrt1.o from > a build log would be more useful. > This patch fixes mips build with --enable-static-pie: Can you try native mips build with --enable-static-pie using hjl/pie/static branch? Thanks. diff --git a/sysdeps/mips/Makefile b/sysdeps/mips/Makefile index fd891ddf09..7ac6fa5031 100644 --- a/sysdeps/mips/Makefile +++ b/sysdeps/mips/Makefile @@ -23,6 +23,9 @@ CPPFLAGS-crtn.S += $(pic-ccflag) endif ASFLAGS-.os += $(pic-ccflag) +# libc.a and libc_p.a must be compiled with -fPIE/-fpie for static PIE. +ASFLAGS-.o += $(pie-default) +ASFLAGS-.op += $(pie-default) ifeq ($(subdir),elf) ifneq ($(o32-fpabi),)