From owner-freebsd-toolchain@FreeBSD.ORG Tue Nov 27 08:00:37 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 BE1099C7 for ; Tue, 27 Nov 2012 08:00:37 +0000 (UTC) (envelope-from pete.chou@gmail.com) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 32BFE8FC13 for ; Tue, 27 Nov 2012 08:00:36 +0000 (UTC) Received: by mail-la0-f54.google.com with SMTP id j13so11541553lah.13 for ; Tue, 27 Nov 2012 00:00:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:x-google-sender-auth:message-id :subject:to:content-type; bh=+RuRoBv0I99hGv+BeFEL0k27+p01wz/JCt/5aQ57qas=; b=CY09sLP5XQqzUPFL9Ffzz8Hia/TnOga+0bldJBGKnR6C4gsN39Zlss09GcIMqdPCpD FAavL3ILcyNrGWOyOokjPRQt5cS9fysZbh1L83Vekei/ug5rk8Fs7OWWGymLaz4Kr6ro FF/ErBsQklGju9NQnSgRKgS2KlpLy9njUx1eHai1e/d7+n/Q/CSGDbMrgNNxNZeR4A1u HI4i2+OUn9JYbzRiOpJ66tSVYIbF3HMtYtgWto0X99u+LMLxzTmrjDLJX2ApJO7l5YHR DNoNqk+/rgJIXYmqX6wPX1+Kp22dY0FsvCSfjd/D2TD6yO67fJzt8qZUq+9xzRLRiI7H ah5g== Received: by 10.152.114.100 with SMTP id jf4mr13810013lab.47.1354003235549; Tue, 27 Nov 2012 00:00:35 -0800 (PST) MIME-Version: 1.0 Sender: pete.chou@gmail.com Received: by 10.114.69.131 with HTTP; Tue, 27 Nov 2012 00:00:05 -0800 (PST) From: pete Date: Tue, 27 Nov 2012 16:00:05 +0800 X-Google-Sender-Auth: eUacTAfY2KxCLz7k3MCRLx-kW_Y Message-ID: Subject: crunchide breaks object files when using mclinker to do base system linking To: freebsd-toolchain@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 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:00:37 -0000 Hi, 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. 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.) 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 ----gnu ld------------ + elf header + ---------------------- + + + + ---------------------- + elf section header + ---------------------- + symbol table + ---------------------- + string table + ---------------------- 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) 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*". 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? Any idea? Thanks, Pete