From patchwork Sat Aug 24 13:23:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1152642 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="F+VC0K1u"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46Fzwq3pkrz9s7T for ; Sat, 24 Aug 2019 23:42:51 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 29106C21D8A; Sat, 24 Aug 2019 13:31:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id CA7A1C21E49; Sat, 24 Aug 2019 13:29:07 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 4C757C21E07; Sat, 24 Aug 2019 13:27:46 +0000 (UTC) Received: from mail-io1-f67.google.com (mail-io1-f67.google.com [209.85.166.67]) by lists.denx.de (Postfix) with ESMTPS id ADF45C21DF9 for ; Sat, 24 Aug 2019 13:27:41 +0000 (UTC) Received: by mail-io1-f67.google.com with SMTP id e20so26588843iob.9 for ; Sat, 24 Aug 2019 06:27:41 -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=5qWe34Qy/1bISohMU7IbFYkAxAfJ+/ilpVNevaPRhOo=; b=F+VC0K1uiOKy1cUZnraeCh2zizTJ6+OEkhB0EO9tt4k1WghZmbOHvtFWlZ79G4uDY2 VxbRV4hjJHO3HaSWn7oMMbtemKcNw8j5fVL3RLUjbxPcSmAOMYUf4aUCZFUvN5Obxuqu 6U082o8q6Xk9BB//AnfsvWYxp3CpVZ/0l4s/M= 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=5qWe34Qy/1bISohMU7IbFYkAxAfJ+/ilpVNevaPRhOo=; b=gXTh7iPAg516EB2rFw3sXVcM75/8f9F6HlV7lWjl1WIb+8PNO9KGIssPXRA4RshigA wdWxOUrRtU3aPa71RCnC0/KBghxAneii45jj64ULaCeDWPJOeTKch0CHs5Xd1Qm+bs0d 7egxRiE5tXhD42yzALS2kltYh3jp60SpnM3nk0IE5rArjFtW4smy08sgUWeD4qn0TtGM i8Zs9WYpqNLZgwwPjczjki2rrIWomtv3PrkoIdidHvgkVxFMBbUamP+TKW6bYX8TzVuo jFcuyzb6Bb9Qa2lPsbUETh0bPwttmyLb3HGTxamMijrN1PI8abFIPJFJhdtUVZtVJLz9 qJ0g== X-Gm-Message-State: APjAAAWdeVjdxgX50828LNOpofWF/5FtLMwleeq0W7qc30B3RUm4W74Y WDLrHqZL/oC9/TeGcM8fn2HbcPgrWmQ= X-Google-Smtp-Source: APXvYqzWQks+D6yPJIYVQ5uqAlF6hnrKt76Kcq5HkG6Qlba2gRiaCcsAnKq7qizcHjfeDcnPIhGimg== X-Received: by 2002:a05:6602:2492:: with SMTP id g18mr13778615ioe.266.1566653260574; Sat, 24 Aug 2019 06:27:40 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id l2sm8881790ioq.83.2019.08.24.06.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Aug 2019 06:27:40 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Sat, 24 Aug 2019 07:23:00 -0600 Message-Id: <20190824132315.53130-21-sjg@chromium.org> X-Mailer: git-send-email 2.23.0.187.g17f5b7556c-goog In-Reply-To: <20190824132315.53130-1-sjg@chromium.org> References: <20190824132315.53130-1-sjg@chromium.org> MIME-Version: 1.0 Subject: [U-Boot] [PATCH 20/34] binman: Allow symbols to be resolved inside sections X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" At present we only support symbols inside binaries which are at the top level of an image. This restrictions seems unreasonable since more complex images may want to group binaries within different sections. Relax the restriction. Also fix a typo in the comment for testTpl(). Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- tools/binman/etype/u_boot_spl.py | 2 +- tools/binman/etype/u_boot_tpl.py | 2 +- tools/binman/ftest.py | 35 +++++++++++++++++++++++++-- tools/binman/test/149_symbols_tpl.dts | 28 +++++++++++++++++++++ 4 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 tools/binman/test/149_symbols_tpl.dts diff --git a/tools/binman/etype/u_boot_spl.py b/tools/binman/etype/u_boot_spl.py index ab78714c8d..7fedd00021 100644 --- a/tools/binman/etype/u_boot_spl.py +++ b/tools/binman/etype/u_boot_spl.py @@ -40,4 +40,4 @@ class Entry_u_boot_spl(Entry_blob): return 'spl/u-boot-spl.bin' def WriteSymbols(self, section): - elf.LookupAndWriteSymbols(self.elf_fname, self, section) + elf.LookupAndWriteSymbols(self.elf_fname, self, section.GetImage()) diff --git a/tools/binman/etype/u_boot_tpl.py b/tools/binman/etype/u_boot_tpl.py index 4d4bb92596..1b69c4f4a7 100644 --- a/tools/binman/etype/u_boot_tpl.py +++ b/tools/binman/etype/u_boot_tpl.py @@ -40,4 +40,4 @@ class Entry_u_boot_tpl(Entry_blob): return 'tpl/u-boot-tpl.bin' def WriteSymbols(self, section): - elf.LookupAndWriteSymbols(self.elf_fname, self, section) + elf.LookupAndWriteSymbols(self.elf_fname, self, section.GetImage()) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 1d774e28e5..008e747270 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -40,7 +40,7 @@ import tout U_BOOT_DATA = b'1234' U_BOOT_IMG_DATA = b'img' U_BOOT_SPL_DATA = b'56780123456789abcde' -U_BOOT_TPL_DATA = b'tpl' +U_BOOT_TPL_DATA = b'tpl9876543210fedcb' BLOB_DATA = b'89' ME_DATA = b'0abcd' VGA_DATA = b'vga' @@ -491,6 +491,16 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('spl/u-boot-spl', tools.ReadFile(cls.ElfTestFile(src_fname))) + @classmethod + def _SetupTplElf(cls, src_fname='bss_data'): + """Set up an ELF file with a '_dt_ucode_base_size' symbol + + Args: + Filename of ELF file to use as TPL + """ + TestFunctional._MakeInputFile('tpl/u-boot-tpl', + tools.ReadFile(cls.ElfTestFile(src_fname))) + @classmethod def TestFile(cls, fname): return os.path.join(cls._binman_dir, 'test', fname) @@ -1557,7 +1567,7 @@ class TestFunctional(unittest.TestCase): "'other'", str(e.exception)) def testTpl(self): - """Test that an image with TPL and ots device tree can be created""" + """Test that an image with TPL and its device tree can be created""" # ELF file with a '__bss_size' symbol with open(self.ElfTestFile('bss_data'), 'rb') as fd: TestFunctional._MakeInputFile('tpl/u-boot-tpl', fd.read()) @@ -3292,6 +3302,27 @@ class TestFunctional(unittest.TestCase): self.assertIn("'intel-fit-ptr' section must have an 'intel-fit' sibling", str(e.exception)) + def testSymbolsTplSection(self): + """Test binman can assign symbols embedded in U-Boot TPL in a section""" + self._SetupSplElf('u_boot_binman_syms') + self._SetupTplElf('u_boot_binman_syms') + data = self._DoReadFile('149_symbols_tpl.dts') + sym_values = struct.pack('; + #size-cells = <1>; + + binman { + pad-byte = <0xff>; + u-boot-spl { + offset = <4>; + }; + + u-boot-spl2 { + offset = <0x18>; + type = "u-boot-spl"; + }; + + u-boot { + offset = <0x30>; + }; + + section { + u-boot-tpl { + type = "u-boot-tpl"; + }; + }; + }; +};