[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


================
@@ -45,7 +45,18 @@ class RISCV final : public TargetInfo {
                 uint64_t val) const override;
   void relocateAlloc(InputSectionBase &sec, uint8_t *buf) const override;
   bool relaxOnce(int pass) const override;
+  template <class ELFT, class RelTy>
+  bool synthesizeAlignOne(uint64_t &dot, InputSection *sec, Relocs<RelTy> rels);
+  template <class ELFT, class RelTy>
+  void synthesizeAlignEnd(uint64_t &dot, InputSection *sec, Relocs<RelTy> rels);
+  template <class ELFT>
+  bool synthesizeAlignAux(uint64_t &dot, InputSection *sec);
+  bool maybeSynthesizeAlign(uint64_t &dot, InputSection *sec) override;
   void finalizeRelax(int passes) const override;
+
+  // Used by synthesized ALIGN relocations.
+  InputSection *baseSec = nullptr;
+  SmallVector<std::pair<uint64_t, uint64_t>, 0> synthesizedAligns;
----------------
mysterymath wrote:

This could use a comment describing the semantics of the two integral components of the pair. I did immediately have a guess, but I also couldn't think of any convention that strongly motivates that guess.

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


More information about the llvm-commits mailing list