Blame nptl/tst-audit-threads-mod1.c

Packit Service f2f644
/* Dummy audit library for test-audit-threads.
Packit Service f2f644
Packit Service f2f644
   Copyright (C) 2018 Free Software Foundation, Inc.
Packit Service f2f644
   This file is part of the GNU C Library.
Packit Service f2f644
Packit Service f2f644
   The GNU C Library is free software; you can redistribute it and/or
Packit Service f2f644
   modify it under the terms of the GNU Lesser General Public
Packit Service f2f644
   License as published by the Free Software Foundation; either
Packit Service f2f644
   version 2.1 of the License, or (at your option) any later version.
Packit Service f2f644
Packit Service f2f644
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service f2f644
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service f2f644
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service f2f644
   Lesser General Public License for more details.
Packit Service f2f644
Packit Service f2f644
   You should have received a copy of the GNU Lesser General Public
Packit Service f2f644
   License along with the GNU C Library; if not, see
Packit Service f2f644
   <http://www.gnu.org/licenses/>.  */
Packit Service f2f644
Packit Service f2f644
#include <elf.h>
Packit Service f2f644
#include <link.h>
Packit Service f2f644
#include <stdio.h>
Packit Service f2f644
#include <assert.h>
Packit Service f2f644
#include <string.h>
Packit Service f2f644
Packit Service f2f644
/* We must use a dummy LD_AUDIT module to force the dynamic loader to
Packit Service f2f644
   *not* update the real PLT, and instead use a cached value for the
Packit Service f2f644
   lazy resolution result.  It is the update of that cached value that
Packit Service f2f644
   we are testing for correctness by doing this.  */
Packit Service f2f644
Packit Service f2f644
/* Library to be audited.  */
Packit Service f2f644
#define LIB "tst-audit-threads-mod2.so"
Packit Service f2f644
/* CALLNUM is the number of retNum functions.  */
Packit Service f2f644
#define CALLNUM 7999
Packit Service f2f644
Packit Service f2f644
#define CONCATX(a, b) __CONCAT (a, b)
Packit Service f2f644
Packit Service f2f644
static int previous = 0;
Packit Service f2f644
Packit Service f2f644
unsigned int
Packit Service f2f644
la_version (unsigned int ver)
Packit Service f2f644
{
Packit Service f2f644
  return 1;
Packit Service f2f644
}
Packit Service f2f644
Packit Service f2f644
unsigned int
Packit Service f2f644
la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
Packit Service f2f644
{
Packit Service f2f644
  return LA_FLG_BINDTO | LA_FLG_BINDFROM;
Packit Service f2f644
}
Packit Service f2f644
Packit Service f2f644
uintptr_t
Packit Service f2f644
CONCATX(la_symbind, __ELF_NATIVE_CLASS) (ElfW(Sym) *sym,
Packit Service f2f644
					unsigned int ndx,
Packit Service f2f644
					uintptr_t *refcook,
Packit Service f2f644
					uintptr_t *defcook,
Packit Service f2f644
					unsigned int *flags,
Packit Service f2f644
					const char *symname)
Packit Service f2f644
{
Packit Service f2f644
  const char * retnum = "retNum";
Packit Service f2f644
  char * num = strstr (symname, retnum);
Packit Service f2f644
  int n;
Packit Service f2f644
  /* Validate if the symbols are getting called in the correct order.
Packit Service f2f644
     This code is here to verify binutils does not optimize out the PLT
Packit Service f2f644
     entries that require the symbol binding.  */
Packit Service f2f644
  if (num != NULL)
Packit Service f2f644
    {
Packit Service f2f644
      n = atoi (num);
Packit Service f2f644
      assert (n >= previous);
Packit Service f2f644
      assert (n <= CALLNUM);
Packit Service f2f644
      previous = n;
Packit Service f2f644
    }
Packit Service f2f644
  return sym->st_value;
Packit Service f2f644
}