mmap: # as in ld-linux.so.2 or libc.so.6 mov %ebx,%edx mov $0x5a,%eax lea 0x4(%esp,1),%ebx int $0x80 # or call *%gs:0x10 mov %edx,%ebx cmp $0xfffff000,%eax ja error ret |
mmap: # as rewritten by tub during execution mov %ebx,%edx call __pre_mmap lea 0x4(%esp,1),%ebx int $0x80 # or call *%gs:0x10 mov %edx,%ebx call __post_mmap ja error ret |
Detecting the body of mmap/mmap64/munmap
in newly-mapped pages is heuristic and not as robust as it could be.
The allocator for page frames is multi-thread safe, and somewhat efficient;
it uses spin wait during thread-to-thread contention.
The allocator also detects re-entrant use by a signal handler.
In theory such a situation can be handled, but it is too complex.
So, the current implementation gives a message on stderr and aborts.
Of course, doing an explicit mmap (or any system call)
in a signal handler is a dubious idea.
However, *printf() buffering typically uses mmap.
So, establish buffering (or no buffering) by calling setbuf,
setbuffer, setlinebuf or setvbuf for the FILE
before enabling the handler.