configure: Add configure check for GCC -no-pie
PATCH 1/2 configure: Add configure check for GCC -no-pie
--- configure.ac | 1 + include/mk/config.mk.in | 1 + m4/ltp-no-pie.m4 | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 m4/ltp-no-pie.m4
configure.ac +1 -0
@@ -135,6 +135,7 @@ AC_CONFIG_COMMANDS([syscalls.h], [cd include/lapi/syscalls; ./regen.sh]) # END testsuites knobs LTP_CHECK_FORTIFY_SOURCE LTP_CHECK_CC_WARN_OLDSTYLE +LTP_CHECK_CC_NO_PIE LTP_CHECK_MKDTEMP LTP_CHECK_CAPABILITY_SUPPORT LTP_CHECK_CRYPTO
include/mk/config.mk.in +1 -0
@@ -71,6 +71,7 @@ OPT_CXXFLAGS ?= $(OPT_CFLAGS) WCFLAGS ?= -Wall -W @GCC_WARN_OLDSTYLE@ WCXXFLAGS ?= $(WCFLAGS) +NOPIEFLAGS ?= @GCC_NO_PIE@ LDFLAGS += $(WLDFLAGS) CFLAGS += $(DEBUG_CFLAGS) $(OPT_CFLAGS) $(WCFLAGS)
m4/ltp-no-pie.m4 new file +37 -0
@@ -0,0 +1,37 @@ +dnl Copyright (c) 2017 FUJITSU LIMITED +dnl +dnl This program is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU General Public License as +dnl published by the Free Software Foundation; either version 2 of +dnl the License, or (at your option) any later version. +dnl +dnl This program is distributed in the hope that it would be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, see <http://www.gnu.org/licenses/>. +dnl +dnl Author: Guangwen Feng <[email protected]> +dnl + +AC_DEFUN([LTP_CHECK_CC_NO_PIE],[dnl + +pflag="-no-pie" +AC_MSG_CHECKING([if $CC supports $pflag]) + +backup_cflags="$CFLAGS" +CFLAGS="$CFLAGS $pflag" + +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([])], + [GCC_NO_PIE="$pflag"] + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])] +) + +AC_SUBST(GCC_NO_PIE) +CFLAGS="$backup_cflags" + +])
Signature · 1 line
2.9.5
PATCH 2/2 commands/file: Compile in.c with -no-pie
On newer gcc, --enable-default-pie is enabled by default, thus in.c is compiled as position independent executable file, which leads to test failure unexpectedly.
--- testcases/commands/file/datafiles/Makefile | 1 + 1 file changed, 1 insertion(+)
testcases/commands/file/datafiles/Makefile +1 -0
@@ -14,6 +14,7 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/env_pre.mk +CFLAGS += $(NOPIEFLAGS) INSTALL_DIR := testcases/data/file01 INSTALL_TARGETS := in* include $(top_srcdir)/include/mk/generic_leaf_target.mk
Signature · 1 line
2.9.5
PATCH 2/2 commands/file: Compile in.c with -no-pie
Hi!
Quoted 15 lines
On newer gcc, --enable-default-pie is enabled by default, thus
in.cis compiled as position independent executable file, which leads to test failure unexpectedly.Signed-off-by Guangwen Feng <[email protected]>Signed-off-by Fei Jie <[email protected]>--- testcases/commands/file/datafiles/Makefile | 1 + 1 file changed, 1 insertion(+)testcases/commands/file/datafiles/Makefile +0
-0
testcases/commands/file/datafiles/Makefile line 20
Quoted 7 lines
testcases/commands/file/datafiles/Makefile +1
-0@@ -14,6 +14,7 @@ top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/env_pre.mk +CFLAGS += $(NOPIEFLAGS) INSTALL_DIR := testcases/data/file01 INSTALL_TARGETS := in* include $(top_srcdir)/include/mk/generic_leaf_target.mk
Isn't adding an alternative expected string easier than this?
We do have, for instance, four alternative expected outputs for shell scripts.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 1/1 commands/file: Fix for "executable" match failure on newer gcc
On newer gcc, --enable-default-pie is enabled by default, thus in.c is compiled as position independent executable, which is described as "shared object", so add this.
--- testcases/commands/file/file01.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
testcases/commands/file/file01.sh +2 -1
@@ -88,7 +88,8 @@ do_test() "[pP]ython script text executable";; 9) file_test in.m4 "M4 macro processor script, ASCII text" \ "ASCII M4 macro language pre-processor text";; - 10) file_test in "ELF .*-bit $TEST_ARCH executable, .*";; + 10) file_test in "ELF .*-bit $TEST_ARCH executable, .*" \ + "ELF .*-bit $TEST_ARCH shared object, .*";; 11) file_test in.ar "current ar archive";; 12) file_test in.tar "tar archive";; 13) file_test in.tar.gz "gzip compressed data, .*";;
Signature · 1 line
2.9.5
PATCH v2 1/1 commands/file: Fix for "executable" match failure on newer gcc
Hi!
I consider this to be safe enough to be included in the release, hence pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]