mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
use __init_array_start to determine readonly data section;
b72e94f used _etext and _edata to distinguish C string literals from heap allocated strings,
but using _edata, global char arrays may be considered as string literals. to avoid the issue,
we have to use __init_array_start, which might be less portable. you can still use _edata, by
using MRB_NO_INIT_ARRAY_START.
This commit is contained in:
@@ -41,6 +41,10 @@
|
||||
/* if _etext and _edata available, mruby can reduce memory used by symbols */
|
||||
//#define MRB_USE_ETEXT_EDATA
|
||||
|
||||
/* do not use __init_array_start to determine readonly data section;
|
||||
effective only when MRB_USE_ETEXT_EDATA is defined */
|
||||
//#define MRB_NO_INIT_ARRAY_START
|
||||
|
||||
/* turn off generational GC by default */
|
||||
//#define MRB_GC_TURN_OFF_GENERATIONAL
|
||||
|
||||
|
||||
@@ -213,6 +213,7 @@ mrb_undef_value(void)
|
||||
|
||||
#ifdef MRB_USE_ETEXT_EDATA
|
||||
extern char _etext[];
|
||||
#ifdef MRB_NO_INIT_ARRAY_START
|
||||
extern char _edata[];
|
||||
|
||||
static inline mrb_bool
|
||||
@@ -221,6 +222,15 @@ mrb_ro_data_p(const char *p)
|
||||
return _etext < p && p < _edata;
|
||||
}
|
||||
#else
|
||||
extern char __init_array_start[];
|
||||
|
||||
static inline mrb_bool
|
||||
mrb_ro_data_p(const char *p)
|
||||
{
|
||||
return _etext < p && p < (char*)&__init_array_start;
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
# define mrb_ro_data_p(p) FALSE
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user