From owner-freebsd-arch@FreeBSD.ORG Thu Apr 1 12:51:40 2010 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 177601065673; Thu, 1 Apr 2010 12:51:40 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id DDC598FC19; Thu, 1 Apr 2010 12:51:39 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 960AB46B0C; Thu, 1 Apr 2010 08:51:39 -0400 (EDT) Received: from jhbbsd.localnet (smtp.hudson-trading.com [209.249.190.9]) by bigwig.baldwin.cx (Postfix) with ESMTPA id AB22B8A021; Thu, 1 Apr 2010 08:51:38 -0400 (EDT) From: John Baldwin To: freebsd-arch@freebsd.org Date: Thu, 1 Apr 2010 07:37:53 -0400 User-Agent: KMail/1.12.1 (FreeBSD/7.3-CBSD-20100217; KDE/4.3.1; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201004010737.53482.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (bigwig.baldwin.cx); Thu, 01 Apr 2010 08:51:38 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.95.1 at bigwig.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-1.8 required=4.2 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bigwig.baldwin.cx Cc: freebsd-hackers@freebsd.org, Daniel Rodrick Subject: Re: Newbie question: kernel image a dynamically linked binary? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Apr 2010 12:51:40 -0000 On Thursday 01 April 2010 6:23:50 am Daniel Rodrick wrote: > Hello List, > > I'm a newbie and coming from Linux background, and am trying to learn > FreeBSD now. The first thing I find a little confusing is that the > final FreeBSD kernel image is shown as a DYNAMICALLY LINKED binary: > > $ > $ pwd > /boot/kernel > $ > $ file kernel > kernel: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), > dynamically linked (uses shared libs), not stripped > $ > > How can the kernel image use shared libraries? And which ones does it > use, if any? > > Also, I cannot find out the libraries the image uses using the > traditional ldd command: > > $ ldd kernel > kernel: > kernel: signal 6 > $ > > Can some please throw some light? It's a hack that is used so that the kernel linker is able to link in kernel modules that are built as shared objects. The kernel is mostly built from static objects, but a single dynamic object (that is empty) is linked in: # This is a hack. BFD "optimizes" away dynamic mode if there are no # dynamic references. We could probably do a '-Bforcedynamic' mode like # in the a.out ld. For now, this works. HACK_EXTRA_FLAGS?= -shared hack.So: Makefile :> hack.c ${CC} ${HACK_EXTRA_FLAGS} -nostdlib hack.c -o hack.So rm -f hack.c -- John Baldwin