| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#include <dlfcn.h> |
| 21 |
#include <stdio.h> |
| 22 |
#include <stdlib.h> |
| 23 |
#include <string.h> |
| 24 |
#include <sys/platform/x86.h> |
| 25 |
|
| 26 |
#include <support/check.h> |
| 27 |
|
| 28 |
static int |
| 29 |
do_test (void) |
| 30 |
{ |
| 31 |
static const char modname[] = "tst-cet-legacy-mod-4.so"; |
| 32 |
int (*fp) (void); |
| 33 |
void *h; |
| 34 |
|
| 35 |
h = dlopen (modname, RTLD_LAZY); |
| 36 |
if (h == NULL) |
| 37 |
{ |
| 38 |
const char *err = dlerror (); |
| 39 |
if (!strstr (err, "rebuild shared object with IBT support enabled")) |
| 40 |
FAIL_EXIT1 ("incorrect dlopen '%s' error: %s\n", modname, err); |
| 41 |
return 0; |
| 42 |
} |
| 43 |
|
| 44 |
#ifdef CET_IS_PERMISSIVE |
| 45 |
TEST_VERIFY (!CPU_FEATURE_ACTIVE (IBT) && !CPU_FEATURE_ACTIVE (SHSTK)); |
| 46 |
#endif |
| 47 |
|
| 48 |
fp = dlsym (h, "test"); |
| 49 |
if (fp == NULL) |
| 50 |
FAIL_EXIT1 ("cannot get symbol 'test': %s\n", dlerror ()); |
| 51 |
|
| 52 |
if (fp () != 0) |
| 53 |
FAIL_EXIT1 ("test () != 0"); |
| 54 |
|
| 55 |
dlclose (h); |
| 56 |
|
| 57 |
return 0; |
| 58 |
} |
| 59 |
|
| 60 |
#include <support/test-driver.c> |