|
829 | 829 |
|
830 | 830 | // CHECK-NSAN-UBSAN: "--whole-archive" "{{[^"]*}}libclang_rt.nsan.a" "--no-whole-archive" |
831 | 831 |
|
832 | | -// CFI by itself does not link runtime libraries. |
| 832 | +// CFI requirements. |
833 | 833 | // RUN: not %clang -fsanitize=cfi \ |
834 | 834 | // RUN: --target=x86_64-unknown-linux -fuse-ld=ld -rtlib=platform \ |
835 | 835 | // RUN: -resource-dir=%S/Inputs/resource_dir \ |
836 | 836 | // RUN: --sysroot=%S/Inputs/basic_linux_tree \ |
837 | 837 | // RUN: -### %s 2>&1 \ |
| 838 | +// RUN: | %{filecheck} --check-prefix=CHECK-CFI-PREREQ-LINUX |
| 839 | +// CHECK-CFI-PREREQ-LINUX: '-fsanitize=cfi' only allowed with '-flto' |
| 840 | +// CHECK-CFI-PREREQ-LINUX: '-fsanitize=cfi' only allowed with '-fvisibility=' |
| 841 | + |
| 842 | +// CFI by itself does not link runtime libraries. |
| 843 | +// RUN: %clang -fsanitize=cfi \ |
| 844 | +// RUN: -flto -fvisibility=hidden \ |
| 845 | +// RUN: --target=x86_64-unknown-linux -fuse-ld=ld -rtlib=platform \ |
| 846 | +// RUN: -resource-dir=%S/Inputs/resource_dir \ |
| 847 | +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ |
| 848 | +// RUN: -### %s 2>&1 \ |
838 | 849 | // RUN: | %{filecheck} --check-prefix=CHECK-CFI-LINUX |
839 | 850 | // CHECK-CFI-LINUX: "{{.*}}ld{{(.exe)?}}" |
840 | 851 |
|
841 | 852 | // CFI with diagnostics links the UBSan runtime. |
842 | | -// RUN: not %clang -fsanitize=cfi -fno-sanitize-trap=cfi -fsanitize-recover=cfi \ |
| 853 | +// RUN: %clang -fsanitize=cfi -fno-sanitize-trap=cfi -fsanitize-recover=cfi \ |
| 854 | +// RUN: -flto -fvisibility=hidden \ |
843 | 855 | // RUN: --target=x86_64-unknown-linux -fuse-ld=ld \ |
844 | 856 | // RUN: -resource-dir=%S/Inputs/resource_dir \ |
845 | 857 | // RUN: --sysroot=%S/Inputs/basic_linux_tree \ |
|
849 | 861 | // CHECK-CFI-DIAG-LINUX: "--whole-archive" "{{[^"]*}}libclang_rt.ubsan_standalone.a" "--no-whole-archive" |
850 | 862 |
|
851 | 863 | // Cross-DSO CFI links the CFI runtime. |
852 | | -// RUN: not %clang -fsanitize=cfi -fsanitize-cfi-cross-dso \ |
| 864 | +// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso \ |
| 865 | +// RUN: -flto -fvisibility=hidden \ |
853 | 866 | // RUN: --target=x86_64-unknown-linux -fuse-ld=ld \ |
854 | 867 | // RUN: -resource-dir=%S/Inputs/resource_dir \ |
855 | 868 | // RUN: --sysroot=%S/Inputs/basic_linux_tree \ |
|
860 | 873 | // CHECK-CFI-CROSS-DSO-LINUX: -export-dynamic |
861 | 874 |
|
862 | 875 | // Cross-DSO CFI with diagnostics links just the CFI runtime. |
863 | | -// RUN: not %clang -fsanitize=cfi -fsanitize-cfi-cross-dso \ |
| 876 | +// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso \ |
| 877 | +// RUN: -flto -fvisibility=hidden \ |
864 | 878 | // RUN: -fno-sanitize-trap=cfi -fsanitize-recover=cfi \ |
865 | 879 | // RUN: --target=x86_64-unknown-linux -fuse-ld=ld \ |
866 | 880 | // RUN: -resource-dir=%S/Inputs/resource_dir \ |
|
872 | 886 | // CHECK-CFI-CROSS-DSO-DIAG-LINUX: -export-dynamic |
873 | 887 |
|
874 | 888 | // Cross-DSO CFI on Android does not link runtime libraries. |
875 | | -// RUN: not %clang -fsanitize=cfi -fsanitize-cfi-cross-dso \ |
| 889 | +// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso \ |
| 890 | +// RUN: -flto -fvisibility=hidden \ |
876 | 891 | // RUN: --target=aarch64-linux-android -fuse-ld=ld \ |
877 | 892 | // RUN: -resource-dir=%S/Inputs/resource_dir \ |
878 | 893 | // RUN: --sysroot=%S/Inputs/basic_android_tree \ |
|
881 | 896 | // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}" |
882 | 897 |
|
883 | 898 | // Cross-DSO CFI with diagnostics on Android links just the UBSAN runtime. |
884 | | -// RUN: not %clang -fsanitize=cfi -fsanitize-cfi-cross-dso \ |
| 899 | +// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso \ |
| 900 | +// RUN: -flto -fvisibility=hidden \ |
885 | 901 | // RUN: -fno-sanitize-trap=cfi -fsanitize-recover=cfi \ |
886 | 902 | // RUN: --target=aarch64-linux-android -fuse-ld=ld \ |
887 | 903 | // RUN: -resource-dir=%S/Inputs/resource_dir \ |
|
0 commit comments