Back to index

glibc  2.9
tst-auditmod1.c
Go to the documentation of this file.
00001 #include <dlfcn.h>
00002 #include <stdint.h>
00003 #include <stdio.h>
00004 #include <stdlib.h>
00005 #include <string.h>
00006 #include <unistd.h>
00007 #include <bits/wordsize.h>
00008 #include <gnu/lib-names.h>
00009 
00010 
00011 unsigned int
00012 la_version (unsigned int v)
00013 {
00014   setlinebuf (stdout);
00015 
00016   printf ("version: %u\n", v);
00017 
00018   char buf[20];
00019   sprintf (buf, "%u", v);
00020 
00021   return v;
00022 }
00023 
00024 void
00025 la_activity (uintptr_t *cookie, unsigned int flag)
00026 {
00027   if (flag == LA_ACT_CONSISTENT)
00028     printf ("activity: consistent\n");
00029   else if (flag == LA_ACT_ADD)
00030     printf ("activity: add\n");
00031   else if (flag == LA_ACT_DELETE)
00032     printf ("activity: delete\n");
00033   else
00034     printf ("activity: unknown activity %u\n", flag);
00035 }
00036 
00037 char *
00038 la_objsearch (const char *name, uintptr_t *cookie, unsigned int flag)
00039 {
00040   char buf[100];
00041   const char *flagstr;
00042   if (flag == LA_SER_ORIG)
00043     flagstr = "LA_SET_ORIG";
00044   else if (flag == LA_SER_LIBPATH)
00045     flagstr = "LA_SER_LIBPATH";
00046   else if (flag == LA_SER_RUNPATH)
00047     flagstr = "LA_SER_RUNPATH";
00048   else if (flag == LA_SER_CONFIG)
00049     flagstr = "LA_SER_CONFIG";
00050   else if (flag == LA_SER_DEFAULT)
00051     flagstr = "LA_SER_DEFAULT";
00052   else if (flag == LA_SER_SECURE)
00053     flagstr = "LA_SER_SECURE";
00054   else
00055     {
00056        sprintf (buf, "unknown flag %d", flag);
00057        flagstr = buf;
00058     }
00059   printf ("objsearch: %s, %s\n", name, flagstr);
00060 
00061   return (char *) name;
00062 }
00063 
00064 unsigned int
00065 la_objopen (struct link_map *l, Lmid_t lmid, uintptr_t *cookie)
00066 {
00067   printf ("objopen: %ld, %s\n", lmid, l->l_name);
00068 
00069   return 3;
00070 }
00071 
00072 void
00073 la_preinit (uintptr_t *cookie)
00074 {
00075   printf ("preinit\n");
00076 }
00077 
00078 unsigned int
00079 la_objclose  (uintptr_t *cookie)
00080 {
00081   printf ("objclose\n");
00082   return 0;
00083 }
00084 
00085 uintptr_t
00086 la_symbind32 (Elf32_Sym *sym, unsigned int ndx, uintptr_t *refcook,
00087              uintptr_t *defcook, unsigned int *flags, const char *symname)
00088 {
00089   printf ("symbind32: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
00090          symname, (long int) sym->st_value, ndx, *flags);
00091 
00092   return sym->st_value;
00093 }
00094 
00095 uintptr_t
00096 la_symbind64 (Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
00097              uintptr_t *defcook, unsigned int *flags, const char *symname)
00098 {
00099   printf ("symbind64: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
00100          symname, (long int) sym->st_value, ndx, *flags);
00101 
00102   return sym->st_value;
00103 }
00104 
00105 #ifdef __i386__
00106 # define pltenter la_i86_gnu_pltenter
00107 # define pltexit la_i86_gnu_pltexit
00108 # define La_regs La_i86_regs
00109 # define La_retval La_i86_retval
00110 # define int_retval lrv_eax
00111 #elif defined __x86_64__
00112 # define pltenter la_x86_64_gnu_pltenter
00113 # define pltexit la_x86_64_gnu_pltexit
00114 # define La_regs La_x86_64_regs
00115 # define La_retval La_x86_64_retval
00116 # define int_retval lrv_rax
00117 #elif defined __powerpc__ && __WORDSIZE == 32
00118 # define pltenter la_ppc32_gnu_pltenter
00119 # define pltexit la_ppc32_gnu_pltexit
00120 # define La_regs La_ppc32_regs
00121 # define La_retval La_ppc32_retval
00122 # define int_retval lrv_r3
00123 #elif defined __powerpc__ && __WORDSIZE == 64
00124 # define pltenter la_ppc64_gnu_pltenter
00125 # define pltexit la_ppc64_gnu_pltexit
00126 # define La_regs La_ppc64_regs
00127 # define La_retval La_ppc64_retval
00128 # define int_retval lrv_r3
00129 #elif defined __sh__
00130 # define pltenter la_sh_gnu_pltenter
00131 # define pltexit la_sh_gnu_pltexit
00132 # define La_regs La_sh_regs
00133 # define La_retval La_sh_retval
00134 # define int_retval lrv_r0
00135 #elif defined __alpha__
00136 # define pltenter la_alpha_gnu_pltenter
00137 # define pltexit la_alpha_gnu_pltexit
00138 # define La_regs La_alpha_regs
00139 # define La_retval La_alpha_retval
00140 # define int_retval lrv_r0
00141 #elif defined __s390__ && __WORDSIZE == 32
00142 # define pltenter la_s390_32_gnu_pltenter
00143 # define pltexit la_s390_32_gnu_pltexit
00144 # define La_regs La_s390_32_regs
00145 # define La_retval La_s390_32_retval
00146 # define int_retval lrv_r2
00147 #elif defined __s390__ && __WORDSIZE == 64
00148 # define pltenter la_s390_64_gnu_pltenter
00149 # define pltexit la_s390_64_gnu_pltexit
00150 # define La_regs La_s390_64_regs
00151 # define La_retval La_s390_64_retval
00152 # define int_retval lrv_r2
00153 #elif defined __ia64__
00154 # define pltenter la_ia64_gnu_pltenter
00155 # define pltexit la_ia64_gnu_pltexit
00156 # define La_regs La_ia64_regs
00157 # define La_retval La_ia64_retval
00158 # define int_retval lrv_r8
00159 #elif defined __sparc__ && __WORDSIZE == 32
00160 # define pltenter la_sparc32_gnu_pltenter
00161 # define pltexit la_sparc32_gnu_pltexit
00162 # define La_regs La_sparc32_regs
00163 # define La_retval La_sparc32_retval
00164 # define int_retval lrv_reg[0]
00165 #elif defined __sparc__ && __WORDSIZE == 64
00166 # define pltenter la_sparc64_gnu_pltenter
00167 # define pltexit la_sparc64_gnu_pltexit
00168 # define La_regs La_sparc64_regs
00169 # define La_retval La_sparc64_retval
00170 # define int_retval lrv_reg[0]
00171 #endif
00172 
00173 #include <tst-audit.h>
00174 #if (!defined (pltenter) || !defined (pltexit) || !defined (La_regs) \
00175      || !defined (La_retval) || !defined (int_retval))
00176 # error "architecture specific code needed in sysdeps/CPU/tst-audit.h or here"
00177 #endif
00178 
00179 
00180 ElfW(Addr)
00181 pltenter (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
00182          uintptr_t *defcook, La_regs *regs, unsigned int *flags,
00183          const char *symname, long int *framesizep)
00184 {
00185   printf ("pltenter: symname=%s, st_value=%#lx, ndx=%u, flags=%u\n",
00186          symname, (long int) sym->st_value, ndx, *flags);
00187 
00188   return sym->st_value;
00189 }
00190 
00191 unsigned int
00192 pltexit (ElfW(Sym) *sym, unsigned int ndx, uintptr_t *refcook,
00193         uintptr_t *defcook, const La_regs *inregs, La_retval *outregs,
00194         const char *symname)
00195 {
00196   printf ("pltexit: symname=%s, st_value=%#lx, ndx=%u, retval=%tu\n",
00197          symname, (long int) sym->st_value, ndx, outregs->int_retval);
00198 
00199   return 0;
00200 }