This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: HEADSUP: toolchain modifications required for built-in SSP


On 30/11/17 02:43, Yaakov Selkowitz wrote:
Newlib/RTEMS users,

Please be aware that, as of today's git master, and the next (2.6.0?)
tarball release, Newlib includes its own implementation of Stack
Smashing Protection (-fstack-protector*) and Object Size Checking
(-D_FORTIFY_SOURCE=*) features.  This implementation replaces and
conflicts with GCC's libssp, which is practically broken and unmaintained.

In order to avoid the conflict with GCC's libssp, Newlib/RTEMS
toolchains using git master or the next release MUST be rebuilt,
configuring with the --disable-libssp flag,

Since libssp was apparently broken, the --disable-libssp does no harm if used with older Newlib versions?

and exporting
gcc_cv_libc_provides_ssp=yes in the environment during 'make'.

I think this should be fixed for Newlib in general in the GCC gcc/configure.ac:

# Test for stack protector support in target C library.
AC_CACHE_CHECK(__stack_chk_fail in target C library,
      gcc_cv_libc_provides_ssp,
      [gcc_cv_libc_provides_ssp=no
    case "$target" in
       *-*-musl*)
     # All versions of musl provide stack protector
     gcc_cv_libc_provides_ssp=yes;;
       *-*-linux* | *-*-kfreebsd*-gnu)
      # glibc 2.4 and later provides __stack_chk_fail and
      # either __stack_chk_guard, or TLS access to stack guard canary.
      GCC_GLIBC_VERSION_GTE_IFELSE([2], [4], [gcc_cv_libc_provides_ssp=yes], [
      [if test -f $target_header_dir/features.h \
     && $EGREP '^[     ]*#[     ]*define[ ]+__GNU_LIBRARY__[     ]+([1-9][0-9]|[6-9])' \
        $target_header_dir/features.h > /dev/null; then
    if $EGREP '^[     ]*#[     ]*define[     ]+__UCLIBC__[     ]+1' \
         $target_header_dir/features.h > /dev/null && \
         test -f $target_header_dir/bits/uClibc_config.h && \
         $EGREP '^[     ]*#[     ]*define[     ]+__UCLIBC_HAS_SSP__[     ]+1' \
         $target_header_dir/bits/uClibc_config.h > /dev/null; then
      gcc_cv_libc_provides_ssp=yes
    fi
      # all versions of Bionic support stack protector
      elif test -f $target_header_dir/sys/cdefs.h \
        && $EGREP '^[  ]*#[    ]*define[ ]+__BIONIC__[   ]+1' \
           $target_header_dir/sys/cdefs.h > /dev/null; then
         gcc_cv_libc_provides_ssp=yes
      fi]])
    ;;
       *-*-gnu*)
     # Avoid complicated tests (see
     # <http://gcc.gnu.org/ml/gcc/2008-10/msg00130.html>) and for now
     # simply assert that glibc does provide this, which is true for all
     # realistically usable GNU/Hurd configurations.
     # All supported versions of musl provide it as well
     gcc_cv_libc_provides_ssp=yes;;
       *-*-darwin* | *-*-freebsd* | *-*-netbsd*)
     AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
           [echo "no __stack_chk_fail on this target"])
        ;;
  *) gcc_cv_libc_provides_ssp=no ;;
    esac])

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber@embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]