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. --- doc/guides/mrbconf.md | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'doc') diff --git a/doc/guides/mrbconf.md b/doc/guides/mrbconf.md index 4f5349e77..2f81776df 100644 --- a/doc/guides/mrbconf.md +++ b/doc/guides/mrbconf.md @@ -134,21 +134,16 @@ largest value of required alignment. ## Reduce heap memory configuration. -`MRB_USE_ETEXT_EDATA` +`MRB_USE_LINK_TIME_RO_DATA_P` +* Only available on ELF platforms. * If you specify the address of a read-only section when creating a symbol or string, that string will be used as it is. * Heap memory can be saved. -* Uses `_etext` and `__init_array_start`. -* It must be `_etext < data_addr < &__init_array_start`. - -`MRB_NO_INIT_ARRAY_START` -* Ignored if `MRB_USE_ETEXT_EDATA` is not defined. -* Please try if `__init_array_start` is not available. -* Uses `_etext` and `_edata`. -* It must be `_etext < data_addr < _edata`. +* Uses `__ehdr_start` and `__init_array_start`. +* It must be `__ehdr_start < data_addr < __init_array_start`. `MRB_USE_CUSTOM_RO_DATA_P` -* Takes precedence over `MRB_USE_ETEXT_EDATA`. -* Please try if both `MRB_USE_ETEXT_EDATA` and `MRB_NO_INIT_ARRAY_START` are not available. +* Takes precedence over `MRB_USE_LINK_TIME_RO_DATA_P`. +* Please try if `MRB_USE_LINK_TIME_RO_DATA_P` is not available. * The `mrb_ro_data_p()` function is implemented by the user in an arbitrary file. * The prototype declaration is `mrb_bool mrb_ro_data_p(const char *ptr)`. * Return `TRUE` if `ptr` is in read-only section, otherwise return `FALSE`. -- cgit v1.2.3