public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/hjl/cet/master] Fix test
@ 2020-04-28 17:58 H.J. Lu
0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2020-04-28 17:58 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e772a01f9cdbf8e9d824f793301437ff0bd725a6
commit e772a01f9cdbf8e9d824f793301437ff0bd725a6
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Tue Apr 28 10:57:24 2020 -0700
Fix test
Diff:
---
sysdeps/x86/Makefile | 8 ++++++++
sysdeps/x86/tst-cet-legacy-5.c | 21 +++++++++++++--------
sysdeps/x86/tst-cet-legacy-6.c | 21 +++++++++++++--------
3 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile
index 4fbfa7bffd..4fd5acac04 100644
--- a/sysdeps/x86/Makefile
+++ b/sysdeps/x86/Makefile
@@ -43,12 +43,20 @@ CFLAGS-tst-cet-legacy-4a.c += -fcf-protection
CFLAGS-tst-cet-legacy-4b.c += -fcf-protection
CFLAGS-tst-cet-legacy-mod-4.c += -fcf-protection=none
CFLAGS-tst-cet-legacy-5a.c += -fcf-protection
+ifeq ($(enable-cet),permissive)
+CPPFLAGS-tst-cet-legacy-5a.c += -DCET_IS_PERMISSIVE=1
+endif
CFLAGS-tst-cet-legacy-5b.c += -fcf-protection
+CPPFLAGS-tst-cet-legacy-5b.c += -DCET_DISABLED_BY_ENV=1
CFLAGS-tst-cet-legacy-mod-5a.c += -fcf-protection=branch
CFLAGS-tst-cet-legacy-mod-5b.c += -fcf-protection
CFLAGS-tst-cet-legacy-mod-5c.c += -fcf-protection
CFLAGS-tst-cet-legacy-6a.c += -fcf-protection
+ifeq ($(enable-cet),permissive)
+CPPFLAGS-tst-cet-legacy-6a.c += -DCET_IS_PERMISSIVE=1
+endif
CFLAGS-tst-cet-legacy-6b.c += -fcf-protection
+CPPFLAGS-tst-cet-legacy-6b.c += -DCET_DISABLED_BY_ENV=1
CFLAGS-tst-cet-legacy-mod-6a.c += -fcf-protection=branch
CFLAGS-tst-cet-legacy-mod-6b.c += -fcf-protection
CFLAGS-tst-cet-legacy-mod-6c.c += -fcf-protection
diff --git a/sysdeps/x86/tst-cet-legacy-5.c b/sysdeps/x86/tst-cet-legacy-5.c
index e2e95b6749..94aa9d1cfa 100644
--- a/sysdeps/x86/tst-cet-legacy-5.c
+++ b/sysdeps/x86/tst-cet-legacy-5.c
@@ -22,6 +22,13 @@
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
+#include <support/check.h>
+
+#if defined CET_IS_PERMISSIVE || defined CET_DISABLED_BY_ENV
+# define CET_MAYBE_DISABLED 1
+#else
+# define CET_MAYBE_DISABLED 0
+#endif
static void
do_test_1 (const char *modname, bool fail)
@@ -32,24 +39,22 @@ do_test_1 (const char *modname, bool fail)
h = dlopen (modname, RTLD_LAZY);
if (h == NULL)
{
+ const char *err = dlerror ();
if (fail)
{
- const char *err = dlerror ();
if (strstr (err, "rebuild shared object with SHSTK support enabled")
== NULL)
- {
- printf ("incorrect dlopen '%s' error: %s\n", modname,
- err);
- exit (1);
- }
+ FAIL_EXIT1 ("incorrect dlopen '%s' error: %s\n", modname, err);
return;
}
- printf ("cannot open '%s': %s\n", modname, dlerror ());
- exit (1);
+ FAIL_EXIT1 ("cannot open '%s': %s\n", modname, err);
}
+ if (fail && !CET_MAYBE_DISABLED)
+ FAIL_EXIT1 ("dlopen should have failed\n");
+
fp = dlsym (h, "test");
if (fp == NULL)
{
diff --git a/sysdeps/x86/tst-cet-legacy-6.c b/sysdeps/x86/tst-cet-legacy-6.c
index bdbbb9075f..2095a1ba8e 100644
--- a/sysdeps/x86/tst-cet-legacy-6.c
+++ b/sysdeps/x86/tst-cet-legacy-6.c
@@ -22,6 +22,13 @@
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
+#include <support/check.h>
+
+#if defined CET_IS_PERMISSIVE || defined CET_DISABLED_BY_ENV
+# define CET_MAYBE_DISABLED 1
+#else
+# define CET_MAYBE_DISABLED 0
+#endif
static void
do_test_1 (const char *modname, bool fail)
@@ -32,24 +39,22 @@ do_test_1 (const char *modname, bool fail)
h = dlopen (modname, RTLD_LAZY);
if (h == NULL)
{
+ const char *err = dlerror ();
if (fail)
{
- const char *err = dlerror ();
if (strstr (err, "rebuild shared object with SHSTK support enabled")
== NULL)
- {
- printf ("incorrect dlopen '%s' error: %s\n", modname,
- err);
- exit (1);
- }
+ FAIL_EXIT1 ("incorrect dlopen '%s' error: %s\n", modname, err);
return;
}
- printf ("cannot open '%s': %s\n", modname, dlerror ());
- exit (1);
+ FAIL_EXIT1 ("cannot open '%s': %s\n", modname, err);
}
+ if (fail && !CET_MAYBE_DISABLED)
+ FAIL_EXIT1 ("dlopen should have failed\n");
+
fp = dlsym (h, "test");
if (fp == NULL)
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-04-28 17:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-28 17:58 [glibc/hjl/cet/master] Fix test H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).