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