I did not work with production-quality virtual machines, but here are my five cents.
.text sections in Unix executables refer to the file in which executable code is stored; at runtime, this section of the file is mapped to the memory area allocated by the system linker during program initialization, which is all (on Linux, you can see the partition markup in memory in /proc/$PID/maps ).
Regarding JIT compilation on Unix-like systems, I can only think of the memory areas that were allocated by mmap system call with the PROT_EXEC flag. This call is defined by POSIX standards and is used by the Linux system linker ld.so to load any native executable into memory. This call can equally be used to allocate new areas of executable memory at run time.
The regular heap is often protected by the OS / MMU from execution, as any /proc/$PID/maps file shows:
00dd4000-01292000 rw-p 00000000 00:00 0 [heap]
here rw-p means that no data in [heap] can be executed (although, for example, this does not apply to x86 32-bit processors without PAE, they do not have hardware capabilities to prevent some memory data from running as code), but can be read / written.
Thus, the virtual machine requires a dedicated memory area with permission to execute code. In fact, let's look at the rwx memory areas in some Java memory layouts:
# cat /proc/12929/maps | grep rwx
Then executing native code is a matter of building a JIT-compiled native code, regardless of position (for example, shared object code, with gcc option -fPIC ) or using the address returned by mmap() .
Dmytro sirenko
source share