This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] audit: put the correct st_value in pltexit callback


On Fri, Jan 21, 2011 at 12:52:52PM -0500, Ulrich Drepper wrote:
> On Fri, Jan 21, 2011 at 11:21, Jiri Olsa <jolsa@redhat.com> wrote:
> > the ElfW(Sym) param in the PLT entry callback gives
> > different st_value than the same symbol in adjacent
> > PLT exit callback.
> 
> Where is the test case showing that there is a problem in the first place?

sure.. running following program

---
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
        printf("krava\n");
        malloc(100);
        return 0;
}
---

with attached library (used via LD_AUDIT env),
I got following:

[jolsa@jolsa pex]$ sudo ./pex/runner
/home/jolsa/projects/latrace/pex/root /ex
ROOT '/home/jolsa/projects/latrace/pex/root' app '/ex'
entry __libc_start_main 0x7f1be788fd80
entry puts 0x7f1be78d6700
krava
exit  puts 0x65700
entry malloc 0x7f1be78e7c90
exit  malloc 0x76c90


with the fix applied I got:

[jolsa@jolsa pex]$ sudo ./pex/runner
/home/jolsa/projects/latrace/pex/root /ex
ROOT '/home/jolsa/projects/latrace/pex/root' app '/ex'
entry __libc_start_main 0x7f6197ca6d80
entry puts 0x7f6197ced700
krava1
exit  puts 0x7f6197ced700
entry malloc 0x7f6197cfec90
exit  malloc 0x7f6197cfec90


please let me know if you need more info

hope this helps,
jirka


---
#include <link.h>
#include <dlfcn.h>
#include <stdio.h>
#include <sys/time.h>


unsigned int la_version (unsigned int v)
{
	return v;
}

unsigned int la_objopen(struct link_map *l, Lmid_t a, uintptr_t *cookie)
{
	return 3;
}

uintptr_t la_symbind32(Elf32_Sym *sym, unsigned int ndx, uintptr_t *refcook,
          uintptr_t *defcook, unsigned int *flags, const char *symname)
{
	return sym->st_value;
}

uintptr_t la_symbind64(Elf64_Sym *sym, unsigned int ndx, uintptr_t *refcook,
                uintptr_t *defcook, unsigned int *flags, const char *symname)
{
	return sym->st_value;
}

static int depth_current = 0;
static int depth_vfork   = -1;
Elf64_Addr la_x86_64_gnu_pltenter (Elf64_Sym *__sym,
                                          unsigned int __ndx,
                                          uintptr_t *__refcook,
                                          uintptr_t *__defcook,
                                          La_x86_64_regs *__regs,
                                          unsigned int *__flags,
                                          const char *__symname,
                                          long int *__framesizep)
{
	printf("entry %s %p\n", __symname, __sym->st_value);
	fflush(NULL);
	*__framesizep = 100;
	return __sym->st_value;
}

unsigned int la_x86_64_gnu_pltexit (Elf64_Sym *__sym,
                                           unsigned int __ndx,
                                           uintptr_t *__refcook,
                                           uintptr_t *__defcook,
                                           const La_x86_64_regs *__inregs,
                                           La_x86_64_retval *__outregs,
                                           const char *__symname)
{
	printf("exit  %s %p\n", __symname, __sym->st_value);
	fflush(NULL);
	return 0;
}

void la_activity(uintptr_t *cookie, unsigned int act)
{
}

char* la_objsearch(const char *name, uintptr_t *cookie, unsigned int flag)
{
	return (char*) name;
}

void la_preinit(uintptr_t *__cookie)
{
}

unsigned int la_objclose(uintptr_t *__cookie)
{
	return 0;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]