Skip to content
systemcoding.dev
Security

Enable Intel CET instrumentation with -fcf-protection=full

Build with GCC 14 and -fcf-protection=full to emit endbr64 landing pads and shadow-stack-compatible code for Intel CET on x86-64, and count the markers.

1 min read
Summarize in AI

Intel's Control-flow Enforcement Technology has two halves. Indirect branch tracking requires every indirect jump or call to land on an endbr64 instruction, and the shadow stack keeps a second copy of return addresses that ordinary stores cannot touch. -fcf-protection=full makes GCC emit the endbr64 markers that the first half needs and mark the object as compatible with the second.

add.cc
int add(int a, int b)
{
    return a + b;
}
Shell
gcc -O2 -fcf-protection=full -c add.c
objdump -d add.o | grep -c endbr64
gcc -O2 -fcf-protection=none -c add.c
objdump -d add.o | grep -c endbr64
Text
1
0

The marker is a no-op on older CPUs, so the build runs everywhere. Enforcement is a separate matter: Linux gained user-space shadow stack support for x86 in 6.6, and every object linked into the program must carry the CET property note or the loader leaves the feature off. Link with -Wl,-z,cet-report=error to make GNU ld refuse an object that lacks it. The flag is described under Instrumentation Options.

Also inToolchains
Share

More snippets

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.