Skip to content

[PPC] ROP protection won't be supported with the ELFV1 ABI. #139947

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions clang/lib/Basic/Targets/PPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,12 @@ bool PPCTargetInfo::initFeatureMap(
return false;
}

if (ABI == "elfv1") {
Diags.Report(diag::err_unsupported_abi_for_opt)
<< "-mrop-protect" << "elfv2";
return false;
}

if (!(ArchDefs & ArchDefinePwr8)) {
// We can turn on ROP Protect on Power 8 and above.
Diags.Report(diag::err_opt_not_valid_with_opt) << "-mrop-protect" << CPU;
Expand Down
13 changes: 13 additions & 0 deletions clang/test/Driver/ppc-mrop-protection-support-check.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,23 @@
// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
// RUN: -mcpu=pwr7 -mrop-protect %s 2>&1 | FileCheck %s --check-prefix=NOROP

// RUN: not %clang -target powerpc64-unknown-linux-gnu -fsyntax-only \
// RUN: -mcpu=power8 -mrop-protect %s 2>&1 | FileCheck %s --check-prefix=ELFV1
// RUN: not %clang -target powerpc64le-unknown-linux-gnu -fsyntax-only \
// RUN: -mcpu=power8 -mrop-protect -mabi=elfv1 %s 2>&1 | \
// RUN: FileCheck %s --check-prefix=ELFV1

// RUN: not %clang -target powerpc-unknown-linux -fsyntax-only \
// RUN: -mcpu=pwr8 -mrop-protect %s 2>&1 | FileCheck %s --check-prefix=32BIT
// RUN: not %clang -target powerpc-unknown-aix -fsyntax-only \
// RUN: -mcpu=pwr8 -mrop-protect %s 2>&1 | FileCheck %s --check-prefix=32BIT

#ifdef __ROP_PROTECT__
#if defined(__CALL_ELF) && __CALL_ELF == 1
#error "ROP protection not supported with 64-bit elfv1 abi"
#endif
#endif

#ifdef __ROP_PROTECT__
static_assert(false, "ROP Protect enabled");
#endif
Expand All @@ -20,3 +32,4 @@ static_assert(false, "ROP Protect enabled");
// NOROP: option '-mrop-protect' cannot be specified with

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