From 2a5b4f7a715921a232f67f6810268c6cd6aa0af2 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Fri, 8 Jul 2022 12:08:48 +0200 Subject: elf: Rename tst-audit26 to tst-audit28 tst-audit26 and tst-audit27 are already used by aarch64. Reviewed-by: Szabolcs Nagy --- elf/Makefile | 10 ++--- elf/tst-audit26.c | 35 ----------------- elf/tst-audit28.c | 35 +++++++++++++++++ elf/tst-auditmod26.c | 104 --------------------------------------------------- elf/tst-auditmod28.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 144 insertions(+), 144 deletions(-) delete mode 100644 elf/tst-audit26.c create mode 100644 elf/tst-audit28.c delete mode 100644 elf/tst-auditmod26.c create mode 100644 elf/tst-auditmod28.c diff --git a/elf/Makefile b/elf/Makefile index 2b646a91e0..fd77d0c7c8 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -394,7 +394,7 @@ tests += \ tst-audit24d \ tst-audit25a \ tst-audit25b \ - tst-audit26 \ + tst-audit28 \ tst-auditmany \ tst-auxobj \ tst-auxobj-dlopen \ @@ -816,7 +816,7 @@ modules-names += \ tst-auditmod24c \ tst-auditmod24d \ tst-auditmod25 \ - tst-auditmod26 \ + tst-auditmod28 \ tst-auxvalmod \ tst-big-note-lib \ tst-deep1mod1 \ @@ -2358,9 +2358,9 @@ $(objpfx)tst-audit25b: $(objpfx)tst-audit25mod1.so \ LDFLAGS-tst-audit25b = -Wl,-z,now tst-audit25b-ARGS = -- $(host-test-program-cmd) -$(objpfx)tst-audit26.out: $(objpfx)tst-auditmod26.so -$(objpfx)tst-auditmod26.so: $(libsupport) -tst-audit26-ENV = LD_AUDIT=$(objpfx)tst-auditmod26.so +$(objpfx)tst-audit28.out: $(objpfx)tst-auditmod28.so +$(objpfx)tst-auditmod28.so: $(libsupport) +tst-audit28-ENV = LD_AUDIT=$(objpfx)tst-auditmod28.so # tst-sonamemove links against an older implementation of the library. LDFLAGS-tst-sonamemove-linkmod1.so = \ diff --git a/elf/tst-audit26.c b/elf/tst-audit26.c deleted file mode 100644 index 3f920e83ba..0000000000 --- a/elf/tst-audit26.c +++ /dev/null @@ -1,35 +0,0 @@ -/* Check the usability of functions in audit modules. - Copyright (C) 2022 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 - . */ - -#include - -#include -#include - -static int -do_test (void) -{ - /* Check that the audit module has been loaded. */ - void *handle = xdlopen ("mapped to libc", RTLD_LOCAL | RTLD_NOW); - TEST_VERIFY (handle - == xdlopen (LIBC_SO, RTLD_LOCAL | RTLD_NOW | RTLD_NOLOAD)); - - return 0; -} - -#include diff --git a/elf/tst-audit28.c b/elf/tst-audit28.c new file mode 100644 index 0000000000..3f920e83ba --- /dev/null +++ b/elf/tst-audit28.c @@ -0,0 +1,35 @@ +/* Check the usability of functions in audit modules. + Copyright (C) 2022 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 + . */ + +#include + +#include +#include + +static int +do_test (void) +{ + /* Check that the audit module has been loaded. */ + void *handle = xdlopen ("mapped to libc", RTLD_LOCAL | RTLD_NOW); + TEST_VERIFY (handle + == xdlopen (LIBC_SO, RTLD_LOCAL | RTLD_NOW | RTLD_NOLOAD)); + + return 0; +} + +#include diff --git a/elf/tst-auditmod26.c b/elf/tst-auditmod26.c deleted file mode 100644 index db7ba95abe..0000000000 --- a/elf/tst-auditmod26.c +++ /dev/null @@ -1,104 +0,0 @@ -/* Check the usability of functions in audit modules. Audit module. - Copyright (C) 2022 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 - . */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -unsigned int -la_version (unsigned int current) -{ - /* Exercise various functions. */ - - /* Check dlopen, dlsym, dlclose. */ - void *handle = xdlopen (LIBM_SO, RTLD_LOCAL | RTLD_NOW); - void *ptr = xdlsym (handle, "sincos"); - TEST_VERIFY (ptr != NULL); - ptr = dlsym (handle, "SINCOS"); - TEST_VERIFY (ptr == NULL); - const char *message = dlerror (); - TEST_VERIFY (strstr (message, ": undefined symbol: SINCOS") != NULL); - ptr = dlsym (handle, "SINCOS"); - TEST_VERIFY (ptr == NULL); - xdlclose (handle); - TEST_COMPARE_STRING (dlerror (), NULL); - - handle = xdlopen (LIBC_SO, RTLD_LOCAL | RTLD_NOW | RTLD_NOLOAD); - - /* Check dlvsym. _exit is unlikely to gain another symbol - version. */ - TEST_VERIFY (xdlsym (handle, "_exit") - == xdlvsym (handle, "_exit", FIRST_VERSION_libc__exit_STRING)); - - /* Check dlinfo. */ - { - void *handle2 = NULL; - TEST_COMPARE (dlinfo (handle, RTLD_DI_LINKMAP, &handle2), 0); - TEST_VERIFY (handle2 == handle); - } - - /* Check dladdr and dladdr1. */ - Dl_info info = { }; - TEST_VERIFY (dladdr (&_exit, &info) != 0); - if (strcmp (info.dli_sname, "_Exit") != 0) /* _Exit is an alias. */ - TEST_COMPARE_STRING (info.dli_sname, "_exit"); - TEST_VERIFY (info.dli_saddr == &_exit); - TEST_VERIFY (strstr (info.dli_fname, LIBC_SO)); - void *extra_info; - memset (&info, 0, sizeof (info)); - TEST_VERIFY (dladdr1 (&_exit, &info, &extra_info, RTLD_DL_LINKMAP) != 0); - TEST_VERIFY (extra_info == handle); - - /* Verify that dlmopen creates a new namespace. */ - void *dlmopen_handle = xdlmopen (LM_ID_NEWLM, LIBC_SO, RTLD_NOW); - TEST_VERIFY (dlmopen_handle != handle); - memset (&info, 0, sizeof (info)); - extra_info = NULL; - ptr = xdlsym (dlmopen_handle, "_exit"); - TEST_VERIFY (dladdr1 (ptr, &info, &extra_info, RTLD_DL_LINKMAP) != 0); - TEST_VERIFY (extra_info == dlmopen_handle); - xdlclose (dlmopen_handle); - - /* Terminate the process with an error state. This does not happen - automatically because the audit module state is not shared with - the main program. */ - if (support_record_failure_is_failed ()) - { - fflush (stdout); - fflush (stderr); - _exit (1); - } - - return LAV_CURRENT; -} - -char * -la_objsearch (const char *name, uintptr_t *cookie, unsigned int flag) -{ - if (strcmp (name, "mapped to libc") == 0) - return (char *) LIBC_SO; - else - return (char *) name; -} diff --git a/elf/tst-auditmod28.c b/elf/tst-auditmod28.c new file mode 100644 index 0000000000..db7ba95abe --- /dev/null +++ b/elf/tst-auditmod28.c @@ -0,0 +1,104 @@ +/* Check the usability of functions in audit modules. Audit module. + Copyright (C) 2022 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 + . */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +unsigned int +la_version (unsigned int current) +{ + /* Exercise various functions. */ + + /* Check dlopen, dlsym, dlclose. */ + void *handle = xdlopen (LIBM_SO, RTLD_LOCAL | RTLD_NOW); + void *ptr = xdlsym (handle, "sincos"); + TEST_VERIFY (ptr != NULL); + ptr = dlsym (handle, "SINCOS"); + TEST_VERIFY (ptr == NULL); + const char *message = dlerror (); + TEST_VERIFY (strstr (message, ": undefined symbol: SINCOS") != NULL); + ptr = dlsym (handle, "SINCOS"); + TEST_VERIFY (ptr == NULL); + xdlclose (handle); + TEST_COMPARE_STRING (dlerror (), NULL); + + handle = xdlopen (LIBC_SO, RTLD_LOCAL | RTLD_NOW | RTLD_NOLOAD); + + /* Check dlvsym. _exit is unlikely to gain another symbol + version. */ + TEST_VERIFY (xdlsym (handle, "_exit") + == xdlvsym (handle, "_exit", FIRST_VERSION_libc__exit_STRING)); + + /* Check dlinfo. */ + { + void *handle2 = NULL; + TEST_COMPARE (dlinfo (handle, RTLD_DI_LINKMAP, &handle2), 0); + TEST_VERIFY (handle2 == handle); + } + + /* Check dladdr and dladdr1. */ + Dl_info info = { }; + TEST_VERIFY (dladdr (&_exit, &info) != 0); + if (strcmp (info.dli_sname, "_Exit") != 0) /* _Exit is an alias. */ + TEST_COMPARE_STRING (info.dli_sname, "_exit"); + TEST_VERIFY (info.dli_saddr == &_exit); + TEST_VERIFY (strstr (info.dli_fname, LIBC_SO)); + void *extra_info; + memset (&info, 0, sizeof (info)); + TEST_VERIFY (dladdr1 (&_exit, &info, &extra_info, RTLD_DL_LINKMAP) != 0); + TEST_VERIFY (extra_info == handle); + + /* Verify that dlmopen creates a new namespace. */ + void *dlmopen_handle = xdlmopen (LM_ID_NEWLM, LIBC_SO, RTLD_NOW); + TEST_VERIFY (dlmopen_handle != handle); + memset (&info, 0, sizeof (info)); + extra_info = NULL; + ptr = xdlsym (dlmopen_handle, "_exit"); + TEST_VERIFY (dladdr1 (ptr, &info, &extra_info, RTLD_DL_LINKMAP) != 0); + TEST_VERIFY (extra_info == dlmopen_handle); + xdlclose (dlmopen_handle); + + /* Terminate the process with an error state. This does not happen + automatically because the audit module state is not shared with + the main program. */ + if (support_record_failure_is_failed ()) + { + fflush (stdout); + fflush (stderr); + _exit (1); + } + + return LAV_CURRENT; +} + +char * +la_objsearch (const char *name, uintptr_t *cookie, unsigned int flag) +{ + if (strcmp (name, "mapped to libc") == 0) + return (char *) LIBC_SO; + else + return (char *) name; +} -- cgit 1.4.1