MAP_FIXED is necessary for almost all execve() and dlopen()
MAP_FIXED is necessary for almost all execve() and dlopen()
Posted Dec 14, 2017 5:58 UTC (Thu) by jreiser (subscriber, #11027)In reply to: How about this? by wahern
Parent article: MAP_FIXED_SAFE
MAP_FIXED is necessary for the proper mapping by execve() of any native ET_EXEC file. The addresses are fixed, after all. There are ET_EXEC files which are several percent smaller and run several percent faster than the corresponding ET_DYN. Some environments have done a good risk-vs-benefit analysis, and for them ET_EXEC is worth it.
MAP_FIXED is necessary for the proper mapping by execve() and dlopen() of any native ET_DYN file which has more than one PT_LOAD, which is nearly all of them. The second and subsequent PT_LOADs must have fixed offsets from the first PT_LOAD. In most cases the best strategy is to use mmap(0, size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, FD_ANON, 0) to obtain enough contiguous space to hold the convex hull of all PT_LOAD, then mmap() each PT_LOAD into that space using MAP_FIXED.
MAP_FIXED is essential for program-manipulating programs such as valgrind and upx.
Posted Dec 14, 2017 19:14 UTC (Thu)
by roc (subscriber, #30627)
[Link]
MAP_FIXED is necessary for almost all execve() and dlopen()