Skip to content

Commit 6339938

Browse files
authored
Disable inlining and inter-procedure-analyses for zend_string_equal_val() function that may be overriden for valgrind (php#13099)
This is a more safely way to fix phpGH-9068
1 parent 29cb814 commit 6339938

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

Zend/zend_string.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -364,36 +364,28 @@ ZEND_API void zend_interned_strings_switch_storage(bool request)
364364
}
365365
}
366366

367+
#if defined(__GNUC__) && (defined(__i386__) || (defined(__x86_64__) && !defined(__ILP32__)))
367368
/* Even if we don't build with valgrind support, include the symbol so that valgrind available
368369
* only at runtime will not result in false positives. */
369370
#ifndef I_REPLACE_SONAME_FNNAME_ZU
370371
# define I_REPLACE_SONAME_FNNAME_ZU(soname, fnname) _vgr00000ZU_ ## soname ## _ ## fnname
371372
#endif
372373

373374
/* See GH-9068 */
374-
#if defined(__GNUC__) && (__GNUC__ >= 11 || defined(__clang__)) && __has_attribute(no_caller_saved_registers)
375-
# define NO_CALLER_SAVED_REGISTERS __attribute__((no_caller_saved_registers))
376-
# ifndef __clang__
377-
# pragma GCC push_options
378-
# pragma GCC target ("general-regs-only")
379-
# define POP_OPTIONS
380-
# endif
375+
#if __has_attribute(noipa)
376+
# define NOIPA __attribute__((noipa))
381377
#else
382-
# define NO_CALLER_SAVED_REGISTERS
378+
# define NOIPA
383379
#endif
384380

385-
ZEND_API bool ZEND_FASTCALL NO_CALLER_SAVED_REGISTERS I_REPLACE_SONAME_FNNAME_ZU(NONE,zend_string_equal_val)(const zend_string *s1, const zend_string *s2)
381+
ZEND_API bool ZEND_FASTCALL I_REPLACE_SONAME_FNNAME_ZU(NONE,zend_string_equal_val)(const zend_string *s1, const zend_string *s2)
386382
{
387383
return !memcmp(ZSTR_VAL(s1), ZSTR_VAL(s2), ZSTR_LEN(s1));
388384
}
389-
390-
#ifdef POP_OPTIONS
391-
# pragma GCC pop_options
392-
# undef POP_OPTIONS
393385
#endif
394386

395387
#if defined(__GNUC__) && defined(__i386__)
396-
ZEND_API bool ZEND_FASTCALL zend_string_equal_val(const zend_string *s1, const zend_string *s2)
388+
ZEND_API zend_never_inline NOIPA bool ZEND_FASTCALL zend_string_equal_val(const zend_string *s1, const zend_string *s2)
397389
{
398390
const char *ptr = ZSTR_VAL(s1);
399391
size_t delta = (const char*)s2 - (const char*)s1;
@@ -431,7 +423,7 @@ ZEND_API bool ZEND_FASTCALL zend_string_equal_val(const zend_string *s1, const z
431423
}
432424

433425
#elif defined(__GNUC__) && defined(__x86_64__) && !defined(__ILP32__)
434-
ZEND_API bool ZEND_FASTCALL zend_string_equal_val(const zend_string *s1, const zend_string *s2)
426+
ZEND_API zend_never_inline NOIPA bool ZEND_FASTCALL zend_string_equal_val(const zend_string *s1, const zend_string *s2)
435427
{
436428
const char *ptr = ZSTR_VAL(s1);
437429
size_t delta = (const char*)s2 - (const char*)s1;

0 commit comments

Comments
 (0)