Date: Wed, 05 Jul 2006 00:13:05 -0600 (MDT) From: "M. Warner Losh" <imp@bsdimp.com> To: aag.lists@gmail.com Cc: freebsd-hackers@freebsd.org Subject: Re: assyms.s Message-ID: <20060705.001305.1661916063.imp@bsdimp.com> In-Reply-To: <2f3a439f0607040654h1983febbhfbceb974e366e855@mail.gmail.com> References: <2f3a439f0607040654h1983febbhfbceb974e366e855@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In message: <2f3a439f0607040654h1983febbhfbceb974e366e855@mail.gmail.com> "Aditya Godbole" <aag.lists@gmail.com> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060705.001305.1661916063.imp>