Skip to content

[ARM] Forbid use of TLS with execute-only #124806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2025
Merged

Conversation

ostannard
Copy link
Collaborator

Thread-local code generation requires constant pools because most of the relocations needed for it operate on data, so it cannot be used with -mexecute-only (or -mpure-code, which is aliased in the driver).

Without this we hit an assertion in the backend when trying to generate a constant pool.

Thread-local code generation requires constant pools because most of the
relocations needed for it operate on data, so it cannot be used with
-mexecute-only (or -mpure-code, which is aliased in the driver).

Without this we hit an assertion in the backend when trying to generate
a constant pool.
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:ARM clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Jan 28, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 28, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-arm

Author: Oliver Stannard (ostannard)

Changes

Thread-local code generation requires constant pools because most of the relocations needed for it operate on data, so it cannot be used with -mexecute-only (or -mpure-code, which is aliased in the driver).

Without this we hit an assertion in the backend when trying to generate a constant pool.


Full diff: https://github.com/llvm/llvm-project/pull/124806.diff

2 Files Affected:

  • (modified) clang/lib/Basic/Targets/ARM.cpp (+2)
  • (added) clang/test/Sema/arm-execute-only-tls.c (+10)
diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 0fd5433a76402e..5aa2baeb81b731 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -608,6 +608,8 @@ bool ARMTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
       HasBTI = 1;
     } else if (Feature == "+fullbf16") {
       HasFullBFloat16 = true;
+    } else if (Feature == "+execute-only") {
+      TLSSupported = false;
     }
   }
 
diff --git a/clang/test/Sema/arm-execute-only-tls.c b/clang/test/Sema/arm-execute-only-tls.c
new file mode 100644
index 00000000000000..b17ff450cb74d1
--- /dev/null
+++ b/clang/test/Sema/arm-execute-only-tls.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple arm-none-eabi                               -fsyntax-only -verify=default      %s
+// RUN: %clang_cc1 -triple arm-none-eabi -target-feature +execute-only -fsyntax-only -verify=execute-only %s
+
+// default-no-diagnostics
+
+/// Thread-local code generation requires constant pools because most of the
+/// relocations needed for it operate on data, so it cannot be used with
+/// -mexecute-only (or -mpure-code, which is aliased in the driver).
+
+_Thread_local int t; // execute-only-error {{thread-local storage is not supported for the current target}}

@ostannard ostannard merged commit 5e43418 into llvm:main Jan 29, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:ARM clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants