rtld-audit.7: Use correct printf() specifier for pointer types

In the example code you used %x rather than %p in the example
code for an audit library. The problem is that it truncates the
pointers on 64b platforms. So you get something like:

la_symbind64(): symname = strrchr sym->st_value = 0x7f4b8a3f8960
ndx = 222 flags = 0x0 refcook = 8b53e5c8 defcook = 8b537e30

rather than:

la_symbind64(): symname = fclose sym->st_value = 0x7fa452dd49b0
ndx = 1135 flags = 0x0 refcook = 0x7fa453f395c8 defcook = 0x7fa453f32e30

This has bitten me a handful of times when playing around with
audit test libraries to investigate its behavior.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Ben Woodard 2015-05-19 08:48:08 +02:00 committed by Michael Kerrisk
parent d850c7e08f
commit 8e83cef60d
1 changed files with 7 additions and 7 deletions

View File

@ -515,7 +515,7 @@ la_version(unsigned int version)
char *
la_objsearch(const char *name, uintptr_t *cookie, unsigned int flag)
{
printf("la_objsearch(): name = %s; cookie = %x", name, cookie);
printf("la_objsearch(): name = %s; cookie = %p", name, cookie);
printf("; flag = %s\\n",
(flag == LA_SER_ORIG) ? "LA_SER_ORIG" :
(flag == LA_SER_LIBPATH) ? "LA_SER_LIBPATH" :
@ -531,7 +531,7 @@ la_objsearch(const char *name, uintptr_t *cookie, unsigned int flag)
void
la_activity (uintptr_t *cookie, unsigned int flag)
{
printf("la_activity(): cookie = %x; flag = %s\\n", cookie,
printf("la_activity(): cookie = %p; flag = %s\\n", cookie,
(flag == LA_ACT_CONSISTENT) ? "LA_ACT_CONSISTENT" :
(flag == LA_ACT_ADD) ? "LA_ACT_ADD" :
(flag == LA_ACT_DELETE) ? "LA_ACT_DELETE" :
@ -541,7 +541,7 @@ la_activity (uintptr_t *cookie, unsigned int flag)
unsigned int
la_objopen(struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
{
printf("la_objopen(): loading \\"%s\\"; lmid = %s; cookie=%x\\n",
printf("la_objopen(): loading \\"%s\\"; lmid = %s; cookie=%p\\n",
map\->l_name,
(lmid == LM_ID_BASE) ? "LM_ID_BASE" :
(lmid == LM_ID_NEWLM) ? "LM_ID_NEWLM" :
@ -554,7 +554,7 @@ la_objopen(struct link_map *map, Lmid_t lmid, uintptr_t *cookie)
unsigned int
la_objclose (uintptr_t *cookie)
{
printf("la_objclose(): %x\\n", cookie);
printf("la_objclose(): %p\\n", cookie);
return 0;
}
@ -562,7 +562,7 @@ la_objclose (uintptr_t *cookie)
void
la_preinit(uintptr_t *cookie)
{
printf("la_preinit(): %x\\n", cookie);
printf("la_preinit(): %p\\n", cookie);
}
uintptr_t
@ -572,7 +572,7 @@ la_symbind32(Elf32_Sym *sym, unsigned int ndx, uintptr_t *refcook,
printf("la_symbind32(): symname = %s; sym\->st_value = %p\\n",
symname, sym\->st_value);
printf(" ndx = %d; flags = 0x%x", ndx, *flags);
printf("; refcook = %x; defcook = %x\\n", refcook, defcook);
printf("; refcook = %p; defcook = %p\\n", refcook, defcook);
return sym\->st_value;
}
@ -584,7 +584,7 @@ la_symbind64(Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
printf("la_symbind64(): symname = %s; sym\->st_value = %p\\n",
symname, sym\->st_value);
printf(" ndx = %d; flags = 0x%x", ndx, *flags);
printf("; refcook = %x; defcook = %x\\n", refcook, defcook);
printf("; refcook = %p; defcook = %p\\n", refcook, defcook);
return sym\->st_value;
}