0004-static-pie.diff 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. diff --git a/gcc/common.opt b/gcc/common.opt
  2. index ec5235c3a41..dcee05500ba 100644
  3. --- a/gcc/common.opt
  4. +++ b/gcc/common.opt
  5. @@ -3401,11 +3401,11 @@ Driver
  6. no-pie
  7. Driver RejectNegative Negative(shared)
  8. -Don't create a dynamically linked position independent executable.
  9. +Don't create a position independent executable.
  10. pie
  11. Driver RejectNegative Negative(no-pie)
  12. -Create a dynamically linked position independent executable.
  13. +Create a position independent executable.
  14. static-pie
  15. Driver RejectNegative Negative(pie)
  16. diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
  17. index ff2e880b1fa..bafde149202 100644
  18. --- a/gcc/config/gnu-user.h
  19. +++ b/gcc/config/gnu-user.h
  20. @@ -51,13 +51,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  21. #define GNU_USER_TARGET_STARTFILE_SPEC \
  22. "%{shared:; \
  23. pg|p|profile:%{static-pie:grcrt1.o%s;:gcrt1.o%s}; \
  24. - static:crt1.o%s; \
  25. - static-pie:rcrt1.o%s; \
  26. + static|static-pie:%{" PIE_SPEC ":rcrt1.o%s;:crt1.o%s}; \
  27. " PIE_SPEC ":Scrt1.o%s; \
  28. :crt1.o%s} " \
  29. GNU_USER_TARGET_CRTI " \
  30. - %{static:crtbeginT.o%s; \
  31. - shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \
  32. + %{shared|" PIE_SPEC ":crtbeginS.o%s; \
  33. + static:crtbeginT.o%s; \
  34. :crtbegin.o%s} \
  35. %{fvtable-verify=none:%s; \
  36. fvtable-verify=preinit:vtv_start_preinit.o%s; \
  37. @@ -73,11 +72,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  38. GNU userspace "finalizer" file, `crtn.o'. */
  39. #define GNU_USER_TARGET_ENDFILE_SPEC \
  40. - "%{!static:%{fvtable-verify=none:%s; \
  41. + "%{static|static-pie:; \
  42. + fvtable-verify=none:%s; \
  43. fvtable-verify=preinit:vtv_end_preinit.o%s; \
  44. - fvtable-verify=std:vtv_end.o%s}} \
  45. - %{static:crtend.o%s; \
  46. - shared|static-pie|" PIE_SPEC ":crtendS.o%s; \
  47. + fvtable-verify=std:vtv_end.o%s} \
  48. + %{shared|" PIE_SPEC ":crtendS.o%s; \
  49. :crtend.o%s} " \
  50. GNU_USER_TARGET_CRTN " " \
  51. CRTOFFLOADEND
  52. @@ -106,7 +105,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  53. #define LIB_SPEC GNU_USER_TARGET_LIB_SPEC
  54. #if defined(HAVE_LD_EH_FRAME_HDR)
  55. -#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
  56. +#define LINK_EH_SPEC "%{!static|" PIE_SPEC ":--eh-frame-hdr} "
  57. #endif
  58. #define GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC \
  59. diff --git a/gcc/gcc.c b/gcc/gcc.c
  60. index e6887590ae2..df6e3965f13 100644
  61. --- a/gcc/gcc.c
  62. +++ b/gcc/gcc.c
  63. @@ -907,7 +907,7 @@ proper position among the other output files. */
  64. #define NO_FPIE_AND_FPIC_SPEC NO_FPIE_SPEC "|" NO_FPIC_SPEC
  65. #define FPIE_OR_FPIC_SPEC NO_FPIE_AND_FPIC_SPEC ":;"
  66. #else
  67. -#define PIE_SPEC "pie"
  68. +#define PIE_SPEC "pie|static-pie"
  69. #define FPIE1_SPEC "fpie"
  70. #define NO_FPIE1_SPEC FPIE1_SPEC ":;"
  71. #define FPIE2_SPEC "fPIE"
  72. @@ -931,12 +931,12 @@ proper position among the other output files. */
  73. #ifndef LINK_PIE_SPEC
  74. #ifdef HAVE_LD_PIE
  75. #ifndef LD_PIE_SPEC
  76. -#define LD_PIE_SPEC "-pie"
  77. +#define LD_PIE_SPEC "-pie %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic}"
  78. #endif
  79. #else
  80. #define LD_PIE_SPEC ""
  81. #endif
  82. -#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
  83. +#define LINK_PIE_SPEC "%{shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
  84. #endif
  85. #ifndef LINK_BUILDID_SPEC