Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Apr 2008 09:00:50 +0200
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        "M. Warner Losh" <imp@bsdimp.com>
Cc:        emily.bckr@gmail.com, freebsd-hackers@freebsd.org
Subject:   Re: symbol table
Message-ID:  <20080421070050.GA13685@owl.midgard.homeip.net>
In-Reply-To: <20080420.232432.-1175574853.imp@bsdimp.com>
References:  <5124a9390804200202h535112dcx4005e9df6e5e0f5e@mail.gmail.com> <20080420103910.GA92852@owl.midgard.homeip.net> <20080420.232432.-1175574853.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Apr 20, 2008 at 11:24:32PM -0600, M. Warner Losh wrote:
> In message: <20080420103910.GA92852@owl.midgard.homeip.net>
>             Erik Trulsson <ertr1013@student.uu.se> writes:
> : On Sun, Apr 20, 2008 at 12:02:09PM +0300, emily becker wrote:
> : > Hi,
> : > 
> : > I have a question about symbol table.
> : > One of the section In symbol table is memory adress which symbol is located.
> : > I wonder if this memory adress is bound at run-time or compile-time?
> : 
> : It depends.  Symbols referring to objects in a dynamically loaded library
> : will be bound at run-time, the rest should be bound at compile-time.
> 
> They are bound at link-time, not compile-time.  This is splitting a
> fine hair, but compile-time is when a .o or .so is created, while link
> time combines .o-like things together into a bigger thing.

Well, I consider linking to be part of the compilation process so for
me link-time is a subset of compile-time.
You are however completely correct that it is at link-time that the binding
happens (for those symbols that can be resolved at link-time anyway.)

>  When that
> bigger thing is a final link, the addresses for the static portions of
> the binary are set.  When the final thing is a dynamic library, the
> addresses float (since all the code is PIC anyway, they don't really
> matter).  Dynamic parts of executables are bound at run-time.
> 
> : > if it is compile-time, I don't understand how do we know whether the symbol
> : > is located this adress.
> : > Maybe this adress is already bound by other process or like this.
> : 
> : Each process runs in its own address space, and therefore the compiler
> : (actually: the linker) can know exactly where in this address space things
> : will end up.
> 
> The run-time linker (ld.so) is the one that knows where things wind up
> in a given process...  libc.so and other shared libraries can and do
> link at different addresses for different processes.

My comment referred to those symbols that are bound at compile^W link-time.
For those the linker does know what addresses they refer to.  For
dynamically loaded libraries it is indeed the runtime loader that knows
where in the address space they will end up.




-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se



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