Skip to content

Commit

Permalink
Merge pull request #5885 from FnControlOption/patch-2
Browse files Browse the repository at this point in the history
Use `getsegmentdata` instead of deprecated `get_etext`/`get_edata`
  • Loading branch information
matz committed Dec 29, 2022
2 parents 9845872 + 8c23385 commit 618d8c6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion include/mruby/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -435,10 +435,20 @@ mrb_ro_data_p(const char *p)
#elif defined(__APPLE__)
#define MRB_LINK_TIME_RO_DATA_P
#include <mach-o/getsect.h>
#include <crt_externs.h> // for _NSGetMachExecuteHeader
static inline mrb_bool
mrb_ro_data_p(const char *p)
{
return (char*)get_etext() < p && p < (char*)get_edata();
#ifdef __LP64__
struct mach_header_64 *mhp;
#else
struct mach_header *mhp;
#endif
mhp = _NSGetMachExecuteHeader();
unsigned long textsize, datasize;
char *text = (char*)getsegmentdata(mhp, SEG_TEXT, &textsize);
char *data = (char*)getsegmentdata(mhp, SEG_DATA, &datasize);
return text + textsize < p && p < data + datasize;
}
#endif /* Linux or macOS */
#endif /* MRB_NO_DEFAULT_RO_DATA_P */
Expand Down

0 comments on commit 618d8c6

Please sign in to comment.