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

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