Hello Waldemar,
Le 21/05/2021 à 10:34, Waldemar Brodkorb a écrit :
Hi Romain,
can you confirm that attached patch works for you?
I tested with non-PIE and PIE and both seems to work.
Thanks for your feedback.
Indeed, removing the code enabled by HAVE_ASM_PPC_REL16 allow to boot the system
(We could also remove entirely the PPC_HAS_REL16 test from Rules.mak) but I
would keep this code instead (based on Glibc code history analysis).
Yann Sionneau seems to have an interesting findings.
Best regards,
Romain
best regards
Waldemar
Romain Naour wrote,
> 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#…
>
> 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=810ba387bec3c5b6904e8893fb4c…
>>> [2]
>>>
https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/libc/sysdeps/linux/p…
>>> [3]
>>>
https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/Rules.mak?id=2bf4991…
>>> [4]
>>>
https://sourceware.org/git/?p=glibc.git;a=commit;h=59261ad3eb345e0d7b9f5c73…
>>
>> best regards
>> Waldemar
>>
>