This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: ld.so binding time


On Aug 01 2017, Yubin Ruan <ablacktshirt@gmail.com> wrote:

> I am curious the binding time of ld.so when it try to resolve a
> symbol. I got an simple example in a shared lib:
>
> typedef int (*open_t) (const char *pathname, int flags, ...);
>
> open_t open = NULL;
>
> __attribute__((constructor))
> void __theconstructor(void)
> {
>     open = some_function;
> }
>
> int some_function(const char *pathname, int flags, ...)
> {
>     ...
> }
>
> and I compile this to a .so file, and then use LD_PRELOAD to preload
> it before every program startup, so that when a test program use
> `open' it would use the customized `open' system call.

This has nothing to do with binding time, you are replacing a function
with a different type object.  That won't work.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


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