Prev Next | OpenBSD and Rthreads | Slide #22 |
To provide W^X on i386, segments of each shared library are mapped with specific offsets
e.g., data segment is placed exactly 1GB above the code segment
ld.so implements that for dlopen() by using mquery() to probe the address space for a base address where everything will fit:
base = 0 foreach segment { ret = mquery(base + segment->offset, segment->size) if (base == 0) base = ret; else if (ret == MAP_FAILED) /* get hint, reset base to match */ goto begin; }
EuroBSDCon 2012 | Copyright © 2012 Philip Guenther |