https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81523
Bug ID: 81523 Summary: -static -pie behaves differently depending on if --enable-default-pie is used Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: driver Assignee: unassigned at gcc dot gnu.org Reporter: hjl.tools at gmail dot com Blocks: 81170, 81498 Target Milestone: --- [hjl@gnu-tools-1 tmp]$ cat x.c #include <stdio.h> int main () { printf ("hello\n"); return 0; } [hjl@gnu-tools-1 tmp]$ /mnt/test/usr/gcc-7.1.1-x32-pie/bin/gcc -static -pie -fPIE x.c [hjl@gnu-tools-1 tmp]$ /mnt/test/usr/gcc-7.1.1-x32/bin/gcc -static -pie -fPIE x.c /usr/local/bin/ld: /mnt/test/usr/gcc-7.1.1-x32/bin/../lib/gcc/x86_64-pc-linux-gnu/7.1.1/crtbeginT.o: relocation R_X86_64_32 against hidden symbol `__TMC_END__' can not be used when making a shared object /usr/local/bin/ld: /lib/../lib64/libc.a(libc-start.o): relocation R_X86_64_32 against symbol `_dl_starting_up' can not be used when making a shared object; recompile with -fPIC ... When gcc is configured with --enable-default-pie, -static completely overrides -pie. When gcc is configured without --enable-default-pie, -static partially overrides -pie. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81170 [Bug 81170] powerpc*-linux --enable-default-pie chooses incorrect startup files https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81498 [Bug 81498] Support creating static PIE