0012-static-pie.diff 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. diff --git a/gcc/common.opt b/gcc/common.opt
  2. index d342c4f3749..2aae4a3cefb 100644
  3. --- a/gcc/common.opt
  4. +++ b/gcc/common.opt
  5. @@ -3287,11 +3287,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 055a4f0afec..7a671c6a49c 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. @@ -76,8 +75,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. GNU_USER_TARGET_CRTN " " \
  46. CRTOFFLOADEND
  47. @@ -106,7 +104,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. #define GNU_USER_TARGET_LINK_GCC_C_SEQUENCE_SPEC \
  54. diff --git a/gcc/gcc.c b/gcc/gcc.c
  55. index d185c01b257..5d3f81c5fc5 100644
  56. --- a/gcc/gcc.c
  57. +++ b/gcc/gcc.c
  58. @@ -908,7 +908,7 @@ proper position among the other output files. */
  59. #define NO_FPIE_AND_FPIC_SPEC NO_FPIE_SPEC "|" NO_FPIC_SPEC
  60. #define FPIE_OR_FPIC_SPEC NO_FPIE_AND_FPIC_SPEC ":;"
  61. #else
  62. -#define PIE_SPEC "pie"
  63. +#define PIE_SPEC "pie|static-pie"
  64. #define FPIE1_SPEC "fpie"
  65. #define NO_FPIE1_SPEC FPIE1_SPEC ":;"
  66. #define FPIE2_SPEC "fPIE"
  67. @@ -932,12 +932,12 @@ proper position among the other output files. */
  68. #ifndef LINK_PIE_SPEC
  69. #ifdef HAVE_LD_PIE
  70. #ifndef LD_PIE_SPEC
  71. -#define LD_PIE_SPEC "-pie"
  72. +#define LD_PIE_SPEC "-pie %{static-pie:-static} %{static|static-pie:--no-dynamic-linker -z text -Bsymbolic}"
  73. #endif
  74. #else
  75. #define LD_PIE_SPEC ""
  76. #endif
  77. -#define LINK_PIE_SPEC "%{static|shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
  78. +#define LINK_PIE_SPEC "%{shared|r:;" PIE_SPEC ":" LD_PIE_SPEC "} "
  79. #endif
  80. #ifndef LINK_BUILDID_SPEC