Browse code

Add a check for -Wl, --wrap support in linker

- Also make tests that require --wrap option to be
conditional on this support

[ DS: Removed AC_DEFINE([HAVE_LD_WRAP_SUPPORT],...) at commit time
as we now see no real use for such a #define in config.h ]

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <1484772172-19758-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13897.html
Signed-off-by: David Sommerseth <davids@openvpn.net>

Selva Nair authored on 2017/01/19 05:42:52
Showing 2 changed files
... ...
@@ -582,6 +582,30 @@ AC_COMPILE_IFELSE(
582 582
 	[AC_MSG_RESULT([no])]
583 583
 )
584 584
 
585
+saved_LDFLAGS="$LDFLAGS"
586
+LDFLAGS="$LDFLAGS -Wl,--wrap=exit"
587
+AC_MSG_CHECKING([linker supports --wrap])
588
+AC_LINK_IFELSE(
589
+	[AC_LANG_PROGRAM(
590
+		[[
591
+			void exit(int);
592
+			void __real_exit(int);
593
+			void __wrap_exit(int i) {
594
+				__real_exit(i);
595
+			}
596
+		]],
597
+		[[
598
+			exit(0);
599
+		]]
600
+	)],
601
+	[
602
+		AC_MSG_RESULT([yes])
603
+		have_ld_wrap_support=yes
604
+	],
605
+	[AC_MSG_RESULT([no])],
606
+)
607
+LDFLAGS="$saved_LDFLAGS"
608
+
585 609
 dnl We emulate signals in Windows
586 610
 AC_CHECK_DECLS(
587 611
 	[SIGHUP],
... ...
@@ -1244,6 +1268,7 @@ AM_CONDITIONAL([GIT_CHECKOUT], [test "${GIT_CHECKOUT}" = "yes"])
1244 1244
 AM_CONDITIONAL([ENABLE_PLUGIN_AUTH_PAM], [test "${enable_plugin_auth_pam}" = "yes"])
1245 1245
 AM_CONDITIONAL([ENABLE_PLUGIN_DOWN_ROOT], [test "${enable_plugin_down_root}" = "yes"])
1246 1246
 AM_CONDITIONAL([ENABLE_CRYPTO], [test "${enable_crypto}" = "yes"])
1247
+AM_CONDITIONAL([HAVE_LD_WRAP_SUPPORT], [test "${have_ld_wrap_support}" = "yes"])
1247 1248
 
1248 1249
 plugindir="${with_plugindir}"
1249 1250
 sampledir="\$(docdir)/sample"
... ...
@@ -1,6 +1,10 @@
1 1
 AUTOMAKE_OPTIONS = foreign
2 2
 
3
-check_PROGRAMS = argv_testdriver buffer_testdriver
3
+check_PROGRAMS=
4
+
5
+if HAVE_LD_WRAP_SUPPORT
6
+check_PROGRAMS += argv_testdriver buffer_testdriver
7
+endif
4 8
 
5 9
 if ENABLE_CRYPTO
6 10
 check_PROGRAMS += tls_crypt_testdriver