[PATCH 3/6] Split sparc out of main Linux kernel-features.h.
[glibc.git] / elf / tst-auditmod1.c
blob227a3b623a118958a6ac0c756a7e382af7dbfd18
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 #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
112 ElfW(Addr)
113 pltenter (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)
117 printf ("pltenter: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
118 symname, (long int) sym->st_value, ndx, *flags);
120 return sym->st_value;
123 unsigned int
124 pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
125 uintptr_t *defcook, const La_regs *inregs, La_retval *outregs,
126 const char *symname)
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);
132 return 0;