1/* Audit module loaded by tst-audit23.
2 Copyright (C) 2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#include <link.h>
20#include <inttypes.h>
21#include <stdlib.h>
22#include <stdio.h>
23#include <string.h>
24#include <sys/auxv.h>
25
26unsigned int
27la_version (unsigned int version)
28{
29 return LAV_CURRENT;
30}
31
32struct map_desc_t
33{
34 char *lname;
35 uintptr_t laddr;
36 Lmid_t lmid;
37};
38
39void
40la_activity (uintptr_t *cookie, unsigned int flag)
41{
42 fprintf (stderr, format: "%s: %d %"PRIxPTR"\n", __func__, flag, (uintptr_t) cookie);
43}
44
45unsigned int
46la_objopen (struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
47{
48 const char *l_name = map->l_name[0] == '\0' ? "mainapp" : map->l_name;
49 fprintf (stderr, format: "%s: %"PRIxPTR" %s %"PRIxPTR" %ld\n", __func__,
50 (uintptr_t) cookie, l_name, map->l_addr, lmid);
51
52 struct map_desc_t *map_desc = malloc (size: sizeof (struct map_desc_t));
53 if (map_desc == NULL)
54 abort ();
55
56 map_desc->lname = strdup (s: l_name);
57 map_desc->laddr = map->l_addr;
58 map_desc->lmid = lmid;
59
60 *cookie = (uintptr_t) map_desc;
61
62 return 0;
63}
64
65unsigned int
66la_objclose (uintptr_t *cookie)
67{
68 struct map_desc_t *map_desc = (struct map_desc_t *) *cookie;
69 fprintf (stderr, format: "%s: %"PRIxPTR" %s %"PRIxPTR" %ld\n", __func__,
70 (uintptr_t) cookie, map_desc->lname, map_desc->laddr,
71 map_desc->lmid);
72
73 return 0;
74}
75

source code of glibc/elf/tst-auditmod23.c