Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A76EDC433FE for ; Thu, 13 Oct 2022 12:32:30 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2663884F70; Thu, 13 Oct 2022 14:31:05 +0200 (CEST) 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="Ky+kvVmt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 77A7084F48; Thu, 13 Oct 2022 14:30:29 +0200 (CEST) Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 2151384F1D for ; Thu, 13 Oct 2022 14:30:19 +0200 (CEST) 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-x12b.google.com with SMTP id q11so844244ilj.10 for ; Thu, 13 Oct 2022 05:30:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QOB/1WpfXDOjjggrXldy88KX0h2msrE91nAMPsIKW3s=; b=Ky+kvVmtKXaj/exgYgqB8v84XV/u1ZuxJZsM48B51JEiXn7N29yCXoxcYH/ZPWyLJw AY0maLpObShLBPJJiawnafDAKMMzg9RGfcPJNoJAQHdg4X2Ez12qcxnXUoM1WcSIyi4Q Va+Pub00uRF5Q1Fs+35hqkfGvLhY+9DwGC4Jc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QOB/1WpfXDOjjggrXldy88KX0h2msrE91nAMPsIKW3s=; b=vYoEvVKIDyOLBUKZzohMC6b3WLNub+7RSR8sEqLHi3S06Jcf+IhTGVyDpCLiiPUl0z i+Pqcge8N1F46U36rZEzPMhdE7lw1u7HuT5IaUfwsNb3+aDf2wwJCyfGQyAo9QudBMpU 6US8dFyqb+JoIK6Pl7tykTsyF4GM4lLLjIPiN4K+AtByLo4/7WVIdIO1+0MZSN6P7aRT gRpo89AXcdt/BSPEoXm9YYLqRGay4KLQ2ZhFEHgfCMFx+gNSpgq5lBNR+6y2yLXj/QKa 4jWFROwknbsMpc1eXru9w1SV7DfOZtPfLfNoNx1tBdqjFT3kF5gsr6L/X0ojr7aXd8fa yakg== X-Gm-Message-State: ACrzQf1tjbYsnbjX+/LXrVjsmADBf+mAhJ1pEDbaA0gms48dW6O651f7 sGbWiBgzYDSFcAxXYlw8fj3FL185CuwEOg== X-Google-Smtp-Source: AMsMyM43Yqm6BXjw+w/NJvJ/4KAWcY1/Y7hBMpx8vDc/cfzcRpq/eGGz6mtcdScJMBPQpcnoL92BIA== X-Received: by 2002:a05:6e02:1c2b:b0:2fa:569c:ccb6 with SMTP id m11-20020a056e021c2b00b002fa569cccb6mr17147159ilh.291.1665664217097; Thu, 13 Oct 2022 05:30:17 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id a9-20020a027a09000000b003635ab4a7b7sm7321626jac.3.2022.10.13.05.30.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 05:30:16 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Alper Nebi Yasak , Heiko Thiery Subject: [PATCH v2 10/45] binman: Handle writing ELF symbols in the Entry class Date: Thu, 13 Oct 2022 06:28:52 -0600 Message-Id: <20221013122927.636867-11-sjg@chromium.org> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog In-Reply-To: <20221013122927.636867-1-sjg@chromium.org> References: <20221013122927.636867-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.6 at phobos.denx.de X-Virus-Status: Clean This feature is used by several etypes and we plan to add more that use it. Make symbol writing a feature of the base class to reduce the code duplication. Signed-off-by: Simon Glass --- (no changes since v1) tools/binman/entry.py | 13 +++++++++++-- tools/binman/etype/blob.py | 5 +++-- tools/binman/etype/u_boot_spl.py | 7 ++----- tools/binman/etype/u_boot_spl_nodtb.py | 6 +----- tools/binman/etype/u_boot_tpl.py | 6 +----- tools/binman/etype/u_boot_tpl_nodtb.py | 6 +----- tools/binman/etype/u_boot_vpl.py | 6 +----- tools/binman/etype/u_boot_vpl_nodtb.py | 6 +----- 8 files changed, 21 insertions(+), 34 deletions(-) diff --git a/tools/binman/entry.py b/tools/binman/entry.py index 63ec5cea3b2..bdf53ddd922 100644 --- a/tools/binman/entry.py +++ b/tools/binman/entry.py @@ -12,6 +12,7 @@ import sys import time from binman import bintool +from binman import elf from dtoc import fdt_util from patman import tools from patman.tools import to_hex, to_hex_size @@ -86,10 +87,15 @@ class Entry(object): fake_fname: Fake filename, if one was created, else None required_props (dict of str): Properties which must be present. This can be added to by subclasses + elf_fname (str): Filename of the ELF file, if this entry holds an ELF + file, or is a binary file produced from an ELF file + auto_write_symbols (bool): True to write ELF symbols into this entry's + contents """ fake_dir = None - def __init__(self, section, etype, node, name_prefix=''): + def __init__(self, section, etype, node, name_prefix='', + auto_write_symbols=False): # Put this here to allow entry-docs and help to work without libfdt global state from binman import state @@ -125,6 +131,8 @@ class Entry(object): self.fake_fname = None self.required_props = [] self.comp_bintool = None + self.elf_fname = None + self.auto_write_symbols = auto_write_symbols @staticmethod def FindEntryClass(etype, expanded): @@ -647,7 +655,8 @@ class Entry(object): Args: section: Section containing the entry """ - pass + if self.auto_write_symbols: + elf.LookupAndWriteSymbols(self.elf_fname, self, section.GetImage()) def CheckEntries(self): """Check that the entry offsets are correct diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py index ceaefb07b73..a50a8068901 100644 --- a/tools/binman/etype/blob.py +++ b/tools/binman/etype/blob.py @@ -31,8 +31,9 @@ class Entry_blob(Entry): the node (if enabled with -u) which provides the uncompressed size of the data. """ - def __init__(self, section, etype, node): - super().__init__(section, etype, node) + def __init__(self, section, etype, node, auto_write_symbols=False): + super().__init__(section, etype, node, + auto_write_symbols=auto_write_symbols) self._filename = fdt_util.GetString(self._node, 'filename', self.etype) def ObtainContents(self, fake_size=0): diff --git a/tools/binman/etype/u_boot_spl.py b/tools/binman/etype/u_boot_spl.py index 6f79bf59f9f..d1aa3b4fdad 100644 --- a/tools/binman/etype/u_boot_spl.py +++ b/tools/binman/etype/u_boot_spl.py @@ -5,7 +5,6 @@ # Entry-type module for spl/u-boot-spl.bin # -from binman import elf from binman.entry import Entry from binman.etype.blob import Entry_blob @@ -35,11 +34,9 @@ class Entry_u_boot_spl(Entry_blob): unless --no-expanded is used or the node has a 'no-expanded' property. """ def __init__(self, section, etype, node): - super().__init__(section, etype, node) + super().__init__(section, etype, node, auto_write_symbols=True) self.elf_fname = 'spl/u-boot-spl' + self.auto_write_symbols = True def GetDefaultFilename(self): return 'spl/u-boot-spl.bin' - - def WriteSymbols(self, section): - elf.LookupAndWriteSymbols(self.elf_fname, self, section.GetImage()) diff --git a/tools/binman/etype/u_boot_spl_nodtb.py b/tools/binman/etype/u_boot_spl_nodtb.py index 316b38172ef..50a126dc7ef 100644 --- a/tools/binman/etype/u_boot_spl_nodtb.py +++ b/tools/binman/etype/u_boot_spl_nodtb.py @@ -5,7 +5,6 @@ # Entry-type module for 'u-boot-spl-nodtb.bin' # -from binman import elf from binman.entry import Entry from binman.etype.blob import Entry_blob @@ -32,11 +31,8 @@ class Entry_u_boot_spl_nodtb(Entry_blob): binman uses that to look up symbols to write into the SPL binary. """ def __init__(self, section, etype, node): - super().__init__(section, etype, node) + super().__init__(section, etype, node, auto_write_symbols=True) self.elf_fname = 'spl/u-boot-spl' def GetDefaultFilename(self): return 'spl/u-boot-spl-nodtb.bin' - - def WriteSymbols(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 0c575df8cdc..1883a2bd5f1 100644 --- a/tools/binman/etype/u_boot_tpl.py +++ b/tools/binman/etype/u_boot_tpl.py @@ -5,7 +5,6 @@ # Entry-type module for tpl/u-boot-tpl.bin # -from binman import elf from binman.entry import Entry from binman.etype.blob import Entry_blob @@ -35,11 +34,8 @@ class Entry_u_boot_tpl(Entry_blob): unless --no-expanded is used or the node has a 'no-expanded' property. """ def __init__(self, section, etype, node): - super().__init__(section, etype, node) + super().__init__(section, etype, node, auto_write_symbols=True) self.elf_fname = 'tpl/u-boot-tpl' def GetDefaultFilename(self): return 'tpl/u-boot-tpl.bin' - - def WriteSymbols(self, section): - elf.LookupAndWriteSymbols(self.elf_fname, self, section.GetImage()) diff --git a/tools/binman/etype/u_boot_tpl_nodtb.py b/tools/binman/etype/u_boot_tpl_nodtb.py index 98f3853f457..7e08e58f1e5 100644 --- a/tools/binman/etype/u_boot_tpl_nodtb.py +++ b/tools/binman/etype/u_boot_tpl_nodtb.py @@ -5,7 +5,6 @@ # Entry-type module for 'u-boot-tpl-nodtb.bin' # -from binman import elf from binman.entry import Entry from binman.etype.blob import Entry_blob @@ -32,11 +31,8 @@ class Entry_u_boot_tpl_nodtb(Entry_blob): binman uses that to look up symbols to write into the TPL binary. """ def __init__(self, section, etype, node): - super().__init__(section, etype, node) + super().__init__(section, etype, node, auto_write_symbols=True) self.elf_fname = 'tpl/u-boot-tpl' def GetDefaultFilename(self): return 'tpl/u-boot-tpl-nodtb.bin' - - def WriteSymbols(self, section): - elf.LookupAndWriteSymbols(self.elf_fname, self, section.GetImage()) diff --git a/tools/binman/etype/u_boot_vpl.py b/tools/binman/etype/u_boot_vpl.py index 9daaca4f6fd..62e5969c6ec 100644 --- a/tools/binman/etype/u_boot_vpl.py +++ b/tools/binman/etype/u_boot_vpl.py @@ -5,7 +5,6 @@ # Entry-type module for vpl/u-boot-vpl.bin # -from binman import elf from binman.entry import Entry from binman.etype.blob import Entry_blob @@ -32,11 +31,8 @@ class Entry_u_boot_vpl(Entry_blob): binman uses that to look up symbols to write into the VPL binary. """ def __init__(self, section, etype, node): - super().__init__(section, etype, node) + super().__init__(section, etype, node, auto_write_symbols=True) self.elf_fname = 'vpl/u-boot-vpl' def GetDefaultFilename(self): return 'vpl/u-boot-vpl.bin' - - def WriteSymbols(self, section): - elf.LookupAndWriteSymbols(self.elf_fname, self, section.GetImage()) diff --git a/tools/binman/etype/u_boot_vpl_nodtb.py b/tools/binman/etype/u_boot_vpl_nodtb.py index 25c966cf342..db3d8a91c9b 100644 --- a/tools/binman/etype/u_boot_vpl_nodtb.py +++ b/tools/binman/etype/u_boot_vpl_nodtb.py @@ -5,7 +5,6 @@ # Entry-type module for 'u-boot-vpl-nodtb.bin' # -from binman import elf from binman.entry import Entry from binman.etype.blob import Entry_blob @@ -32,11 +31,8 @@ class Entry_u_boot_vpl_nodtb(Entry_blob): binman uses that to look up symbols to write into the VPL binary. """ def __init__(self, section, etype, node): - super().__init__(section, etype, node) + super().__init__(section, etype, node, auto_write_symbols=True) self.elf_fname = 'vpl/u-boot-vpl' def GetDefaultFilename(self): return 'vpl/u-boot-vpl-nodtb.bin' - - def WriteSymbols(self, section): - elf.LookupAndWriteSymbols(self.elf_fname, self, section.GetImage()) -- 2.38.0.rc1.362.ged0d419d3c-goog