[PATCH] D143673: [lld][RISCV][WIP] Implement GP relaxation for R_RISCV_HI20/R_RISCV_LO12_I/R_RISCV_LO12_S.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 9 13:57:31 PST 2023


MaskRay added inline comments.


================
Comment at: lld/ELF/Arch/RISCV.cpp:442
+    Defined *gp = ElfSym::riscvGlobalPointer;
+    assert(gp && "Can't find GP pointer?");
+    int64_t displace = val - gp->getVA();
----------------
remove


================
Comment at: lld/ELF/Arch/RISCV.cpp:634
+                          Relocation &r, uint32_t &remove) {
+  uint64_t target = r.sym->getVA(r.addend);
+  Defined *gp = ElfSym::riscvGlobalPointer;
----------------
`const`. Actually avoid this used-once variable


================
Comment at: lld/ELF/Arch/RISCV.cpp:636
+  Defined *gp = ElfSym::riscvGlobalPointer;
+  if (gp) {
+    int64_t displace = target - gp->getVA();
----------------
early return


================
Comment at: lld/ELF/Options.td:237
 
+def gp_relax: F<"gp-relax">, HelpText<"Enable GP relaxation">;
+
----------------
Update lld/docs/ld.lld.1

Use `BB` to support `no-`. Don't add single-dash long options for new options.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143673/new/

https://reviews.llvm.org/D143673



More information about the llvm-commits mailing list