From 7f044341f9f5c227d7c13c9c8ac2e9b00c8ed287 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 16 Sep 2019 07:44:05 -0700 Subject: Rename MRB_USE_ETEXT_EDATA to MRB_USE_LINK_TIME_RO_DATA_P and support lld linked programs In lld linked programs, .rodata comes before .text, thus mrb_ro_data_p will return false for strings in .rodata. Change the lower bound from _etext to __ehdr_start to catch these cases. This works for ld.bfd, gold and lld, and it does not have false positives even if .init_array does not exist. Remove the branch that uses _edata: strings in .data can be modified so this is semantically incorrect. Delete the __APPLE__ branch (its manpages say get_etext() and get_edata() are strongly discouraged). .init_array has been adopted by most ELF platforms to supersede .ctors. Neither _etext nor _edata is used, so rename MRB_USE_ETEXT_EDATA to MRB_USE_EHDR_START. --- include/mrbconf.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'include/mrbconf.h') diff --git a/include/mrbconf.h b/include/mrbconf.h index c5b9afd05..b86ce82e8 100644 --- a/include/mrbconf.h +++ b/include/mrbconf.h @@ -88,14 +88,10 @@ /* number of object per heap page */ //#define MRB_HEAP_PAGE_SIZE 1024 -/* if _etext and _edata available, mruby can reduce memory used by symbols */ -//#define MRB_USE_ETEXT_EDATA +/* if __ehdr_start is available, mruby can reduce memory used by symbols */ +//#define MRB_USE_LINK_TIME_RO_DATA_P -/* 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 - -/* if do not works both MRB_USE_ETEXT_EDATA and MRB_NO_INIT_ARRAY_START, +/* if MRB_USE_LINK_TIME_RO_DATA_P does not work, you can try mrb_ro_data_p() that you have implemented yourself in any file; prototype is `mrb_bool mrb_ro_data_p(const char *ptr)` */ //#define MRB_USE_CUSTOM_RO_DATA_P -- cgit v1.2.3