[lld] [lld][AArch64] Add support for GCS (PR #90732)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri May 3 10:55:49 PDT 2024
================
@@ -0,0 +1,128 @@
+# REQUIRES: aarch64
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu func1.s -o func1.o
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu func2.s -o func2.o
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu func2-gcs.s -o func2-gcs.o
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu func3.s -o func3.o
+# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu func3-gcs.s -o func3-gcs.o
+
+## GCS should be enabled when it's enabled in all inputs or when it's forced on.
+
+# RUN: ld.lld func1.o func2-gcs.o func3-gcs.o --shared -o gcs.exe
+# RUN: llvm-readelf -n gcs.exe | FileCheck --check-prefix GCS %s
+# RUN: ld.lld func1.o func3-gcs.o --shared -o gcs.so
+# RUN: llvm-readelf -n gcs.so | FileCheck --check-prefix GCS %s
+# RUN: ld.lld func1.o func2.o func3-gcs.o --shared -o force-gcs.exe -z gcs
+# RUN: llvm-readelf -n force-gcs.exe | FileCheck --allow-empty --check-prefix GCS %s
+# RUN: ld.lld func2-gcs.o func3.o --shared -o force-gcs.so -z gcs=always
+# RUN: llvm-readelf -n force-gcs.so | FileCheck --allow-empty --check-prefix GCS %s
+# RUN: ld.lld func2-gcs.o func3.o --shared -o force-gcs2.so -z gcs=never -z gcs=always
+# RUN: llvm-readelf -n force-gcs2.so | FileCheck --allow-empty --check-prefix GCS %s
+
+# GCS: Properties: aarch64 feature: GCS
+
+## GCS should not be enabled if it's not enabled in at least one input, and we
+## should warn or error when using the report option.
+
+# RUN: ld.lld func1.o func2.o func3-gcs.o --shared -o no-gcs.exe
+# RUN: llvm-readelf -n no-gcs.exe | FileCheck --allow-empty --check-prefix NOGCS %s
+# RUN: ld.lld func2-gcs.o func3.o --shared -o no-gcs.so
+# RUN: llvm-readelf -n no-gcs.so | FileCheck --allow-empty --check-prefix NOGCS %s
+# RUN: ld.lld func1.o func2.o func3-gcs.o --shared -o no-gcs.exe -z gcs-report=warning 2>&1 | FileCheck --check-prefix=REPORT-WARN %s
+# RUN: llvm-readelf -n no-gcs.exe | FileCheck --allow-empty --check-prefix NOGCS %s
+# RUN: not ld.lld func2-gcs.o func3.o --shared -o no-gcs.so -z gcs-report=error 2>&1 | FileCheck --check-prefix=REPORT-ERROR %s
+
+# NOGCS-NOT: Properties
+# REPORT-WARN: warning: func2.o: -z gcs-report: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_GCS property
+# REPORT-ERROR: error: func3.o: -z gcs-report: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_GCS property
+
+## GCS should be disabled with gcs=never, even if GCS is present in all inputs.
+
+# RUN: ld.lld func1.o func2-gcs.o func3-gcs.o -z gcs=never --shared -o never-gcs.exe
+# RUN: llvm-readelf -n never-gcs.exe | FileCheck --allow-empty --check-prefix NOGCS %s
+# RUN: ld.lld func1.o func2-gcs.o func3-gcs.o -z gcs=always -z gcs=never --shared -o never-gcs2.exe
+# RUN: llvm-readelf -n never-gcs2.exe | FileCheck --allow-empty --check-prefix NOGCS %s
----------------
MaskRay wrote:
Test interaction of `-z gcs=never` & `-z gcs-report=warning`
https://github.com/llvm/llvm-project/pull/90732
More information about the llvm-commits
mailing list