filesystem: add flag to open files in a RAM

On Linux, it uses memfd_create syscall that can be found on Linux 3.17 and
higher. By default memfds are executable, so we set MFD_NOEXEC_SEAL flag to
prevent execution at creation time.
This commit is contained in:
Alibek Omarov
2024-12-19 04:18:19 +03:00
parent 93c5853356
commit 3d60770b84
2 changed files with 50 additions and 15 deletions

View File

@@ -1,5 +1,9 @@
#!/usr/bin/env python
MEMFD_CREATE_TEST = '''#define _GNU_SOURCE
#include <sys/mman.h>
int main(int argc, char **argv) { return memfd_create(argv[0], 0); }'''
def options(opt):
pass
@@ -11,6 +15,9 @@ def configure(conf):
elif conf.env.cxxshlib_PATTERN.startswith('lib'): # remove lib prefix for other systems than Android
conf.env.cxxshlib_PATTERN = conf.env.cxxshlib_PATTERN[3:]
if conf.check_cc(fragment=MEMFD_CREATE_TEST, msg='Checking for memfd_create', mandatory=False):
conf.define('HAVE_MEMFD_CREATE', 1)
def build(bld):
bld(name = 'filesystem_includes', export_includes = '.')