Skip to content

Commit dc9c00b

Browse files
chen-hu-97root
authored andcommitted
Fixed bug #8338 (Intel CET is disabled unintentionally since PHP-8.1.0)
Intel Control Flow Enforcement Technology (CET) is enabled by default since gcc v8.1. With CET, gcc emits following processor-specific program property types in .note.gnu.property section: - Indirect Branch Tracking (IBT) - Shadow Stack (SHSTK) Such properties are there before PHP-8.1.0. $ sudo readelf -n sapi/cli/php Displaying notes found in: .note.gnu.property Owner Data size Description GNU 0x00000020 NT_GNU_PROPERTY_TYPE_0 Properties: x86 feature: IBT, SHSTK x86 ISA needed: x86-64-baseline However, the properties are missing since PHP-8.1.0. $ sudo readelf -n sapi/cli/php Displaying notes found in: .note.gnu.property Owner Data size Description GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 Properties: x86 ISA needed: x86-64-baseline This is caused by commit c276c16 "Implement Fibers" which introduces some assembly files such as jump_x86_64_sysv_elf_gas.S and make_x86_64_sysv_elf_gas.S. The object files of such assembly miss .note.gnu.property section and thus the final output files miss it too. Fix this via adding linker option. Signed-off-by: Chen, Hu <[email protected]>
1 parent 414f7fc commit dc9c00b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

configure.ac

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,23 @@ if test -d /usr/pkg/include -a -d /usr/pkg/lib ; then
352352
fi
353353
test -d /usr/ucblib && PHP_ADD_LIBPATH(/usr/ucblib)
354354

355+
dnl Check whether the Intel CET is enabled
356+
AC_CACHE_CHECK([whether Intel CET is enabled], ac_cv_intel_cet_enabled, [
357+
AC_COMPILE_IFELSE([
358+
AC_LANG_SOURCE([[
359+
#ifndef __CET__
360+
# error CET is not enabled
361+
#endif
362+
]])], [
363+
ac_cv_intel_cet_enabled=yes
364+
], [
365+
ac_cv_intel_cet_enabled=no
366+
])
367+
if test "$ac_cv_intel_cet_enabled" = yes; then
368+
EXTRA_LDFLAGS_PROGRAM="$EXTRA_LDFLAGS_PROGRAM -Wl,-zibt -Wl,-zshstk"
369+
fi
370+
])
371+
355372
dnl First, library checks.
356373
dnl ----------------------------------------------------------------------------
357374

0 commit comments

Comments
 (0)