Blame elf/tst-dlopenfail-2.c

Packit Bot fc237c
/* Test unrelated dlopen after dlopen failure involving NODELETE.
Packit Bot fc237c
   Copyright (C) 2019-2020 Free Software Foundation, Inc.
Packit Bot fc237c
   This file is part of the GNU C Library.
Packit Bot fc237c
Packit Bot fc237c
   The GNU C Library is free software; you can redistribute it and/or
Packit Bot fc237c
   modify it under the terms of the GNU Lesser General Public
Packit Bot fc237c
   License as published by the Free Software Foundation; either
Packit Bot fc237c
   version 2.1 of the License, or (at your option) any later version.
Packit Bot fc237c
Packit Bot fc237c
   The GNU C Library is distributed in the hope that it will be useful,
Packit Bot fc237c
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Bot fc237c
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Bot fc237c
   Lesser General Public License for more details.
Packit Bot fc237c
Packit Bot fc237c
   You should have received a copy of the GNU Lesser General Public
Packit Bot fc237c
   License along with the GNU C Library; if not, see
Packit Bot fc237c
   <https://www.gnu.org/licenses/>.  */
Packit Bot fc237c
Packit Bot fc237c
#include <dlfcn.h>
Packit Bot fc237c
#include <errno.h>
Packit Bot fc237c
#include <gnu/lib-names.h>
Packit Bot fc237c
#include <stddef.h>
Packit Bot fc237c
#include <stdio.h>
Packit Bot fc237c
#include <string.h>
Packit Bot fc237c
#include <support/check.h>
Packit Bot fc237c
#include <support/xdlfcn.h>
Packit Bot fc237c
Packit Bot fc237c
static int
Packit Bot fc237c
do_test (void)
Packit Bot fc237c
{
Packit Bot fc237c
  /* This test uses libpthread as the canonical NODELETE module.  If
Packit Bot fc237c
     libpthread is no longer NODELETE because it has been merged into
Packit Bot fc237c
     libc, the test needs to be updated.  */
Packit Bot fc237c
  TEST_VERIFY (dlsym (NULL, "pthread_create") == NULL);
Packit Bot fc237c
Packit Bot fc237c
  /* This is expected to fail because of the missing dependency.  */
Packit Bot fc237c
  puts ("info: attempting to load tst-dlopenfailmod1.so");
Packit Bot fc237c
  TEST_VERIFY (dlopen ("tst-dlopenfailmod1.so", RTLD_LAZY) == NULL);
Packit Bot fc237c
  const char *message = dlerror ();
Packit Bot fc237c
  TEST_COMPARE_STRING (message,
Packit Bot fc237c
                       "tst-dlopenfail-missingmod.so:"
Packit Bot fc237c
                       " cannot open shared object file:"
Packit Bot fc237c
                       " No such file or directory");
Packit Bot fc237c
Packit Bot fc237c
  /* Open a small shared object.  With a dangling GL (dl_initfirst)
Packit Bot fc237c
     pointer, this is likely to crash because there is no longer any
Packit Bot fc237c
     mapped text segment there (bug 25396).  */
Packit Bot fc237c
Packit Bot fc237c
  puts ("info: attempting to load tst-dlopenfailmod3.so");
Packit Bot fc237c
  xdlclose (xdlopen ("tst-dlopenfailmod3.so", RTLD_NOW));
Packit Bot fc237c
Packit Bot fc237c
  return 0;
Packit Bot fc237c
}
Packit Bot fc237c
Packit Bot fc237c
/* Do not perturb the dangling link map.  With M_PERTURB, the link map
Packit Bot fc237c
   appears to have l_init_called set, so there are no constructor
Packit Bot fc237c
   calls and no crashes.  */
Packit Bot fc237c
#define TEST_NO_MALLOPT
Packit Bot fc237c
#include <support/test-driver.c>