Blame elf/tst-auxobj-dlopen.c

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