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 3:31 PM, Maciej W. Rozycki <macro@mips.com> wrote:
> On Thu, 30 Nov 2017, H.J. Lu wrote:
>
>> >  Or likely a bug in the `make' recipe used to link `sln' -- Scrt1.o has to
>> > be chosen instead for PIE links and the GCC driver gets it right, however
>> > we use `-nostartfiles' and link in the bits by hand.
>>
>> My current patch links rcrt1.o for static PIE.  I got
>>
>> mips64-glibc-linux-gnu-gcc -mabi=32 -nostdlib -nostartfiles -static -o
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/elf/sln
>> -Wl,-pie,--no-dynamic-linker,--eh-frame-hdr,-z,text
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/csu/rcrt1.o
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/csu/crti.o
>> `mips64-glibc-linux-gnu-gcc -mabi=32  --print-file-name=crtbeginS.o`
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/elf/sln.o
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/elf/static-stubs.o
>>  -Wl,--start-group
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/libc.a
>> -lgcc  -Wl,--end-group `mips64-glibc-linux-gnu-gcc -mabi=32
>> --print-file-name=crtendS.o`
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/csu/crtn.o
>> /export/ssd/git/toolchain/install/compilers/mips64-linux-gnu/bin/../lib/gcc/mips64-glibc-linux-gnu/7.2.1/../../../../mips64-glibc-linux-gnu/bin/ld:
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/csu/rcrt1.o:
>> relocation R_MIPS_HI16 against `_gp' can not be used when making a
>> shared object; recompile with -fPIC
>> /export/ssd/git/toolchain/install/compilers/mips64-linux-gnu/bin/../lib/gcc/mips64-glibc-linux-gnu/7.2.1/../../../../mips64-glibc-linux-gnu/bin/ld:
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/libc.a(bsd-_setjmp.o):
>> relocation R_MIPS_26 against `__sigsetjmp' can not be used when making
>> a shared object; recompile with -fPIC
>> /export/ssd/git/toolchain/install/compilers/mips64-linux-gnu/bin/../lib/gcc/mips64-glibc-linux-gnu/7.2.1/../../../../mips64-glibc-linux-gnu/bin/ld:
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/libc.a(sched_yield.o):
>> relocation R_MIPS_26 against `__syscall_error' can not be used when
>> making a shared object; recompile with -fPIC
>> /export/ssd/git/toolchain/install/compilers/mips64-linux-gnu/bin/../lib/gcc/mips64-glibc-linux-gnu/7.2.1/../../../../mips64-glibc-linux-gnu/bin/ld:
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/libc.a(symlink.o):
>> relocation R_MIPS_26 against `__syscall_error' can not be used when
>> making a shared object; recompile with -fPIC
>> /export/ssd/git/toolchain/install/compilers/mips64-linux-gnu/bin/../lib/gcc/mips64-glibc-linux-gnu/7.2.1/../../../../mips64-glibc-linux-gnu/bin/ld:
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/libc.a(unlink.o):
>> relocation R_MIPS_26 against `__syscall_error' can not be used when
>> making a shared object; recompile with -fPIC
>> /export/ssd/git/toolchain/install/compilers/mips64-linux-gnu/bin/../lib/gcc/mips64-glibc-linux-gnu/7.2.1/../../../../mips64-glibc-linux-gnu/bin/ld:
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/libc.a(munmap.o):
>> relocation R_MIPS_26 against `__syscall_error' can not be used when
>> making a shared object; recompile with -fPIC
>> /export/ssd/git/toolchain/install/compilers/mips64-linux-gnu/bin/../lib/gcc/mips64-glibc-linux-gnu/7.2.1/../../../../mips64-glibc-linux-gnu/bin/ld:
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/libc.a(mprotect.o):
>> relocation R_MIPS_26 against `__syscall_error' can not be used when
>> making a shared object; recompile with -fPIC
>> /export/ssd/git/toolchain/install/compilers/mips64-linux-gnu/bin/../lib/gcc/mips64-glibc-linux-gnu/7.2.1/../../../../mips64-glibc-linux-gnu/bin/ld:
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/libc.a(madvise.o):
>> relocation R_MIPS_26 against `__syscall_error' can not be used when
>> making a shared object; recompile with -fPIC
>> /export/ssd/git/toolchain/install/compilers/mips64-linux-gnu/bin/../lib/gcc/mips64-glibc-linux-gnu/7.2.1/../../../../mips64-glibc-linux-gnu/bin/ld:
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/libc.a(mremap.o):
>> relocation R_MIPS_26 against `__syscall_error' can not be used when
>> making a shared object; recompile with -fPIC
>> /export/ssd/git/toolchain/install/compilers/mips64-linux-gnu/bin/../lib/gcc/mips64-glibc-linux-gnu/7.2.1/../../../../mips64-glibc-linux-gnu/bin/ld:
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/libc.a(sysinfo.o):
>> relocation R_MIPS_26 against `__syscall_error' can not be used when
>> making a shared object; recompile with -fPIC
>> /export/ssd/git/toolchain/install/compilers/mips64-linux-gnu/bin/../lib/gcc/mips64-glibc-linux-gnu/7.2.1/../../../../mips64-glibc-linux-gnu/bin/ld:
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/libc.a(sysdep.o):
>> relocation R_MIPS_26 against `__errno_location' can not be used when
>> making a shared object; recompile with -fPIC
>> /export/ssd/git/toolchain/install/compilers/mips64-linux-gnu/bin/../lib/gcc/mips64-glibc-linux-gnu/7.2.1/../../../../mips64-glibc-linux-gnu/bin/ld:
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/libc.a(setjmp.o):
>> relocation R_MIPS_26 against `__sigsetjmp_aux' can not be used when
>> making a shared object; recompile with -fPIC
>> /export/ssd/git/toolchain/install/compilers/mips64-linux-gnu/bin/../lib/gcc/mips64-glibc-linux-gnu/7.2.1/../../../../mips64-glibc-linux-gnu/bin/ld:
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/libc.a(uname.o):
>> relocation R_MIPS_26 against `__syscall_error' can not be used when
>> making a shared object; recompile with -fPIC
>> /export/ssd/git/toolchain/install/compilers/mips64-linux-gnu/bin/../lib/gcc/mips64-glibc-linux-gnu/7.2.1/../../../../mips64-glibc-linux-gnu/bin/ld:
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/libc.a(prctl.o):
>> relocation R_MIPS_26 against `__syscall_error' can not be used when
>> making a shared object; recompile with -fPIC
>> /export/ssd/git/toolchain/install/compilers/mips64-linux-gnu/bin/../lib/gcc/mips64-glibc-linux-gnu/7.2.1/../../../../mips64-glibc-linux-gnu/bin/ld:
>> /export/gnu/import/git/toolchain/build/glibcs/mips-linux-gnu/glibc/libc.a(setitimer.o):
>> relocation R_MIPS_26 against `__syscall_error' can not be used when
>> making a shared object; recompile with -fPIC
>> collect2: error: ld returned 1 exit status
>
>  I don't know what rcrt1.o is, this is the first time I see it mentioned.

See:

https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00247.html

> 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.

>  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


-- 
H.J.


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