This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: cross mode -fstack-protector ?


On Wed, Jan 17, 2007 at 11:15:55AM +0200, Balint Cristian wrote:
>  Is it a bug ?
> 
>  Maybe i still dont understand how this is emmited, but anyone knows why a
> cross-compiler vs normal compiler using the -fstack-protector option why
> will act differnetly ?
> 
> e.g nm on same object compiled with:
>  cross:
>           U __stack_chk_fail
>           U __stack_chk_guard
>  native:
>          U __stack_chk_guard
> 
>  somehow the cross one still put outside reference to __stack_chk_fail ...

Badly configured cross?
The configure check in question is:

case "$target" in
  *-*-linux*)
    AC_CACHE_CHECK(__stack_chk_fail in target GNU C library,
      gcc_cv_libc_provides_ssp,
      [gcc_cv_libc_provides_ssp=no
      if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x; then
        if test "x$with_sysroot" = x; then
          glibc_header_dir="${exec_prefix}/${target_noncanonical}/sys-include"
        elif test "x$with_sysroot" = xyes; then
          glibc_header_dir="${exec_prefix}/${target_noncanonical}/sys-root/usr/include"
        else
          glibc_header_dir="${with_sysroot}/usr/include"
        fi
      else
        glibc_header_dir=/usr/include
      fi
      # glibc 2.4 and later provides __stack_chk_fail and
      # either __stack_chk_guard, or TLS access to stack guard canary.
      if test -f $glibc_header_dir/features.h \
         && $EGREP '^@<:@       @:>@*#[         ]*define[       ]+__GNU_LIBRARY__[      ]+([1-9][0-9]|[6-9])' \
            $glibc_header_dir/features.h > /dev/null; then
        if $EGREP '^@<:@        @:>@*#[         ]*define[       ]+__GLIBC__[    ]+([1-9][0-9]|[3-9])' \
           $glibc_header_dir/features.h > /dev/null; then
          gcc_cv_libc_provides_ssp=yes
        elif $EGREP '^@<:@      @:>@*#[         ]*define[       ]+__GLIBC__[    ]+2' \
             $glibc_header_dir/features.h > /dev/null \
             && $EGREP '^@<:@   @:>@*#[         ]*define[       ]+__GLIBC_MINOR__[      ]+([1-9][0-9]|[4-9])' \
             $glibc_header_dir/features.h > /dev/null; then
          gcc_cv_libc_provides_ssp=yes
        fi
      fi]) ;;
  *) gcc_cv_libc_provides_ssp=no ;;
esac

so when your cross is not --with-sysroot, you should have your
target glibc headers in /usr/sparc-redhat-linux/sys-include
before configure.

	Jakub


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