Skip to content

Commit 21bbe51

Browse files
committed
[PPC] ROP protection won't be supported with the ELFV1 ABI.
1 parent 0afa62c commit 21bbe51

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

clang/lib/Basic/Targets/PPC.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,12 @@ bool PPCTargetInfo::initFeatureMap(
685685
return false;
686686
}
687687

688+
if (ABI == "elfv1") {
689+
Diags.Report(diag::err_unsupported_abi_for_opt)
690+
<< "-mrop-protect" << "elfv2";
691+
return false;
692+
}
693+
688694
if (!(ArchDefs & ArchDefinePwr8)) {
689695
// We can turn on ROP Protect on Power 8 and above.
690696
Diags.Report(diag::err_opt_not_valid_with_opt) << "-mrop-protect" << CPU;

clang/test/Driver/ppc-mrop-protection-support-check.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,23 @@
66
// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
77
// RUN: -mcpu=pwr7 -mrop-protect %s 2>&1 | FileCheck %s --check-prefix=NOROP
88

9+
// RUN: not %clang -target powerpc64-unknown-linux-gnu -fsyntax-only \
10+
// RUN: -mcpu=power8 -mrop-protect %s 2>&1 | FileCheck %s --check-prefix=ELFV1
11+
// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
12+
// RUN: -mcpu=power8 -mrop-protect -mabi=elfv1 %s 2>&1 | \
13+
// RUN: FileCheck %s --check-prefix=ELFV1
14+
915
// RUN: not %clang -target powerpc-unknown-linux -fsyntax-only \
1016
// RUN: -mcpu=pwr8 -mrop-protect %s 2>&1 | FileCheck %s --check-prefix=32BIT
1117
// RUN: not %clang -target powerpc-unknown-aix -fsyntax-only \
1218
// RUN: -mcpu=pwr8 -mrop-protect %s 2>&1 | FileCheck %s --check-prefix=32BIT
1319

20+
#ifdef __ROP_PROTECT__
21+
#if defined(__CALL_ELF) && __CALL_ELF == 1
22+
#error "ROP protection not supported with 64-bit elfv1 abi"
23+
#endif
24+
#endif
25+
1426
#ifdef __ROP_PROTECT__
1527
static_assert(false, "ROP Protect enabled");
1628
#endif
@@ -20,3 +32,4 @@ static_assert(false, "ROP Protect enabled");
2032
// NOROP: option '-mrop-protect' cannot be specified with
2133

2234
// 32BIT: option '-mrop-protect' cannot be specified on this target
35+
// ELFV1: '-mrop-protect' can only be used with the 'elfv2' ABI

0 commit comments

Comments
 (0)