0008-Revert-PR-driver-81523-Make-static-override-pie.diff 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. diff --git a/gcc/config/gnu-user.h b/gcc/config/gnu-user.h
  2. index de605b0c466..2787a3d16be 100644
  3. --- a/gcc/config/gnu-user.h
  4. +++ b/gcc/config/gnu-user.h
  5. @@ -50,28 +50,19 @@ 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:; \
  9. - pg|p|profile:gcrt1.o%s; \
  10. - static:crt1.o%s; \
  11. - " PIE_SPEC ":Scrt1.o%s; \
  12. - :crt1.o%s} \
  13. - crti.o%s \
  14. - %{static:crtbeginT.o%s; \
  15. - shared|" PIE_SPEC ":crtbeginS.o%s; \
  16. - :crtbegin.o%s} \
  17. + "%{!shared: %{pg|p|profile:gcrt1.o%s;: \
  18. + %{" PIE_SPEC ":Scrt1.o%s} %{" NO_PIE_SPEC ":crt1.o%s}}} \
  19. + crti.o%s %{static:crtbeginT.o%s;: %{shared:crtbeginS.o%s} \
  20. + %{" PIE_SPEC ":crtbeginS.o%s} \
  21. + %{" NO_PIE_SPEC ":crtbegin.o%s}} \
  22. %{fvtable-verify=none:%s; \
  23. fvtable-verify=preinit:vtv_start_preinit.o%s; \
  24. fvtable-verify=std:vtv_start.o%s} \
  25. " CRTOFFLOADBEGIN
  26. #else
  27. #define GNU_USER_TARGET_STARTFILE_SPEC \
  28. - "%{shared:; \
  29. - pg|p|profile:gcrt1.o%s; \
  30. - :crt1.o%s} \
  31. - crti.o%s \
  32. - %{static:crtbeginT.o%s; \
  33. - shared|pie:crtbeginS.o%s; \
  34. - :crtbegin.o%s} \
  35. + "%{!shared: %{pg|p|profile:gcrt1.o%s;:crt1.o%s}} \
  36. + crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s} \
  37. %{fvtable-verify=none:%s; \
  38. fvtable-verify=preinit:vtv_start_preinit.o%s; \
  39. fvtable-verify=std:vtv_start.o%s} \
  40. @@ -91,20 +82,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  41. "%{fvtable-verify=none:%s; \
  42. fvtable-verify=preinit:vtv_end_preinit.o%s; \
  43. fvtable-verify=std:vtv_end.o%s} \
  44. - %{static:crtend.o%s; \
  45. - shared|" PIE_SPEC ":crtendS.o%s; \
  46. - :crtend.o%s} \
  47. - crtn.o%s \
  48. + %{shared:crtendS.o%s;: %{" PIE_SPEC ":crtendS.o%s} \
  49. + %{" NO_PIE_SPEC ":crtend.o%s}} crtn.o%s \
  50. " CRTOFFLOADEND
  51. #else
  52. #define GNU_USER_TARGET_ENDFILE_SPEC \
  53. "%{fvtable-verify=none:%s; \
  54. fvtable-verify=preinit:vtv_end_preinit.o%s; \
  55. fvtable-verify=std:vtv_end.o%s} \
  56. - %{static:crtend.o%s; \
  57. - shared|pie:crtendS.o%s; \
  58. - :crtend.o%s} \
  59. - crtn.o%s \
  60. + %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s \
  61. " CRTOFFLOADEND
  62. #endif
  63. #undef ENDFILE_SPEC
  64. diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
  65. index d522de03f4a..13b27873719 100644
  66. --- a/gcc/config/sol2.h
  67. +++ b/gcc/config/sol2.h
  68. @@ -174,9 +174,9 @@ along with GCC; see the file COPYING3. If not see
  69. %{!ansi:values-Xa.o%s}"
  70. #if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
  71. -#define STARTFILE_CRTBEGIN_SPEC "%{static:crtbegin.o%s; \
  72. - shared|" PIE_SPEC ":crtbeginS.o%s; \
  73. - :crtbegin.o%s}"
  74. +#define STARTFILE_CRTBEGIN_SPEC "%{shared:crtbeginS.o%s} \
  75. + %{" PIE_SPEC ":crtbeginS.o%s} \
  76. + %{" NO_PIE_SPEC ":crtbegin.o%s}"
  77. #else
  78. #define STARTFILE_CRTBEGIN_SPEC "crtbegin.o%s"
  79. #endif
  80. @@ -224,9 +224,9 @@ along with GCC; see the file COPYING3. If not see
  81. #endif
  82. #if defined(HAVE_LD_PIE) && defined(HAVE_SOLARIS_CRTS)
  83. -#define ENDFILE_CRTEND_SPEC "%{static:crtend.o%s; \
  84. - shared|" PIE_SPEC ":crtendS.o%s; \
  85. - :crtend.o%s}"
  86. +#define ENDFILE_CRTEND_SPEC "%{shared:crtendS.o%s;: \
  87. + %{" PIE_SPEC ":crtendS.o%s} \
  88. + %{" NO_PIE_SPEC ":crtend.o%s}}"
  89. #else
  90. #define ENDFILE_CRTEND_SPEC "crtend.o%s"
  91. #endif
  92. diff --git a/gcc/gcc.c b/gcc/gcc.c
  93. index e2fae4ef055..91eb0534722 100644
  94. --- a/gcc/gcc.c
  95. +++ b/gcc/gcc.c
  96. @@ -873,7 +873,8 @@ proper position among the other output files. */
  97. #endif
  98. #ifdef ENABLE_DEFAULT_PIE
  99. -#define PIE_SPEC "!no-pie"
  100. +#define NO_PIE_SPEC "no-pie|static"
  101. +#define PIE_SPEC NO_PIE_SPEC "|r|shared:;"
  102. #define NO_FPIE1_SPEC "fno-pie"
  103. #define FPIE1_SPEC NO_FPIE1_SPEC ":;"
  104. #define NO_FPIE2_SPEC "fno-PIE"
  105. @@ -894,6 +895,7 @@ proper position among the other output files. */
  106. #define FPIE_OR_FPIC_SPEC NO_FPIE_AND_FPIC_SPEC ":;"
  107. #else
  108. #define PIE_SPEC "pie"
  109. +#define NO_PIE_SPEC PIE_SPEC "|r|shared:;"
  110. #define FPIE1_SPEC "fpie"
  111. #define NO_FPIE1_SPEC FPIE1_SPEC ":;"
  112. #define FPIE2_SPEC "fPIE"
  113. @@ -922,7 +924,7 @@ proper position among the other output files. */
  114. #else
  115. #define LD_PIE_SPEC ""
  116. #endif
  117. -#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
  118. +#define LINK_PIE_SPEC "%{no-pie:} " "%{" PIE_SPEC ":" LD_PIE_SPEC "} "
  119. #endif
  120. #ifndef LINK_BUILDID_SPEC
  121. @@ -1010,10 +1012,8 @@ proper position among the other output files. */
  122. #endif
  123. /* -u* was put back because both BSD and SysV seem to support it. */
  124. -/* %{static|no-pie:} simply prevents an error message:
  125. - 1. If the target machine doesn't handle -static.
  126. - 2. If PIE isn't enabled by default.
  127. - */
  128. +/* %{static:} simply prevents an error message if the target machine
  129. + doesn't handle -static. */
  130. /* We want %{T*} after %{L*} and %D so that it can be used to specify linker
  131. scripts which exist in user specified directories, or in standard
  132. directories. */
  133. @@ -1030,7 +1030,7 @@ proper position among the other output files. */
  134. "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
  135. "%X %{o*} %{e*} %{N} %{n} %{r}\
  136. %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} \
  137. - %{static|no-pie:} %{L*} %(mfwrap) %(link_libgcc) " \
  138. + %{static:} %{L*} %(mfwrap) %(link_libgcc) " \
  139. VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o " CHKP_SPEC " \
  140. %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\
  141. %:include(libgomp.spec)%(link_gomp)}\