I'm wanting to write a replacement C function for a few different
glibc calls for debugging purposes, and other uses as well.

The functions in mind are small, including straight kernel
syscalls, etc..

I'm looking at the glibc source and it goes way over my
head.  Some of the functions appear to contain no code
whatsoever, and are marked up with odd stuff I've never seen
before, particularly in the sysdeps/generic/ directory, but in
others as well...

When you call a given glibc function, in particular one that maps
direct to a syscall, how do you intercept it via ldpreload, and
how do you build the .so file properly without trashing
something?

If someone could give me an example of overriding the built in
getpid() call for example to do what it does, but to also open a
file "/tmp/getpid-test" and write out the date and time stamp, as
well as the executable program's full path that called getpid(),
it would give me something to go on...

Preferably I'd like examples, either direct, or pointers to some
downloadable easy to understand code that shows interception of a
general C library call, how to replace it, or chain to/through
it, as well as interception of a kernel system call through the C
library and how to replace it or chain to/through it.

Any help would be greatly appreciated.

Thanks,
TTYL



--
Mike A. Harris                                     Linux advocate     
Computer Consultant                                  GNU advocate  
Capslock Consulting                          Open Source advocate

Be up to date on nerd news and stuff that matters:  http://slashdot.org



_______________________________________________
Redhat-devel-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-devel-list

Reply via email to