[lld] 67e8fc4 - [ELF, test] Cover target-specific option errors (#196247)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 23:44:47 PDT 2026


Author: Fangrui Song
Date: 2026-05-06T23:44:43-07:00
New Revision: 67e8fc468cc7c90fdb7ba6bc78ec6cb1890e56a6

URL: https://github.com/llvm/llvm-project/commit/67e8fc468cc7c90fdb7ba6bc78ec6cb1890e56a6
DIFF: https://github.com/llvm/llvm-project/commit/67e8fc468cc7c90fdb7ba6bc78ec6cb1890e56a6.diff

LOG: [ELF,test] Cover target-specific option errors (#196247)

Added: 
    

Modified: 
    lld/test/ELF/aarch64-execute-only.s
    lld/test/ELF/target-specific-options.s
    lld/test/ELF/x86-64-feature-cet.s

Removed: 
    lld/test/ELF/aarch64-bti-pac-cli-error.s


################################################################################
diff  --git a/lld/test/ELF/aarch64-bti-pac-cli-error.s b/lld/test/ELF/aarch64-bti-pac-cli-error.s
deleted file mode 100644
index 6355298fb788f..0000000000000
--- a/lld/test/ELF/aarch64-bti-pac-cli-error.s
+++ /dev/null
@@ -1,17 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc --triple=x86_64-pc-linux --filetype=obj -o %t.o %s
-# RUN: not ld.lld -z pac-plt -z force-bti -z bti-report=error   \
-# RUN:     -z pauth-report=error   %t.o -o /dev/null 2>&1 | FileCheck %s
-# RUN: not ld.lld -z pac-plt -z force-bti -z bti-report=warning \
-# RUN:     -z pauth-report=warning %t.o -o /dev/null 2>&1 | FileCheck %s
-#
-## Check that we error if -z pac-plt, -z force-bti are present and
-## -z bti-report and -z pauth-report are not none when target is not aarch64
-
-# CHECK: error: -z pac-plt only supported on AArch64
-# CHECK-NEXT: error: -z force-bti only supported on AArch64
-# CHECK-NEXT: error: -z bti-report only supported on AArch64
-# CHECK-NEXT: error: -z pauth-report only supported on AArch64
-
-        .globl start
-start:  ret

diff  --git a/lld/test/ELF/aarch64-execute-only.s b/lld/test/ELF/aarch64-execute-only.s
index d4ee783e2c578..34c0ee8492f40 100644
--- a/lld/test/ELF/aarch64-execute-only.s
+++ b/lld/test/ELF/aarch64-execute-only.s
@@ -4,6 +4,9 @@
 // RUN: ld.lld --xosegment %t.o -o %t.so -shared
 // RUN: llvm-readelf -l %t.so | FileCheck --implicit-check-not=LOAD %s
 
+// RUN: not ld.lld --execute-only --no-rosegment %t.o -shared -o /dev/null 2>&1 | FileCheck --check-prefix=ERR-NOROSEGMENT %s
+// ERR-NOROSEGMENT: error: --execute-only and --no-rosegment cannot be used together
+
 // RUN: echo ".section .foo,\"ax\"; ret" > %t.s
 // RUN: llvm-mc -filetype=obj -triple=aarch64 %t.s -o %t2.o
 // RUN: ld.lld --xosegment %t.o %t2.o -o %t.so -shared

diff  --git a/lld/test/ELF/target-specific-options.s b/lld/test/ELF/target-specific-options.s
index 9d57776fcfbef..3d34ad294eb7b 100644
--- a/lld/test/ELF/target-specific-options.s
+++ b/lld/test/ELF/target-specific-options.s
@@ -1,26 +1,49 @@
 # REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
+# RUN: rm -rf %t && mkdir %t && cd %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o a.o
 
-# RUN: not ld.lld %t --fix-cortex-a53-843419 -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-843419
-# ERR-843419: error: --fix-cortex-a53-843419 is only supported on AArch64
+# RUN: not ld.lld a.o --fix-cortex-a8 --fix-cortex-a53-843419 2>&1 | FileCheck %s --check-prefix=ERR-ARM
+# ERR-ARM: error: --fix-cortex-a8 is only supported on ARM targets
+# ERR-ARM: error: --fix-cortex-a53-843419 is only supported on AArch64
 
-# RUN: not ld.lld %t --be8 -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-BE8
+# RUN: not ld.lld a.o --be8 2>&1 | FileCheck %s --check-prefix=ERR-BE8
 # ERR-BE8: error: --be8 is only supported on ARM targets
 
-# RUN: not ld.lld %t --pcrel-optimize -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-PCREL
-# ERR-PCREL: error: --pcrel-optimize is only supported on PowerPC64 targets
+# RUN: not ld.lld a.o --execute-only -z pac-plt -z force-bti -z bti-report=error \
+# RUN:   -z pauth-report=error -z gcs-report=error -z gcs-report-dynamic=error \
+# RUN:   -z gcs=always 2>&1 | FileCheck %s --check-prefix=CHECK-AARCH64
+# CHECK-AARCH64:      error: --execute-only is only supported on AArch64 targets
+# CHECK-AARCH64-NEXT: error: -z pac-plt only supported on AArch64
+# CHECK-AARCH64-NEXT: error: -z force-bti only supported on AArch64
+# CHECK-AARCH64-NEXT: error: -z bti-report only supported on AArch64
+# CHECK-AARCH64-NEXT: error: -z pauth-report only supported on AArch64
+# CHECK-AARCH64-NEXT: error: -z gcs-report only supported on AArch64
+# CHECK-AARCH64-NEXT: error: -z gcs-report-dynamic only supported on AArch64
+# CHECK-AARCH64-NEXT: error: -z gcs only supported on AArch64
 
-# RUN: not ld.lld %t --toc-optimize -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-TOC
-# ERR-TOC: error: --toc-optimize is only supported on PowerPC64 targets
+# RUN: not ld.lld a.o --relax-gp -z zicfilp-unlabeled-report=warning \
+# RUN:   -z zicfilp-func-sig-report=warning -z zicfiss-report=warning \
+# RUN:   -z zicfilp=unlabeled -z zicfiss=always 2>&1 | \
+# RUN:   FileCheck %s --check-prefix=ERR-RISCV
+# ERR-RISCV:      error: --relax-gp is only supported on RISC-V targets
+# ERR-RISCV-NEXT: error: -z zicfilip-unlabeled-report is only supported on RISC-V targets
+# ERR-RISCV-NEXT: error: -z zicfilip-func-sig-report is only supported on RISC-V targets
+# ERR-RISCV-NEXT: error: -z zicfiss-report is only supported on RISC-V targets
+# ERR-RISCV-NEXT: error: -z zicfilp is only supported on RISC-V targets
+# ERR-RISCV-NEXT: error: -z zicfiss is only supported on RISC-V targets
 
-# RUN: not ld.lld %t -z execute-only-report=warning -o /dev/null 2>&1 | \
-# RUN:     FileCheck %s --check-prefix=ERR-EXECUTE-ONLY
-# RUN: not ld.lld %t -z execute-only-report=error -o /dev/null 2>&1 | \
-# RUN:     FileCheck %s --check-prefix=ERR-EXECUTE-ONLY
+# RUN: not ld.lld a.o --toc-optimize --pcrel-optimize 2>&1 | FileCheck %s --check-prefix=ERR-PPC64
+# ERR-PPC64: error: --toc-optimize is only supported on PowerPC64 targets
+# ERR-PPC64: error: --pcrel-optimize is only supported on PowerPC64 targets
+
+# RUN: not ld.lld a.o -z execute-only-report=warning 2>&1 | \
+# RUN:   FileCheck %s --check-prefix=ERR-EXECUTE-ONLY
+# RUN: not ld.lld a.o -z execute-only-report=error 2>&1 | \
+# RUN:   FileCheck %s --check-prefix=ERR-EXECUTE-ONLY
 # ERR-EXECUTE-ONLY: error: -z execute-only-report only supported on AArch64 and ARM
 
-# RUN: not ld.lld %t -z execute-only-report=foo -o /dev/null 2>&1 | \
-# RUN:     FileCheck %s --check-prefix=ERR-EXECUTE-ONLY-INVALID
+# RUN: not ld.lld a.o -z execute-only-report=foo 2>&1 | \
+# RUN:   FileCheck %s --check-prefix=ERR-EXECUTE-ONLY-INVALID
 # ERR-EXECUTE-ONLY-INVALID: error: unknown -z execute-only-report= value: foo
 
 .globl _start

diff  --git a/lld/test/ELF/x86-64-feature-cet.s b/lld/test/ELF/x86-64-feature-cet.s
index 6a88463ff8bfd..bf90538543ff7 100644
--- a/lld/test/ELF/x86-64-feature-cet.s
+++ b/lld/test/ELF/x86-64-feature-cet.s
@@ -102,6 +102,9 @@
 # NOPLT:     .note.gnu.property
 # NOPLT-NOT: .plt
 
+# RUN: not ld.lld %t1.o -z retpolineplt -z force-ibt -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-IBT-RETPOLINE
+# ERR-IBT-RETPOLINE: error: -z force-ibt may not be used with -z retpolineplt
+
 .section ".note.gnu.property", "a"
 .long 4
 .long 0x10


        


More information about the llvm-commits mailing list