From patchwork Tue Oct 16 21:50:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 191900 X-Patchwork-Delegate: twarren@nvidia.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id CBD1E2C009F for ; Wed, 17 Oct 2012 08:51:08 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3F7C14A217; Tue, 16 Oct 2012 23:50:57 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id DoBT09qIBoCZ; Tue, 16 Oct 2012 23:50:57 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 83B2B4A21E; Tue, 16 Oct 2012 23:50:43 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2FB904A1F6 for ; Tue, 16 Oct 2012 23:50:29 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Vxg7ETrLMXBq for ; Tue, 16 Oct 2012 23:50:26 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from avon.wwwdotorg.org (avon.wwwdotorg.org [70.85.31.133]) by theia.denx.de (Postfix) with ESMTPS id 6D6964A1F4 for ; Tue, 16 Oct 2012 23:50:20 +0200 (CEST) Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id 3D502622D; Tue, 16 Oct 2012 15:50:48 -0600 (MDT) Received: from localhost.localdomain (localhost [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id 8447AE4104; Tue, 16 Oct 2012 15:50:17 -0600 (MDT) From: Stephen Warren To: Tom Warren , Albert ARIBAUD Date: Tue, 16 Oct 2012 15:50:08 -0600 Message-Id: <1350424209-11186-3-git-send-email-swarren@wwwdotorg.org> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1350424209-11186-1-git-send-email-swarren@wwwdotorg.org> References: <1350424209-11186-1-git-send-email-swarren@wwwdotorg.org> X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.96.5 at avon.wwwdotorg.org X-Virus-Status: Clean Cc: u-boot@lists.denx.de, Stephen Warren , Tom Warren Subject: [U-Boot] [PATCH 3/4] ARM: tegra: check for SPL size overflow in makefile X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Stephen Warren If the SPL extends beyond CONFIG_SYS_TEXT_BASE, then it will likely corrupt the main U-Boot binary during execution, causing the main U-Boot binary to fail. Check for this situation during the build to avoid extremely annoying and hard-to-find bugs. Note that checking the size of u-boot-spl.bin is not enough, since BSS size doesn't affect the size of u-boot-spl.bin. Signed-off-by: Stephen Warren --- Makefile | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/Makefile b/Makefile index 425adf4..2c2d8b6 100644 --- a/Makefile +++ b/Makefile @@ -522,6 +522,11 @@ dtbfile= endif $(obj)u-boot-$(nodtb)-tegra.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin $(dtbfile) + ebss=`${CROSS_COMPILE}objdump -t spl/u-boot-spl|awk '/__bss_end__/ {print "0x"$$1}'` ; \ + if [ $$(($$ebss)) -gt $$(($(CONFIG_SYS_TEXT_BASE))) ]; then \ + echo ERROR: SPL BSS ends beyond CONFIG_SYS_TEXT_BASE > /dev/stderr; \ + exit 1; \ + fi $(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SYS_TEXT_BASE) -O binary $(obj)spl/u-boot-spl $(obj)spl/u-boot-spl-pad.bin cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin $(dtbfile) > $@ rm $(obj)spl/u-boot-spl-pad.bin