From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 7 19:41:19 2012 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3DE9AC2C for ; Fri, 7 Dec 2012 19:41:19 +0000 (UTC) (envelope-from lidl@hydra.pix.net) Received: from hydra.pix.net (hydra.pix.net [IPv6:2001:470:e254::3c]) by mx1.freebsd.org (Postfix) with ESMTP id 078EF8FC08 for ; Fri, 7 Dec 2012 19:41:18 +0000 (UTC) Received: from hydra.pix.net (localhost [127.0.0.1]) by hydra.pix.net (8.14.5/8.14.5) with ESMTP id qB7JfGHw094968; Fri, 7 Dec 2012 14:41:16 -0500 (EST) (envelope-from lidl@hydra.pix.net) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.97.5 at mail.pix.net Received: (from lidl@localhost) by hydra.pix.net (8.14.5/8.14.5/Submit) id qB7JfG0B094967; Fri, 7 Dec 2012 14:41:16 -0500 (EST) (envelope-from lidl) Date: Fri, 7 Dec 2012 14:41:16 -0500 From: Kurt Lidl To: pete Subject: Re: [CFT/RFC] Make crunched compatible with external linkers Message-ID: <20121207194115.GA94794@pix.net> References: <779286D2-F710-45FF-8C38-59513B5C1B7D@cederstrand.dk> <20121204191140.GA56790@pix.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: FreeBSD Hackers , Erik Cederstrand X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Dec 2012 19:41:19 -0000 On Thu, Dec 06, 2012 at 10:39:27AM +0800, pete wrote: > On Wed, Dec 5, 2012 at 3:11 AM, Kurt Lidl wrote: > > > On Tue, Dec 04, 2012 at 11:06:56AM +0100, Erik Cederstrand wrote: > > > Hello hackers, > > > > > > The following PR patches crunchide(1) to accept object files produced by > > the gold and mclinker linkers: > > http://www.freebsd.org/cgi/query-pr.cgi?pr=bin%2F174011 > > > > > > On behalf of the submitter, I'd like to request a review of the patch, > > and testing of crunchide/crunchgen especially on SPARC and ARM. > > > > I applied this patch to a 9/stable source tree, and was able to > > "buildworld" with it in place, on my sparc64 machine. > > > > I know that's not a great test case, but the patched binary > > is good enough to generate the objects that are needed for the > > 'rescue' binary. And that binary runs at least a trivial test > > of '/usr/obj/usr/src/rescue/rescue/rescue ifconfig -a' and > > produces correct output. > > > > -Kurt > > > > Really thanks for your help! > > This patch is for crunchide to handle ELF object file in a more general > way, but not be limited to the custom section layout (i.e., section > headers, .symtab, and then .strtab are @EOF). And if we are still using > ld(1), I think the patched crunchide should produce exactly the same output > as before. Then the rescue binary would also be the same. > > I checked and verified the intermediate object files and rescue binary (via > binary diff) on X86 FreeBSD 9.0. If you can also kindly help check this on > different archs and feedback, I think the result will be very helpful. Well, I updated my sparc64 machine's source tree to the latest stable/9 code, and then did two complete buildworld runs, one without the changes to the crunchide code, and second with the crunchide changes. Diffing the obj tree (selectively) shows: root@spork-143: diff -r usr.modified/src/rescue usr/src/rescue Files usr.modified/src/rescue/librescue/librescue.a and usr/src/rescue/librescue/librescue.a differ root@spork-144: md5 usr.modified/src/rescue/rescue/rescue usr/src/rescue/rescue/rescue MD5 (usr.modified/src/rescue/rescue/rescue) = 75fc2a1b06ae38df2be668eff7cec72e MD5 (usr/src/rescue/rescue/rescue) = 75fc2a1b06ae38df2be668eff7cec72e And: root@spork-143: diff -r usr.modified/src/usr.sbin/crunch usr/src/usr.sbin/crunch diff -r usr.modified/src/usr.sbin/crunch/crunchide/.depend usr/src/usr.sbin/crunch/crunchide/.depend 65,68d64 < /usr/obj/usr/src/tmp/usr/include/limits.h \ < /usr/obj/usr/src/tmp/usr/include/sys/limits.h \ < /usr/obj/usr/src/tmp/usr/include/machine/_limits.h \ < /usr/obj/usr/src/tmp/usr/include/sys/syslimits.h \ Files usr.modified/src/usr.sbin/crunch/crunchide/crunchide and usr/src/usr.sbin/crunch/crunchide/crunchide differ Files usr.modified/src/usr.sbin/crunch/crunchide/exec_elf64.o and usr/src/usr.sbin/crunch/crunchide/exec_elf64.o differ So, the crunchide binaries are different (as expected) and the resulting 'rescue' binary is identical. -Kurt