Skip to content

Commit

Permalink
Check for -fstack-protector
Browse files Browse the repository at this point in the history
Not all toolchains provide support for -fstack-protector. This patch
provides a configure check to avoid build errors like

/home/buildroot/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-uclibc/6.4.0/../../../../x86_64-buildroot-linux-uclibc/bin/ld: cannot find -lssp_nonshared
/home/buildroot/buildroot/output/host/opt/ext-toolchain/bin/../lib/gcc/x86_64-buildroot-linux-uclibc/6.4.0/../../../../x86_64-buildroot-linux-uclibc/bin/ld: cannot find -lssp
  • Loading branch information
bkuhls authored and XinfengZhang committed Apr 9, 2019
1 parent 72dab0c commit d71e260
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
16 changes: 16 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ if test "$ac_cv_have_gnuc_visibility_attribute" = "yes"; then
[Defined to 1 if GCC visibility attribute is supported])
fi

# Check for -fstack-protector
ssp_cc=yes
if test "X$CC-cc" != "X"; then
AC_MSG_CHECKING([whether ${CC-cc} accepts -fstack-protector])
ssp_old_cflags="$CFLAGS"
CFLAGS="$CFLAGS -fstack-protector"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[alloca(100);]])], [], [ssp_cc=no])
AC_MSG_RESULT([$ssp_cc])
if test "X$ssp_cc" = "Xno"; then
CFLAGS="$ssp_old_cflags"
else
AC_DEFINE([ENABLE_SSP_CC], 1, [Define if SSP C support is enabled.])
fi
fi
AM_CONDITIONAL(USE_SSP, test "$ssp_cc" = "yes")

# Check for DRM (mandatory)
LIBDRM_VERSION=libdrm_version
PKG_CHECK_MODULES([DRM], [libdrm >= $LIBDRM_VERSION])
Expand Down
5 changes: 4 additions & 1 deletion decode/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ bin_PROGRAMS = mpeg2vldemo loadjpeg

AM_CPPFLAGS = \
-Wall \
-fstack-protector \
$(LIBVA_CFLAGS) \
-I$(top_srcdir)/common \
$(NULL)

if USE_SSP
AM_CPPFLAGS += -fstack-protector
endif

TEST_LIBS = \
$(LIBVA_LIBS) \
$(top_builddir)/common/libva-display.la \
Expand Down
5 changes: 4 additions & 1 deletion encode/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,13 @@ noinst_PROGRAMS = svctenc

AM_CPPFLAGS = \
-Wall \
-fstack-protector \
$(LIBVA_CFLAGS) \
$(NULL)

if USE_SSP
AM_CPPFLAGS += -fstack-protector
endif

h264encode_SOURCES = h264encode.c
h264encode_CFLAGS = -I$(top_srcdir)/common -g
h264encode_LDADD = \
Expand Down
5 changes: 4 additions & 1 deletion putsurface/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ TEST_CFLAGS = \
$(LIBVA_CFLAGS) \
-I$(top_srcdir)/common \
-Wall \
-fstack-protector \
$(NULL)

if USE_SSP
TEST_CFLAGS += -fstack-protector
endif

TEST_LIBS = \
$(LIBVA_LIBS) \
$(top_builddir)/common/libva-display.la \
Expand Down
5 changes: 4 additions & 1 deletion vainfo/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ vainfo_cflags = \
$(LIBVA_CFLAGS) \
-DLIBVA_VERSION_S="\"$(LIBVA_VERSION)\"" \
-Wall \
-fstack-protector \
$(NULL)

if USE_SSP
vainfo_cflags += -fstack-protector
endif

vainfo_libs = \
$(LIBVA_LIBS) \
$(top_builddir)/common/libva-display.la \
Expand Down
5 changes: 4 additions & 1 deletion videoprocess/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ bin_PROGRAMS = vavpp vppscaling_csc vppdenoise vppsharpness vppchromasitting vpp

AM_CPPFLAGS = \
-Wall \
-fstack-protector \
$(LIBVA_CFLAGS) \
-I$(top_srcdir)/common \
$(NULL)

if USE_SSP
AM_CPPFLAGS += -fstack-protector
endif

TEST_LIBS = \
$(LIBVA_LIBS) \
$(top_builddir)/common/libva-display.la \
Expand Down

0 comments on commit d71e260

Please sign in to comment.