blob: 975c7907f619e23c85a8c250f888f292a50a59cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
Weird stuff noted while developing
----------------------------------
A PT_LOAD segment which is mapped to memory by the kernel with (PF_R | PF_W |
PF_X) priviledges (phdr.p_flags = 0x0007) which defines the brk(0) initial
value cannot shrink. If the priviledges are (PF_R | PF_W) it can somehow. Maybe
the kernel assumes the last mapped page with (PF_R | PF_W) priviledges to be a
dynamic (.bss or malloc) page, while one with (PF_R | PF_W | PF_X) already
contains a fixed amount of program code, which would be lost otherwise. Anyway,
you can change the page flags using mprotect later, the kernel does not mind
shrinking it then. Weird.
|