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

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