Skip to content

Commit c25a4a9

Browse files
authored
[Clang] Restore SafeStack support for x86-32 Fuchsia (#165471)
Fuchsia does not fully support an x86-32 (i?86-fuchsia) target. But the x86_64-fuchsia target in -m32 mode is used when building some kernel / boot-loader related code. This narrow use of an (effective) i?86-fuchsia target still supports SafeStack using the same Fuchsia-specific ABI as x86_64-fuchsia.
1 parent 10afda0 commit c25a4a9

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

clang/lib/Driver/ToolChains/Fuchsia.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ SanitizerMask Fuchsia::getSupportedSanitizers() const {
483483
Res |= SanitizerKind::Leak;
484484
Res |= SanitizerKind::Scudo;
485485
Res |= SanitizerKind::Thread;
486-
if (getTriple().getArch() == llvm::Triple::x86_64) {
486+
if (getTriple().getArch() == llvm::Triple::x86_64 ||
487+
getTriple().getArch() == llvm::Triple::x86) {
487488
Res |= SanitizerKind::SafeStack;
488489
}
489490
return Res;
@@ -496,6 +497,7 @@ SanitizerMask Fuchsia::getDefaultSanitizers() const {
496497
case llvm::Triple::riscv64:
497498
Res |= SanitizerKind::ShadowCallStack;
498499
break;
500+
case llvm::Triple::x86:
499501
case llvm::Triple::x86_64:
500502
Res |= SanitizerKind::SafeStack;
501503
break;

clang/test/Driver/fuchsia.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@
130130
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
131131
// RUN: -fuse-ld=ld \
132132
// RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK
133+
// RUN: %clang -### %s --target=x86_64-unknown-fuchsia -m32 \
134+
// RUN: -fsanitize=safe-stack 2>&1 \
135+
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
136+
// RUN: -fuse-ld=ld \
137+
// RUN: | FileCheck %s -check-prefix=CHECK-SAFESTACK
133138
// CHECK-SAFESTACK: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
134139
// CHECK-SAFESTACK: "-fsanitize=safe-stack"
135140
// CHECK-SAFESTACK-NOT: "[[RESOURCE_DIR]]{{/|\\\\}}lib{{/|\\\\}}x86_64-unknown-fuchsia{{/|\\\\}}libclang_rt.safestack.a"

0 commit comments

Comments
 (0)