Blame elf/tst-auxobj-dlopen.c

Packit Bot 5ef3dd
/* Test for BZ#16272, dlopen'ing an auxiliary filter object.
Packit Bot 5ef3dd
   Ensure that symbols from the resolve correctly.
Packit Bot 5ef3dd
Packit Bot 5ef3dd
   Copyright (C) 2020 Free Software Foundation, Inc.
Packit Bot 5ef3dd
   This file is part of the GNU C Library.
Packit Bot 5ef3dd
Packit Bot 5ef3dd
   The GNU C Library is free software; you can redistribute it and/or
Packit Bot 5ef3dd
   modify it under the terms of the GNU Lesser General Public
Packit Bot 5ef3dd
   License as published by the Free Software Foundation; either
Packit Bot 5ef3dd
   version 2.1 of the License, or (at your option) any later version.
Packit Bot 5ef3dd
Packit Bot 5ef3dd
   The GNU C Library is distributed in the hope that it will be useful,
Packit Bot 5ef3dd
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Bot 5ef3dd
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Bot 5ef3dd
   Lesser General Public License for more details.
Packit Bot 5ef3dd
Packit Bot 5ef3dd
   You should have received a copy of the GNU Lesser General Public
Packit Bot 5ef3dd
   License along with the GNU C Library; if not, see
Packit Bot 5ef3dd
   <https://www.gnu.org/licenses/>.  */
Packit Bot 5ef3dd
Packit Bot 5ef3dd
#include <stdio.h>
Packit Bot 5ef3dd
#include <support/check.h>
Packit Bot 5ef3dd
#include <support/xdlfcn.h>
Packit Bot 5ef3dd
Packit Bot 5ef3dd
static int do_test (void)
Packit Bot 5ef3dd
{
Packit Bot 5ef3dd
  void *lib = xdlopen ("tst-filterobj-aux.so", RTLD_LAZY);
Packit Bot 5ef3dd
  char *(*fn)(void) = xdlsym (lib, "get_text");
Packit Bot 5ef3dd
  const char* text = fn ();
Packit Bot 5ef3dd
Packit Bot 5ef3dd
  printf ("%s\n", text);
Packit Bot 5ef3dd
Packit Bot 5ef3dd
  /* Verify the text matches what we expect from the filtee */
Packit Bot 5ef3dd
  TEST_COMPARE_STRING (text, "Hello from filtee (PASS)");
Packit Bot 5ef3dd
Packit Bot 5ef3dd
  fn = xdlsym (lib, "get_text2");
Packit Bot 5ef3dd
  text = fn ();
Packit Bot 5ef3dd
Packit Bot 5ef3dd
  printf ("%s\n", text);
Packit Bot 5ef3dd
Packit Bot 5ef3dd
  /* Verify the text matches what we expect from the auxiliary object */
Packit Bot 5ef3dd
  TEST_COMPARE_STRING (text, "Hello from auxiliary filter object (PASS)");
Packit Bot 5ef3dd
Packit Bot 5ef3dd
  return 0;
Packit Bot 5ef3dd
}
Packit Bot 5ef3dd
Packit Bot 5ef3dd
#include <support/test-driver.c>