This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PING^N: [PATCH] Add --enable-static-pie to build static PIE [BZ #19574]


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:

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?

Thanks.

-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]