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

Daniel Thornburgh via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 14:38:29 PDT 2025


================
@@ -1230,6 +1230,9 @@ bool LinkerScript::assignOffsets(OutputSection *sec) {
   if (sec->firstInOverlay)
     state->overlaySize = 0;
 
+  bool synthesizeAlign = ctx.arg.relocatable && ctx.arg.relax &&
+                         (sec->flags & SHF_EXECINSTR) &&
+                         ctx.arg.emachine == EM_RISCV;
----------------
mysterymath wrote:

It might be unlikely that another target would need this, but conceptually, it seems like the determination of whether a call to `maybeSynthesizeAlign` is needed should be a target hook.

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


More information about the llvm-commits mailing list