Ticket #9948: bug9948.patch

File bug9948.patch, 2.3 KB (added by sqrt2, 6 years ago)

patch against git master

  • acinclude.m4

    diff --git a/acinclude.m4 b/acinclude.m4
    index af15051..2943734 100644
    a b AC_DEFUN([TOR_DEFINE_CODEPATH], 
    4343])
    4444
    4545dnl 1:flags
     46dnl 2:also try to link (yes: non-empty string)
     47dnl   will set yes or no in $tor_can_link_$1 (as modified by AS_VAR_PUSHDEF)
    4648AC_DEFUN([TOR_CHECK_CFLAGS], [
    4749  AS_VAR_PUSHDEF([VAR],[tor_cv_cflags_$1])
    4850  AC_CACHE_CHECK([whether the compiler accepts $1], VAR, [
    AC_DEFUN([TOR_CHECK_CFLAGS], [ 
    5153    AC_TRY_COMPILE([], [return 0;],
    5254                   [AS_VAR_SET(VAR,yes)],
    5355                   [AS_VAR_SET(VAR,no)])
     56    if test x$2 != x; then
     57      AS_VAR_PUSHDEF([can_link],[tor_can_link_$1])
     58      AC_TRY_LINK([], [return 0;],
     59                  [AS_VAR_SET(can_link,yes)],
     60                  [AS_VAR_SET(can_link,no)])
     61      AS_VAR_POPDEF([can_link])
     62    fi
    5463    CFLAGS="$tor_saved_CFLAGS"
    5564  ])
    5665  if test x$VAR = xyes; then
  • new file changes/bug9948

    diff --git a/changes/bug9948 b/changes/bug9948
    new file mode 100644
    index 0000000..1ad5936
    - +  
     1  o Minor features (build):
     2
     3    - Check in configure whether we can link an executable when
     4      stack protection is enabled so we can warn the user about a
     5      potentially missing libssp. Addresses ticket 9948.
  • configure.ac

    diff --git a/configure.ac b/configure.ac
    index 77767c5..f1fa881 100644
    a b if test x$enable_gcc_hardening != xno; then 
    589589    if test x$have_clang = xyes; then
    590590        TOR_CHECK_CFLAGS(-Qunused-arguments)
    591591    fi
    592     TOR_CHECK_CFLAGS(-fstack-protector-all)
     592    TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
     593    AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
     594    AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
     595    AS_VAR_IF(can_compile, [yes],
     596        AS_VAR_IF(can_link, [yes],
     597                  [],
     598                  AC_MSG_ERROR([We tried to build with stack protection; it looks like your compiler supports it but your libc does not provide it. Are you missing libssp? (You can --disable-gcc-hardening to ignore this error.)]))
     599        )
     600    AS_VAR_POPDEF([can_link])
     601    AS_VAR_POPDEF([can_compile])
    593602    TOR_CHECK_CFLAGS(-Wstack-protector)
    594603    TOR_CHECK_CFLAGS(-fwrapv)
    595604    TOR_CHECK_CFLAGS(--param ssp-buffer-size=1)