Skip to content

Commit b111674

Browse files
committed
Only use ifunc resolvers if __builtin_cpu_supports+init available
If either of them is not available, the use of zend_cpu_supports() inside ifunc resolvers may not be safe.
1 parent 5dc9418 commit b111674

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Zend/zend_portability.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,10 @@ extern "C++" {
489489
# undef HAVE_FUNC_ATTRIBUTE_IFUNC
490490
#endif
491491

492-
#if defined(HAVE_FUNC_ATTRIBUTE_IFUNC) && defined(HAVE_FUNC_ATTRIBUTE_TARGET)
492+
/* Only use ifunc resolvers if we have __builtin_cpu_supports() and __builtin_cpu_init(),
493+
* otherwise the use of zend_cpu_supports() may not be safe inside ifunc resolvers. */
494+
#if defined(HAVE_FUNC_ATTRIBUTE_IFUNC) && defined(HAVE_FUNC_ATTRIBUTE_TARGET) && \
495+
defined(PHP_HAVE_BUILTIN_CPU_SUPPORTS) && defined(PHP_HAVE_BUILTIN_CPU_INIT)
493496
# define ZEND_INTRIN_HAVE_IFUNC_TARGET 1
494497
#endif
495498

0 commit comments

Comments
 (0)