From owner-freebsd-toolchain@FreeBSD.ORG Tue Nov 27 08:23:32 2012 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6DD8CDF5 for ; Tue, 27 Nov 2012 08:23:32 +0000 (UTC) (envelope-from erik@cederstrand.dk) Received: from csmtp3.one.com (csmtp3.one.com [91.198.169.23]) by mx1.freebsd.org (Postfix) with ESMTP id 28EAA8FC0C for ; Tue, 27 Nov 2012 08:23:31 +0000 (UTC) Received: from [192.168.1.18] (unknown [217.157.7.221]) by csmtp3.one.com (Postfix) with ESMTPA id 36DE32404986; Tue, 27 Nov 2012 08:16:48 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) Subject: Re: crunchide breaks object files when using mclinker to do base system linking From: Erik Cederstrand In-Reply-To: Date: Tue, 27 Nov 2012 09:16:49 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: To: pete X-Mailer: Apple Mail (2.1499) Cc: freebsd-toolchain@freebsd.org X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Nov 2012 08:23:32 -0000 Den 27/11/2012 kl. 09.00 skrev pete : > Hi, >=20 > I meet a problem when using mclinker to do base system linking. And = the > problem is crunchide is gnu ld specific. it presumes the section = layout of > a object file is like what gnu ld generates. >=20 > To make it clear, gnu ld would generate the following layout. And = crunchide > will update elf section header, symbol table, and then string table. = (The > string table is likely enlarged.) >=20 > ld -dc -r -o cat.lo cat_stub.o > /usr/obj/usr/src/rescue/rescue//usr/src/bin/cat/cat.o > crunchide -k _crunched_cat_stub cat.lo >=20 > ----gnu ld------------ > + elf header + > ---------------------- > + + > + + > ---------------------- > + elf section header + > ---------------------- > + symbol table + > ---------------------- > + string table + > ---------------------- >=20 > However, mclinker does not produce this layout, but put elf section = header > in the end of file. And then crunchide will break the object file = generated > by mclinker. (elf section header is overwritten by new strings) >=20 > I know the layout generated by gold linker is also different to gnu = ld. On > the other hand, we can find only ELF header is required to be fixed in = *"System > V Application Binary Interface*". >=20 > For mclinker, I think it's not difficult to add the change to be = compatible > with gnu ld. But do you think if it will be better to modify crunchide > utility to support more elf linkers? Unless you have compelling technical reasons to keep your layout, I = think it's better for mclinker to be as compatible with GNU ld as = possible, even though your layout also adheres to the standards. If = other tools in FreeBSD or other platforms also make assumptions about = the header layout, you'll end up patching lots of tools instead of = working on mclinker. With that in mind, I also think it's worthwhile to patch our crunchide = to be more permissive. If you have the resources, please send patches. Thanks, Erik=