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