Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Nov 1998 08:13:20 -0800 (PST)
From:      John Polstra <jdp@polstra.com>
To:        Joel Ray Holveck <joelh@gnu.org>
Cc:        current@FreeBSD.ORG
Subject:   Re: Elf linker question.
Message-ID:  <XFMail.981125081320.jdp@polstra.com>
In-Reply-To: <86btlwxv7p.fsf@detlev.UUCP>

next in thread | previous in thread | raw e-mail | index | archive | help
If you follow up to this, let's drop it off the mailing list.  It's getting
pretty far off topic.

On 25-Nov-98 Joel Ray Holveck wrote:
>>> How are things like:
>>>   sighander_t mysig = libsig;
>>> handled?
>> Any time you take the address of a function, the linker actually fills
>> in the address of a little stub routine.  It's the same stub that
>> gets called when you call an external function.  The first time it is
>> executed, the stub jumps to code in the dynamic linker that does the
>> lazy binding to whatever function is being called.  Then it rewires
>> itself (an indirect jump is used) so that all future calls will go
>> straight to the target function.
> 
> Oh, so it doesn't snap the pointer in the code?  It just leaves it
> pointing to the stub?

That's right.  The whole point of PIC is that you don't relocate anything in
the text (code) segment.  That way, all the processes using a given shared
library can share the exact same copy of the code.

Once the lazy binding has already been done for a given function, the "stub"
hardly deserves the name.  It's nothing more than an indirect jump through a
location that contains a pointer to the real function's entry point.

John
---
  John Polstra                                               jdp@polstra.com
  John D. Polstra & Co., Inc.                        Seattle, Washington USA
  "Nobody ever went broke underestimating the taste of the American public."
                                                            -- H. L. Mencken

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.981125081320.jdp>