brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.0 KiB · 795e4c9 Raw
140 lines · plain
1# REQUIRES: aarch642## Test the Guarded Control Stack (GCS) feature.3## Naming convention: *-s.s files enable GCS.4# RUN: rm -rf %t && split-file %s %t && cd %t5# RUN: llvm-mc -filetype=obj -triple=aarch64 f1-s.s -o f1-s.o6# RUN: llvm-mc -filetype=obj -triple=aarch64 f2.s -o f2.o7# RUN: llvm-mc -filetype=obj -triple=aarch64 f2-s.s -o f2-s.o8# RUN: llvm-mc -filetype=obj -triple=aarch64 f3.s -o f3.o9# RUN: llvm-mc -filetype=obj -triple=aarch64 f3-s.s -o f3-s.o10 11## GCS should be enabled when it's enabled in all inputs or when it's forced on.12 13# RUN: ld.lld f1-s.o f2-s.o f3-s.o -o out --fatal-warnings14# RUN: llvm-readelf -n out | FileCheck --check-prefix GCS %s15# RUN: ld.lld f1-s.o f2.o f3-s.o -o out.force -z gcs=always --fatal-warnings16# RUN: llvm-readelf -n out.force | FileCheck --check-prefix GCS %s17# RUN: ld.lld f2-s.o f3.o --shared -o out.force.so -z gcs=never -z gcs=always --fatal-warnings18# RUN: llvm-readelf -n out.force.so | FileCheck --check-prefix GCS %s19 20# GCS: Properties:    aarch64 feature: GCS21 22## GCS should not be enabled if it's not enabled in at least one input.23 24# RUN: ld.lld f1-s.o f2.o f3-s.o -o out.no --fatal-warnings25# RUN: llvm-readelf -n out.no | count 026# RUN: ld.lld f2-s.o f3.o --shared -o out.no.so27 28## GCS should be disabled with gcs=never, even if GCS is present in all inputs.29 30# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z gcs=always -z gcs=never -o out.never --fatal-warnings31# RUN: llvm-readelf -n out.never | count 032 33## gcs-report should report any input files that don't have the gcs property.34 35# RUN: ld.lld f1-s.o f2.o f3-s.o -z gcs-report=warning 2>&1 | FileCheck --check-prefix=REPORT-WARN %s36# RUN: ld.lld f1-s.o f2.o f3-s.o -z gcs-report=warning -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-WARN %s37# RUN: ld.lld f1-s.o f2.o f3-s.o -z gcs-report=warning -z gcs=never 2>&1 | FileCheck --check-prefix=REPORT-WARN %s38# RUN: not ld.lld f2-s.o f3.o --shared -z gcs-report=error 2>&1 | FileCheck --check-prefix=REPORT-ERROR %s39# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z gcs-report=warning -z gcs=always 2>&1 | count 040 41# REPORT-WARN: warning: f2.o: -z gcs-report: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_GCS property42# REPORT-WARN-NOT: {{.}}43# REPORT-ERROR: error: f3.o: -z gcs-report: file does not have GNU_PROPERTY_AARCH64_FEATURE_1_GCS property44# REPORT-ERROR-NOT: {{.}}45 46## gcs-report-dynamic should report any dynamic objects that does not have the gcs property. This also ensures the inhertance from gcs-report is working correctly.47 48# RUN: ld.lld f1-s.o f3-s.o out.no.so out.force.so -z gcs-report=warning -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-WARN-DYNAMIC %s49# RUN: ld.lld f1-s.o f3-s.o out.no.so out.force.so -z gcs-report=error -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-WARN-DYNAMIC %s50# RUN: ld.lld f1-s.o f3-s.o out.no.so out.force.so -z gcs-report-dynamic=warning -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-WARN-DYNAMIC %s51# RUN: not ld.lld f1-s.o f3-s.o out.no.so out.force.so -z gcs-report-dynamic=error -z gcs=always 2>&1 | FileCheck --check-prefix=REPORT-ERROR-DYNAMIC %s52# RUN: ld.lld f1-s.o f3-s.o out.force.so -z gcs-report-dynamic=error -z gcs=always 2>&1 | count 053 54# REPORT-WARN-DYNAMIC: warning: out.no.so: GCS is required by -z gcs, but this shared library lacks the necessary property note. The dynamic loader might not enable GCS or refuse to load the program unless all shared library dependencies have the GCS marking.55# REPORT-WARN-DYNAMIC-NOT: {{.}}56# REPORT-ERROR-DYNAMIC: error: out.no.so: GCS is required by -z gcs, but this shared library lacks the necessary property note. The dynamic loader might not enable GCS or refuse to load the program unless all shared library dependencies have the GCS marking.57# REPORT-ERROR-DYNAMIC-NOT: error:58 59## An invalid gcs option should give an error60# RUN: not ld.lld f1-s.o -z gcs=x -z gcs-report=x -z gcs-report-dynamic=x 2>&1 | FileCheck --check-prefix=INVALID %s61 62# INVALID: error: unknown -z gcs= value: x63# INVALID: error: unknown -z gcs-report= value: x64# INVALID: error: unknown -z gcs-report-dynamic= value: x65 66#--- f1-s.s67.section ".note.gnu.property", "a"68.long 469.long 0x1070.long 0x571.asciz "GNU"72 73.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND74.long 475.long 4          // GNU_PROPERTY_AARCH64_FEATURE_1_GCS76.long 077 78.text79.globl _start80.type f1,%function81f1:82  bl f283  ret84 85#--- f2.s86.text87.globl f288.type f2,@function89f2:90  .globl f391  .type f3, @function92  bl f393  ret94 95#--- f2-s.s96.section ".note.gnu.property", "a"97.long 498.long 0x1099.long 0x5100.asciz "GNU"101 102.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND103.long 4104.long 4          // GNU_PROPERTY_AARCH64_FEATURE_1_GCS105.long 0106 107.text108.globl f2109.type f2,@function110f2:111  .globl f3112  .type f3, @function113  bl f3114  ret115 116#--- f3.s117.text118.globl f3119.type f3,@function120f3:121  ret122 123#--- f3-s.s124.section ".note.gnu.property", "a"125.long 4126.long 0x10127.long 0x5128.asciz "GNU"129 130.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND131.long 4132.long 4          // GNU_PROPERTY_AARCH64_FEATURE_1_GCS133.long 0134 135.text136.globl f3137.type f3,@function138f3:139  ret140