From owner-freebsd-hackers@FreeBSD.ORG Wed Jul 5 06:14:43 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 03CCE16A4E6 for ; Wed, 5 Jul 2006 06:14:43 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8C07843D58 for ; Wed, 5 Jul 2006 06:14:42 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [IPv6:::1] (may be forged)) by harmony.bsdimp.com (8.13.4/8.13.4) with ESMTP id k656D0bv079938; Wed, 5 Jul 2006 00:13:01 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Wed, 05 Jul 2006 00:13:05 -0600 (MDT) Message-Id: <20060705.001305.1661916063.imp@bsdimp.com> To: aag.lists@gmail.com From: "M. Warner Losh" In-Reply-To: <2f3a439f0607040654h1983febbhfbceb974e366e855@mail.gmail.com> References: <2f3a439f0607040654h1983febbhfbceb974e366e855@mail.gmail.com> X-Mailer: Mew version 4.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: freebsd-hackers@freebsd.org Subject: Re: assyms.s 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: Wed, 05 Jul 2006 06:14:43 -0000 In message: <2f3a439f0607040654h1983febbhfbceb974e366e855@mail.gmail.com> "Aditya Godbole" writes: : I was going through the machine dependant code and found that : assembler symbols are created using a script that parses symbol names : taken from an object file. Why is it done this way? Are there any : advantages of doing this? genassym is done so that the C compiler can tell us the offsets of different fields of different structures shared between C and aseembler code. This method is done because it doesn't require execution of a program to determine the offsets. Once upon a time, it used to be implemented as something approximating: printf("#define FOO_BAR %d\n", offsetof(foo, foo_bar)); but this required execution in the target environment. When host and target were the same, this didn't matter. But when the host is i386 and the target is alpha, for example, the program would produce different numbers on i386 than on alpha for any data structure that contained pointers. The current method of creating a .o file using the target compiler and then teasing the information out of that .o file generates the same results on both host and target. Well, assuming the absense of compiler bugs for the target compiler running a given host. Warner