0004-Actually-link-the-test-program-when-checking-for-stack-protector.patch 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. When checking for stack protector support we need to actually link the
  2. test program.
  3. Backported from upstream:
  4. http://www.sudo.ws/repos/sudo/rev/ab4f94aac7de
  5. Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
  6. # HG changeset patch
  7. # User Todd C. Miller <Todd.Miller@courtesan.com>
  8. # Date 1446216562 21600
  9. # Node ID ab4f94aac7de73efa1b201890354c74126baf7ca
  10. # Parent e6bc59225c06c5d45580197519a73e3feea14cbd
  11. When checking for stack protector support we need to actually link
  12. the test program.
  13. diff -r e6bc59225c06 -r ab4f94aac7de configure
  14. --- a/configure Thu Oct 29 14:06:21 2015 -0600
  15. +++ b/configure Fri Oct 30 08:49:22 2015 -0600
  16. @@ -23922,11 +23922,17 @@
  17. $as_echo_n "(cached) " >&6
  18. else
  19. - sudo_cv_var_stack_protector=no
  20. + # Avoid using CFLAGS since the compiler might optimize away our
  21. + # test. We don't want LIBS to interfere with the test but keep
  22. + # LDFLAGS as it may have an rpath needed to find the ssp lib.
  23. _CFLAGS="$CFLAGS"
  24. _LDFLAGS="$LDFLAGS"
  25. - CFLAGS="-fstack-protector-strong"
  26. - LDFLAGS="$_LDFLAGS -fstack-protector-strong"
  27. + _LIBS="$LIBS"
  28. + LIBS=
  29. +
  30. + sudo_cv_var_stack_protector="-fstack-protector-strong"
  31. + CFLAGS="$sudo_cv_var_stack_protector"
  32. + LDFLAGS="$_LDFLAGS $sudo_cv_var_stack_protector"
  33. cat confdefs.h - <<_ACEOF >conftest.$ac_ext
  34. /* end confdefs.h. */
  35. @@ -23940,14 +23946,13 @@
  36. }
  37. _ACEOF
  38. -if ac_fn_c_try_compile "$LINENO"; then :
  39. -
  40. - sudo_cv_var_stack_protector="-fstack-protector-strong"
  41. -
  42. -else
  43. -
  44. - CFLAGS="-fstack-protector-all"
  45. - LDFLAGS="$_LDFLAGS -fstack-protector-all"
  46. +if ac_fn_c_try_link "$LINENO"; then :
  47. +
  48. +else
  49. +
  50. + sudo_cv_var_stack_protector="-fstack-protector-all"
  51. + CFLAGS="$sudo_cv_var_stack_protector"
  52. + LDFLAGS="$_LDFLAGS $sudo_cv_var_stack_protector"
  53. cat confdefs.h - <<_ACEOF >conftest.$ac_ext
  54. /* end confdefs.h. */
  55. @@ -23961,14 +23966,13 @@
  56. }
  57. _ACEOF
  58. -if ac_fn_c_try_compile "$LINENO"; then :
  59. -
  60. - sudo_cv_var_stack_protector="-fstack-protector-all"
  61. -
  62. -else
  63. -
  64. - CFLAGS="-fstack-protector"
  65. - LDFLAGS="$_LDFLAGS -fstack-protector"
  66. +if ac_fn_c_try_link "$LINENO"; then :
  67. +
  68. +else
  69. +
  70. + sudo_cv_var_stack_protector="-fstack-protector"
  71. + CFLAGS="$sudo_cv_var_stack_protector"
  72. + LDFLAGS="$_LDFLAGS $sudo_cv_var_stack_protector"
  73. cat confdefs.h - <<_ACEOF >conftest.$ac_ext
  74. /* end confdefs.h. */
  75. @@ -23982,20 +23986,26 @@
  76. }
  77. _ACEOF
  78. -if ac_fn_c_try_compile "$LINENO"; then :
  79. -
  80. - sudo_cv_var_stack_protector="-fstack-protector"
  81. -
  82. -fi
  83. -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
  84. -
  85. -fi
  86. -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
  87. -
  88. -fi
  89. -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
  90. +if ac_fn_c_try_link "$LINENO"; then :
  91. +
  92. +else
  93. +
  94. + sudo_cv_var_stack_protector=no
  95. +
  96. +fi
  97. +rm -f core conftest.err conftest.$ac_objext \
  98. + conftest$ac_exeext conftest.$ac_ext
  99. +
  100. +fi
  101. +rm -f core conftest.err conftest.$ac_objext \
  102. + conftest$ac_exeext conftest.$ac_ext
  103. +
  104. +fi
  105. +rm -f core conftest.err conftest.$ac_objext \
  106. + conftest$ac_exeext conftest.$ac_ext
  107. CFLAGS="$_CFLAGS"
  108. LDFLAGS="$_LDFLAGS"
  109. + LIBS="$_LIBS"
  110. fi
  111. diff -r e6bc59225c06 -r ab4f94aac7de configure.ac
  112. --- a/configure.ac Thu Oct 29 14:06:21 2015 -0600
  113. +++ b/configure.ac Fri Oct 30 08:49:22 2015 -0600
  114. @@ -3981,37 +3981,42 @@
  115. AC_CACHE_CHECK([for compiler stack protector support],
  116. [sudo_cv_var_stack_protector],
  117. [
  118. - sudo_cv_var_stack_protector=no
  119. + # Avoid using CFLAGS since the compiler might optimize away our
  120. + # test. We don't want LIBS to interfere with the test but keep
  121. + # LDFLAGS as it may have an rpath needed to find the ssp lib.
  122. _CFLAGS="$CFLAGS"
  123. _LDFLAGS="$LDFLAGS"
  124. - CFLAGS="-fstack-protector-strong"
  125. - LDFLAGS="$_LDFLAGS -fstack-protector-strong"
  126. - AC_COMPILE_IFELSE([
  127. + _LIBS="$LIBS"
  128. + LIBS=
  129. +
  130. + sudo_cv_var_stack_protector="-fstack-protector-strong"
  131. + CFLAGS="$sudo_cv_var_stack_protector"
  132. + LDFLAGS="$_LDFLAGS $sudo_cv_var_stack_protector"
  133. + AC_LINK_IFELSE([
  134. AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
  135. [[char buf[1024]; buf[1023] = '\0';]])
  136. - ], [
  137. - sudo_cv_var_stack_protector="-fstack-protector-strong"
  138. - ], [
  139. - CFLAGS="-fstack-protector-all"
  140. - LDFLAGS="$_LDFLAGS -fstack-protector-all"
  141. - AC_COMPILE_IFELSE([
  142. + ], [], [
  143. + sudo_cv_var_stack_protector="-fstack-protector-all"
  144. + CFLAGS="$sudo_cv_var_stack_protector"
  145. + LDFLAGS="$_LDFLAGS $sudo_cv_var_stack_protector"
  146. + AC_LINK_IFELSE([
  147. AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
  148. [[char buf[1024]; buf[1023] = '\0';]])
  149. - ], [
  150. - sudo_cv_var_stack_protector="-fstack-protector-all"
  151. - ], [
  152. - CFLAGS="-fstack-protector"
  153. - LDFLAGS="$_LDFLAGS -fstack-protector"
  154. - AC_COMPILE_IFELSE([
  155. + ], [], [
  156. + sudo_cv_var_stack_protector="-fstack-protector"
  157. + CFLAGS="$sudo_cv_var_stack_protector"
  158. + LDFLAGS="$_LDFLAGS $sudo_cv_var_stack_protector"
  159. + AC_LINK_IFELSE([
  160. AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
  161. [[char buf[1024]; buf[1023] = '\0';]])
  162. - ], [
  163. - sudo_cv_var_stack_protector="-fstack-protector"
  164. - ], [])
  165. + ], [], [
  166. + sudo_cv_var_stack_protector=no
  167. + ])
  168. ])
  169. ])
  170. CFLAGS="$_CFLAGS"
  171. LDFLAGS="$_LDFLAGS"
  172. + LIBS="$_LIBS"
  173. ]
  174. )
  175. if test X"$sudo_cv_var_stack_protector" != X"no"; then