Re: intercepting system calls works on tiger(10.4.5) but not on panther(10.3.9)
Re: intercepting system calls works on tiger(10.4.5) but not on panther(10.3.9)
- Subject: Re: intercepting system calls works on tiger(10.4.5) but not on panther(10.3.9)
- From: "Puthali H.B" <email@hidden>
- Date: Wed, 17 May 2006 23:19:49 -0600
ok, i'm not very much clear on this, so please pardon, if its very
obvious.
Actually I don't use RTLD_NEXT, but rather get a handle for
libSystem.dylib using dlopen and use that handle in dlsym. And if I use
the resulting function handle from dlsym, shouldn't it call the function
from libSystem, rather than my own? as it does in tiger?
and will try again with syscall, hopefully it will work.
>>> Peter O'Gorman <email@hidden> 5/18/2006 10:38:38 am >>>
On Wed, 2006-05-17 at 22:50 -0600, Puthali H.B wrote:
>
> But on panther, I face two kinds of problems, depending on whether I
> use dlopen or syscall to call the underlying system connect.
>
> If I use dlopen, followed by dlsym, then it loops in the over-ridden
> connect, which is very weird.
Not really, on panther dlsym(RTLD_NEXT,"connect") is always going to
give you the first connect function it finds when force flat namespace
is in effect. So you get into an infinite loop, exhaust stack and
crash.
This is fixed in tiger.
>
> where as, if I use syscall, then it throws up the following-
Again, works for me:
peter$ cat connect.c
#include <stdio.h>
#include <sys/syscall.h>
int
connect(int s, const struct sockaddr *name, int namelen)
{
fprintf(stderr,"Connect Called\n");
return syscall(SYS_connect,s,name,namelen);
}
peter$ cc -dynamiclib -o test_connect.dylib connect.c
peter$ env DYLD_INSERT_LIBRARIES=./test_connect.dylib \
DYLD_FORCE_FLAT_NAMESPACE=1 ftp ftp.pogma.com
Connect Called
Connected to ftp.pogma.com.
I think you probably want to avoid dlsym RTLD_NEXT et.al. on panther
and
just use the syscalls.
Peter
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden