Skip to content

Commit 0158137

Browse files
committed
Supply -z,nobtcfi on x86_64 as well.
On older x86_64 hardware, this isn't a problem since CET IBT hardware support may not have been available. However, newer x86_64 hardware supports the feature, which will lead to BTCFI failures. Therefore ensure the same BTCFI disabling logic applies on x86_64 as well as aarch64.
1 parent f095990 commit 0158137

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ function(add_swift_host_tool executable)
995995
endif()
996996

997997
# Opt-out of OpenBSD BTCFI if instructed where it is enforced by default.
998-
if(SWIFT_HOST_VARIANT_SDK STREQUAL "OPENBSD" AND SWIFT_HOST_VARIANT_ARCH STREQUAL "aarch64" AND NOT SWIFT_OPENBSD_BTCFI)
998+
if(SWIFT_HOST_VARIANT_SDK STREQUAL "OPENBSD" AND SWIFT_HOST_VARIANT_ARCH MATCHES "aarch64|x86_64" AND NOT SWIFT_OPENBSD_BTCFI)
999999
target_link_options(${executable} PRIVATE "LINKER:-z,nobtcfi")
10001000
endif()
10011001

lib/Basic/Platform.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ bool swift::tripleRequiresRPathForSwiftLibrariesInOS(
150150
}
151151

152152
bool swift::tripleBTCFIByDefaultInOpenBSD(const llvm::Triple &triple) {
153-
return triple.isOSOpenBSD() && triple.getArch() == llvm::Triple::aarch64;
153+
return triple.isOSOpenBSD() && (
154+
triple.getArch() == llvm::Triple::aarch64 ||
155+
triple.getArch() == llvm::Triple::x86_64);
156+
154157
}
155158

156159
DarwinPlatformKind swift::getDarwinPlatformKind(const llvm::Triple &triple) {

0 commit comments

Comments
 (0)