All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 20/34] binman: Allow symbols to be resolved inside sections
Date: Sat, 24 Aug 2019 07:23:00 -0600	[thread overview]
Message-ID: <20190824132315.53130-21-sjg@chromium.org> (raw)
In-Reply-To: <20190824132315.53130-1-sjg@chromium.org>

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 <sjg@chromium.org>
---

 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('<LQL', 4, 0x18, 0x30)
+        upto1 = 4 + len(U_BOOT_SPL_DATA)
+        expected1 = tools.GetBytes(0xff, 4) + sym_values + U_BOOT_SPL_DATA[16:]
+        self.assertEqual(expected1, data[:upto1])
+
+        upto2 = upto1 + 1 + len(U_BOOT_SPL_DATA)
+        expected2 = tools.GetBytes(0xff, 1) + sym_values + U_BOOT_SPL_DATA[16:]
+        self.assertEqual(expected2, data[upto1:upto2])
+
+        upto3 = 0x30 + len(U_BOOT_DATA)
+        expected3 = tools.GetBytes(0xff, 5) + U_BOOT_DATA
+        self.assertEqual(expected3, data[upto2:upto3])
+
+        expected4 = sym_values + U_BOOT_TPL_DATA[16:]
+        self.assertEqual(expected4, data[upto3:])
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/149_symbols_tpl.dts b/tools/binman/test/149_symbols_tpl.dts
new file mode 100644
index 0000000000..087e10f292
--- /dev/null
+++ b/tools/binman/test/149_symbols_tpl.dts
@@ -0,0 +1,28 @@
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#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";
+			};
+		};
+	};
+};
-- 
2.23.0.187.g17f5b7556c-goog

  parent reply	other threads:[~2019-08-24 13:23 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-24 13:22 [U-Boot] [PATCH 00/34] binman: Various improvements and tidy-ups Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 01/34] patman: Drop binary parameter Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 02/34] patman: Update command.Run() to handle failure better Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 03/34] binman: Use cls instead of self for class methods Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 04/34] binman: Allow use of help and entry-docs without libfdt Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 05/34] binman: Drop .note section from ELF Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 06/34] binman: Handle hidden symbols in ELF files Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 07/34] binman: Correct use of 'replace' in IFWI tests Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 08/34] binman: Add support for an x86 'reset' section Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 09/34] binman: x86: Separate out 16-bit reset and init code Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 10/34] binman: Add support for Intel FIT Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 11/34] binman: Fix IFWI output when using an Intel FIT image Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 12/34] binman: Use tools.Run() to run objdump Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 13/34] binman: Use the Makefile to build ELF test files Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 14/34] binman: Use the Makefile for u_boot_ucode_ptr Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 15/34] binman: Use the Makefile for u_boot_no_ucode_ptr Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 16/34] binman: Use the Makefile for u_boot_binman_syms Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 17/34] binman: Use the Makefile for u_boot_binman_syms_size Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 18/34] binman: Use the Makefile for u_boot_binman_syms_bad Simon Glass
2019-08-24 13:22 ` [U-Boot] [PATCH 19/34] binman: Clean up unnecessary code related to ELF test files Simon Glass
2019-08-24 13:23 ` Simon Glass [this message]
2019-08-24 13:23 ` [U-Boot] [PATCH 21/34] binman: Use underscore in test filenames Simon Glass
2019-08-24 13:23 ` [U-Boot] [PATCH 22/34] binman: Rename some two-digit test files Simon Glass
2019-08-24 13:23 ` [U-Boot] [PATCH 23/34] binman: Avoid needing the section size in advance Simon Glass
2019-08-24 13:23 ` [U-Boot] [PATCH 24/34] binman: Increase size of TPL and SPL test data Simon Glass
2019-08-24 13:23 ` [U-Boot] [PATCH 25/34] binman: Allow support for writing a size symbol to binaries Simon Glass
2019-08-24 13:23 ` [U-Boot] [PATCH 26/34] binman: Correct symbol calculation with non-zero image base Simon Glass
2019-08-24 13:23 ` [U-Boot] [PATCH 27/34] binman: Add support for Intel FSP meminit Simon Glass
2019-08-24 13:23 ` [U-Boot] [PATCH 28/34] binman: Fix entry comment for Intel descriptor Simon Glass
2019-08-24 13:23 ` [U-Boot] [PATCH 29/34] binman: Update IFWI entry to read entries outside constructor Simon Glass
2019-08-24 13:23 ` [U-Boot] [PATCH 30/34] binman: Update IFWI entry to support updates Simon Glass
2019-08-24 13:23 ` [U-Boot] [PATCH 31/34] binman: Support writing symbols into entries within an IFWI Simon Glass
2019-08-24 13:23 ` [U-Boot] [PATCH 32/34] binman: Write symbol info before image inclusion Simon Glass
2019-08-24 13:23 ` [U-Boot] [PATCH 33/34] binman: Add logging for the number of pack passes Simon Glass
2019-08-24 13:23 ` [U-Boot] [PATCH 34/34] binman: Drop comment-out code in testUpdateFdtOutput() Simon Glass
2019-09-27  0:38 ` [U-Boot] [PATCH 33/34] binman: Add logging for the number of pack passes sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 34/34] binman: Drop comment-out code in testUpdateFdtOutput() sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 32/34] binman: Write symbol info before image inclusion sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 31/34] binman: Support writing symbols into entries within an IFWI sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 30/34] binman: Update IFWI entry to support updates sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 29/34] binman: Update IFWI entry to read entries outside constructor sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 28/34] binman: Fix entry comment for Intel descriptor sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 27/34] binman: Add support for Intel FSP meminit sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 26/34] binman: Correct symbol calculation with non-zero image base sjg at google.com
2019-10-14 15:49   ` Stephen Warren
2019-10-15 14:07     ` Simon Glass
2019-10-15 16:09       ` Stephen Warren
2019-11-04 17:34         ` Stephen Warren
2019-11-05 16:33           ` Simon Glass
2019-09-27  0:38 ` [U-Boot] [PATCH 25/34] binman: Allow support for writing a size symbol to binaries sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 24/34] binman: Increase size of TPL and SPL test data sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 23/34] binman: Avoid needing the section size in advance sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 22/34] binman: Rename some two-digit test files sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 20/34] binman: Allow symbols to be resolved inside sections sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 21/34] binman: Use underscore in test filenames sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 19/34] binman: Clean up unnecessary code related to ELF test files sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 18/34] binman: Use the Makefile for u_boot_binman_syms_bad sjg at google.com
2019-09-27  0:38 ` [U-Boot] [PATCH 17/34] binman: Use the Makefile for u_boot_binman_syms_size sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 16/34] binman: Use the Makefile for u_boot_binman_syms sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 15/34] binman: Use the Makefile for u_boot_no_ucode_ptr sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 14/34] binman: Use the Makefile for u_boot_ucode_ptr sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 12/34] binman: Use tools.Run() to run objdump sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 13/34] binman: Use the Makefile to build ELF test files sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 11/34] binman: Fix IFWI output when using an Intel FIT image sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 09/34] binman: x86: Separate out 16-bit reset and init code sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 10/34] binman: Add support for Intel FIT sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 08/34] binman: Add support for an x86 'reset' section sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 07/34] binman: Correct use of 'replace' in IFWI tests sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 06/34] binman: Handle hidden symbols in ELF files sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 04/34] binman: Allow use of help and entry-docs without libfdt sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 05/34] binman: Drop .note section from ELF sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 03/34] binman: Use cls instead of self for class methods sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 02/34] patman: Update command.Run() to handle failure better sjg at google.com
2019-09-27  0:39 ` [U-Boot] [PATCH 01/34] patman: Drop binary parameter sjg at google.com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190824132315.53130-21-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.