Skip to content

Commit 9a2113a

Browse files
dstogovshivammathur
authored andcommitted
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 2f2fb1f commit 9a2113a

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
@@ -366,36 +366,28 @@ ZEND_API void zend_interned_strings_switch_storage(bool request)
366366
}
367367
}
368368

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

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

387-
ZEND_API bool ZEND_FASTCALL NO_CALLER_SAVED_REGISTERS I_REPLACE_SONAME_FNNAME_ZU(NONE,zend_string_equal_val)(zend_string *s1, zend_string *s2)
383+
ZEND_API bool ZEND_FASTCALL I_REPLACE_SONAME_FNNAME_ZU(NONE,zend_string_equal_val)(zend_string *s1, zend_string *s2)
388384
{
389385
return !memcmp(ZSTR_VAL(s1), ZSTR_VAL(s2), ZSTR_LEN(s1));
390386
}
391-
392-
#ifdef POP_OPTIONS
393-
# pragma GCC pop_options
394-
# undef POP_OPTIONS
395387
#endif
396388

397389
#if defined(__GNUC__) && defined(__i386__)
398-
ZEND_API bool ZEND_FASTCALL zend_string_equal_val(zend_string *s1, zend_string *s2)
390+
ZEND_API zend_never_inline NOIPA bool ZEND_FASTCALL zend_string_equal_val(zend_string *s1, zend_string *s2)
399391
{
400392
const char *ptr = ZSTR_VAL(s1);
401393
uintptr_t delta = (uintptr_t) s2 - (uintptr_t) s1;
@@ -433,7 +425,7 @@ ZEND_API bool ZEND_FASTCALL zend_string_equal_val(zend_string *s1, zend_string *
433425
}
434426

435427
#elif defined(__GNUC__) && defined(__x86_64__) && !defined(__ILP32__)
436-
ZEND_API bool ZEND_FASTCALL zend_string_equal_val(zend_string *s1, zend_string *s2)
428+
ZEND_API zend_never_inline NOIPA bool ZEND_FASTCALL zend_string_equal_val(zend_string *s1, zend_string *s2)
437429
{
438430
const char *ptr = ZSTR_VAL(s1);
439431
uintptr_t delta = (uintptr_t) s2 - (uintptr_t) s1;

0 commit comments

Comments
 (0)