Problem with LD_PRELOAD

Manuel Arriaga m.arriaga@ip.pt
Wed Mar 20 18:56:00 GMT 2002


Hi Ian, Daniel,

On Tuesday 19 March 2002 23:24, Ian Lance Taylor wrote:
> Manuel Arriaga <m.arriaga@ip.pt> writes:
> > So my question is: why aren't all calls to open() being redirected to the
> > preloaded object? Why does this redirection only work in some cases?
>
> I would guess that cp is not calling open().  strace does not report
> the libc functions called by a program.  It reports the system calls
> called by a program.  I would guess that cp is calling some libc
> function which calls the system call open().  Use objdump -T to see
> which dynamic symbols appear in cp; if open() is not one of them, then
> using LD_PRELOAD will not be able to intercept calls to open().

Thank you for the tip. Using objdump -T showed that 'cp' was using the 64-bit 
version of open(), and my code now works correctly.

On Tuesday 19 March 2002 23:37, Daniel Jacobowitz wrote:
> Also, to override functions in GNU libc, you need to provide versioned
> symbols using the same versions as GNU libc uses.  

Could you tell me how/where they are used? Don't all userland programs just 
use the un-versioned  symbol?

 > I'd recommend a good reference on ELF symbol versioning, but I don't know
> one :)

:-)

Best regards, and thank you both,

Manuel 



More information about the Binutils mailing list