[llvm-branch-commits] [RISCV] Replace @plt/@gotpcrel in data directives with %plt %gotpcrel (PR #132569)

Fangrui Song via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Mar 22 20:35:03 PDT 2025


================
@@ -18,6 +18,6 @@
 .globl _start
 _start:
 .data
-  .word foo at PLT - .
-  .word foo at PLT - . + 1
-  .word foo at PLT - . - 1
+  .word %plt(foo - .)
----------------
MaskRay wrote:

The core principle is that relocation specifiers must operate on the full expression, not just a part of it.
This would avoid a lot of complexity/ambiguity in parsing and expression folding.

`.word %plt(foo - .)` might look unusual. It describes a PC-relative relocatable expression.
We evaluate it to a relocatable expression (`relocation_specifier(sym_a - sym_b + offset)`), and allows the referenced "addend" (sym_a) to be a PLT.

`.word %plt(foo)` describes an absolute reference to foo's PLT, which we don't support.


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


More information about the llvm-branch-commits mailing list