This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: ld.so binding time
- From: Yubin Ruan <ablacktshirt at gmail dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: binutils at sourceware dot org
- Date: Tue, 1 Aug 2017 16:02:29 +0800
- Subject: Re: ld.so binding time
- Authentication-results: sourceware.org; auth=none
- References: <CAJYFCiN5BwPspkp0EMMVLbCHM+jbbLQ=c_gShON6kWz4tU18ig@mail.gmail.com> <mvmmv7jra6o.fsf@suse.de>
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