Project

General

Profile

Bug #163

PIE binaries cannot allocate memory

Added by Igor Pashev almost 6 years ago. Updated about 2 years ago.

Status:
New
Priority:
Low
Assignee:
-
Start date:
2013-12-01
Due date:
% Done:

0%

Estimated time:

Description

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

$ 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

Associated revisions

Revision 0e39b90e (diff)
Added by Igor Pashev about 6 years ago

made crt1.o PIE-friendly (crt1.o-amd64-PIE.patch)

Revision c9987346 (diff)
Added by Igor Pashev over 5 years ago

Disabled crt1.o-amd64-PIE.patch

History

#1

Updated by Igor Pashev almost 6 years ago

  • Description updated (diff)
#2

Updated by Igor Pashev over 5 years ago

  • Priority changed from Normal to Low

Also available in: Atom PDF