1
I tried compile C source code to apply Partial RELRO, enabling PIE and disabling NX but failed.
Steps to reproduce
I used checksec script to check RELRO option of the binary.
wisedier@ubuntu:~$ gcc --version
gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
Copyright (C) 2017 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.
wisedier@ubuntu:~$ uname -a
Linux ubuntu 4.15.0-46-generic #49-Ubuntu SMP Wed Feb 6 09:33:07 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
wisedier@ubuntu:~$ cat test.c
void main(){}
wisedier@ubuntu:~$ gcc -fPIE -pie -z execstack -Wl,-z,relro -o partial test.c
wisedier@ubuntu:~$ gcc -fPIE -pie -z execstack -Wl,-z,relro -Wl,-z,now -o full test.c
wisedier@ubuntu:~$ objdump -h full > full.log
wisedier@ubuntu:~$ objdump -h partial > partial.log
wisedier@ubuntu:~$ diff full.log partial.log
2c2
< full: file format elf64-x86-64
---
> partial: file format elf64-x86-64
wisedier@ubuntu:~$ checksec --file full
RELRO STACK CANARY NX PIE RPATH RUNPATH Symbols FORTIFY Fortified Fortifiable FILE
Full RELRO No canary found NX disabled PIE enabled No RPATH No RUNPATH 66 Symbols No 0 0 full
wisedier@ubuntu:~$ checksec --file partial
RELRO STACK CANARY NX PIE RPATH RUNPATH Symbols FORTIFY Fortified Fortifiable FILE
Full RELRO No canary found NX disabled PIE enabled No RPATH No RUNPATH 66 Symbols No 0 0 partial
What is the expected correct behavior?
I expected the result of checksec for the binary compiled with partial RELRO option shows Partial RELRO and there are some differences between objdump results.
Do I missed something? If you know a solution to get partial RELRO binary or related information, please let me know.
Add more detail what this does and explain. – Pimp Juice IT – 2019-10-19T21:51:49.753
Without PIE option, the compiler applies Full RELRO with partial RELRO options. – junsang – 2019-10-22T07:09:06.907