Solskogen
Posts: 24
Joined: Tue Sep 27, 2016 6:07 am

Position-independent code

Tue Feb 04, 2020 10:28 am

On Debian buster (x86_64) gcc creates PIE binaries by default, while Raspbian does not.

Rasbian

Code: Select all

 cat test.c
int main(void)
{
        return 0;
}

gcc test.c
 hardening-check a.out
a.out:
 Position Independent Executable: no, normal executable!
 Stack protected: no, not found!
 Fortify Source functions: unknown, no protectable libc functions used
 Read-only relocations: yes
 Immediate binding: no, not found!

Debian x86_64

Code: Select all

hardening-check a.out
a.out:
 Position Independent Executable: yes
 Stack protected: no, not found!
 Fortify Source functions: unknown, no protectable libc functions used
 Read-only relocations: yes
 Immediate binding: no, not found!

arm-linux-gnueabihf-gcc test.c
hardening-check a.out
a.out:
 Position Independent Executable: yes
 Stack protected: no, not found!
 Fortify Source functions: unknown, no protectable libc functions used
 Read-only relocations: yes
 Immediate binding: no, not found!
So both the native and the cross compiler on Debian buster creates PIE by default. Why doesn't Raspbian do the same?

Return to “Raspberry Pi OS”