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

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