mirror of
https://sourceware.org/git/glibc.git
synced 2025-10-12 19:04:54 +03:00
aarch64: Add GCS tests for dlopen
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
This commit is contained in:
@@ -633,7 +633,7 @@ link-libc-printers-tests = $(link-libc-rpath) \
|
|||||||
$(link-libc-tests-after-rpath-link)
|
$(link-libc-tests-after-rpath-link)
|
||||||
|
|
||||||
# This is how to find at build-time things that will be installed there.
|
# This is how to find at build-time things that will be installed there.
|
||||||
rpath-dirs = math elf dlfcn nss nis rt resolv mathvec support
|
rpath-dirs = math elf dlfcn nss nis rt resolv mathvec support misc
|
||||||
rpath-link = \
|
rpath-link = \
|
||||||
$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
|
$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
|
||||||
else # build-static
|
else # build-static
|
||||||
|
@@ -8,6 +8,11 @@ ifneq (no,$(findstring no,$(have-cc-gcs) $(have-test-cc-gcs) $(have-ld-gcs)))
|
|||||||
|
|
||||||
gcs-tests-dynamic = \
|
gcs-tests-dynamic = \
|
||||||
tst-gcs-disabled \
|
tst-gcs-disabled \
|
||||||
|
tst-gcs-dlopen-disabled \
|
||||||
|
tst-gcs-dlopen-enforced \
|
||||||
|
tst-gcs-dlopen-optional-off \
|
||||||
|
tst-gcs-dlopen-optional-on \
|
||||||
|
tst-gcs-dlopen-override \
|
||||||
tst-gcs-enforced \
|
tst-gcs-enforced \
|
||||||
tst-gcs-enforced-abort \
|
tst-gcs-enforced-abort \
|
||||||
tst-gcs-optional-off \
|
tst-gcs-optional-off \
|
||||||
@@ -100,6 +105,24 @@ tst-gcs-shared-enforced-abort-ENV = GLIBC_TUNABLES=glibc.cpu.aarch64_gcs=1
|
|||||||
tst-gcs-shared-optional-ENV = GLIBC_TUNABLES=glibc.cpu.aarch64_gcs=2
|
tst-gcs-shared-optional-ENV = GLIBC_TUNABLES=glibc.cpu.aarch64_gcs=2
|
||||||
tst-gcs-shared-override-ENV = GLIBC_TUNABLES=glibc.cpu.aarch64_gcs=3
|
tst-gcs-shared-override-ENV = GLIBC_TUNABLES=glibc.cpu.aarch64_gcs=3
|
||||||
|
|
||||||
|
LDFLAGS-tst-gcs-dlopen-disabled = -Wl,-z gcs=always
|
||||||
|
LDFLAGS-tst-gcs-dlopen-enforced = -Wl,-z gcs=always
|
||||||
|
LDFLAGS-tst-gcs-dlopen-optional-on = -Wl,-z gcs=always
|
||||||
|
LDFLAGS-tst-gcs-dlopen-optional-off = -Wl,-z gcs=never
|
||||||
|
LDFLAGS-tst-gcs-dlopen-override = -Wl,-z gcs=always
|
||||||
|
|
||||||
|
tst-gcs-dlopen-disabled-ENV = GLIBC_TUNABLES=glibc.cpu.aarch64_gcs=0
|
||||||
|
tst-gcs-dlopen-enforced-ENV = GLIBC_TUNABLES=glibc.cpu.aarch64_gcs=1
|
||||||
|
tst-gcs-dlopen-optional-on-ENV = GLIBC_TUNABLES=glibc.cpu.aarch64_gcs=2
|
||||||
|
tst-gcs-dlopen-optional-off-ENV = GLIBC_TUNABLES=glibc.cpu.aarch64_gcs=2
|
||||||
|
tst-gcs-dlopen-override-ENV = GLIBC_TUNABLES=glibc.cpu.aarch64_gcs=3
|
||||||
|
|
||||||
|
$(objpfx)tst-gcs-dlopen-disabled.out: $(objpfx)tst-gcs-mod2.so
|
||||||
|
$(objpfx)tst-gcs-dlopen-enforced.out: $(objpfx)tst-gcs-mod2.so
|
||||||
|
$(objpfx)tst-gcs-dlopen-optional-on.out: $(objpfx)tst-gcs-mod2.so
|
||||||
|
$(objpfx)tst-gcs-dlopen-optional-off.out: $(objpfx)tst-gcs-mod2.so
|
||||||
|
$(objpfx)tst-gcs-dlopen-override.out: $(objpfx)tst-gcs-mod2.so
|
||||||
|
|
||||||
endif # ifeq ($(have-test-cc-gcs),yes)
|
endif # ifeq ($(have-test-cc-gcs),yes)
|
||||||
|
|
||||||
endif # ifeq ($(subdir),misc)
|
endif # ifeq ($(subdir),misc)
|
||||||
|
@@ -0,0 +1,3 @@
|
|||||||
|
#define TEST_GCS_EXPECT_ENABLED 0
|
||||||
|
#define TEST_GCS_EXPECT_DLOPEN 1
|
||||||
|
#include "tst-gcs-dlopen.c"
|
@@ -0,0 +1,3 @@
|
|||||||
|
#define TEST_GCS_EXPECT_ENABLED 1
|
||||||
|
#define TEST_GCS_EXPECT_DLOPEN 0
|
||||||
|
#include "tst-gcs-dlopen.c"
|
@@ -0,0 +1,3 @@
|
|||||||
|
#define TEST_GCS_EXPECT_ENABLED 0
|
||||||
|
#define TEST_GCS_EXPECT_DLOPEN 1
|
||||||
|
#include "tst-gcs-dlopen.c"
|
@@ -0,0 +1,3 @@
|
|||||||
|
#define TEST_GCS_EXPECT_ENABLED 1
|
||||||
|
#define TEST_GCS_EXPECT_DLOPEN 0
|
||||||
|
#include "tst-gcs-dlopen.c"
|
@@ -0,0 +1,3 @@
|
|||||||
|
#define TEST_GCS_EXPECT_ENABLED 1
|
||||||
|
#define TEST_GCS_EXPECT_DLOPEN 1
|
||||||
|
#include "tst-gcs-dlopen.c"
|
62
sysdeps/unix/sysv/linux/aarch64/tst-gcs-dlopen.c
Normal file
62
sysdeps/unix/sysv/linux/aarch64/tst-gcs-dlopen.c
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/* AArch64 tests for GCS for dlopen use case.
|
||||||
|
Copyright (C) 2025 Free Software Foundation, Inc.
|
||||||
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The GNU C Library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with the GNU C Library; if not, see
|
||||||
|
<https://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#include "tst-gcs-helper.h"
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
static int
|
||||||
|
do_test (void)
|
||||||
|
{
|
||||||
|
/* Check if GCS could possible by enabled. */
|
||||||
|
if (!(getauxval (AT_HWCAP) & HWCAP_GCS))
|
||||||
|
{
|
||||||
|
puts ("kernel or CPU does not support GCS");
|
||||||
|
return EXIT_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
/* The tst-gcs-mod2.so test library does not have GCS marking. */
|
||||||
|
void *h = dlopen ("tst-gcs-mod2.so", RTLD_NOW);
|
||||||
|
const char *err = dlerror ();
|
||||||
|
|
||||||
|
#if TEST_GCS_EXPECT_DLOPEN
|
||||||
|
TEST_VERIFY (h != NULL);
|
||||||
|
#else
|
||||||
|
TEST_VERIFY (h == NULL);
|
||||||
|
/* Only accept expected GCS-related errors. */
|
||||||
|
TEST_VERIFY (strstr (err, "not GCS compatible") != NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if TEST_GCS_EXPECT_ENABLED
|
||||||
|
TEST_VERIFY (__check_gcs_status ());
|
||||||
|
#else
|
||||||
|
TEST_VERIFY (!__check_gcs_status ());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (h == NULL)
|
||||||
|
printf ("dlopen error: %s\n", err);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
puts ("library loaded normally");
|
||||||
|
dlclose (h);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <support/test-driver.c>
|
Reference in New Issue
Block a user