]> Savannah Git Hosting - gnulib.git/commitdiff
jit/cache tests: Avoid test failure on OpenBSD.
authorBruno Haible <bruno@clisp.org>
Mon, 8 Jan 2024 17:10:28 +0000 (18:10 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 18 Jan 2024 08:27:18 +0000 (09:27 +0100)
* modules/jit/cache-tests (Files): Add m4/warnings.m4.
(configure.ac): Set and substitute DISABLE_OPENBSD_RETGUARD.
(Makefile.am): Set test_cache_CFLAGS.
* tests/jit/test-cache.c (main): If the compiler defines _RET_PROTECTOR,
skip the test.

ChangeLog
modules/jit/cache-tests
tests/jit/test-cache.c

index 543a8000a792be7a7b9bd423b1c2d3cce7f455ed..2e11913f238accfdd5e0d84ef6ef80a24f795f3b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-01-08  Bruno Haible  <bruno@clisp.org>
+
+       jit/cache tests: Avoid test failure on OpenBSD.
+       * modules/jit/cache-tests (Files): Add m4/warnings.m4.
+       (configure.ac): Set and substitute DISABLE_OPENBSD_RETGUARD.
+       (Makefile.am): Set test_cache_CFLAGS.
+       * tests/jit/test-cache.c (main): If the compiler defines _RET_PROTECTOR,
+       skip the test.
+
 2024-01-08  Bruno Haible  <bruno@clisp.org>
 
        jit/cache tests: Avoid test failure on CentOS, *BSD, macOS.
index e4229476c88efbd10a933af528c34f8182ecc42c..d7776840939bd6cc7b321a5b521823eeff0fbbfa 100644 (file)
@@ -2,6 +2,7 @@ Files:
 tests/jit/test-cache.c
 tests/macros.h
 m4/mmap-anon.m4
+m4/warnings.m4
 
 Status:
 unportable-test
@@ -15,8 +16,14 @@ stdint
 configure.ac:
 AC_CHECK_HEADERS_ONCE([sys/mman.h])
 gl_FUNC_MMAP_ANON
+dnl Disable the OpenBSD "retguard" stack protector for this test.
+gl_COMPILER_OPTION_IF([-fno-ret-protector],
+  [DISABLE_OPENBSD_RETGUARD='-fno-ret-protector'],
+  [DISABLE_OPENBSD_RETGUARD=])
+AC_SUBST([DISABLE_OPENBSD_RETGUARD])
 
 Makefile.am:
 TESTS += test-cache
 check_PROGRAMS += test-cache
 test_cache_SOURCES = jit/test-cache.c
+test_cache_CFLAGS = $(AM_CFLAGS) $(DISABLE_OPENBSD_RETGUARD)
index 35d63b784205c0ad2d93ce1489064d8c3aa09c8a..1d77dadaa5d42f954f87b71b6f9ab506a102df3b 100644 (file)
@@ -107,7 +107,14 @@ return2 (void)
 int
 main ()
 {
-#if !HAVE_SYS_MMAN_H
+#if defined _RET_PROTECTOR
+  /* The OpenBSD "retguard" stack protector produces code for 'return1' and
+     'return2' that is not position independent, and there is no clang
+     attribute for turning this instrumentation off for specific functions.
+     If this stack protector has not been disabled through a configure test,
+     we need to skip this unit test.  */
+  return 77;
+#elif !HAVE_SYS_MMAN_H
   return 77;
 #else
   int const pagesize = getpagesize ();