[all-commits] [llvm/llvm-project] ab1c25: [RISCV] Assemble `call foo` to R_RISCV_CALL_PLT

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Sep 13 18:48:11 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ab1c2596137220e1165115fa9079373aa0d1823b
      https://github.com/llvm/llvm-project/commit/ab1c2596137220e1165115fa9079373aa0d1823b
  Author: Fangrui Song <i at maskray.me>
  Date:   2022-09-13 (Tue, 13 Sep 2022)

  Changed paths:
    M lld/test/ELF/riscv-call.s
    M lld/test/ELF/riscv-undefined-weak.s
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp
    M llvm/test/ExecutionEngine/JITLink/RISCV/ELF_pc_indirect.s
    M llvm/test/MC/RISCV/function-call.s
    M llvm/test/MC/RISCV/linker-relaxation.s
    M llvm/test/MC/RISCV/option-pushpop.s
    M llvm/test/MC/RISCV/option-relax.s
    M llvm/test/MC/RISCV/pseudo-jump.s
    M llvm/test/MC/RISCV/tail-call.s

  Log Message:
  -----------
  [RISCV] Assemble `call foo` to R_RISCV_CALL_PLT

R_RISCV_CALL/R_RISCV_CALL_PLT distinction isn't necessary. R_RISCV_CALL has been
deprecated as a resolution to
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/98 .

ld.lld and mold treat the two relocation types the same. GNU ld has a custom
handling for undefined weak functions which is unnecessary: calling an
unresolved undefined weak function is UB and GNU ld can handle the case without
a relocation error (such a function call is usually guarded by a zero value
check and should be allowed).

This patch assembles `call foo` to use R_RISCV_CALL_PLT instead of the
deprecated R_RISCV_CALL.

Note: the code generator still differentiates `call foo` and (maybe preemptible)
`call foo at plt`, but the difference is purely aesthetic.

Note: D105429 does not support R_RISCV_CALL_PLT correctly. Changed the test to
force R_RISCV_CALL for now.

Reviewed By: kito-cheng

Differential Revision: https://reviews.llvm.org/D132530




More information about the All-commits mailing list