All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] configure: Add configure check for GCC -no-pie
@ 2017-09-26  9:29 Guangwen Feng
  2017-09-26  9:29 ` [LTP] [PATCH 2/2] commands/file: Compile in.c with -no-pie Guangwen Feng
  0 siblings, 1 reply; 5+ messages in thread
From: Guangwen Feng @ 2017-09-26  9:29 UTC (permalink / raw)
  To: ltp

Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
Signed-off-by: Fei Jie <feij.fnst@cn.fujitsu.com>
---
 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

diff --git a/configure.ac b/configure.ac
index 458a5b1..e30fd69 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/include/mk/config.mk.in b/include/mk/config.mk.in
index dde2a9e..4fe380d 100644
--- a/include/mk/config.mk.in
+++ b/include/mk/config.mk.in
@@ -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)
diff --git a/m4/ltp-no-pie.m4 b/m4/ltp-no-pie.m4
new file mode 100644
index 0000000..608b70f
--- /dev/null
+++ b/m4/ltp-no-pie.m4
@@ -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 <fenggw-fnst@cn.fujitsu.com>
+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"
+
+])
-- 
2.9.5




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [LTP] [PATCH 2/2] commands/file: Compile in.c with -no-pie
  2017-09-26  9:29 [LTP] [PATCH 1/2] configure: Add configure check for GCC -no-pie Guangwen Feng
@ 2017-09-26  9:29 ` Guangwen Feng
  2017-09-26  9:37   ` Cyril Hrubis
  0 siblings, 1 reply; 5+ messages in thread
From: Guangwen Feng @ 2017-09-26  9:29 UTC (permalink / raw)
  To: ltp

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.

Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
Signed-off-by: Fei Jie <feij.fnst@cn.fujitsu.com>
---
 testcases/commands/file/datafiles/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/testcases/commands/file/datafiles/Makefile b/testcases/commands/file/datafiles/Makefile
index d3cb847..b26ce5b 100644
--- a/testcases/commands/file/datafiles/Makefile
+++ b/testcases/commands/file/datafiles/Makefile
@@ -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
-- 
2.9.5




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [LTP] [PATCH 2/2] commands/file: Compile in.c with -no-pie
  2017-09-26  9:29 ` [LTP] [PATCH 2/2] commands/file: Compile in.c with -no-pie Guangwen Feng
@ 2017-09-26  9:37   ` Cyril Hrubis
  2017-09-27  5:32     ` [LTP] [PATCH v2] commands/file: Fix for "executable" match failure on newer gcc Guangwen Feng
  0 siblings, 1 reply; 5+ messages in thread
From: Cyril Hrubis @ 2017-09-26  9:37 UTC (permalink / raw)
  To: ltp

Hi!
> 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.
> 
> Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
> Signed-off-by: Fei Jie <feij.fnst@cn.fujitsu.com>
> ---
>  testcases/commands/file/datafiles/Makefile | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/testcases/commands/file/datafiles/Makefile b/testcases/commands/file/datafiles/Makefile
> index d3cb847..b26ce5b 100644
> --- a/testcases/commands/file/datafiles/Makefile
> +++ b/testcases/commands/file/datafiles/Makefile
> @@ -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.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [LTP] [PATCH v2] commands/file: Fix for "executable" match failure on newer gcc
  2017-09-26  9:37   ` Cyril Hrubis
@ 2017-09-27  5:32     ` Guangwen Feng
  2017-09-27  9:15       ` Cyril Hrubis
  0 siblings, 1 reply; 5+ messages in thread
From: Guangwen Feng @ 2017-09-27  5:32 UTC (permalink / raw)
  To: ltp

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.

Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
Signed-off-by: Fei Jie <feij.fnst@cn.fujitsu.com>
Signed-off-by: Lei Shaoting <leist.fnst@cn.fujitsu.com>
---
 testcases/commands/file/file01.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/testcases/commands/file/file01.sh b/testcases/commands/file/file01.sh
index 1b253cb..ff1a795 100755
--- a/testcases/commands/file/file01.sh
+++ b/testcases/commands/file/file01.sh
@@ -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, .*";;
-- 
2.9.5




^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [LTP] [PATCH v2] commands/file: Fix for "executable" match failure on newer gcc
  2017-09-27  5:32     ` [LTP] [PATCH v2] commands/file: Fix for "executable" match failure on newer gcc Guangwen Feng
@ 2017-09-27  9:15       ` Cyril Hrubis
  0 siblings, 0 replies; 5+ messages in thread
From: Cyril Hrubis @ 2017-09-27  9:15 UTC (permalink / raw)
  To: ltp

Hi!
I consider this to be safe enough to be included in the release, hence
pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-09-27  9:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-26  9:29 [LTP] [PATCH 1/2] configure: Add configure check for GCC -no-pie Guangwen Feng
2017-09-26  9:29 ` [LTP] [PATCH 2/2] commands/file: Compile in.c with -no-pie Guangwen Feng
2017-09-26  9:37   ` Cyril Hrubis
2017-09-27  5:32     ` [LTP] [PATCH v2] commands/file: Fix for "executable" match failure on newer gcc Guangwen Feng
2017-09-27  9:15       ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.