mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Inline ASAN poison functions when ASAN is not enabled
The ASAN poison functions was always defined in gc.c, even if ASAN was not enabled. This made function calls to happen all the time even if ASAN is not enabled. This commit defines these functions as empty macros when ASAN is not enabled.
This commit is contained in:
parent
3071c5d04c
commit
ead3739c34
2 changed files with 8 additions and 0 deletions
2
gc.c
2
gc.c
|
@ -4940,6 +4940,7 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU
|
|||
|
||||
#undef C
|
||||
|
||||
#ifdef RUBY_ASAN_ENABLED
|
||||
void
|
||||
rb_asan_poison_object(VALUE obj)
|
||||
{
|
||||
|
@ -4960,6 +4961,7 @@ rb_asan_poisoned_object_p(VALUE obj)
|
|||
MAYBE_UNUSED(struct RVALUE *) ptr = (void *)obj;
|
||||
return __asan_region_is_poisoned(ptr, rb_gc_obj_slot_size(obj));
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
raw_obj_info(char *const buff, const size_t buff_size, VALUE obj)
|
||||
|
|
|
@ -127,6 +127,7 @@ asan_poison_memory_region(const volatile void *ptr, size_t size)
|
|||
#define asan_poison_object_if(ptr, obj) ((void)(ptr), (void)(obj))
|
||||
#endif
|
||||
|
||||
#ifdef RUBY_ASAN_ENABLED
|
||||
RUBY_SYMBOL_EXPORT_BEGIN
|
||||
/**
|
||||
* This is a variant of asan_poison_memory_region that takes a VALUE.
|
||||
|
@ -153,6 +154,11 @@ void *rb_asan_poisoned_object_p(VALUE obj);
|
|||
void rb_asan_unpoison_object(VALUE obj, bool newobj_p);
|
||||
|
||||
RUBY_SYMBOL_EXPORT_END
|
||||
#else
|
||||
# define rb_asan_poison_object(obj) ((void)obj)
|
||||
# define rb_asan_poisoned_object_p(obj) ((void)obj, NULL)
|
||||
# define rb_asan_unpoison_object(obj, newobj_p) ((void)obj, (void)newobj_p)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This function asserts that a (formally poisoned) memory region from ptr to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue