mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-03 09:00:21 +00:00
f39b4f8899
lld on RISC-V is not yet able to handle undefined weak symbols for non-PIC code in the code model (medany/medium) used by the RISC-V kernel. Both GCC and clang emit an auipc / addi pair of instructions to generate an address relative to the current PC with a 31-bit offset. Undefined weak symbols need to have an address of 0, but the kernel runs with PC values much greater than 2^31, so there is no way to construct a NULL pointer as a PC-relative value. The bfd linker rewrites the instruction pair to use lui / addi with values of 0 to force a NULL pointer address. (There are similar cases for 'ld' becoming auipc / ld that bfd rewrites to lui / ld with an address of 0.) To work around this, compile the kernel with -fPIE when using lld. This does not make the kernel position-independent, but it does force the compiler to indirect address lookups through GOT entries (so auipc / ld against a GOT entry to fetch the address). This adds extra memory indirections for global symbols, so should be disabled once lld is finally fixed. A few 'la' instructions in locore that depend on PC-relative addressing to load physical addresses before paging is enabled have to use auipc / addi and not indirect via GOT entries, so change those to use 'lla' which always uses auipc / addi for both PIC and non-PIC. Submitted by: jrtc27 Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D23064 |
||
---|---|---|
.. | ||
config.mk | ||
dtb.build.mk | ||
dtb.mk | ||
files | ||
files.amd64 | ||
files.arm | ||
files.arm64 | ||
files.i386 | ||
files.mips | ||
files.powerpc | ||
files.riscv | ||
files.sparc64 | ||
files.x86 | ||
kern.mk | ||
kern.opts.mk | ||
kern.post.mk | ||
kern.pre.mk | ||
kmod_syms_prefix.awk | ||
kmod_syms.awk | ||
kmod.mk | ||
kmod.opts.mk | ||
ldscript.amd64 | ||
ldscript.arm | ||
ldscript.arm64 | ||
ldscript.i386 | ||
ldscript.kmod.amd64 | ||
ldscript.kmod.i386 | ||
ldscript.mips | ||
ldscript.mips.cfe | ||
ldscript.mips.mips64 | ||
ldscript.mips.octeon1 | ||
ldscript.powerpc | ||
ldscript.powerpc64 | ||
ldscript.powerpcspe | ||
ldscript.riscv | ||
ldscript.sparc64 | ||
Makefile.amd64 | ||
Makefile.arm | ||
Makefile.arm64 | ||
Makefile.i386 | ||
Makefile.mips | ||
Makefile.powerpc | ||
Makefile.riscv | ||
Makefile.sparc64 | ||
makeLINT.mk | ||
makeLINT.sed | ||
newvers.sh | ||
NOTES | ||
options | ||
options.amd64 | ||
options.arm | ||
options.arm64 | ||
options.i386 | ||
options.mips | ||
options.powerpc | ||
options.riscv | ||
options.sparc64 | ||
systags.sh | ||
WITHOUT_SOURCELESS | ||
WITHOUT_SOURCELESS_HOST | ||
WITHOUT_SOURCELESS_UCODE |