blob: 227a3b623a118958a6ac0c756a7e382af7dbfd18 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001#include <dlfcn.h>
2#include <stdint.h>
3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h>
6#include <unistd.h>
7#include <bits/wordsize.h>
8#include <gnu/lib-names.h>
9
10
11unsigned int
12la_version (unsigned int v)
13{
14 setlinebuf (stdout);
15
16 printf ("version: %u\n", v);
17
18 char buf[20];
19 sprintf (buf, "%u", v);
20
21 return v;
22}
23
24void
25la_activity (uintptr_t *cookie, unsigned int flag)
26{
27 if (flag == LA_ACT_CONSISTENT)
28 printf ("activity: consistent\n");
29 else if (flag == LA_ACT_ADD)
30 printf ("activity: add\n");
31 else if (flag == LA_ACT_DELETE)
32 printf ("activity: delete\n");
33 else
34 printf ("activity: unknown activity %u\n", flag);
35}
36
37char *
38la_objsearch (const char *name, uintptr_t *cookie, unsigned int flag)
39{
40 char buf[100];
41 const char *flagstr;
42 if (flag == LA_SER_ORIG)
43 flagstr = "LA_SET_ORIG";
44 else if (flag == LA_SER_LIBPATH)
45 flagstr = "LA_SER_LIBPATH";
46 else if (flag == LA_SER_RUNPATH)
47 flagstr = "LA_SER_RUNPATH";
48 else if (flag == LA_SER_CONFIG)
49 flagstr = "LA_SER_CONFIG";
50 else if (flag == LA_SER_DEFAULT)
51 flagstr = "LA_SER_DEFAULT";
52 else if (flag == LA_SER_SECURE)
53 flagstr = "LA_SER_SECURE";
54 else
55 {
56 sprintf (buf, "unknown flag %d", flag);
57 flagstr = buf;
58 }
59 printf ("objsearch: %s, %s\n", name, flagstr);
60
61 return (char *) name;
62}
63
64unsigned int
65la_objopen (struct link_map *l, Lmid_t lmid, uintptr_t *cookie)
66{
67 printf ("objopen: %ld, %s\n", lmid, l->l_name);
68
69 return 3;
70}
71
72void
73la_preinit (uintptr_t *cookie)
74{
75 printf ("preinit\n");
76}
77
78unsigned int
79la_objclose (uintptr_t *cookie)
80{
81 printf ("objclose\n");
82 return 0;
83}
84
85uintptr_t
86la_symbind32 (Elf32_Sym *sym, unsigned int ndx, uintptr_t *refcook,
87 uintptr_t *defcook, unsigned int *flags, const char *symname)
88{
89 printf ("symbind32: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
90 symname, (long int) sym->st_value, ndx, *flags);
91
92 return sym->st_value;
93}
94
95uintptr_t
96la_symbind64 (Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
97 uintptr_t *defcook, unsigned int *flags, const char *symname)
98{
99 printf ("symbind64: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
100 symname, (long int) sym->st_value, ndx, *flags);
101
102 return sym->st_value;
103}
104
105#include <tst-audit.h>
106#if (!defined (pltenter) || !defined (pltexit) || !defined (La_regs) \
107 || !defined (La_retval) || !defined (int_retval))
108# error "architecture specific code needed in sysdeps/CPU/tst-audit.h"
109#endif
110
111
112ElfW(Addr)
113pltenter (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
114 uintptr_t *defcook, La_regs *regs, unsigned int *flags,
115 const char *symname, long int *framesizep)
116{
117 printf ("pltenter: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
118 symname, (long int) sym->st_value, ndx, *flags);
119
120 return sym->st_value;
121}
122
123unsigned int
124pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
125 uintptr_t *defcook, const La_regs *inregs, La_retval *outregs,
126 const char *symname)
127{
128 printf ("pltexit: symname=%s, st_value=%#lx, ndx=%u, retval=%tu\n",
129 symname, (long int) sym->st_value, ndx,
130 (ptrdiff_t) outregs->int_retval);
131
132 return 0;
133}