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