Message ID | CAMe9rOq=9Fah3OB65VJ_J+jyQGAOPH9cnSzwm4516tUAM0-x_A@mail.gmail.com |
---|---|
State | New, archived |
Headers |
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: <libc-alpha.sourceware.org> List-Unsubscribe: <mailto:libc-alpha-unsubscribe-##L=##H@sourceware.org> List-Subscribe: <mailto:libc-alpha-subscribe@sourceware.org> List-Archive: <http://sourceware.org/ml/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-help@sourceware.org>, <http://sourceware.org/ml/#faqs> 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: <alpine.DEB.2.00.1712010142540.31156@tp.orcam.me.uk> References: <CAMe9rOoyPf-77=cqmEW5Vg2KHwq48g6giW38qpA=oDUsnHaxCA@mail.gmail.com> <alpine.DEB.2.20.1711011603010.26405@digraph.polyomino.org.uk> <CAMe9rOrWi1W+F6K3TRL-2ipz-K4e0aP0ywsVg0XWgdCU1FV7OQ@mail.gmail.com> <CAMe9rOrTW7-JBtfOWjQrqMtS6Kp8efsAAbouFwQOnaAzh=sNpA@mail.gmail.com> <CAMe9rOr5qR-MnP+bEY_3OPdPK1qTnn_7JLi3Xn688E9JWKr1Zw@mail.gmail.com> <5A12C781.3030700@arm.com> <CAMe9rOohYeS4BJFp=TB4Zz26V4K2n8ZXSJX9kYqgEa=eW+w1xQ@mail.gmail.com> <5A18196C.90208@arm.com> <CAMe9rOqFfabivUDke1_ZxyEtV+L9T7VwKKdsdnR9M418L2TQBg@mail.gmail.com> <CAMe9rOpNdwd52vEnAUzOkmwkJXUWZz9-=dc9xfeZ96CYVM=8gQ@mail.gmail.com> <02278c7c-ade4-c8f2-c978-e66f77a101bd@redhat.com> <alpine.DEB.2.00.1711302227190.31156@tp.orcam.me.uk> <CAMe9rOpDRknZANuSvXAqU_qaXzGRjt=uY5BZLJoE_o9Ke+9yfw@mail.gmail.com> <alpine.DEB.2.00.1711302308170.31156@tp.orcam.me.uk> <CAMe9rOoaP=LT16Ee=-MOsL=zpem5XDjo4avhkJgC38FbeqSF4w@mail.gmail.com> <alpine.DEB.2.00.1712010142540.31156@tp.orcam.me.uk> From: "H.J. Lu" <hjl.tools@gmail.com> Date: Thu, 30 Nov 2017 20:18:21 -0800 Message-ID: <CAMe9rOq=9Fah3OB65VJ_J+jyQGAOPH9cnSzwm4516tUAM0-x_A@mail.gmail.com> Subject: Re: PING^N: [PATCH] Add --enable-static-pie to build static PIE [BZ #19574] To: "Maciej W. Rozycki" <macro@mips.com> Cc: GNU C Library <libc-alpha@sourceware.org> Content-Type: text/plain; charset="UTF-8" |
Commit Message
H.J. Lu
Dec. 1, 2017, 4:18 a.m. UTC
On Thu, Nov 30, 2017 at 5:57 PM, Maciej W. Rozycki <macro@mips.com> 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.
Comments
On Thu, 30 Nov 2017, H.J. Lu wrote: > This patch fixes mips build with --enable-static-pie: > > 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),) > > Can you try native mips build with --enable-static-pie using hjl/pie/static > branch? I'm not sure if I'm set up for a native glibc build right now, I haven't done one for a while now. I could try a cross build right away, however I am too loaded with other stuff to commit to do testing for you at the moment. Perhaps Joseph would be kind enough, as the MIPS port maintainer -- Joseph? Maciej
On Fri, 1 Dec 2017, Maciej W. Rozycki wrote: > > Can you try native mips build with --enable-static-pie using hjl/pie/static > > branch? > > I'm not sure if I'm set up for a native glibc build right now, I haven't > done one for a while now. I could try a cross build right away, however I > am too loaded with other stuff to commit to do testing for you at the > moment. I've not done native MIPS builds at all, but I don't think native versus cross is relevant here. The main thing is that the wiki instructions, if and when this feature reaches consensus for inclusion on master, give sufficient information on what testing is needed of whether the feature works on a given architecture before that architecture can be removed from the list of those that haven't had execution testing (whether or not the build completes OK for them). For example, are any special GCC configure options needed, or just the glibc configure option --enable-static-pie? Does GCC need to be a version (i.e. GCC 8 or later) that supports the -static-pie option in order to test this glibc feature?
On Fri, Dec 1, 2017 at 4:27 AM, Joseph Myers <joseph@codesourcery.com> wrote: > On Fri, 1 Dec 2017, Maciej W. Rozycki wrote: > >> > Can you try native mips build with --enable-static-pie using hjl/pie/static >> > branch? >> >> I'm not sure if I'm set up for a native glibc build right now, I haven't >> done one for a while now. I could try a cross build right away, however I >> am too loaded with other stuff to commit to do testing for you at the >> moment. > > I've not done native MIPS builds at all, but I don't think native versus > cross is relevant here. The main thing is that the wiki instructions, if > and when this feature reaches consensus for inclusion on master, give > sufficient information on what testing is needed of whether the feature > works on a given architecture before that architecture can be removed from > the list of those that haven't had execution testing (whether or not the > build completes OK for them). For example, are any special GCC configure > options needed, or just the glibc configure option --enable-static-pie? > Does GCC need to be a version (i.e. GCC 8 or later) that supports the > -static-pie option in order to test this glibc feature? > GCC must support PIE to build static PIE glibc. The main issue is linker. Many ELF linker backends have various issues with PIE, especially static PIE. Other than those, there are no special requirements. To use static PIE glibc to create static PIE with "gcc -static-pie", GCC 8 is needed. I also have backported it to GCC 7 on hjl/pie/gcc-7-branch branch in gcc git repo.
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),)