x86-64: Remove redundant strcspn-generic/strpbrk-generic/strspn-generic
[glibc.git] / nptl / tst-audit-threads-mod1.c
blob679b02a10b54a72ac61ae200e71d572a41fc31b8
1 /* Dummy audit library for test-audit-threads.
3 Copyright (C) 2018-2022 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
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.
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.
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 <https://www.gnu.org/licenses/>. */
20 #include <elf.h>
21 #include <link.h>
22 #include <stdio.h>
23 #include <assert.h>
24 #include <string.h>
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. */
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
36 #define CONCATX(a, b) __CONCAT (a, b)
38 static int previous = 0;
40 unsigned int
41 la_version (unsigned int ver)
43 return 1;
46 unsigned int
47 la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
49 return LA_FLG_BINDTO | LA_FLG_BINDFROM;
52 uintptr_t
53 CONCATX(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)
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)
68 n = atoi (num);
69 assert (n >= previous);
70 assert (n <= CALLNUM);
71 previous = n;
73 return sym->st_value;