ld.so binding time
Yubin Ruan
ablacktshirt@gmail.com
Tue Aug 1 08:02:00 GMT 2017
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
More information about the Binutils
mailing list