Project

General

Profile

Bug #163

Updated by Igor Pashev almost 7 years ago

After this commit illumos-packaging:commit:0e39b90eab160820ae938fcb3ea27f056c482ef5 it is allowed to build PIE binaries, but such binaries cannot allocate memory. It probably probabrly because of wrong address of _END.

<pre>
$ cat malloc-pie.c
#include <stdlib.h>

int
main (int argc, char *argv[])
{
return malloc (1024) == NULL;
}

$ gcc -pie -fpie malloc-pie.c -o malloc-pie
$ ./malloc-pie ; echo $?
1

$ gcc malloc-pie.c -o malloc-no-pie
$ ./malloc-no-pie ; echo $?
0

$ truss -o pie.log ./malloc-pie
$ grep brk pie.log
brk(0xFFFFFD7FFF400E30) Err#12 ENOMEM

$ truss -o no-pie.log ./malloc-no-pie
$ grep brk no-pie.log
brk(0x00600D50) = 0
brk(0x00604D50) = 0

</pre>

Back