This patch fixes the following lld link errors:
- unsupported dynamic relocations on read-only sections
- out-of-range TOC references
This patch is derived from git_bdragon.rtk0.net work, that did most of
the changes in fact.
Differential D19352
Fix PPC64 kernel build with clang8 + lld8 bdragon on Feb 25 2019, 5:53 PM. Authored by Tags None Referenced Files
Details This patch fixes the following lld link errors:
This patch is derived from git_bdragon.rtk0.net work, that did most of Built and booted FreeBSD kernel with clang8 + lld8 on QEMU. Also checked that the kernel still compiles and works with base gcc + ld.
Diff Detail
Event TimelineComment Actions Regarding the sys/conf/Makefile.powerpc, sys/conf/kern.pre.mk and Regarding the linker script changes, I have been running with them for a very long time, but could always use more input on them. The main idea behind the linker script changes is to force a simplified header so that petitboot can successfully load it, but it also has some bugfixes in it. It may be possible to run without the linker script changes, but I haven't tried to. Caveat about elfv2 kernel:
This may be fixed for good in the future by providing a version of loader that runs inside petitboot as a petitboot plugin, but for now I've just been using my modified kexec to load. Comment Actions I've confirmed that a kernel with this change compiles fine with base gcc + ld, and works fine on both pseries (qemu+kvm) and powernv (power8 machine).
Comment Actions Some parts of this will land separately. The ldscript chanages are split off to D19574 as more cases have been discovered where kernels were built with multiple PT_LOAD sections, even on ELFv1, and it should probably go in first.
Comment Actions @alfredo.junior_eldorado.org.br and I found out that a kernel linked with lld won't boot if the .toc section is merged into .got. This needs further investigation to understand the real causes. Comment Actions Well, it's probably from the alignment being off. Ensuring alignment there makes sense to me imo. Checking what the actual requirements are... Comment Actions Yep, there is indeed an 8-byte alignment restriction on .toc. Comment Actions Commandeering this to post updated trap code.
Comment Actions Rewrote trap code to not waste valuable trap space for addresses that are easily calculatable. Comment Actions @luporl Feel free to commandeer this back again. Please do a test of the updated trap code with clang8/lld8. I have sucessfully booted this with my base/gcc 8.2.0. Comment Actions Going to work on some issues I noticed with the power_save_sequence.
Comment Actions This one is not tested properly yet but I wanted to bounce the idea off jhibbits.
Comment Actions @git_bdragon.rtk0.net, I haven't tested your last revision, but Alfredo and I have been using your previous revision for more than a month, both in ELFv1 environments as in ELFv2, with no issues so far, and it is essential for the ELFv2 transition on PPC. Wouldn't it be better to commit the previous version and put this last change in a new review, until it is tested? @jhibbits?
Comment Actions Remove DMAP_ZERO bits -- since we're in real mode while in the trap area, we can reach the magic trap address as TRAP_GENTRAP(0). |