Warning: That file was not part of the compilation database. It may have many parsing errors.

1/* Dummy audit library for test-audit-threads.
2
3 Copyright (C) 2018-2019 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
19
20#include <elf.h>
21#include <link.h>
22#include <stdio.h>
23#include <assert.h>
24#include <string.h>
25
26/* We must use a dummy LD_AUDIT module to force the dynamic loader to
27 *not* update the real PLT, and instead use a cached value for the
28 lazy resolution result. It is the update of that cached value that
29 we are testing for correctness by doing this. */
30
31/* Library to be audited. */
32#define LIB "tst-audit-threads-mod2.so"
33/* CALLNUM is the number of retNum functions. */
34#define CALLNUM 7999
35
36#define CONCATX(a, b) __CONCAT (a, b)
37
38static int previous = 0;
39
40unsigned int
41la_version (unsigned int ver)
42{
43 return 1;
44}
45
46unsigned int
47la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
48{
49 return LA_FLG_BINDTO | LA_FLG_BINDFROM;
50}
51
52uintptr_t
53CONCATX(la_symbind, __ELF_NATIVE_CLASS) (ElfW(Sym) *sym,
54 unsigned int ndx,
55 uintptr_t *refcook,
56 uintptr_t *defcook,
57 unsigned int *flags,
58 const char *symname)
59{
60 const char * retnum = "retNum";
61 char * num = strstr (symname, retnum);
62 int n;
63 /* Validate if the symbols are getting called in the correct order.
64 This code is here to verify binutils does not optimize out the PLT
65 entries that require the symbol binding. */
66 if (num != NULL)
67 {
68 n = atoi (num);
69 assert (n >= previous);
70 assert (n <= CALLNUM);
71 previous = n;
72 }
73 return sym->st_value;
74}
75

Warning: That file was not part of the compilation database. It may have many parsing errors.