From patchwork Mon Oct 26 23:40:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1388224 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Ox/FWNFN; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CKs3s2wb0z9sT6 for ; Tue, 27 Oct 2020 10:48:41 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2ABA682555; Tue, 27 Oct 2020 00:42:20 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Ox/FWNFN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 85740824A7; Tue, 27 Oct 2020 00:41:11 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x135.google.com (mail-il1-x135.google.com [IPv6:2607:f8b0:4864:20::135]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C5FD6824F1 for ; Tue, 27 Oct 2020 00:40:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x135.google.com with SMTP id q1so10924067ilt.6 for ; Mon, 26 Oct 2020 16:40:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GsfefXGKBCNniSyCbjHKgZvQzDPze+nIfPNAGEnyivY=; b=Ox/FWNFNUnrpmqBOKof2vSGGfQ8N/xr7r3ij8XjDoGuEKULe+C/rtPoWgFBdpuJhNe 4G1dWKnj2dv37CMNxt9EsFu3qzbEhkbukXREqlg+FnDThoy0PgFB+fGpFCSnlIOJB+EC Ag9qJmTAbvhIf+OZWRW3kSuRfZEqaObVI1wr0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GsfefXGKBCNniSyCbjHKgZvQzDPze+nIfPNAGEnyivY=; b=WiBgkbFIa7BEhymG+BNOHpup2NlE1nhj4f06pVhx0PADGOjlzIEhpmPPiv9R2Zdbkt /ZgDoJoNSl2BeNTTUkDqsvd9KYQ6s3RBmgUJ9tD8037246kolLinHDIuCWCEaiFatD95 KcBXecdoxEdPi9MScp6317j3LwowvkGH3nqbuswZFmbo4CQyAfeoUippmnggOgi8Rk46 MUBsbkXuf3+4HVUhnHZdy/2NV0q8HT+pTHKNvUGGxJhhQLEXaK/NbXHSxt9Dq+yoJYuz dxq9tjnIoBb2Kz7QG/LPHzMjMrAjnZWYRBiZI1RigHotlQscLUYF2yLeRsIG4VUJ5ecv +MQw== X-Gm-Message-State: AOAM533/SwojfJcCC9DceguICkheOxLj+ufLdaAspvuTAVccNiiwdaer cyJeUMLnQRvoT/B/JGj91BPcQZRgHKfclsnO X-Google-Smtp-Source: ABdhPJwy9/o3UAcpaga60jYKzJ3WlQrpVYDRt69YNA7oRROHBIrX/IFrarBw0r4f3Xp+bU8oNqeHxA== X-Received: by 2002:a92:ad0f:: with SMTP id w15mr11758224ilh.97.1603755652253; Mon, 26 Oct 2020 16:40:52 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id e17sm7066857ile.60.2020.10.26.16.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 16:40:51 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Alper Nebi Yasak , Simon Glass Subject: [PATCH v2 26/28] binman: Use the actual contents in CheckSize() Date: Mon, 26 Oct 2020 17:40:24 -0600 Message-Id: <20201026234026.1903778-26-sjg@chromium.org> X-Mailer: git-send-email 2.29.0.rc2.309.g374f81d7ae-goog In-Reply-To: <20201026234026.1903778-1-sjg@chromium.org> References: <20201026234026.1903778-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean At present this function adds up the total size of entries to work out the size of a section's contents. With compression this is no-longer enough. We may as well bite the bullet and build the section contents instead. Call _BuildSectionData() to get the (possibly compressed) contents and GetPaddedData() to get the same but with padding added. Note that this is inefficient since the section contents is calculated twice. Future work will improve this. This affects testPackOverlapMap() since the error is reported with a different section size now (enough to hold the contents). Update that at the same time. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/etype/section.py | 11 ++++------- tools/binman/ftest.py | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index b146239b779..570dbfcfd41 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -544,16 +544,13 @@ class Entry_section(Entry): def CheckSize(self): - """Check that the section contents does not exceed its size, etc.""" - contents_size = 0 - for entry in self._entries.values(): - contents_size = max(contents_size, entry.offset + entry.size) - - contents_size -= self._skip_at_start + data = self._BuildSectionData() + contents_size = len(data) size = self.size if not size: - size = self.pad_before + contents_size + self.pad_after + data = self.GetPaddedData() + size = len(data) size = tools.Align(size, self.align_size) if self.size and contents_size > self.size: diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 6f47deac3b6..5bcdb70c41a 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -2024,7 +2024,7 @@ class TestFunctional(unittest.TestCase): self.assertTrue(os.path.exists(map_fname)) map_data = tools.ReadFile(map_fname, binary=False) self.assertEqual('''ImagePos Offset Size Name - 00000000 00000007 main-section + 00000000 00000008 main-section 00000000 00000004 u-boot 00000003 00000004 u-boot-align ''', map_data)