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.
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.
int add(int a, int b)
{
return a + b;
}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 endbr641
0The 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.