0010-static-pie-support.diff 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
  2. index 2787a3d16be..ee7b781319e 100644
  3. --- a/gcc/config/gnu-user.h
  4. +++ b/gcc/config/gnu-user.h
  5. @@ -51,10 +51,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  6. #if defined HAVE_LD_PIE
  7. #define GNU_USER_TARGET_STARTFILE_SPEC \
  8. "%{!shared: %{pg|p|profile:gcrt1.o%s;: \
  9. - %{" PIE_SPEC ":Scrt1.o%s} %{" NO_PIE_SPEC ":crt1.o%s}}} \
  10. - crti.o%s %{static:crtbeginT.o%s;: %{shared:crtbeginS.o%s} \
  11. + %{" PIE_SPEC ":%{static:rcrt1.o%s;:Scrt1.o%s}} %{" NO_PIE_SPEC ":crt1.o%s}}} \
  12. + crti.o%s %{shared:crtbeginS.o%s;: \
  13. %{" PIE_SPEC ":crtbeginS.o%s} \
  14. - %{" NO_PIE_SPEC ":crtbegin.o%s}} \
  15. + %{" NO_PIE_SPEC ":%{static:crtbeginT.o%s;:crtbegin.o%s}}} \
  16. %{fvtable-verify=none:%s; \
  17. fvtable-verify=preinit:vtv_start_preinit.o%s; \
  18. fvtable-verify=std:vtv_start.o%s} \
  19. diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
  20. index de386291a51..577fddc8a7c 100644
  21. --- a/gcc/config/rs6000/sysv4.h
  22. +++ b/gcc/config/rs6000/sysv4.h
  23. @@ -759,9 +759,12 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
  24. #ifdef HAVE_LD_PIE
  25. #define STARTFILE_LINUX_SPEC "\
  26. -%{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} \
  27. +%{!shared: %{pg|p|profile:gcrt1.o%s;: \
  28. + %{" PIE_SPEC ":%{static:rcrt1.o%s;:Scrt1.o%s}} %{" NO_PIE_SPEC ":crt1.o%s}}} \
  29. %{mnewlib:ecrti.o%s;:crti.o%s} \
  30. -%{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \
  31. +%{shared:crtbeginS.o%s;: \
  32. + %{" PIE_SPEC ":crtbeginS.o%s} \
  33. + %{" NO_PIE_SPEC ":%{static:crtbeginT.o%s;:crtbegin.o%s}}} \
  34. " CRTOFFLOADBEGIN
  35. #else
  36. #define STARTFILE_LINUX_SPEC "\
  37. diff --git a/gcc/gcc.c b/gcc/gcc.c
  38. index 91eb0534722..74a390e6005 100644
  39. --- a/gcc/gcc.c
  40. +++ b/gcc/gcc.c
  41. @@ -873,7 +873,7 @@ proper position among the other output files. */
  42. #endif
  43. #ifdef ENABLE_DEFAULT_PIE
  44. -#define NO_PIE_SPEC "no-pie|static"
  45. +#define NO_PIE_SPEC "no-pie"
  46. #define PIE_SPEC NO_PIE_SPEC "|r|shared:;"
  47. #define NO_FPIE1_SPEC "fno-pie"
  48. #define FPIE1_SPEC NO_FPIE1_SPEC ":;"
  49. @@ -919,7 +919,7 @@ proper position among the other output files. */
  50. #ifndef LINK_PIE_SPEC
  51. #ifdef HAVE_LD_PIE
  52. #ifndef LD_PIE_SPEC
  53. -#define LD_PIE_SPEC "-pie"
  54. +#define LD_PIE_SPEC "-pie %{static:--no-dynamic-linker -Bsymbolic}"
  55. #endif
  56. #else
  57. #define LD_PIE_SPEC ""