(WINT_MAX): Define as 2147483647 since this is the maximum UCS4 value.
[glibc/history.git] / elf / tst-auditmod1.c
blob2d39df21e801f7e6b93609ba4c2390d7411a2d6a
1 #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>
11 unsigned int
12 la_version (unsigned int v)
14 setlinebuf (stdout);
16 printf ("version: %u\n", v);
18 char buf[20];
19 sprintf (buf, "%u", v);
21 return v;
24 void
25 la_activity (uintptr_t *cookie, unsigned int flag)
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);
37 char *
38 la_objsearch (const char *name, uintptr_t *cookie, unsigned int flag)
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
56 sprintf (buf, "unknown flag %d", flag);
57 flagstr = buf;
59 printf ("objsearch: %s, %s\n", name, flagstr);
61 return (char *) name;
64 unsigned int
65 la_objopen (struct link_map *l, Lmid_t lmid, uintptr_t *cookie)
67 printf ("objopen: %ld, %s\n", lmid, l->l_name);
69 return 3;
72 void
73 la_preinit (uintptr_t *cookie)
75 printf ("preinit\n");
78 unsigned int
79 la_objclose (uintptr_t *cookie)
81 printf ("objclose\n");
82 return 0;
85 uintptr_t
86 la_symbind32 (Elf32_Sym *sym, unsigned int ndx, uintptr_t *refcook,
87 uintptr_t *defcook, unsigned int *flags, const char *symname)
89 printf ("symbind32: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
90 symname, (long int) sym->st_value, ndx, *flags);
92 return sym->st_value;
95 uintptr_t
96 la_symbind64 (Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
97 uintptr_t *defcook, unsigned int *flags, const char *symname)
99 printf ("symbind64: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
100 symname, (long int) sym->st_value, ndx, *flags);
102 return sym->st_value;
105 #ifdef __i386__
106 # define pltenter la_i86_gnu_pltenter
107 # define pltexit la_i86_gnu_pltexit
108 # define La_regs La_i86_regs
109 # define La_retval La_i86_retval
110 # define int_retval lrv_eax
111 #elif defined __x86_64__
112 # define pltenter la_x86_64_gnu_pltenter
113 # define pltexit la_x86_64_gnu_pltexit
114 # define La_regs La_x86_64_regs
115 # define La_retval La_x86_64_retval
116 # define int_retval lrv_rax
117 #elif defined __powerpc__ && __WORDSIZE == 32
118 # define pltenter la_ppc32_gnu_pltenter
119 # define pltexit la_ppc32_gnu_pltexit
120 # define La_regs La_ppc32_regs
121 # define La_retval La_ppc32_retval
122 # define int_retval lrv_r3
123 #elif defined __powerpc__ && __WORDSIZE == 64
124 # define pltenter la_ppc64_gnu_pltenter
125 # define pltexit la_ppc64_gnu_pltexit
126 # define La_regs La_ppc64_regs
127 # define La_retval La_ppc64_retval
128 # define int_retval lrv_r3
129 #elif defined __sh__
130 # define pltenter la_sh_gnu_pltenter
131 # define pltexit la_sh_gnu_pltexit
132 # define La_regs La_sh_regs
133 # define La_retval La_sh_retval
134 # define int_retval lrv_r0
135 #elif defined __alpha__
136 # define pltenter la_alpha_gnu_pltenter
137 # define pltexit la_alpha_gnu_pltexit
138 # define La_regs La_alpha_regs
139 # define La_retval La_alpha_retval
140 # define int_retval lrv_r0
141 #elif defined __s390__ && __WORDSIZE == 32
142 # define pltenter la_s390_32_gnu_pltenter
143 # define pltexit la_s390_32_gnu_pltexit
144 # define La_regs La_s390_32_regs
145 # define La_retval La_s390_32_retval
146 # define int_retval lrv_r2
147 #elif defined __s390__ && __WORDSIZE == 64
148 # define pltenter la_s390_64_gnu_pltenter
149 # define pltexit la_s390_64_gnu_pltexit
150 # define La_regs La_s390_64_regs
151 # define La_retval La_s390_64_retval
152 # define int_retval lrv_r2
153 #elif defined __ia64__
154 # define pltenter la_ia64_gnu_pltenter
155 # define pltexit la_ia64_gnu_pltexit
156 # define La_regs La_ia64_regs
157 # define La_retval La_ia64_retval
158 # define int_retval lrv_r8
159 #elif defined __sparc__ && __WORDSIZE == 32
160 # define pltenter la_sparc32_gnu_pltenter
161 # define pltexit la_sparc32_gnu_pltexit
162 # define La_regs La_sparc32_regs
163 # define La_retval La_sparc32_retval
164 # define int_retval lrv_reg[0]
165 #elif defined __sparc__ && __WORDSIZE == 64
166 # define pltenter la_sparc64_gnu_pltenter
167 # define pltexit la_sparc64_gnu_pltexit
168 # define La_regs La_sparc64_regs
169 # define La_retval La_sparc64_retval
170 # define int_retval lrv_reg[0]
171 #endif
173 #include <tst-audit.h>
174 #if (!defined (pltenter) || !defined (pltexit) || !defined (La_regs) \
175 || !defined (La_retval) || !defined (int_retval))
176 # error "architecture specific code needed in sysdeps/CPU/tst-audit.h or here"
177 #endif
180 ElfW(Addr)
181 pltenter (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
182 uintptr_t *defcook, La_regs *regs, unsigned int *flags,
183 const char *symname, long int *framesizep)
185 printf ("pltenter: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
186 symname, (long int) sym->st_value, ndx, *flags);
188 return sym->st_value;
191 unsigned int
192 pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
193 uintptr_t *defcook, const La_regs *inregs, La_retval *outregs,
194 const char *symname)
196 printf ("pltexit: symname=%s, st_value=%#lx, ndx=%u, retval=%tu\n",
197 symname, (long int) sym->st_value, ndx, outregs->int_retval);
199 return 0;