[lld] [ELF] -r: Synthesize R_RISCV_ALIGN at input section start (PR #151639)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 5 01:14:02 PDT 2025


================
@@ -1543,6 +1543,8 @@ template <class ELFT> void Writer<ELFT>::finalizeAddressDependentContent() {
 
   uint32_t pass = 0, assignPasses = 0;
   for (;;) {
+    if (ctx.arg.relocatable)
----------------
smithp35 wrote:

I agree that it shouldn't be called with -r in its current implementation. Especially if the output of -r is not a kernel module and is relinked with additional object files.

It could be made to work with the -r relink case but it would need to emit relocations that could be processed by the subsequent link phase. As MaskRay says, this would only help with the relocatable link that creates a section larger than the branch range which at least up to now I haven't seen yet. 

https://github.com/llvm/llvm-project/pull/151639


More information about the llvm-commits mailing list