http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52753
Bug #: 52753 Summary: GCC not honoring -fPIE Classification: Unclassified Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: noloa...@gmail.com It appears GCC 4.6.1 is not honoring -fPIE under all circumstances. Below, I expect to see "Elf file type is DYN" $ cat warn-test.c #include <stdio.h> int main(int argc, char* argv[]) { (void)argc; (void)argv; printf("argc: %d\n", argc); printf("argv: %p\n", argv); printf("main: %p\n", &main); return 0; } $ gcc -Wall -Wextra -O2 -fPIE -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -Wl,-z,noexecheap warn-test.c -o warn-test.exe/usr/bin/ld: warning: -z noexecheap ignored. $ ./warn-test.exe argc: 1 argv: 0x7fffe3139e28 main: 0x400440 $ ./warn-test.exe argc: 1 argv: 0x7fffbd2864f8 main: 0x400440 $ readelf -l warn-test.exe | grep "Elf file type" Elf file type is EXEC (Executable file) $ cat /proc/sys/kernel/randomize_va_space 2 2 $ uname -a Linux mint-12-x64 3.0.0-12-generic #20-Ubuntu SMP Fri Oct 7 14:56:25 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux $ gcc --version gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.