Replace long int with __syscall_slong_t in sys/msg.h
[glibc.git] / elf / tst-auditmod5b.c
blob3a4221536c644a79d70fb79ef9e16838f19be2dd
1 /* Verify that changing xmm registers in audit library won't affect
2 function parameter passing/return. */
4 #include <dlfcn.h>
5 #include <stdint.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 #include <string.h>
9 #include <unistd.h>
10 #include <bits/wordsize.h>
11 #include <gnu/lib-names.h>
12 #include <emmintrin.h>
14 unsigned int
15 la_version (unsigned int v)
17 setlinebuf (stdout);
19 printf ("version: %u\n", v);
21 char buf[20];
22 sprintf (buf, "%u", v);
24 return v;
27 void
28 la_activity (uintptr_t *cookie, unsigned int flag)
30 if (flag == LA_ACT_CONSISTENT)
31 printf ("activity: consistent\n");
32 else if (flag == LA_ACT_ADD)
33 printf ("activity: add\n");
34 else if (flag == LA_ACT_DELETE)
35 printf ("activity: delete\n");
36 else
37 printf ("activity: unknown activity %u\n", flag);
40 char *
41 la_objsearch (const char *name, uintptr_t *cookie, unsigned int flag)
43 char buf[100];
44 const char *flagstr;
45 if (flag == LA_SER_ORIG)
46 flagstr = "LA_SET_ORIG";
47 else if (flag == LA_SER_LIBPATH)
48 flagstr = "LA_SER_LIBPATH";
49 else if (flag == LA_SER_RUNPATH)
50 flagstr = "LA_SER_RUNPATH";
51 else if (flag == LA_SER_CONFIG)
52 flagstr = "LA_SER_CONFIG";
53 else if (flag == LA_SER_DEFAULT)
54 flagstr = "LA_SER_DEFAULT";
55 else if (flag == LA_SER_SECURE)
56 flagstr = "LA_SER_SECURE";
57 else
59 sprintf (buf, "unknown flag %d", flag);
60 flagstr = buf;
62 printf ("objsearch: %s, %s\n", name, flagstr);
64 return (char *) name;
67 unsigned int
68 la_objopen (struct link_map *l, Lmid_t lmid, uintptr_t *cookie)
70 printf ("objopen: %ld, %s\n", lmid, l->l_name);
72 return 3;
75 void
76 la_preinit (uintptr_t *cookie)
78 printf ("preinit\n");
81 unsigned int
82 la_objclose (uintptr_t *cookie)
84 printf ("objclose\n");
85 return 0;
88 uintptr_t
89 la_symbind64 (Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
90 uintptr_t *defcook, unsigned int *flags, const char *symname)
92 printf ("symbind64: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
93 symname, (long int) sym->st_value, ndx, *flags);
95 return sym->st_value;
98 # ifndef __ILP32__
99 # define pltenter la_x86_64_gnu_pltenter
100 # define pltexit la_x86_64_gnu_pltexit
101 # define La_regs La_x86_64_regs
102 # define La_retval La_x86_64_retval
103 #else
104 # define pltenter la_x32_gnu_pltenter
105 # define pltexit la_x32_gnu_pltexit
106 # define La_regs La_x32_regs
107 # define La_retval La_x32_retval
108 #endif
109 #define int_retval lrv_rax
111 #include <tst-audit.h>
113 ElfW(Addr)
114 pltenter (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
115 uintptr_t *defcook, La_regs *regs, unsigned int *flags,
116 const char *symname, long int *framesizep)
118 printf ("pltenter: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
119 symname, (long int) sym->st_value, ndx, *flags);
121 __m128i minusone = _mm_set1_epi32 (-1);
123 if (strcmp (symname, "audit_test") == 0)
125 __m128i zero = _mm_setzero_si128 ();
126 if (memcmp (&regs->lr_xmm[0], &zero, sizeof (zero))
127 || memcmp (&regs->lr_xmm[1], &zero, sizeof (zero))
128 || memcmp (&regs->lr_xmm[2], &zero, sizeof (zero))
129 || memcmp (&regs->lr_xmm[3], &zero, sizeof (zero))
130 || memcmp (&regs->lr_xmm[4], &zero, sizeof (zero))
131 || memcmp (&regs->lr_xmm[5], &zero, sizeof (zero))
132 || memcmp (&regs->lr_xmm[6], &zero, sizeof (zero))
133 || memcmp (&regs->lr_xmm[7], &zero, sizeof (zero)))
134 abort ();
136 for (int i = 0; i < 8; i++)
137 regs->lr_xmm[i] = (La_x86_64_xmm) _mm_set1_epi32 (i + 1);
139 *framesizep = 1024;
142 asm volatile ("movdqa %0, %%xmm0" : : "x" (minusone) : "xmm0" );
143 asm volatile ("movdqa %0, %%xmm1" : : "x" (minusone) : "xmm1" );
144 asm volatile ("movdqa %0, %%xmm2" : : "x" (minusone) : "xmm2" );
145 asm volatile ("movdqa %0, %%xmm3" : : "x" (minusone) : "xmm3" );
146 asm volatile ("movdqa %0, %%xmm4" : : "x" (minusone) : "xmm4" );
147 asm volatile ("movdqa %0, %%xmm5" : : "x" (minusone) : "xmm5" );
148 asm volatile ("movdqa %0, %%xmm6" : : "x" (minusone) : "xmm6" );
149 asm volatile ("movdqa %0, %%xmm7" : : "x" (minusone) : "xmm7" );
151 return sym->st_value;
154 unsigned int
155 pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
156 uintptr_t *defcook, const La_regs *inregs, La_retval *outregs,
157 const char *symname)
159 printf ("pltexit: symname=%s, st_value=%#lx, ndx=%u, retval=%tu\n",
160 symname, (long int) sym->st_value, ndx,
161 (ptrdiff_t) outregs->int_retval);
163 __m128i xmm;
165 if (strcmp (symname, "audit_test") == 0)
167 __m128i zero = _mm_setzero_si128 ();
168 if (memcmp (&outregs->lrv_xmm0, &zero, sizeof (zero)))
169 abort ();
171 for (int i = 0; i < 8; i++)
173 xmm = _mm_set1_epi32 (i + 1);
174 if (memcmp (&inregs->lr_xmm[i], &xmm, sizeof (xmm)) != 0)
175 abort ();
178 outregs->lrv_xmm0 = (La_x86_64_xmm) _mm_set1_epi32 (0x12349876);
181 xmm = _mm_set1_epi32 (-1);
182 asm volatile ("movdqa %0, %%xmm0" : : "x" (xmm) : "xmm0" );
183 asm volatile ("movdqa %0, %%xmm1" : : "x" (xmm) : "xmm1" );
185 return 0;