diff options
author | Yann Sionneau <yann@sionneau.net> | 2021-06-03 07:40:39 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2021-06-04 16:22:31 +0200 |
commit | ca958dc21e854734630870f38975ff05eb930f6d (patch) | |
tree | aecf66c73b56dfde3aa7eacfa27f3ded94bb9e5e /ldso/libdl | |
parent | 85ac4f04d94e98389a8315e720630d0f95bfdfd6 (diff) |
powerpc: fix PIE/PIC builds with newer gcc/binutils which use secureplt by default
This patch fixes segfault of all user space processes (including init, which caused a panic) on recent buildroot powerpc32 builds.
The issue has been reported by Romain Naour in this thread: https://mailman.uclibc-ng.org/pipermail/devel/2021-May/002068.html
Recent buildroot toolchain enables secure PLT in powerpc gcc.
The latter will then supply -msecure-plt to gas invocations by default.
Recent buildroot also enables PIE by defaults.
For the secure PLT to work in PIC, the r30 register needs to point to the GOT.
Old "bss plt" was just a one-instruction-wide PLT slot, pointed-to by a R_PPC_JMP_SLOT relocation, which was written on-the-fly to contain a branch instruction to the correct address. It therefore had to stay writable.
New secure PLT only contains read-only code which loads the branch address from the writable GOT.
Note: secure PLT without PIC does not need r30 to be set. Because offset between plt stub code and got is known at link-time. In this case the PLT entry looks like:
1009b3e0 <__uClibc_main@plt>:
1009b3e0: 3d 60 10 0e lis r11,4110
1009b3e4: 81 6b 03 74 lwz r11,884(r11)
1009b3e8: 7d 69 03 a6 mtctr r11
1009b3ec: 4e 80 04 20 bctr
Whereas secure PLT with PIC - offset between plt and got is unknown at link-time - looks like this:
000af800 <00000000.plt_pic32.__uClibc_main>:
af800: 81 7e 03 80 lwz r11,896(r30)
af804: 7d 69 03 a6 mtctr r11
af808: 4e 80 04 20 bctr
af80c: 60 00 00 00 nop
Signed-off-by: Yann Sionneau <yann@sionneau.net>
Diffstat (limited to 'ldso/libdl')
0 files changed, 0 insertions, 0 deletions