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


2017-08-01 15:58 GMT+08:00 Andreas Schwab <schwab@suse.de>:
> 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.

So, for the `open' symbol,
    open_t open;
is different from
    int open(const char *pathname, int flags, ...);
Is that correct?

Hmm... I don't know. Please clarify.

Yubin


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