GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
i386

i386: Do not define __CET__ for -fcf-protection=check

Corrects the definition of the __CET__ macro for the -fcf-protection=check flag to avoid misrepresenting enabled CET features.

The -fcf-protection=check compiler flag previously caused the __CET__ macro to be defined with a value indicating that both indirect branch tracking (IBT) and shadow stack (SHSTK) were enabled, even when they were not. This commit modifies the definition of __CET__ to only reflect the CF_BRANCH and CF_RETURN bits when they are actually set, preventing incorrect GNU_PROPERTY_X86_FEATURE_1_AND notes in assembly files.

In Details

This change adjusts ix86_target_macros to correctly define the __CET__ preprocessor macro when using -fcf-protection=check. Previously, this flag set flag_cf_protection to CF_CHECK | CF_SET, which ix86_target_macros incorrectly translated to __CET__=8 (implying IBT and SHSTK enabled), even though only the check/set bookkeeping bits were active. The fix ensures __CET__ is defined only if CF_BRANCH or CF_RETURN is set, and its value accurately reflects only those enabled CET security features.

For Context
CET
Control-Flow Enforcement Technology, a security feature in x86 processors that helps protect against control-flow hijacking attacks by adding hardware checks for indirect branches and calls.
-fcf-protection=check
A GCC flag that enables control-flow protection checks. The 'check' level primarily adds instrumentation for detecting control-flow violations without necessarily enabling full hardware enforcement features like Indirect Branch Tracking (IBT) or Shadow Stack (SHSTK).
IBT
Indirect Branch Tracking, a component of Intel's Control-Flow Enforcement Technology (CET) that validates targets of indirect branches.
SHSTK
Shadow Stack, a component of Intel's Control-Flow Enforcement Technology (CET) that maintains a separate stack to protect return addresses from being overwritten by attackers.
__CET__
A preprocessor macro defined by GCC on x86 targets when Control-Flow Enforcement Technology (CET) features are enabled, indicating which specific CET capabilities are active.
Filed Under: i386securitycompiler