[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 15:03:38 PDT 2025


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

clang -fexperimental-relative-c++-abi-vtables might generate @plt and
@gotpcrel specifiers in data directives. The syntax is not used in
humand-written assembly code, and is not supported by GNU assembler.
Note: the `@plt` in `.word foo at plt` is different from
the legacy `call func at plt` (where `@plt` is simply ignored).

The @plt syntax was selected was simply due to a quirk of AsmParser:
the syntax was supported by all targets until I updated it
to be an opt-in feature in a0671758eb6e52a758bd1b096a9b421eec60204c

RISC-V favors the `%specifier(expr)` syntax following MIPS and Sparc,
and we should follow this convention.

This PR adds support for `.word %plt(foo-.)` and
`.word %gotpcreel(foo)` and drops `@plt` `@gotpcrel`.

* MCValue::SymA can no longer have a SymbolVariant. Add an assert
  similar to that of AArch64ELFObjectWriter.cpp before
  https://reviews.llvm.org/D81446 (see my analysis at
  https://maskray.me/blog/2025-03-16-relocation-generation-in-assemblers
  if intrigued)
* `jump foo at plt, x31` now has a different diagnostic.





More information about the llvm-branch-commits mailing list