Blame elf/tst-preload-pthread-libc.c

Packit Service 1bb9a8
/* Test relocation ordering if the main executable is libc.so.6 (bug 20972).
Packit Service 1bb9a8
   Copyright (C) 2020 Free Software Foundation, Inc.
Packit Service 1bb9a8
   This file is part of the GNU C Library.
Packit Service 1bb9a8
Packit Service 1bb9a8
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 1bb9a8
   modify it under the terms of the GNU Lesser General Public
Packit Service 1bb9a8
   License as published by the Free Software Foundation; either
Packit Service 1bb9a8
   version 2.1 of the License, or (at your option) any later version.
Packit Service 1bb9a8
Packit Service 1bb9a8
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 1bb9a8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 1bb9a8
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 1bb9a8
   Lesser General Public License for more details.
Packit Service 1bb9a8
Packit Service 1bb9a8
   You should have received a copy of the GNU Lesser General Public
Packit Service 1bb9a8
   License along with the GNU C Library; if not, see
Packit Service 1bb9a8
   <https://www.gnu.org/licenses/>.  */
Packit Service 1bb9a8
Packit Service 1bb9a8
#include <gnu/lib-names.h>
Packit Service 1bb9a8
#include <stdio.h>
Packit Service 1bb9a8
#include <support/support.h>
Packit Service 1bb9a8
#include <unistd.h>
Packit Service 1bb9a8
Packit Service 1bb9a8
int
Packit Service 1bb9a8
main (void)
Packit Service 1bb9a8
{
Packit Service 1bb9a8
  char *libc = xasprintf ("%s/%s", support_slibdir_prefix, LIBC_SO);
Packit Service 1bb9a8
  char *argv[] = { libc, NULL };
Packit Service 1bb9a8
  char *envp[] = { (char *) "LD_PRELOAD=" LIBPTHREAD_SO,
Packit Service 1bb9a8
    /* Relocation ordering matters most without lazy binding.  */
Packit Service 1bb9a8
    (char *) "LD_BIND_NOW=1",
Packit Service 1bb9a8
    NULL };
Packit Service 1bb9a8
  execve (libc, argv, envp);
Packit Service 1bb9a8
  printf ("execve of %s failed: %m\n", libc);
Packit Service 1bb9a8
  return 1;
Packit Service 1bb9a8
}