[ELF][RISCV] Resolve branch relocations referencing undefined weak to current...
[ELF][RISCV] Resolve branch relocations referencing undefined weak to current location if not using PLT In a -no-pie link we optimize R_PLT_PC to R_PC. Currently we resolve a branch relocation to the link-time zero address. However such a choice tends to cause relocation overflow possibility for RISC architectures. * aarch64: GNU ld: rewrite the instruction to a NOP; ld.lld: branch to the next instruction * mips: GNU ld: branch to the start of the text segment (?); ld.lld: branch to zero * ppc32: GNU ld: rewrite the instruction to a NOP; ld.lld: branch to the current instruction * ppc64: GNU ld: rewrite the instruction to a NOP; ld.lld: branch to the current instruction * riscv: GNU ld: branch to the absolute zero address (with instruction rewriting) * i386/x86_64: GNU ld/ld.lld: branch to the link-time zero address I think that resolving to the same location is a good choice. The instruction, if triggered, is clearly an undefined behavior. Resolving to the same location can cause an infinite loop (making the user aware of the issue) while ensuring no overflow. Reviewed By: jrtc27 Differential Revision: https://reviews.llvm.org/D103001
Loading
Please sign in to comment