[PATCH] D138135: [lld][ELF] Support LoongArch

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 7 14:41:10 PDT 2023


MaskRay added inline comments.


================
Comment at: lld/ELF/Arch/LoongArch.cpp:360
+  case R_LARCH_PCALA_LO12:
+    // This may well be just R_ABS and nothing more, but unfortunately some
+    // people had the brilliant idea of reusing the R_LARCH_PCALA_LO12 reloc on
----------------
This wording may sound irony for a public project. Also, the paragraph is too long.

We could just R_ABS, but the JIRL instruction reuses the relocation type for a different purpose.
This questionable use case is part of glibc 2.37 Scrt1.o (is it true?), which is linked into user programs, so we have to work around it for a while, even if a new relocation type may be introduced in the future.

I wonder why the medium code model designer decides to use pcalau12i+jirl. Range extension thunks are much better.


================
Comment at: lld/ELF/Arch/LoongArch.cpp:370
+    //
+    // * R_LARCH_PCALA_LO12 just places its computed value unmodified, but JIRL
+    //   expects its immediate to be pre-shifted by 2 bits, making the reloc
----------------
The long description about "* R_LARCH_PCALA_LO12 just places its computed value unmodified" can be simplified to just mention that the computation is different.  How it is different is the job of the comment in `relocate`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138135



More information about the llvm-commits mailing list