From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 21 05:26:41 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6F0E11065672 for ; Mon, 21 Apr 2008 05:26:41 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 184348FC24 for ; Mon, 21 Apr 2008 05:26:41 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id m3L5NVIx015698; Sun, 20 Apr 2008 23:23:32 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sun, 20 Apr 2008 23:24:32 -0600 (MDT) Message-Id: <20080420.232432.-1175574853.imp@bsdimp.com> To: ertr1013@student.uu.se From: "M. Warner Losh" In-Reply-To: <20080420103910.GA92852@owl.midgard.homeip.net> References: <5124a9390804200202h535112dcx4005e9df6e5e0f5e@mail.gmail.com> <20080420103910.GA92852@owl.midgard.homeip.net> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: emily.bckr@gmail.com, freebsd-hackers@freebsd.org Subject: Re: symbol table X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Apr 2008 05:26:41 -0000 In message: <20080420103910.GA92852@owl.midgard.homeip.net> Erik Trulsson 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. 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. Warner