Blame elf/tst-dlopenfail-2.c

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