]> granicus.if.org Git - php/commitdiff
Only use ifunc resolvers if __builtin_cpu_supports+init available
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 11 May 2020 10:43:38 +0000 (12:43 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 11 May 2020 10:43:38 +0000 (12:43 +0200)
If either of them is not available, the use of zend_cpu_supports()
inside ifunc resolvers may not be safe.

Zend/zend_portability.h

index e1370eecf88f2aec0f8a5e9297144c946c2ddafe..8a278c93f1919501e2f225a7f1f6fd30567ce8b3 100644 (file)
@@ -489,7 +489,10 @@ extern "C++" {
 # undef HAVE_FUNC_ATTRIBUTE_IFUNC
 #endif
 
-#if defined(HAVE_FUNC_ATTRIBUTE_IFUNC) && defined(HAVE_FUNC_ATTRIBUTE_TARGET)
+/* Only use ifunc resolvers if we have __builtin_cpu_supports() and __builtin_cpu_init(),
+ * otherwise the use of zend_cpu_supports() may not be safe inside ifunc resolvers. */
+#if defined(HAVE_FUNC_ATTRIBUTE_IFUNC) && defined(HAVE_FUNC_ATTRIBUTE_TARGET) && \
+       defined(PHP_HAVE_BUILTIN_CPU_SUPPORTS) && defined(PHP_HAVE_BUILTIN_CPU_INIT)
 # define ZEND_INTRIN_HAVE_IFUNC_TARGET 1
 #endif