Blame elf/tst-dlopenfail-2.c

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