Skip to content

Commit 8723946

Browse files
committedFeb 28, 2017
[ARM] Don't pass -arm-execute-only to cc1as
The option -mexecute-only is translated into the backend option -arm-execute-only. But this option only makes sense for the compiler and the assembler does not recognize it. This patch stops clang from passing this option to the assembler. Change-Id: I4f4cb1162c13cfd50a0a36702a4ecab1bc0324ba Review: https://reviews.llvm.org/D30414 llvm-svn: 296454
1 parent 44038f1 commit 8723946

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed
 

‎clang/lib/Driver/Arch/ARM.cpp

+20-17
Original file line numberDiff line numberDiff line change
@@ -374,25 +374,28 @@ void arm::getARMTargetFeatures(const ToolChain &TC,
374374
}
375375

376376
// Generate execute-only output (no data access to code sections).
377-
// Supported only on ARMv6T2 and ARMv7 and above.
378-
// Cannot be combined with -mno-movt or -mlong-calls
379-
if (Arg *A = Args.getLastArg(options::OPT_mexecute_only, options::OPT_mno_execute_only)) {
380-
if (A->getOption().matches(options::OPT_mexecute_only)) {
381-
if (getARMSubArchVersionNumber(Triple) < 7 &&
382-
llvm::ARM::parseArch(Triple.getArchName()) != llvm::ARM::AK_ARMV6T2)
383-
D.Diag(diag::err_target_unsupported_execute_only) << Triple.getArchName();
384-
else if (Arg *B = Args.getLastArg(options::OPT_mno_movt))
385-
D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) << B->getAsString(Args);
386-
// Long calls create constant pool entries and have not yet been fixed up
387-
// to play nicely with execute-only. Hence, they cannot be used in
388-
// execute-only code for now
389-
else if (Arg *B = Args.getLastArg(options::OPT_mlong_calls, options::OPT_mno_long_calls)) {
390-
if (B->getOption().matches(options::OPT_mlong_calls))
377+
// This only makes sense for the compiler, not for the assembler.
378+
if (!ForAS) {
379+
// Supported only on ARMv6T2 and ARMv7 and above.
380+
// Cannot be combined with -mno-movt or -mlong-calls
381+
if (Arg *A = Args.getLastArg(options::OPT_mexecute_only, options::OPT_mno_execute_only)) {
382+
if (A->getOption().matches(options::OPT_mexecute_only)) {
383+
if (getARMSubArchVersionNumber(Triple) < 7 &&
384+
llvm::ARM::parseArch(Triple.getArchName()) != llvm::ARM::AK_ARMV6T2)
385+
D.Diag(diag::err_target_unsupported_execute_only) << Triple.getArchName();
386+
else if (Arg *B = Args.getLastArg(options::OPT_mno_movt))
391387
D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) << B->getAsString(Args);
388+
// Long calls create constant pool entries and have not yet been fixed up
389+
// to play nicely with execute-only. Hence, they cannot be used in
390+
// execute-only code for now
391+
else if (Arg *B = Args.getLastArg(options::OPT_mlong_calls, options::OPT_mno_long_calls)) {
392+
if (B->getOption().matches(options::OPT_mlong_calls))
393+
D.Diag(diag::err_opt_not_valid_with_opt) << A->getAsString(Args) << B->getAsString(Args);
394+
}
395+
396+
CmdArgs.push_back("-backend-option");
397+
CmdArgs.push_back("-arm-execute-only");
392398
}
393-
394-
CmdArgs.push_back("-backend-option");
395-
CmdArgs.push_back("-arm-execute-only");
396399
}
397400
}
398401

‎clang/test/Driver/arm-execute-only.c

+4
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,14 @@
9090
// RUN: not %clang -target armv8m.main-eabi -mpure-code -mlong-calls %s 2>&1 \
9191
// RUN: | FileCheck %s -check-prefix CHECK-EXECUTE-ONLY-LONG-CALLS
9292

93+
// RUN: %clang -target armv7m-eabi -x assembler -mexecute-only %s -c -### 2>&1 \
94+
// RUN: | FileCheck %s -check-prefix CHECK-NO-EXECUTE-ONLY -check-prefix CHECK-NO-EXECUTE-ONLY-ASM
95+
9396
//
9497
// CHECK-NO-EXECUTE-ONLY-NOT: "-backend-option" "-arm-execute-only"
9598
// CHECK-EXECUTE-ONLY: "-backend-option" "-arm-execute-only"
9699

97100
// CHECK-EXECUTE-ONLY-NOT-SUPPORTED: error: execute only is not supported for the thumbv6m sub-architecture
98101
// CHECK-EXECUTE-ONLY-NO-MOVT: error: option '-mexecute-only' cannot be specified with '-mno-movt'
99102
// CHECK-EXECUTE-ONLY-LONG-CALLS: error: option '-mexecute-only' cannot be specified with '-mlong-calls'
103+
// CHECK-NO-EXECUTE-ONLY-ASM: warning: argument unused during compilation: '-mexecute-only'

0 commit comments

Comments
 (0)
Please sign in to comment.