From owner-freebsd-current@FreeBSD.ORG Mon Feb 5 12:00:39 2007 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 98C3916A402 for ; Mon, 5 Feb 2007 12:00:38 +0000 (UTC) (envelope-from rizzo@icir.org) Received: from xorpc.icir.org (xorpc.icir.org [192.150.187.68]) by mx1.freebsd.org (Postfix) with ESMTP id 84FA913C481 for ; Mon, 5 Feb 2007 12:00:38 +0000 (UTC) (envelope-from rizzo@icir.org) Received: from xorpc.icir.org (localhost [127.0.0.1]) by xorpc.icir.org (8.12.11/8.13.6) with ESMTP id l15C0ccc035841; Mon, 5 Feb 2007 04:00:38 -0800 (PST) (envelope-from rizzo@xorpc.icir.org) Received: (from rizzo@localhost) by xorpc.icir.org (8.12.11/8.12.3/Submit) id l15C0c4x035840; Mon, 5 Feb 2007 04:00:38 -0800 (PST) (envelope-from rizzo) Date: Mon, 5 Feb 2007 04:00:38 -0800 From: Luigi Rizzo To: Kostik Belousov Message-ID: <20070205040037.A35752@xorpc.icir.org> References: <20070202172756.A2649@xorpc.icir.org> <20070205115553.GA3304@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20070205115553.GA3304@deviant.kiev.zoral.com.ua>; from kostikbel@gmail.com on Mon, Feb 05, 2007 at 01:55:53PM +0200 Cc: current@freebsd.org Subject: Re: link_elf.c vs link_elf_obj.c ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2007 12:00:39 -0000 On Mon, Feb 05, 2007 at 01:55:53PM +0200, Kostik Belousov wrote: > On Fri, Feb 02, 2007 at 05:27:56PM -0800, Luigi Rizzo wrote: > > does anyone know what is the difference between these two files ? > > They seem to do two similar but slightly different things related > > to elf file loading. > > > > But diff shows large pieces of common code, and there is even > > more commonality if you factor out whitespace changes and > > variable renaming. > > ELF specification defines 3 kinds of objects (putting core files aside); > - executables > - shared objects (AKA .so) > - relocatable objects (AKA .o, created by assembler). > Executables and .so are usually created by linker, while relocatables are the > assembler output (although ld -r can glue several .o files into one). > Executables and .so are in some sense finalized, and they contain a tables > that are useful for dynamic linker. Also, they usually carry different kind > of relocations then relocatables. > > Now, in-kernel dynamic linker used for linking newly-loaded kld, shall deal > with either .so-kind of modules (on FreeBSD, all arches except amd64), or > relocatables (amd64). Two linkers you found deal with .so-kind (link_elf.c) > or relocatables (link_elf_obj.c). > > Reasons why amd64 cannot use shared objects for kld mostly caused by > toolchains limitations and CPU architecture (it is impossible to create > working non-PIC .so there). > > Note that Solaris uses relocatables for modules. so, if one had to write a few lines of comment on top of each of these two files to tell what they do and how they differ, what would you write ? cheers luigi