[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 22:30:45 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:

It's challenging to use an inherent PC-relative specifier (e.g. `%pltpcrel`; which I actually thought about).... This is because 
in the code block around `llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:3477` (`AsmPrinter::lowerConstant`), the function doesn't actually know its current address. The function call needs a subtrahend. (`llvm/test/CodeGen/X86/x86-64-plt-relative-reloc.ll` contains a better test that demonstrates this: the subtrahend `vtable` might be a few bytes before the current address (that feature might be obsoleted by the dsolocal equivalent feature))

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


More information about the llvm-branch-commits mailing list