[lld] [LLD][ELF][RISCV] Handle .note.gnu.property sections for Zicfilp/Zicfiss features (PR #127193)

Ming-Yi Lai via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 19 01:33:06 PST 2025


https://github.com/mylai-mtk updated https://github.com/llvm/llvm-project/pull/127193

>From 3daf6a912535b0bcc87bf6e1a8d558733d3e1b80 Mon Sep 17 00:00:00 2001
From: Ming-Yi Lai <ming-yi.lai at mediatek.com>
Date: Fri, 24 Jan 2025 17:51:08 +0800
Subject: [PATCH 1/6] [LLD][ELF][RISCV] Handle .note.gnu.property sections for
 Zicfilp/Zicfiss features

RISC-V Zicfilp/Zicfiss features indicate their adoptions as bits in the
`.note.gnu.property` section of ELF files. This patch enables LLD to process
the information correctly by parsing, checking and merging the bits from all
input ELF files and writing the merged result to the output ELF file.

These feature bits are encoded as a mask in each input ELF files and intended
to be "and"-ed together to check that all input files support a particular
feature.

For RISC-V Zicfilp features, there are 2 conflicting bits allocated:
GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED and
GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG. They represent the adoption of
the forward edge protection of control-flow integrity with the "unlabeled" or
"func-sig" policy. Since these 2 policies conflicts with each other, these 2
bits also conflicts with each other. This patch adds the `-z
zicfilp-unlabeled-report=none|warning|error` and `-z
zicfilp-func-sig-report=none|warning|error` commandline options to make LLD
report files that do not have the expected bits toggled on.

For RISC-V Zicfiss feature, there's only one bit allocated:
GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS. This bit indicates that the ELF file
supports Zicfiss-based shadow stack. This patch adds the `-z
zicfiss-report=none|warning|error` commandline option to make LLD report files
that do not have the expected bit toggled on.
---
 lld/ELF/Config.h                              |   3 +
 lld/ELF/Driver.cpp                            |  50 +++-
 lld/ELF/InputFiles.cpp                        |  29 +-
 lld/ELF/SyntheticSections.cpp                 |  22 +-
 lld/test/ELF/riscv-feature-zicfilp-func-sig.s | 201 ++++++++++++++
 .../ELF/riscv-feature-zicfilp-unlabeled.s     | 254 ++++++++++++++++++
 lld/test/ELF/riscv-feature-zicfiss.s          | 201 ++++++++++++++
 7 files changed, 744 insertions(+), 16 deletions(-)
 create mode 100644 lld/test/ELF/riscv-feature-zicfilp-func-sig.s
 create mode 100644 lld/test/ELF/riscv-feature-zicfilp-unlabeled.s
 create mode 100644 lld/test/ELF/riscv-feature-zicfiss.s

diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h
index f132b11b20c63..e452d27828779 100644
--- a/lld/ELF/Config.h
+++ b/lld/ELF/Config.h
@@ -229,6 +229,9 @@ struct Config {
   StringRef zCetReport = "none";
   StringRef zPauthReport = "none";
   StringRef zGcsReport = "none";
+  StringRef zZicfilpUnlabeledReport = "none";
+  StringRef zZicfilpFuncSigReport = "none";
+  StringRef zZicfissReport = "none";
   bool ltoBBAddrMap;
   llvm::StringRef ltoBasicBlockSections;
   std::pair<llvm::StringRef, llvm::StringRef> thinLTOObjectSuffixReplace;
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 7d14180a49926..2500f58df55cc 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -414,8 +414,18 @@ static void checkOptions(Ctx &ctx) {
           << "--pcrel-optimize is only supported on PowerPC64 targets";
   }
 
-  if (ctx.arg.relaxGP && ctx.arg.emachine != EM_RISCV)
-    ErrAlways(ctx) << "--relax-gp is only supported on RISC-V targets";
+  if (ctx.arg.emachine != EM_RISCV) {
+    if (ctx.arg.relaxGP)
+      ErrAlways(ctx) << "--relax-gp is only supported on RISC-V targets";
+    if (ctx.arg.zZicfilpUnlabeledReport != "none")
+      ErrAlways(ctx) << "-z zicfilip-unlabeled-report is only supported on "
+                        "RISC-V targets";
+    if (ctx.arg.zZicfilpFuncSigReport != "none")
+      ErrAlways(ctx) << "-z zicfilip-func-sig-report is only supported on "
+                        "RISC-V targets";
+    if (ctx.arg.zZicfissReport != "none")
+      ErrAlways(ctx) << "-z zicfiss-report is only supported on RISC-V targets";
+  }
 
   if (ctx.arg.emachine != EM_386 && ctx.arg.emachine != EM_X86_64 &&
       ctx.arg.zCetReport != "none")
@@ -1623,7 +1633,12 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
   auto reports = {std::make_pair("bti-report", &ctx.arg.zBtiReport),
                   std::make_pair("cet-report", &ctx.arg.zCetReport),
                   std::make_pair("gcs-report", &ctx.arg.zGcsReport),
-                  std::make_pair("pauth-report", &ctx.arg.zPauthReport)};
+                  std::make_pair("pauth-report", &ctx.arg.zPauthReport),
+                  std::make_pair("zicfilp-unlabeled-report",
+                                 &ctx.arg.zZicfilpUnlabeledReport),
+                  std::make_pair("zicfilp-func-sig-report",
+                                 &ctx.arg.zZicfilpFuncSigReport),
+                  std::make_pair("zicfiss-report", &ctx.arg.zZicfissReport)};
   for (opt::Arg *arg : args.filtered(OPT_z)) {
     std::pair<StringRef, StringRef> option =
         StringRef(arg->getValue()).split('=');
@@ -2796,7 +2811,7 @@ static void redirectSymbols(Ctx &ctx, ArrayRef<WrappedSymbol> wrapped) {
 // ones can be allowed (see -z pauth-report).
 static void readSecurityNotes(Ctx &ctx) {
   if (ctx.arg.emachine != EM_386 && ctx.arg.emachine != EM_X86_64 &&
-      ctx.arg.emachine != EM_AARCH64)
+      ctx.arg.emachine != EM_AARCH64 && ctx.arg.emachine != EM_RISCV)
     return;
 
   ctx.arg.andFeatures = -1;
@@ -2852,6 +2867,33 @@ static void readSecurityNotes(Ctx &ctx) {
         << ": -z cet-report: file does not have "
            "GNU_PROPERTY_X86_FEATURE_1_SHSTK property";
 
+    if (ctx.arg.emachine == EM_RISCV) {
+      reportUnless(ctx.arg.zZicfilpUnlabeledReport,
+                   features & GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED)
+          << f
+          << ": -z zicfilp-unlabeled-report: file does not have "
+             "GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED property";
+
+      reportUnless(ctx.arg.zZicfilpFuncSigReport,
+                   features & GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG)
+          << f
+          << ": -z zicfilp-func-sig-report: file does not have "
+             "GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG property";
+
+      if ((features & GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED) &&
+          (features & GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG))
+        Err(ctx) << f
+                 << ": file has conflicting properties: "
+                    "GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED and "
+                    "GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG";
+
+      reportUnless(ctx.arg.zZicfissReport,
+                   features & GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS)
+          << f
+          << ": -z zicfiss-report: file does not have "
+             "GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS property";
+    }
+
     if (ctx.arg.zForceBti && !(features & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)) {
       features |= GNU_PROPERTY_AARCH64_FEATURE_1_BTI;
       if (ctx.arg.zBtiReport == "none")
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index d43de8ce6dfef..060ea38112fd0 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -920,7 +920,7 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
 
 // Read the following info from the .note.gnu.property section and write it to
 // the corresponding fields in `ObjFile`:
-// - Feature flags (32 bits) representing x86 or AArch64 features for
+// - Feature flags (32 bits) representing x86, AArch64 or RISC-V features for
 //   hardware-assisted call flow control;
 // - AArch64 PAuth ABI core info (16 bytes).
 template <class ELFT>
@@ -929,6 +929,22 @@ static void readGnuProperty(Ctx &ctx, const InputSection &sec,
   using Elf_Nhdr = typename ELFT::Nhdr;
   using Elf_Note = typename ELFT::Note;
 
+  uint32_t featureAndType;
+  switch (ctx.arg.emachine) {
+  case EM_386:
+  case EM_X86_64:
+    featureAndType = GNU_PROPERTY_X86_FEATURE_1_AND;
+    break;
+  case EM_AARCH64:
+    featureAndType = GNU_PROPERTY_AARCH64_FEATURE_1_AND;
+    break;
+  case EM_RISCV:
+    featureAndType = GNU_PROPERTY_RISCV_FEATURE_1_AND;
+    break;
+  default:
+    return;
+  }
+
   ArrayRef<uint8_t> data = sec.content();
   auto err = [&](const uint8_t *place) -> ELFSyncStream {
     auto diag = Err(ctx);
@@ -949,10 +965,6 @@ static void readGnuProperty(Ctx &ctx, const InputSection &sec,
       continue;
     }
 
-    uint32_t featureAndType = ctx.arg.emachine == EM_AARCH64
-                                  ? GNU_PROPERTY_AARCH64_FEATURE_1_AND
-                                  : GNU_PROPERTY_X86_FEATURE_1_AND;
-
     // Read a body of a NOTE record, which consists of type-length-value fields.
     ArrayRef<uint8_t> desc = note.getDesc(sec.addralign);
     while (!desc.empty()) {
@@ -1050,9 +1062,10 @@ InputSectionBase *ObjFile<ELFT>::createInputSection(uint32_t idx,
     }
 
     // Object files that use processor features such as Intel Control-Flow
-    // Enforcement (CET) or AArch64 Branch Target Identification BTI, use a
-    // .note.gnu.property section containing a bitfield of feature bits like the
-    // GNU_PROPERTY_X86_FEATURE_1_IBT flag. Read a bitmap containing the flag.
+    // Enforcement (CET), AArch64 Branch Target Identification BTI or RISC-V
+    // Zicfilp/Zicfiss extensions, use a .note.gnu.property section containing
+    // a bitfield of feature bits like the GNU_PROPERTY_X86_FEATURE_1_IBT flag.
+    // Read a bitmap containing the flag.
     //
     // Since we merge bitmaps from multiple object files to create a new
     // .note.gnu.property containing a single AND'ed bitmap, we discard an input
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index b03c4282ab1aa..a63368597238e 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -325,15 +325,29 @@ GnuPropertySection::GnuPropertySection(Ctx &ctx)
                        ctx.arg.wordsize) {}
 
 void GnuPropertySection::writeTo(uint8_t *buf) {
+  uint32_t featureAndType;
+  switch (ctx.arg.emachine) {
+  case EM_386:
+  case EM_X86_64:
+    featureAndType = GNU_PROPERTY_X86_FEATURE_1_AND;
+    break;
+  case EM_AARCH64:
+    featureAndType = GNU_PROPERTY_AARCH64_FEATURE_1_AND;
+    break;
+  case EM_RISCV:
+    featureAndType = GNU_PROPERTY_RISCV_FEATURE_1_AND;
+    break;
+  default:
+    Err(ctx) << "(e_machine) " << ctx.arg.emachine
+             << ": e_machine does not support .note.gnu.property section";
+    return;
+  }
+
   write32(ctx, buf, 4);                          // Name size
   write32(ctx, buf + 4, getSize() - 16);         // Content size
   write32(ctx, buf + 8, NT_GNU_PROPERTY_TYPE_0); // Type
   memcpy(buf + 12, "GNU", 4);               // Name string
 
-  uint32_t featureAndType = ctx.arg.emachine == EM_AARCH64
-                                ? GNU_PROPERTY_AARCH64_FEATURE_1_AND
-                                : GNU_PROPERTY_X86_FEATURE_1_AND;
-
   unsigned offset = 16;
   if (ctx.arg.andFeatures != 0) {
     write32(ctx, buf + offset + 0, featureAndType);      // Feature type
diff --git a/lld/test/ELF/riscv-feature-zicfilp-func-sig.s b/lld/test/ELF/riscv-feature-zicfilp-func-sig.s
new file mode 100644
index 0000000000000..21cd348b3403e
--- /dev/null
+++ b/lld/test/ELF/riscv-feature-zicfilp-func-sig.s
@@ -0,0 +1,201 @@
+# REQUIRES: riscv
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func1-zicfilp.s -o rv32-func1-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu func2.s -o rv32-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func2-zicfilp.s -o rv32-func2-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu func3.s -o rv32-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func3-zicfilp.s -o rv32-func3-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func1-zicfilp.s -o rv64-func1-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu func2.s -o rv64-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func2-zicfilp.s -o rv64-func2-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu func3.s -o rv64-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func3-zicfilp.s -o rv64-func3-zicfilp.o
+
+## ZICFILP-func-sig should be enabled when it's enabled in all inputs
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-FUNC-SIG %s
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func3-zicfilp.o --shared -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-FUNC-SIG %s
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-FUNC-SIG %s
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func3-zicfilp.o --shared -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-FUNC-SIG %s
+# ZICFILP-FUNC-SIG: Properties: RISC-V feature: ZICFILP-func-sig
+
+## ZICFILP-func-sig should not be enabled if it's not enabled in at least one input.
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2.o rv32-func3-zicfilp.o -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv32-func2-zicfilp.o rv32-func3.o --shared -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2.o rv64-func3-zicfilp.o -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv64-func2-zicfilp.o rv64-func3.o --shared -o - | llvm-readelf -n - | count 0
+
+## zicfilp-func-sig-report should report any input files that don't have the zicfilp-func-sig property.
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2.o rv32-func3-zicfilp.o -o /dev/null -z zicfilp-func-sig-report=warning 2>&1 | FileCheck --check-prefix=MISS-LP-WARN %s
+# RUN: not ld.lld rv32-func2-zicfilp.o rv32-func3.o --shared -o /dev/null -z zicfilp-func-sig-report=error 2>&1 | FileCheck --check-prefix=MISS-LP-ERROR %s
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o /dev/null -z zicfilp-func-sig-report=warning 2>&1 | count 0
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o /dev/null -z zicfilp-func-sig-report=error 2>&1 | count 0
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2.o rv64-func3-zicfilp.o -o /dev/null -z zicfilp-func-sig-report=warning 2>&1 | FileCheck --check-prefix=MISS-LP-WARN %s
+# RUN: not ld.lld rv64-func2-zicfilp.o rv64-func3.o --shared -o /dev/null -z zicfilp-func-sig-report=error 2>&1 | FileCheck --check-prefix=MISS-LP-ERROR %s
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -o /dev/null -z zicfilp-func-sig-report=warning 2>&1 | count 0
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -o /dev/null -z zicfilp-func-sig-report=error 2>&1 | count 0
+# MISS-LP-WARN: warning: rv{{32|64}}-func2.o: -z zicfilp-func-sig-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG property
+# MISS-LP-ERROR: error: rv{{32|64}}-func3.o: -z zicfilp-func-sig-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG property
+
+## An invalid -z zicfilp-func-sig-report option should give an error
+# RUN: not ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -z zicfilp-func-sig-report=nonsense 2>&1 | FileCheck --check-prefix=INVALID-REPORT %s
+# RUN: not ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -z zicfilp-func-sig-report=nonsense 2>&1 | FileCheck --check-prefix=INVALID-REPORT %s
+# INVALID-REPORT: error: -z zicfilp-func-sig-report= parameter nonsense is not recognized
+
+#--- rv32-func1-zicfilp.s
+
+.section ".note.gnu.property", "a"
+.balign 4
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 4
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 4          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG
+.balign 4
+ndesc_end:
+
+.text
+.globl _start
+.type func1,%function
+func1:
+  call func2
+  ret
+
+#--- rv64-func1-zicfilp.s
+
+.section ".note.gnu.property", "a"
+.balign 8
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 8
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 4          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG
+.balign 8
+ndesc_end:
+
+.text
+.globl _start
+.type func1,%function
+func1:
+  call func2
+  ret
+
+#--- func2.s
+
+.text
+.globl func2
+.type func2, at function
+func2:
+  .globl func3
+  .type func3, @function
+  call func3
+  ret
+
+#--- rv32-func2-zicfilp.s
+
+.section ".note.gnu.property", "a"
+.balign 4
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 4
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 4          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG
+.balign 4
+ndesc_end:
+
+.text
+.globl func2
+.type func2, at function
+func2:
+  .globl func3
+  .type func3, @function
+  call func3
+  ret
+
+#--- rv64-func2-zicfilp.s
+
+.section ".note.gnu.property", "a"
+.balign 8
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 8
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 4          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG
+.balign 8
+ndesc_end:
+
+.text
+.globl func2
+.type func2, at function
+func2:
+  .globl func3
+  .type func3, @function
+  call func3
+  ret
+
+#--- func3.s
+
+.text
+.globl func3
+.type func3, at function
+func3:
+  ret
+
+#--- rv32-func3-zicfilp.s
+
+.section ".note.gnu.property", "a"
+.balign 4
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 4
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 4          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG
+.balign 4
+ndesc_end:
+
+.text
+.globl func3
+.type func3, at function
+func3:
+  ret
+
+#--- rv64-func3-zicfilp.s
+
+.section ".note.gnu.property", "a"
+.balign 8
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 8
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 4          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG
+.balign 8
+ndesc_end:
+
+.text
+.globl func3
+.type func3, at function
+func3:
+  ret
diff --git a/lld/test/ELF/riscv-feature-zicfilp-unlabeled.s b/lld/test/ELF/riscv-feature-zicfilp-unlabeled.s
new file mode 100644
index 0000000000000..5c244e8e44500
--- /dev/null
+++ b/lld/test/ELF/riscv-feature-zicfilp-unlabeled.s
@@ -0,0 +1,254 @@
+# REQUIRES: riscv
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func1-zicfilp.s -o rv32-func1-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func1-zicfilp-conflict.s -o rv32-func1-zicfilp-conflict.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu func2.s -o rv32-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func2-zicfilp.s -o rv32-func2-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu func3.s -o rv32-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func3-zicfilp.s -o rv32-func3-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func1-zicfilp.s -o rv64-func1-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func1-zicfilp-conflict.s -o rv64-func1-zicfilp-conflict.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu func2.s -o rv64-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func2-zicfilp.s -o rv64-func2-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu func3.s -o rv64-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func3-zicfilp.s -o rv64-func3-zicfilp.o
+
+## ZICFILP-unlabeled should be enabled when it's enabled in all inputs
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-UNLABELED %s
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func3-zicfilp.o --shared -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-UNLABELED %s
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-UNLABELED %s
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func3-zicfilp.o --shared -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-UNLABELED %s
+# ZICFILP-UNLABELED: Properties: RISC-V feature: ZICFILP-unlabeled
+
+## ZICFILP-unlabeled should not be enabled if it's not enabled in at least one input.
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2.o rv32-func3-zicfilp.o -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv32-func2-zicfilp.o rv32-func3.o --shared -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2.o rv64-func3-zicfilp.o -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv64-func2-zicfilp.o rv64-func3.o --shared -o - | llvm-readelf -n - | count 0
+
+## ZICFILP-unlabeled and ZICFILP-func-sig should conflict with each other
+# RUN: not ld.lld rv32-func1-zicfilp-conflict.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o /dev/null 2>&1 | FileCheck --check-prefix UNLABELED-FUNC-SIG-CONFLICT %s
+# RUN: not ld.lld rv64-func1-zicfilp-conflict.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -o /dev/null 2>&1 | FileCheck --check-prefix UNLABELED-FUNC-SIG-CONFLICT %s
+# UNLABELED-FUNC-SIG-CONFLICT: rv{{32|64}}-func1-zicfilp-conflict.o: file has conflicting properties: GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED and GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG
+
+## zicfilp-unlabeled-report should report any input files that don't have the zicfilp-unlabeled property.
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2.o rv32-func3-zicfilp.o -o /dev/null -z zicfilp-unlabeled-report=warning 2>&1 | FileCheck --check-prefix=MISS-LP-WARN %s
+# RUN: not ld.lld rv32-func2-zicfilp.o rv32-func3.o --shared -o /dev/null -z zicfilp-unlabeled-report=error 2>&1 | FileCheck --check-prefix=MISS-LP-ERROR %s
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o /dev/null -z zicfilp-unlabeled-report=warning 2>&1 | count 0
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o /dev/null -z zicfilp-unlabeled-report=error 2>&1 | count 0
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2.o rv64-func3-zicfilp.o -o /dev/null -z zicfilp-unlabeled-report=warning 2>&1 | FileCheck --check-prefix=MISS-LP-WARN %s
+# RUN: not ld.lld rv64-func2-zicfilp.o rv64-func3.o --shared -o /dev/null -z zicfilp-unlabeled-report=error 2>&1 | FileCheck --check-prefix=MISS-LP-ERROR %s
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -o /dev/null -z zicfilp-unlabeled-report=warning 2>&1 | count 0
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -o /dev/null -z zicfilp-unlabeled-report=error 2>&1 | count 0
+# MISS-LP-WARN: warning: rv{{32|64}}-func2.o: -z zicfilp-unlabeled-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED property
+# MISS-LP-ERROR: error: rv{{32|64}}-func3.o: -z zicfilp-unlabeled-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED property
+
+## An invalid -z zicfilp-unlabeled-report option should give an error
+# RUN: not ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -z zicfilp-unlabeled-report=nonsense 2>&1 | FileCheck --check-prefix=INVALID-REPORT %s
+# RUN: not ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -z zicfilp-unlabeled-report=nonsense 2>&1 | FileCheck --check-prefix=INVALID-REPORT %s
+# INVALID-REPORT: error: -z zicfilp-unlabeled-report= parameter nonsense is not recognized
+
+#--- rv32-func1-zicfilp.s
+
+.section ".note.gnu.property", "a"
+.balign 4
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 4
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 1          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED
+.balign 4
+ndesc_end:
+
+.text
+.globl _start
+.type func1,%function
+func1:
+  call func2
+  ret
+
+#--- rv64-func1-zicfilp.s
+
+.section ".note.gnu.property", "a"
+.balign 8
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 8
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 1          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED
+.balign 8
+ndesc_end:
+
+.text
+.globl _start
+.type func1,%function
+func1:
+  call func2
+  ret
+
+#--- rv32-func1-zicfilp-conflict.s
+
+.section ".note.gnu.property", "a"
+.balign 4
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 4
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 5          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED | GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG
+.balign 4
+ndesc_end:
+
+.text
+.globl _start
+.type func1,%function
+func1:
+  call func2
+  ret
+
+#--- rv64-func1-zicfilp-conflict.s
+
+.section ".note.gnu.property", "a"
+.balign 8
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 8
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 5          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED | GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG
+.balign 8
+ndesc_end:
+
+.text
+.globl _start
+.type func1,%function
+func1:
+  call func2
+  ret
+
+#--- func2.s
+
+.text
+.globl func2
+.type func2, at function
+func2:
+  .globl func3
+  .type func3, @function
+  call func3
+  ret
+
+#--- rv32-func2-zicfilp.s
+
+.section ".note.gnu.property", "a"
+.balign 4
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 4
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 1          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED
+.balign 4
+ndesc_end:
+
+.text
+.globl func2
+.type func2, at function
+func2:
+  .globl func3
+  .type func3, @function
+  call func3
+  ret
+
+#--- rv64-func2-zicfilp.s
+
+.section ".note.gnu.property", "a"
+.balign 8
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 8
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 1          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED
+.balign 8
+ndesc_end:
+
+.text
+.globl func2
+.type func2, at function
+func2:
+  .globl func3
+  .type func3, @function
+  call func3
+  ret
+
+#--- func3.s
+
+.text
+.globl func3
+.type func3, at function
+func3:
+  ret
+
+#--- rv32-func3-zicfilp.s
+
+.section ".note.gnu.property", "a"
+.balign 4
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 4
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 1          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED
+.balign 4
+ndesc_end:
+
+.text
+.globl func3
+.type func3, at function
+func3:
+  ret
+
+#--- rv64-func3-zicfilp.s
+
+.section ".note.gnu.property", "a"
+.balign 8
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 8
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 1          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED
+.balign 8
+ndesc_end:
+
+.text
+.globl func3
+.type func3, at function
+func3:
+  ret
diff --git a/lld/test/ELF/riscv-feature-zicfiss.s b/lld/test/ELF/riscv-feature-zicfiss.s
new file mode 100644
index 0000000000000..d6be9ee6b011e
--- /dev/null
+++ b/lld/test/ELF/riscv-feature-zicfiss.s
@@ -0,0 +1,201 @@
+# REQUIRES: riscv
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func1-zicfiss.s -o rv32-func1-zicfiss.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu func2.s -o rv32-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func2-zicfiss.s -o rv32-func2-zicfiss.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu func3.s -o rv32-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func3-zicfiss.s -o rv32-func3-zicfiss.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func1-zicfiss.s -o rv64-func1-zicfiss.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu func2.s -o rv64-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func2-zicfiss.s -o rv64-func2-zicfiss.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu func3.s -o rv64-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func3-zicfiss.s -o rv64-func3-zicfiss.o
+
+## ZICFISS should be enabled when it's enabled in all inputs
+# RUN: ld.lld rv32-func1-zicfiss.o rv32-func2-zicfiss.o rv32-func3-zicfiss.o -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFISS %s
+# RUN: ld.lld rv32-func1-zicfiss.o rv32-func3-zicfiss.o --shared -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFISS %s
+# RUN: ld.lld rv64-func1-zicfiss.o rv64-func2-zicfiss.o rv64-func3-zicfiss.o -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFISS %s
+# RUN: ld.lld rv64-func1-zicfiss.o rv64-func3-zicfiss.o --shared -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFISS %s
+# ZICFISS: Properties: RISC-V feature: ZICFISS
+
+## ZICFISS should not be enabled if it's not enabled in at least one input.
+# RUN: ld.lld rv32-func1-zicfiss.o rv32-func2.o rv32-func3-zicfiss.o -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv32-func2-zicfiss.o rv32-func3.o --shared -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv64-func1-zicfiss.o rv64-func2.o rv64-func3-zicfiss.o -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv64-func2-zicfiss.o rv64-func3.o --shared -o - | llvm-readelf -n - | count 0
+
+## zicfiss-report should report any input files that don't have the zicfiss property.
+# RUN: ld.lld rv32-func1-zicfiss.o rv32-func2.o rv32-func3-zicfiss.o -o /dev/null -z zicfiss-report=warning 2>&1 | FileCheck --check-prefix=MISS-SS-WARN %s
+# RUN: not ld.lld rv32-func2-zicfiss.o rv32-func3.o --shared -o /dev/null -z zicfiss-report=error 2>&1 | FileCheck --check-prefix=MISS-SS-ERROR %s
+# RUN: ld.lld rv32-func1-zicfiss.o rv32-func2-zicfiss.o rv32-func3-zicfiss.o -o /dev/null -z zicfiss-report=warning 2>&1 | count 0
+# RUN: ld.lld rv32-func1-zicfiss.o rv32-func2-zicfiss.o rv32-func3-zicfiss.o -o /dev/null -z zicfiss-report=error 2>&1 | count 0
+# RUN: ld.lld rv64-func1-zicfiss.o rv64-func2.o rv64-func3-zicfiss.o -o /dev/null -z zicfiss-report=warning 2>&1 | FileCheck --check-prefix=MISS-SS-WARN %s
+# RUN: not ld.lld rv64-func2-zicfiss.o rv64-func3.o --shared -o /dev/null -z zicfiss-report=error 2>&1 | FileCheck --check-prefix=MISS-SS-ERROR %s
+# RUN: ld.lld rv64-func1-zicfiss.o rv64-func2-zicfiss.o rv64-func3-zicfiss.o -o /dev/null -z zicfiss-report=warning 2>&1 | count 0
+# RUN: ld.lld rv64-func1-zicfiss.o rv64-func2-zicfiss.o rv64-func3-zicfiss.o -o /dev/null -z zicfiss-report=error 2>&1 | count 0
+# MISS-SS-WARN: warning: rv{{32|64}}-func2.o: -z zicfiss-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS property
+# MISS-SS-ERROR: error: rv{{32|64}}-func3.o: -z zicfiss-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS property
+
+## An invalid zicfiss option should give an error
+# RUN: not ld.lld rv32-func1-zicfiss.o rv32-func2-zicfiss.o rv32-func3-zicfiss.o -z zicfiss-report=nonsense 2>&1 | FileCheck --check-prefix=INVALID-REPORT %s
+# RUN: not ld.lld rv64-func1-zicfiss.o rv64-func2-zicfiss.o rv64-func3-zicfiss.o -z zicfiss-report=nonsense 2>&1 | FileCheck --check-prefix=INVALID-REPORT %s
+# INVALID-REPORT: error: -z zicfiss-report= parameter nonsense is not recognized
+
+#--- rv32-func1-zicfiss.s
+
+.section ".note.gnu.property", "a"
+.balign 4
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 4
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 2          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS
+.balign 4
+ndesc_end:
+
+.text
+.globl _start
+.type func1,%function
+func1:
+  call func2
+  ret
+
+#--- rv64-func1-zicfiss.s
+
+.section ".note.gnu.property", "a"
+.balign 8
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 8
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 2          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS
+.balign 8
+ndesc_end:
+
+.text
+.globl _start
+.type func1,%function
+func1:
+  call func2
+  ret
+
+#--- func2.s
+
+.text
+.globl func2
+.type func2, at function
+func2:
+  .globl func3
+  .type func3, @function
+  call func3
+  ret
+
+#--- rv32-func2-zicfiss.s
+
+.section ".note.gnu.property", "a"
+.balign 4
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 4
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 2          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS
+.balign 4
+ndesc_end:
+
+.text
+.globl func2
+.type func2, at function
+func2:
+  .globl func3
+  .type func3, @function
+  call func3
+  ret
+
+#--- rv64-func2-zicfiss.s
+
+.section ".note.gnu.property", "a"
+.balign 8
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 8
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 2          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS
+.balign 8
+ndesc_end:
+
+.text
+.globl func2
+.type func2, at function
+func2:
+  .globl func3
+  .type func3, @function
+  call func3
+  ret
+
+#--- func3.s
+
+.text
+.globl func3
+.type func3, at function
+func3:
+  ret
+
+#--- rv32-func3-zicfiss.s
+
+.section ".note.gnu.property", "a"
+.balign 4
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 4
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 2          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS
+.balign 4
+ndesc_end:
+
+.text
+.globl func3
+.type func3, at function
+func3:
+  ret
+
+#--- rv64-func3-zicfiss.s
+
+.section ".note.gnu.property", "a"
+.balign 8
+.4byte 4
+.4byte (ndesc_end - ndesc_begin)
+.4byte 0x5        // NT_GNU_PROPERTY_TYPE_0
+.asciz "GNU"
+ndesc_begin:
+.balign 8
+.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND
+.4byte 4
+.4byte 2          // GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS
+.balign 8
+ndesc_end:
+
+.text
+.globl func3
+.type func3, at function
+func3:
+  ret

>From 745e0b0e05a87d676edc41e957109b6287e12afb Mon Sep 17 00:00:00 2001
From: Ming-Yi Lai <ming-yi.lai at mediatek.com>
Date: Fri, 14 Feb 2025 18:49:20 +0800
Subject: [PATCH 2/6] fixup: format code

---
 lld/ELF/Driver.cpp | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 2500f58df55cc..790fa8b5a1d3b 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1630,15 +1630,15 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
       ErrAlways(ctx) << errPrefix << pat.takeError() << ": " << kv.first;
   }
 
-  auto reports = {std::make_pair("bti-report", &ctx.arg.zBtiReport),
-                  std::make_pair("cet-report", &ctx.arg.zCetReport),
-                  std::make_pair("gcs-report", &ctx.arg.zGcsReport),
-                  std::make_pair("pauth-report", &ctx.arg.zPauthReport),
-                  std::make_pair("zicfilp-unlabeled-report",
-                                 &ctx.arg.zZicfilpUnlabeledReport),
-                  std::make_pair("zicfilp-func-sig-report",
-                                 &ctx.arg.zZicfilpFuncSigReport),
-                  std::make_pair("zicfiss-report", &ctx.arg.zZicfissReport)};
+  auto reports = {
+      std::make_pair("bti-report", &ctx.arg.zBtiReport),
+      std::make_pair("cet-report", &ctx.arg.zCetReport),
+      std::make_pair("gcs-report", &ctx.arg.zGcsReport),
+      std::make_pair("pauth-report", &ctx.arg.zPauthReport),
+      std::make_pair("zicfilp-unlabeled-report",
+                     &ctx.arg.zZicfilpUnlabeledReport),
+      std::make_pair("zicfilp-func-sig-report", &ctx.arg.zZicfilpFuncSigReport),
+      std::make_pair("zicfiss-report", &ctx.arg.zZicfissReport)};
   for (opt::Arg *arg : args.filtered(OPT_z)) {
     std::pair<StringRef, StringRef> option =
         StringRef(arg->getValue()).split('=');

>From f86275e4ce7837718fd828d8f6d7c7cec5c3ba84 Mon Sep 17 00:00:00 2001
From: Ming-Yi Lai <ming-yi.lai at mediatek.com>
Date: Wed, 19 Feb 2025 15:52:51 +0800
Subject: [PATCH 3/6] fixup: Use short triples in tests

---
 lld/test/ELF/riscv-feature-zicfilp-func-sig.s | 20 ++++++++--------
 .../ELF/riscv-feature-zicfilp-unlabeled.s     | 24 +++++++++----------
 lld/test/ELF/riscv-feature-zicfiss.s          | 20 ++++++++--------
 3 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/lld/test/ELF/riscv-feature-zicfilp-func-sig.s b/lld/test/ELF/riscv-feature-zicfilp-func-sig.s
index 21cd348b3403e..9df2a282b1c48 100644
--- a/lld/test/ELF/riscv-feature-zicfilp-func-sig.s
+++ b/lld/test/ELF/riscv-feature-zicfilp-func-sig.s
@@ -1,15 +1,15 @@
 # REQUIRES: riscv
 # RUN: rm -rf %t && split-file %s %t && cd %t
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func1-zicfilp.s -o rv32-func1-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu func2.s -o rv32-func2.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func2-zicfilp.s -o rv32-func2-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu func3.s -o rv32-func3.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func3-zicfilp.s -o rv32-func3-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func1-zicfilp.s -o rv64-func1-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu func2.s -o rv64-func2.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func2-zicfilp.s -o rv64-func2-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu func3.s -o rv64-func3.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func3-zicfilp.s -o rv64-func3-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func1-zicfilp.s -o rv32-func1-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 func2.s -o rv32-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func2-zicfilp.s -o rv32-func2-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 func3.s -o rv32-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func3-zicfilp.s -o rv32-func3-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func1-zicfilp.s -o rv64-func1-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 func2.s -o rv64-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func2-zicfilp.s -o rv64-func2-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 func3.s -o rv64-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func3-zicfilp.s -o rv64-func3-zicfilp.o
 
 ## ZICFILP-func-sig should be enabled when it's enabled in all inputs
 # RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-FUNC-SIG %s
diff --git a/lld/test/ELF/riscv-feature-zicfilp-unlabeled.s b/lld/test/ELF/riscv-feature-zicfilp-unlabeled.s
index 5c244e8e44500..80acef2306a36 100644
--- a/lld/test/ELF/riscv-feature-zicfilp-unlabeled.s
+++ b/lld/test/ELF/riscv-feature-zicfilp-unlabeled.s
@@ -1,17 +1,17 @@
 # REQUIRES: riscv
 # RUN: rm -rf %t && split-file %s %t && cd %t
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func1-zicfilp.s -o rv32-func1-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func1-zicfilp-conflict.s -o rv32-func1-zicfilp-conflict.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu func2.s -o rv32-func2.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func2-zicfilp.s -o rv32-func2-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu func3.s -o rv32-func3.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func3-zicfilp.s -o rv32-func3-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func1-zicfilp.s -o rv64-func1-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func1-zicfilp-conflict.s -o rv64-func1-zicfilp-conflict.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu func2.s -o rv64-func2.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func2-zicfilp.s -o rv64-func2-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu func3.s -o rv64-func3.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func3-zicfilp.s -o rv64-func3-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func1-zicfilp.s -o rv32-func1-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func1-zicfilp-conflict.s -o rv32-func1-zicfilp-conflict.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 func2.s -o rv32-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func2-zicfilp.s -o rv32-func2-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 func3.s -o rv32-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func3-zicfilp.s -o rv32-func3-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func1-zicfilp.s -o rv64-func1-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func1-zicfilp-conflict.s -o rv64-func1-zicfilp-conflict.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 func2.s -o rv64-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func2-zicfilp.s -o rv64-func2-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 func3.s -o rv64-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func3-zicfilp.s -o rv64-func3-zicfilp.o
 
 ## ZICFILP-unlabeled should be enabled when it's enabled in all inputs
 # RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-UNLABELED %s
diff --git a/lld/test/ELF/riscv-feature-zicfiss.s b/lld/test/ELF/riscv-feature-zicfiss.s
index d6be9ee6b011e..3b9266e0b3172 100644
--- a/lld/test/ELF/riscv-feature-zicfiss.s
+++ b/lld/test/ELF/riscv-feature-zicfiss.s
@@ -1,15 +1,15 @@
 # REQUIRES: riscv
 # RUN: rm -rf %t && split-file %s %t && cd %t
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func1-zicfiss.s -o rv32-func1-zicfiss.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu func2.s -o rv32-func2.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func2-zicfiss.s -o rv32-func2-zicfiss.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu func3.s -o rv32-func3.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32-unknown-linux-gnu rv32-func3-zicfiss.s -o rv32-func3-zicfiss.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func1-zicfiss.s -o rv64-func1-zicfiss.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu func2.s -o rv64-func2.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func2-zicfiss.s -o rv64-func2-zicfiss.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu func3.s -o rv64-func3.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64-unknown-linux-gnu rv64-func3-zicfiss.s -o rv64-func3-zicfiss.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func1-zicfiss.s -o rv32-func1-zicfiss.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 func2.s -o rv32-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func2-zicfiss.s -o rv32-func2-zicfiss.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 func3.s -o rv32-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func3-zicfiss.s -o rv32-func3-zicfiss.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func1-zicfiss.s -o rv64-func1-zicfiss.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 func2.s -o rv64-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func2-zicfiss.s -o rv64-func2-zicfiss.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 func3.s -o rv64-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func3-zicfiss.s -o rv64-func3-zicfiss.o
 
 ## ZICFISS should be enabled when it's enabled in all inputs
 # RUN: ld.lld rv32-func1-zicfiss.o rv32-func2-zicfiss.o rv32-func3-zicfiss.o -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFISS %s

>From a1253e5a61c63d48fcf8fc14fc2a03d70a97d431 Mon Sep 17 00:00:00 2001
From: Ming-Yi Lai <ming-yi.lai at mediatek.com>
Date: Wed, 19 Feb 2025 16:04:21 +0800
Subject: [PATCH 4/6] fixup: Use llvm_unreachable on unreachable code path

---
 lld/ELF/SyntheticSections.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index a63368597238e..bd7fc5f6285ee 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -338,9 +338,8 @@ void GnuPropertySection::writeTo(uint8_t *buf) {
     featureAndType = GNU_PROPERTY_RISCV_FEATURE_1_AND;
     break;
   default:
-    Err(ctx) << "(e_machine) " << ctx.arg.emachine
-             << ": e_machine does not support .note.gnu.property section";
-    return;
+    llvm_unreachable(
+        "target machine does not support .note.gnu.property section");
   }
 
   write32(ctx, buf, 4);                          // Name size

>From 3ebfe6ea9c3c22c817848870bdd2f6a52fa2a464 Mon Sep 17 00:00:00 2001
From: Ming-Yi Lai <ming-yi.lai at mediatek.com>
Date: Wed, 19 Feb 2025 17:08:26 +0800
Subject: [PATCH 5/6] fixup: Beautify tests

---
 lld/test/ELF/riscv-feature-zicfilp-func-sig.s |  96 +++++++++-----
 .../ELF/riscv-feature-zicfilp-unlabeled.s     | 121 ++++++++++++------
 lld/test/ELF/riscv-feature-zicfiss.s          |  93 +++++++++-----
 3 files changed, 211 insertions(+), 99 deletions(-)

diff --git a/lld/test/ELF/riscv-feature-zicfilp-func-sig.s b/lld/test/ELF/riscv-feature-zicfilp-func-sig.s
index 9df2a282b1c48..adc83b7e05fda 100644
--- a/lld/test/ELF/riscv-feature-zicfilp-func-sig.s
+++ b/lld/test/ELF/riscv-feature-zicfilp-func-sig.s
@@ -1,45 +1,81 @@
 # REQUIRES: riscv
 # RUN: rm -rf %t && split-file %s %t && cd %t
 # RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func1-zicfilp.s -o rv32-func1-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32 func2.s -o rv32-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 func2.s              -o rv32-func2.o
 # RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func2-zicfilp.s -o rv32-func2-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32 func3.s -o rv32-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 func3.s              -o rv32-func3.o
 # RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func3-zicfilp.s -o rv32-func3-zicfilp.o
+
 # RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func1-zicfilp.s -o rv64-func1-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64 func2.s -o rv64-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 func2.s              -o rv64-func2.o
 # RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func2-zicfilp.s -o rv64-func2-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64 func3.s -o rv64-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 func3.s              -o rv64-func3.o
 # RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func3-zicfilp.s -o rv64-func3-zicfilp.o
 
 ## ZICFILP-func-sig should be enabled when it's enabled in all inputs
-# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-FUNC-SIG %s
-# RUN: ld.lld rv32-func1-zicfilp.o rv32-func3-zicfilp.o --shared -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-FUNC-SIG %s
-# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-FUNC-SIG %s
-# RUN: ld.lld rv64-func1-zicfilp.o rv64-func3-zicfilp.o --shared -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-FUNC-SIG %s
-# ZICFILP-FUNC-SIG: Properties: RISC-V feature: ZICFILP-func-sig
-
-## ZICFILP-func-sig should not be enabled if it's not enabled in at least one input.
-# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2.o rv32-func3-zicfilp.o -o - | llvm-readelf -n - | count 0
-# RUN: ld.lld rv32-func2-zicfilp.o rv32-func3.o --shared -o - | llvm-readelf -n - | count 0
-# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2.o rv64-func3-zicfilp.o -o - | llvm-readelf -n - | count 0
-# RUN: ld.lld rv64-func2-zicfilp.o rv64-func3.o --shared -o - | llvm-readelf -n - | count 0
-
-## zicfilp-func-sig-report should report any input files that don't have the zicfilp-func-sig property.
-# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2.o rv32-func3-zicfilp.o -o /dev/null -z zicfilp-func-sig-report=warning 2>&1 | FileCheck --check-prefix=MISS-LP-WARN %s
-# RUN: not ld.lld rv32-func2-zicfilp.o rv32-func3.o --shared -o /dev/null -z zicfilp-func-sig-report=error 2>&1 | FileCheck --check-prefix=MISS-LP-ERROR %s
-# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o /dev/null -z zicfilp-func-sig-report=warning 2>&1 | count 0
-# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o /dev/null -z zicfilp-func-sig-report=error 2>&1 | count 0
-# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2.o rv64-func3-zicfilp.o -o /dev/null -z zicfilp-func-sig-report=warning 2>&1 | FileCheck --check-prefix=MISS-LP-WARN %s
-# RUN: not ld.lld rv64-func2-zicfilp.o rv64-func3.o --shared -o /dev/null -z zicfilp-func-sig-report=error 2>&1 | FileCheck --check-prefix=MISS-LP-ERROR %s
-# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -o /dev/null -z zicfilp-func-sig-report=warning 2>&1 | count 0
-# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -o /dev/null -z zicfilp-func-sig-report=error 2>&1 | count 0
-# MISS-LP-WARN: warning: rv{{32|64}}-func2.o: -z zicfilp-func-sig-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG property
-# MISS-LP-ERROR: error: rv{{32|64}}-func3.o: -z zicfilp-func-sig-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG property
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o   \
+# RUN:  -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP %s
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func3-zicfilp.o --shared               \
+# RUN:  -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP %s
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o   \
+# RUN:  -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP %s
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func3-zicfilp.o --shared               \
+# RUN:  -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP %s
+# ZICFILP: Properties: RISC-V feature: ZICFILP-func-sig
+
+## ZICFILP-func-sig should not be enabled if it's not enabled in at least one
+## input
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2.o rv32-func3-zicfilp.o           \
+# RUN:  -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv32-func2-zicfilp.o rv32-func3.o --shared                       \
+# RUN:  -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2.o rv64-func3-zicfilp.o           \
+# RUN:  -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv64-func2-zicfilp.o rv64-func3.o --shared                       \
+# RUN:  -o - | llvm-readelf -n - | count 0
+
+## zicfilp-func-sig-report should report any input files that don't have the
+## zicfilp-func-sig property
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2.o rv32-func3-zicfilp.o           \
+# RUN:  -z zicfilp-func-sig-report=warning -o /dev/null 2>&1                   \
+# RUN:  | FileCheck --check-prefix=MISS-LP-WARN %s
+# RUN: not ld.lld rv32-func2-zicfilp.o rv32-func3.o --shared                   \
+# RUN:  -z zicfilp-func-sig-report=error   -o /dev/null 2>&1                   \
+# RUN:  | FileCheck --check-prefix=MISS-LP-ERROR %s
+
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o   \
+# RUN:  -z zicfilp-func-sig-report=warning -o /dev/null 2>&1 | count 0
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o   \
+# RUN:  -z zicfilp-func-sig-report=error   -o /dev/null 2>&1 | count 0
+
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2.o rv64-func3-zicfilp.o           \
+# RUN:  -z zicfilp-func-sig-report=warning -o /dev/null 2>&1                   \
+# RUN:  | FileCheck --check-prefix=MISS-LP-WARN %s
+# RUN: not ld.lld rv64-func2-zicfilp.o rv64-func3.o --shared                   \
+# RUN:  -z zicfilp-func-sig-report=error   -o /dev/null 2>&1                   \
+# RUN:  | FileCheck --check-prefix=MISS-LP-ERROR %s
+
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o   \
+# RUN:  -z zicfilp-func-sig-report=warning -o /dev/null 2>&1 | count 0
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o   \
+# RUN:  -z zicfilp-func-sig-report=error   -o /dev/null 2>&1 | count 0
+
+# MISS-LP-WARN: warning: rv{{32|64}}-func2.o: -z zicfilp-func-sig-report:
+# MISS-LP-WARN-SAME: file does not have
+# MISS-LP-WARN-SAME: GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG property
+# MISS-LP-ERROR: error: rv{{32|64}}-func3.o: -z zicfilp-func-sig-report:
+# MISS-LP-ERROR-SAME: file does not have
+# MISS-LP-ERROR-SAME: GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG property
 
 ## An invalid -z zicfilp-func-sig-report option should give an error
-# RUN: not ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -z zicfilp-func-sig-report=nonsense 2>&1 | FileCheck --check-prefix=INVALID-REPORT %s
-# RUN: not ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -z zicfilp-func-sig-report=nonsense 2>&1 | FileCheck --check-prefix=INVALID-REPORT %s
-# INVALID-REPORT: error: -z zicfilp-func-sig-report= parameter nonsense is not recognized
+# RUN: not ld.lld rv32-func2-zicfilp.o rv32-func3-zicfilp.o                    \
+# RUN:  -z zicfilp-func-sig-report=nonsense 2>&1                               \
+# RUN:  | FileCheck --check-prefix=INVALID-REPORT %s
+# RUN: not ld.lld rv64-func2-zicfilp.o rv64-func3-zicfilp.o                    \
+# RUN:  -z zicfilp-func-sig-report=nonsense 2>&1                               \
+# RUN:  | FileCheck --check-prefix=INVALID-REPORT %s
+# INVALID-REPORT: error: -z zicfilp-func-sig-report= parameter nonsense is not
+# INVALID-REPORT-SAME: recognized
 
 #--- rv32-func1-zicfilp.s
 
diff --git a/lld/test/ELF/riscv-feature-zicfilp-unlabeled.s b/lld/test/ELF/riscv-feature-zicfilp-unlabeled.s
index 80acef2306a36..880f72aff6bad 100644
--- a/lld/test/ELF/riscv-feature-zicfilp-unlabeled.s
+++ b/lld/test/ELF/riscv-feature-zicfilp-unlabeled.s
@@ -1,52 +1,95 @@
 # REQUIRES: riscv
 # RUN: rm -rf %t && split-file %s %t && cd %t
-# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func1-zicfilp.s -o rv32-func1-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func1-zicfilp.s          -o rv32-func1-zicfilp.o
 # RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func1-zicfilp-conflict.s -o rv32-func1-zicfilp-conflict.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32 func2.s -o rv32-func2.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func2-zicfilp.s -o rv32-func2-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32 func3.s -o rv32-func3.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func3-zicfilp.s -o rv32-func3-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func1-zicfilp.s -o rv64-func1-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 func2.s                       -o rv32-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func2-zicfilp.s          -o rv32-func2-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 func3.s                       -o rv32-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func3-zicfilp.s          -o rv32-func3-zicfilp.o
+
+# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func1-zicfilp.s          -o rv64-func1-zicfilp.o
 # RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func1-zicfilp-conflict.s -o rv64-func1-zicfilp-conflict.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64 func2.s -o rv64-func2.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func2-zicfilp.s -o rv64-func2-zicfilp.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64 func3.s -o rv64-func3.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func3-zicfilp.s -o rv64-func3-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 func2.s                       -o rv64-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func2-zicfilp.s          -o rv64-func2-zicfilp.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 func3.s                       -o rv64-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func3-zicfilp.s          -o rv64-func3-zicfilp.o
 
 ## ZICFILP-unlabeled should be enabled when it's enabled in all inputs
-# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-UNLABELED %s
-# RUN: ld.lld rv32-func1-zicfilp.o rv32-func3-zicfilp.o --shared -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-UNLABELED %s
-# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-UNLABELED %s
-# RUN: ld.lld rv64-func1-zicfilp.o rv64-func3-zicfilp.o --shared -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP-UNLABELED %s
-# ZICFILP-UNLABELED: Properties: RISC-V feature: ZICFILP-unlabeled
-
-## ZICFILP-unlabeled should not be enabled if it's not enabled in at least one input.
-# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2.o rv32-func3-zicfilp.o -o - | llvm-readelf -n - | count 0
-# RUN: ld.lld rv32-func2-zicfilp.o rv32-func3.o --shared -o - | llvm-readelf -n - | count 0
-# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2.o rv64-func3-zicfilp.o -o - | llvm-readelf -n - | count 0
-# RUN: ld.lld rv64-func2-zicfilp.o rv64-func3.o --shared -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o   \
+# RUN:  -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP %s
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func3-zicfilp.o --shared               \
+# RUN:  -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP %s
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o   \
+# RUN:  -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP %s
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func3-zicfilp.o --shared               \
+# RUN:  -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFILP %s
+# ZICFILP: Properties: RISC-V feature: ZICFILP-unlabeled
+
+## ZICFILP-unlabeled should not be enabled if it's not enabled in at least one
+## input
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2.o rv32-func3-zicfilp.o           \
+# RUN:  -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv32-func2-zicfilp.o rv32-func3.o --shared                       \
+# RUN:  -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2.o rv64-func3-zicfilp.o           \
+# RUN:  -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv64-func2-zicfilp.o rv64-func3.o --shared                       \
+# RUN:  -o - | llvm-readelf -n - | count 0
 
 ## ZICFILP-unlabeled and ZICFILP-func-sig should conflict with each other
-# RUN: not ld.lld rv32-func1-zicfilp-conflict.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o /dev/null 2>&1 | FileCheck --check-prefix UNLABELED-FUNC-SIG-CONFLICT %s
-# RUN: not ld.lld rv64-func1-zicfilp-conflict.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -o /dev/null 2>&1 | FileCheck --check-prefix UNLABELED-FUNC-SIG-CONFLICT %s
-# UNLABELED-FUNC-SIG-CONFLICT: rv{{32|64}}-func1-zicfilp-conflict.o: file has conflicting properties: GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED and GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG
-
-## zicfilp-unlabeled-report should report any input files that don't have the zicfilp-unlabeled property.
-# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2.o rv32-func3-zicfilp.o -o /dev/null -z zicfilp-unlabeled-report=warning 2>&1 | FileCheck --check-prefix=MISS-LP-WARN %s
-# RUN: not ld.lld rv32-func2-zicfilp.o rv32-func3.o --shared -o /dev/null -z zicfilp-unlabeled-report=error 2>&1 | FileCheck --check-prefix=MISS-LP-ERROR %s
-# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o /dev/null -z zicfilp-unlabeled-report=warning 2>&1 | count 0
-# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -o /dev/null -z zicfilp-unlabeled-report=error 2>&1 | count 0
-# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2.o rv64-func3-zicfilp.o -o /dev/null -z zicfilp-unlabeled-report=warning 2>&1 | FileCheck --check-prefix=MISS-LP-WARN %s
-# RUN: not ld.lld rv64-func2-zicfilp.o rv64-func3.o --shared -o /dev/null -z zicfilp-unlabeled-report=error 2>&1 | FileCheck --check-prefix=MISS-LP-ERROR %s
-# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -o /dev/null -z zicfilp-unlabeled-report=warning 2>&1 | count 0
-# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -o /dev/null -z zicfilp-unlabeled-report=error 2>&1 | count 0
-# MISS-LP-WARN: warning: rv{{32|64}}-func2.o: -z zicfilp-unlabeled-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED property
-# MISS-LP-ERROR: error: rv{{32|64}}-func3.o: -z zicfilp-unlabeled-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED property
+# RUN: not ld.lld rv32-func1-zicfilp-conflict.o rv32-func2-zicfilp.o           \
+# RUN:  rv32-func3-zicfilp.o -o /dev/null 2>&1                                 \
+# RUN:  | FileCheck --check-prefix FEATURE-CONFLICT %s
+# RUN: not ld.lld rv64-func1-zicfilp-conflict.o rv64-func2-zicfilp.o           \
+# RUN:  rv64-func3-zicfilp.o -o /dev/null 2>&1                                 \
+# RUN:  | FileCheck --check-prefix FEATURE-CONFLICT %s
+# FEATURE-CONFLICT: error: rv{{32|64}}-func1-zicfilp-conflict.o: file has
+# FEATURE-CONFLICT-SAME: conflicting properties:
+# FEATURE-CONFLICT-SAME: GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED and
+# FEATURE-CONFLICT-SAME: GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_FUNC_SIG
+
+## zicfilp-unlabeled-report should report any input files that don't have the
+## zicfilp-unlabeled property
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2.o rv32-func3-zicfilp.o           \
+# RUN:  -z zicfilp-unlabeled-report=warning -o /dev/null 2>&1                  \
+# RUN:  | FileCheck --check-prefix=MISS-LP-WARN %s
+# RUN: not ld.lld rv32-func2-zicfilp.o rv32-func3.o --shared                   \
+# RUN:  -z zicfilp-unlabeled-report=error   -o /dev/null 2>&1                  \
+# RUN:  | FileCheck --check-prefix=MISS-LP-ERROR %s
+
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o   \
+# RUN:  -z zicfilp-unlabeled-report=warning -o /dev/null 2>&1 | count 0
+# RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o   \
+# RUN:  -z zicfilp-unlabeled-report=error   -o /dev/null 2>&1 | count 0
+
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2.o rv64-func3-zicfilp.o           \
+# RUN:  -z zicfilp-unlabeled-report=warning -o /dev/null 2>&1                  \
+# RUN:  | FileCheck --check-prefix=MISS-LP-WARN %s
+# RUN: not ld.lld rv64-func2-zicfilp.o rv64-func3.o --shared                   \
+# RUN:  -z zicfilp-unlabeled-report=error   -o /dev/null 2>&1                  \
+# RUN:  | FileCheck --check-prefix=MISS-LP-ERROR %s
+
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o   \
+# RUN:  -z zicfilp-unlabeled-report=warning -o /dev/null 2>&1 | count 0
+# RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o   \
+# RUN:  -z zicfilp-unlabeled-report=error   -o /dev/null 2>&1 | count 0
+
+# MISS-LP-WARN: warning: rv{{32|64}}-func2.o: -z zicfilp-unlabeled-report:
+# MISS-LP-WARN-SAME: file does not have
+# MISS-LP-WARN-SAME: GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED property
+# MISS-LP-ERROR: error: rv{{32|64}}-func3.o: -z zicfilp-unlabeled-report:
+# MISS-LP-ERROR-SAME: file does not have
+# MISS-LP-ERROR-SAME: GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED property
 
 ## An invalid -z zicfilp-unlabeled-report option should give an error
-# RUN: not ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o -z zicfilp-unlabeled-report=nonsense 2>&1 | FileCheck --check-prefix=INVALID-REPORT %s
-# RUN: not ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o -z zicfilp-unlabeled-report=nonsense 2>&1 | FileCheck --check-prefix=INVALID-REPORT %s
-# INVALID-REPORT: error: -z zicfilp-unlabeled-report= parameter nonsense is not recognized
+# RUN: not ld.lld rv32-func2-zicfilp.o rv32-func3-zicfilp.o                    \
+# RUN:  -z zicfilp-unlabeled-report=nonsense 2>&1                              \
+# RUN:  | FileCheck --check-prefix=INVALID-REPORT %s
+# RUN: not ld.lld rv64-func2-zicfilp.o rv64-func3-zicfilp.o                    \
+# RUN:  -z zicfilp-unlabeled-report=nonsense 2>&1                              \
+# RUN:  | FileCheck --check-prefix=INVALID-REPORT %s
+# INVALID-REPORT: error: -z zicfilp-unlabeled-report= parameter nonsense is not
+# INVALID-REPORT-SAME: recognized
 
 #--- rv32-func1-zicfilp.s
 
diff --git a/lld/test/ELF/riscv-feature-zicfiss.s b/lld/test/ELF/riscv-feature-zicfiss.s
index 3b9266e0b3172..a0dbb2a9bf2ac 100644
--- a/lld/test/ELF/riscv-feature-zicfiss.s
+++ b/lld/test/ELF/riscv-feature-zicfiss.s
@@ -1,45 +1,78 @@
 # REQUIRES: riscv
 # RUN: rm -rf %t && split-file %s %t && cd %t
 # RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func1-zicfiss.s -o rv32-func1-zicfiss.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32 func2.s -o rv32-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 func2.s              -o rv32-func2.o
 # RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func2-zicfiss.s -o rv32-func2-zicfiss.o
-# RUN: llvm-mc --filetype=obj --triple=riscv32 func3.s -o rv32-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv32 func3.s              -o rv32-func3.o
 # RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-func3-zicfiss.s -o rv32-func3-zicfiss.o
+
 # RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func1-zicfiss.s -o rv64-func1-zicfiss.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64 func2.s -o rv64-func2.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 func2.s              -o rv64-func2.o
 # RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func2-zicfiss.s -o rv64-func2-zicfiss.o
-# RUN: llvm-mc --filetype=obj --triple=riscv64 func3.s -o rv64-func3.o
+# RUN: llvm-mc --filetype=obj --triple=riscv64 func3.s              -o rv64-func3.o
 # RUN: llvm-mc --filetype=obj --triple=riscv64 rv64-func3-zicfiss.s -o rv64-func3-zicfiss.o
 
 ## ZICFISS should be enabled when it's enabled in all inputs
-# RUN: ld.lld rv32-func1-zicfiss.o rv32-func2-zicfiss.o rv32-func3-zicfiss.o -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFISS %s
-# RUN: ld.lld rv32-func1-zicfiss.o rv32-func3-zicfiss.o --shared -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFISS %s
-# RUN: ld.lld rv64-func1-zicfiss.o rv64-func2-zicfiss.o rv64-func3-zicfiss.o -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFISS %s
-# RUN: ld.lld rv64-func1-zicfiss.o rv64-func3-zicfiss.o --shared -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFISS %s
+# RUN: ld.lld rv32-func1-zicfiss.o rv32-func2-zicfiss.o rv32-func3-zicfiss.o   \
+# RUN:  -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFISS %s
+# RUN: ld.lld rv32-func1-zicfiss.o rv32-func3-zicfiss.o --shared               \
+# RUN:  -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFISS %s
+# RUN: ld.lld rv64-func1-zicfiss.o rv64-func2-zicfiss.o rv64-func3-zicfiss.o   \
+# RUN:  -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFISS %s
+# RUN: ld.lld rv64-func1-zicfiss.o rv64-func3-zicfiss.o --shared               \
+# RUN:  -o - | llvm-readelf -n - | FileCheck --check-prefix ZICFISS %s
 # ZICFISS: Properties: RISC-V feature: ZICFISS
 
-## ZICFISS should not be enabled if it's not enabled in at least one input.
-# RUN: ld.lld rv32-func1-zicfiss.o rv32-func2.o rv32-func3-zicfiss.o -o - | llvm-readelf -n - | count 0
-# RUN: ld.lld rv32-func2-zicfiss.o rv32-func3.o --shared -o - | llvm-readelf -n - | count 0
-# RUN: ld.lld rv64-func1-zicfiss.o rv64-func2.o rv64-func3-zicfiss.o -o - | llvm-readelf -n - | count 0
-# RUN: ld.lld rv64-func2-zicfiss.o rv64-func3.o --shared -o - | llvm-readelf -n - | count 0
-
-## zicfiss-report should report any input files that don't have the zicfiss property.
-# RUN: ld.lld rv32-func1-zicfiss.o rv32-func2.o rv32-func3-zicfiss.o -o /dev/null -z zicfiss-report=warning 2>&1 | FileCheck --check-prefix=MISS-SS-WARN %s
-# RUN: not ld.lld rv32-func2-zicfiss.o rv32-func3.o --shared -o /dev/null -z zicfiss-report=error 2>&1 | FileCheck --check-prefix=MISS-SS-ERROR %s
-# RUN: ld.lld rv32-func1-zicfiss.o rv32-func2-zicfiss.o rv32-func3-zicfiss.o -o /dev/null -z zicfiss-report=warning 2>&1 | count 0
-# RUN: ld.lld rv32-func1-zicfiss.o rv32-func2-zicfiss.o rv32-func3-zicfiss.o -o /dev/null -z zicfiss-report=error 2>&1 | count 0
-# RUN: ld.lld rv64-func1-zicfiss.o rv64-func2.o rv64-func3-zicfiss.o -o /dev/null -z zicfiss-report=warning 2>&1 | FileCheck --check-prefix=MISS-SS-WARN %s
-# RUN: not ld.lld rv64-func2-zicfiss.o rv64-func3.o --shared -o /dev/null -z zicfiss-report=error 2>&1 | FileCheck --check-prefix=MISS-SS-ERROR %s
-# RUN: ld.lld rv64-func1-zicfiss.o rv64-func2-zicfiss.o rv64-func3-zicfiss.o -o /dev/null -z zicfiss-report=warning 2>&1 | count 0
-# RUN: ld.lld rv64-func1-zicfiss.o rv64-func2-zicfiss.o rv64-func3-zicfiss.o -o /dev/null -z zicfiss-report=error 2>&1 | count 0
-# MISS-SS-WARN: warning: rv{{32|64}}-func2.o: -z zicfiss-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS property
-# MISS-SS-ERROR: error: rv{{32|64}}-func3.o: -z zicfiss-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS property
-
-## An invalid zicfiss option should give an error
-# RUN: not ld.lld rv32-func1-zicfiss.o rv32-func2-zicfiss.o rv32-func3-zicfiss.o -z zicfiss-report=nonsense 2>&1 | FileCheck --check-prefix=INVALID-REPORT %s
-# RUN: not ld.lld rv64-func1-zicfiss.o rv64-func2-zicfiss.o rv64-func3-zicfiss.o -z zicfiss-report=nonsense 2>&1 | FileCheck --check-prefix=INVALID-REPORT %s
-# INVALID-REPORT: error: -z zicfiss-report= parameter nonsense is not recognized
+## ZICFISS should not be enabled if it's not enabled in at least one input
+# RUN: ld.lld rv32-func1-zicfiss.o rv32-func2.o rv32-func3-zicfiss.o           \
+# RUN:  -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv32-func2-zicfiss.o rv32-func3.o --shared                       \
+# RUN:  -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv64-func1-zicfiss.o rv64-func2.o rv64-func3-zicfiss.o           \
+# RUN:  -o - | llvm-readelf -n - | count 0
+# RUN: ld.lld rv64-func2-zicfiss.o rv64-func3.o --shared                       \
+# RUN:  -o - | llvm-readelf -n - | count 0
+
+## zicfiss-report should report any input files that don't have the zicfiss
+## property
+# RUN: ld.lld rv32-func1-zicfiss.o rv32-func2.o rv32-func3-zicfiss.o           \
+# RUN:  -z zicfiss-report=warning -o /dev/null 2>&1                            \
+# RUN:  | FileCheck --check-prefix=MISS-SS-WARN %s
+# RUN: not ld.lld rv32-func2-zicfiss.o rv32-func3.o --shared                   \
+# RUN:  -z zicfiss-report=error   -o /dev/null 2>&1                            \
+# RUN:  | FileCheck --check-prefix=MISS-SS-ERROR %s
+
+# RUN: ld.lld rv32-func1-zicfiss.o rv32-func2-zicfiss.o rv32-func3-zicfiss.o   \
+# RUN:  -z zicfiss-report=warning -o /dev/null 2>&1 | count 0
+# RUN: ld.lld rv32-func1-zicfiss.o rv32-func2-zicfiss.o rv32-func3-zicfiss.o   \
+# RUN:  -z zicfiss-report=error   -o /dev/null 2>&1 | count 0
+
+# RUN: ld.lld rv64-func1-zicfiss.o rv64-func2.o rv64-func3-zicfiss.o           \
+# RUN:  -z zicfiss-report=warning -o /dev/null 2>&1                            \
+# RUN:  | FileCheck --check-prefix=MISS-SS-WARN %s
+# RUN: not ld.lld rv64-func2-zicfiss.o rv64-func3.o --shared                   \
+# RUN:  -z zicfiss-report=error   -o /dev/null 2>&1                            \
+# RUN:  | FileCheck --check-prefix=MISS-SS-ERROR %s
+
+# RUN: ld.lld rv64-func1-zicfiss.o rv64-func2-zicfiss.o rv64-func3-zicfiss.o   \
+# RUN:  -z zicfiss-report=warning -o /dev/null 2>&1 | count 0
+# RUN: ld.lld rv64-func1-zicfiss.o rv64-func2-zicfiss.o rv64-func3-zicfiss.o   \
+# RUN:  -z zicfiss-report=error   -o /dev/null 2>&1 | count 0
+
+# MISS-SS-WARN: warning: rv{{32|64}}-func2.o: -z zicfiss-report: file does not
+# MISS-SS-WARN-SAME: have GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS property
+# MISS-SS-ERROR: error: rv{{32|64}}-func3.o: -z zicfiss-report: file does not
+# MISS-SS-ERROR-SAME: have GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS property
+
+## An invalid -z zicfiss-report option should give an error
+# RUN: not ld.lld rv32-func2-zicfilp.o rv32-func3-zicfilp.o                    \
+# RUN:  -z zicfiss-report=nonsense 2>&1                                        \
+# RUN:  | FileCheck --check-prefix=INVALID-REPORT %s
+# RUN: not ld.lld rv64-func2-zicfilp.o rv64-func3-zicfilp.o                    \
+# RUN:  -z zicfiss-report=nonsense 2>&1                                        \
+# RUN:  | FileCheck --check-prefix=INVALID-REPORT %s
+# INVALID-REPORT: error: -z zicfiss-report= parameter nonsense is not
+# INVALID-REPORT-SAME: recognized
 
 #--- rv32-func1-zicfiss.s
 

>From 2a282905fd65f8fe2f2b3580b10d395fb0e266e6 Mon Sep 17 00:00:00 2001
From: Ming-Yi Lai <ming-yi.lai at mediatek.com>
Date: Wed, 19 Feb 2025 17:23:45 +0800
Subject: [PATCH 6/6] fixup: Remove useless `-o` flag for expect-to-fail LLD
 test invocations

---
 lld/test/ELF/riscv-feature-zicfilp-func-sig.s  | 4 ++--
 lld/test/ELF/riscv-feature-zicfilp-unlabeled.s | 8 ++++----
 lld/test/ELF/riscv-feature-zicfiss.s           | 4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/lld/test/ELF/riscv-feature-zicfilp-func-sig.s b/lld/test/ELF/riscv-feature-zicfilp-func-sig.s
index adc83b7e05fda..f0a069850b596 100644
--- a/lld/test/ELF/riscv-feature-zicfilp-func-sig.s
+++ b/lld/test/ELF/riscv-feature-zicfilp-func-sig.s
@@ -40,7 +40,7 @@
 # RUN:  -z zicfilp-func-sig-report=warning -o /dev/null 2>&1                   \
 # RUN:  | FileCheck --check-prefix=MISS-LP-WARN %s
 # RUN: not ld.lld rv32-func2-zicfilp.o rv32-func3.o --shared                   \
-# RUN:  -z zicfilp-func-sig-report=error   -o /dev/null 2>&1                   \
+# RUN:  -z zicfilp-func-sig-report=error                2>&1                   \
 # RUN:  | FileCheck --check-prefix=MISS-LP-ERROR %s
 
 # RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o   \
@@ -52,7 +52,7 @@
 # RUN:  -z zicfilp-func-sig-report=warning -o /dev/null 2>&1                   \
 # RUN:  | FileCheck --check-prefix=MISS-LP-WARN %s
 # RUN: not ld.lld rv64-func2-zicfilp.o rv64-func3.o --shared                   \
-# RUN:  -z zicfilp-func-sig-report=error   -o /dev/null 2>&1                   \
+# RUN:  -z zicfilp-func-sig-report=error                2>&1                   \
 # RUN:  | FileCheck --check-prefix=MISS-LP-ERROR %s
 
 # RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o   \
diff --git a/lld/test/ELF/riscv-feature-zicfilp-unlabeled.s b/lld/test/ELF/riscv-feature-zicfilp-unlabeled.s
index 880f72aff6bad..fed647c8dbe92 100644
--- a/lld/test/ELF/riscv-feature-zicfilp-unlabeled.s
+++ b/lld/test/ELF/riscv-feature-zicfilp-unlabeled.s
@@ -38,10 +38,10 @@
 
 ## ZICFILP-unlabeled and ZICFILP-func-sig should conflict with each other
 # RUN: not ld.lld rv32-func1-zicfilp-conflict.o rv32-func2-zicfilp.o           \
-# RUN:  rv32-func3-zicfilp.o -o /dev/null 2>&1                                 \
+# RUN:  rv32-func3-zicfilp.o 2>&1                                              \
 # RUN:  | FileCheck --check-prefix FEATURE-CONFLICT %s
 # RUN: not ld.lld rv64-func1-zicfilp-conflict.o rv64-func2-zicfilp.o           \
-# RUN:  rv64-func3-zicfilp.o -o /dev/null 2>&1                                 \
+# RUN:  rv64-func3-zicfilp.o 2>&1                                              \
 # RUN:  | FileCheck --check-prefix FEATURE-CONFLICT %s
 # FEATURE-CONFLICT: error: rv{{32|64}}-func1-zicfilp-conflict.o: file has
 # FEATURE-CONFLICT-SAME: conflicting properties:
@@ -54,7 +54,7 @@
 # RUN:  -z zicfilp-unlabeled-report=warning -o /dev/null 2>&1                  \
 # RUN:  | FileCheck --check-prefix=MISS-LP-WARN %s
 # RUN: not ld.lld rv32-func2-zicfilp.o rv32-func3.o --shared                   \
-# RUN:  -z zicfilp-unlabeled-report=error   -o /dev/null 2>&1                  \
+# RUN:  -z zicfilp-unlabeled-report=error                2>&1                  \
 # RUN:  | FileCheck --check-prefix=MISS-LP-ERROR %s
 
 # RUN: ld.lld rv32-func1-zicfilp.o rv32-func2-zicfilp.o rv32-func3-zicfilp.o   \
@@ -66,7 +66,7 @@
 # RUN:  -z zicfilp-unlabeled-report=warning -o /dev/null 2>&1                  \
 # RUN:  | FileCheck --check-prefix=MISS-LP-WARN %s
 # RUN: not ld.lld rv64-func2-zicfilp.o rv64-func3.o --shared                   \
-# RUN:  -z zicfilp-unlabeled-report=error   -o /dev/null 2>&1                  \
+# RUN:  -z zicfilp-unlabeled-report=error                2>&1                  \
 # RUN:  | FileCheck --check-prefix=MISS-LP-ERROR %s
 
 # RUN: ld.lld rv64-func1-zicfilp.o rv64-func2-zicfilp.o rv64-func3-zicfilp.o   \
diff --git a/lld/test/ELF/riscv-feature-zicfiss.s b/lld/test/ELF/riscv-feature-zicfiss.s
index a0dbb2a9bf2ac..9e795ed0097c5 100644
--- a/lld/test/ELF/riscv-feature-zicfiss.s
+++ b/lld/test/ELF/riscv-feature-zicfiss.s
@@ -39,7 +39,7 @@
 # RUN:  -z zicfiss-report=warning -o /dev/null 2>&1                            \
 # RUN:  | FileCheck --check-prefix=MISS-SS-WARN %s
 # RUN: not ld.lld rv32-func2-zicfiss.o rv32-func3.o --shared                   \
-# RUN:  -z zicfiss-report=error   -o /dev/null 2>&1                            \
+# RUN:  -z zicfiss-report=error                2>&1                            \
 # RUN:  | FileCheck --check-prefix=MISS-SS-ERROR %s
 
 # RUN: ld.lld rv32-func1-zicfiss.o rv32-func2-zicfiss.o rv32-func3-zicfiss.o   \
@@ -51,7 +51,7 @@
 # RUN:  -z zicfiss-report=warning -o /dev/null 2>&1                            \
 # RUN:  | FileCheck --check-prefix=MISS-SS-WARN %s
 # RUN: not ld.lld rv64-func2-zicfiss.o rv64-func3.o --shared                   \
-# RUN:  -z zicfiss-report=error   -o /dev/null 2>&1                            \
+# RUN:  -z zicfiss-report=error                2>&1                            \
 # RUN:  | FileCheck --check-prefix=MISS-SS-ERROR %s
 
 # RUN: ld.lld rv64-func1-zicfiss.o rv64-func2-zicfiss.o rv64-func3-zicfiss.o   \



More information about the llvm-commits mailing list