0012-static-pie.diff 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. diff --git a/gcc/common.opt b/gcc/common.opt
  2. index b52ef0b38c8..0ce5857e01d 100644
  3. --- a/gcc/common.opt
  4. +++ b/gcc/common.opt
  5. @@ -3197,11 +3197,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 8620de3e42d..235328a2642 100644
  18. --- a/gcc/config/gnu-user.h
  19. +++ b/gcc/config/gnu-user.h
  20. @@ -52,13 +52,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. crti.o%s \
  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. @@ -92,8 +91,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  38. "%{fvtable-verify=none:%s; \
  39. fvtable-verify=preinit:vtv_end_preinit.o%s; \
  40. fvtable-verify=std:vtv_end.o%s} \
  41. - %{static:crtend.o%s; \
  42. - shared|static-pie|" PIE_SPEC ":crtendS.o%s; \
  43. + %{shared|" PIE_SPEC ":crtendS.o%s; \
  44. :crtend.o%s} \
  45. crtn.o%s \
  46. " CRTOFFLOADEND
  47. @@ -133,7 +131,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  48. #define LIB_SPEC GNU_USER_TARGET_LIB_SPEC
  49. #if defined(HAVE_LD_EH_FRAME_HDR)
  50. -#define LINK_EH_SPEC "%{!static|static-pie:--eh-frame-hdr} "
  51. +#define LINK_EH_SPEC "%{!static|" PIE_SPEC ":--eh-frame-hdr} "
  52. #endif
  53. #undef LINK_GCC_C_SEQUENCE_SPEC
  54. diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
  55. index bb19d0dcd41..bb2a2324eb0 100644
  56. --- a/gcc/config/rs6000/sysv4.h
  57. +++ b/gcc/config/rs6000/sysv4.h
  58. @@ -763,12 +763,12 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
  59. #define STARTFILE_LINUX_SPEC \
  60. "%{shared:; \
  61. pg|p|profile:gcrt1.o%s; \
  62. - static:crt1.o%s; \
  63. - static-pie|" PIE_SPEC ":Scrt1.o%s; \
  64. + static|static-pie:%{" PIE_SPEC ":rcrt1.o%s;:crt1.o%s}; \
  65. + " PIE_SPEC ":Scrt1.o%s; \
  66. :crt1.o%s} \
  67. %{mnewlib:ecrti.o%s;:crti.o%s} \
  68. - %{static:crtbeginT.o%s; \
  69. - shared|static-pie|" PIE_SPEC ":crtbeginS.o%s; \
  70. + %{shared|" PIE_SPEC ":crtbeginS.o%s; \
  71. + static:crtbeginT.o%s; \
  72. :crtbegin.o%s} \
  73. %{fvtable-verify=none:%s; \
  74. fvtable-verify=preinit:vtv_start_preinit.o%s; \
  75. @@ -781,8 +781,7 @@ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN)
  76. "%{fvtable-verify=none:%s; \
  77. fvtable-verify=preinit:vtv_end_preinit.o%s; \
  78. fvtable-verify=std:vtv_end.o%s} \
  79. - %{static:crtend.o%s; \
  80. - shared|static-pie|" PIE_SPEC ":crtendS.o%s; \
  81. + %{shared|" PIE_SPEC ":crtendS.o%s; \
  82. :crtend.o%s} \
  83. %{mnewlib:ecrtn.o%s;:crtn.o%s} \
  84. " CRTOFFLOADEND
  85. diff --git a/gcc/gcc.c b/gcc/gcc.c
  86. index eb1610ba8b0..87560afb03c 100644
  87. --- a/gcc/gcc.c
  88. +++ b/gcc/gcc.c
  89. @@ -900,7 +900,7 @@ proper position among the other output files. */
  90. #define NO_FPIE_AND_FPIC_SPEC NO_FPIE_SPEC "|" NO_FPIC_SPEC
  91. #define FPIE_OR_FPIC_SPEC NO_FPIE_AND_FPIC_SPEC ":;"
  92. #else
  93. -#define PIE_SPEC "pie"
  94. +#define PIE_SPEC "pie|static-pie"
  95. #define FPIE1_SPEC "fpie"
  96. #define NO_FPIE1_SPEC FPIE1_SPEC ":;"
  97. #define FPIE2_SPEC "fPIE"
  98. @@ -924,12 +924,12 @@ proper position among the other output files. */
  99. #ifndef LINK_PIE_SPEC
  100. #ifdef HAVE_LD_PIE
  101. #ifndef LD_PIE_SPEC
  102. -#define LD_PIE_SPEC "-pie"
  103. +#define LD_PIE_SPEC "-pie %{static-pie:-static} %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic}"
  104. #endif
  105. #else
  106. #define LD_PIE_SPEC ""
  107. #endif
  108. -#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
  109. +#define LINK_PIE_SPEC "%{shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
  110. #endif
  111. #ifndef LINK_BUILDID_SPEC