Re: DYLD_INSERT_LIBRARIES doesn't work with Leopard?
Re: DYLD_INSERT_LIBRARIES doesn't work with Leopard?
- Subject: Re: DYLD_INSERT_LIBRARIES doesn't work with Leopard?
- From: Greg Parker <email@hidden>
- Date: Mon, 12 Nov 2007 20:08:29 -0800
bejo wrote:
I'm trying to interpose system's open() function with my own using
the dyld, I had no problem with that on Tiger, but the same code on
Leopard doesn't work any longer. I compile my library this way:
gcc -arch ppc -dynamiclib -fno-common -o open_interposer.dylib
open_interposer.c
and then I run my app this way:
DYLD_INSERT_LIBRARIES=open_interposer.dylib
DYLD_FORCE_FLAT_NAMESPACE=1 ./my_app
and the application is still using system's open() function instead
of mine :(. DYLD_PRINT_LIBRARIES=1 shows that pen_interposer.dylib
is loaded before other libs.
open() is more than meets the eye in Leopard. You may need to
interpose more than one entry point.
% nm -m /usr/lib/libc.dylib | grep _open
...
00085324 (__TEXT,__text) external _open
000012c8 (__TEXT,__text) external _open$NOCANCEL$UNIX2003
0000be8c (__TEXT,__text) external _open$UNIX2003
When you type `open(...)` in your C code, one of those symbol names is
chosen depending on your compile options (specifically UNIX
compliance, in this case). You can use `nm -m` on your app to see
which version it's linking to. For example, a trivial 32-bit i386 test
program built on Leopard with `cc` and no other options uses _open
$UNIX2003.
(I don't know whether function interposing still works the way you
want even after working around this change.)
--
Greg Parker email@hidden Runtime Wrangler
_______________________________________________
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