Hi Waldemar,

Le 19/05/2021 à 00:09, Waldemar Brodkorb a écrit :
> Hi Romain,
> Romain Naour wrote,
> 
>> Hello,
>>
>> Recently in Buildroot the option BR2_PIC_PIE has been enabled by default 
>> along
>> with other hardening features [1]. Since then some ppc defconfig such
>> qemu_ppc_e500mc_defconfig are failing to boot due to a segfault in init 
>> program.
>>
>> The segfault appear very early in __uClibc_main while starting any binaries,
>> an issue located in crt1.S (powerpc)[2].
>>
>> After some trial and error, removing HAVE_ASM_PPC_REL16 from CFLAGS [3]
>> allow to generate a working system again. But this is actually wrong since
>> instead we should consider HAVE_ASM_PPC_REL16 always true nowadays.
> 
> What if the assembly inside HAVE_ASM_PPC_REL16 isn't pie safe?

Good question.

I guess it should work with pie (see PIEFLAG_NAME:=-fpie)
https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/Rules.mak?h=v1.0.38#n480

I did a try with Glibc without any problem with BR2_PIC_PIE enabled.

Best regards,
Romain

> 
>> Indeed, Glibc removed HAVE_ASM_PPC_REL16 since version 2.22 [4] since "the
>> minimum binutils supports rel16 relocs". Binutils 2.22 supports R_PPC_REL16 
>> as
>> default.
>>
>> uClibc-ng should remove HAVE_ASM_PPC_REL16 but keep the code as it was 
>> defined.
>> But this doesn't fix the initial issue.
>>
>> Any idea ?
>>
>> [1]
>> https://git.buildroot.net/buildroot/commit/?id=810ba387bec3c5b6904e8893fb4cb6f9d3717466
>> [2]
>> https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/libc/sysdeps/linux/powerpc/crt1.S?id=2bf4991c4dd7b50b74656011dea9c40464ff390c#n47
>> [3]
>> https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/Rules.mak?id=2bf4991c4dd7b50b74656011dea9c40464ff390c#n486
>> [4]
>> https://sourceware.org/git/?p=glibc.git;a=commit;h=59261ad3eb345e0d7b9f5c73e1a09d046991cea5
> 
> best regards
>  Waldemar
> 

_______________________________________________
devel mailing list
devel@uclibc-ng.org
https://mailman.uclibc-ng.org/cgi-bin/mailman/listinfo/devel

Reply via email to