[all-commits] [llvm/llvm-project] 691ca5: [RISCV] Emit .note.gnu.property section when Zicfi...

Ming-Yi Lai via All-commits all-commits at lists.llvm.org
Tue May 13 20:49:21 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 691ca556e04dafa3d755e975ea3432fbfd4ca9ad
      https://github.com/llvm/llvm-project/commit/691ca556e04dafa3d755e975ea3432fbfd4ca9ad
  Author: Ming-Yi Lai <ming-yi.lai at mediatek.com>
  Date:   2025-05-14 (Wed, 14 May 2025)

  Changed paths:
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h
    M llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
    A llvm/test/CodeGen/RISCV/note-gnu-property-zicfiss.ll

  Log Message:
  -----------
  [RISCV] Emit .note.gnu.property section when Zicfiss-based shadow stack is enabled (#127036)

RISC-V Zicfiss-based shadow stack needs to let the linker/loader know if
the binary is built with the mechanism enabled to support proper
link-time/load-time management of this feature. The information is
encoded as a bit in the `.note.gnu.property` section. This patch
implements emitting the section for RISC-V targets when Zicfiss-based
shadow stack is enabled.

When Clang receives the `-fcf-protection=return` flag, it adds the
`hw-shadow-stack` attribute to LLVM functions, and adds a non-zero
valued attribute named `cf-protection-return` to the LLVM module it
generates. The backend depends on the `hw-shadow-stack` attributes to
generate Zicfiss-based shadow stack instructions for each function, but
at the module scope, the `cf-protection-return` attribute is a better
indication of whether the translation unit is built with Zicfiss-based
shadow stack enabled, so this patch emits the `.note.gnu.property`
section with the "Zicfiss-based shadow stack" bit toggled on when it
sees the `cf-protection-return` attribute.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list