]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
binman: Allow support for writing a size symbol to binaries
authorSimon Glass <sjg@chromium.org>
Sat, 24 Aug 2019 13:23:05 +0000 (07:23 -0600)
committerSimon Glass <sjg@chromium.org>
Tue, 15 Oct 2019 14:40:02 +0000 (08:40 -0600)
It is useful to be able to access the size of an image in SPL, with
something like:

binman_sym_declare(unsigned long, u_boot_any, size);

...
   ulong u_boot_size = binman_sym(ulong, u_boot_any, size);

Add support for this and update the tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/binman/elf_test.py
tools/binman/etype/section.py
tools/binman/ftest.py
tools/binman/test/u_boot_binman_syms.c

index f05545bcb13b5e592b4f4708619fbf082ac7e533..c0c11cb3403195fd0bb7b4a17a411960fc90f2c9 100644 (file)
@@ -155,11 +155,11 @@ class TestElf(unittest.TestCase):
         This should produce -1 values for all thress symbols, taking up the
         first 16 bytes of the image.
         """
-        entry = FakeEntry(20)
+        entry = FakeEntry(24)
         section = FakeSection(sym_value=None)
         elf_fname = self.ElfTestFile('u_boot_binman_syms')
         syms = elf.LookupAndWriteSymbols(elf_fname, entry, section)
-        self.assertEqual(tools.GetBytes(255, 16) + tools.GetBytes(ord('a'), 4),
+        self.assertEqual(tools.GetBytes(255, 20) + tools.GetBytes(ord('a'), 4),
                                                                   entry.data)
 
     def testDebug(self):
index 8fea6e0b24e3f7ec34bf22f57c46e57494ee3ba9..ab0c42cee045eef1ec02878b7ced769d50e20a45 100644 (file)
@@ -344,6 +344,8 @@ class Entry_section(Entry):
             return entry.offset
         elif prop_name == 'image_pos':
             return entry.image_pos
+        if prop_name == 'size':
+            return entry.size
         else:
             raise ValueError("%s: No such property '%s'" % (msg, prop_name))
 
index 5433c80e8e096e4b8dc6e020aee85c9fc6c360ff..6d59fa4874ed6a257a638e2e6f38f418bdab72a3 100644 (file)
@@ -1236,10 +1236,10 @@ class TestFunctional(unittest.TestCase):
 
         self._SetupSplElf('u_boot_binman_syms')
         data = self._DoReadFile('053_symbols.dts')
-        sym_values = struct.pack('<LQL', 0, 28, 24)
-        expected = (sym_values + U_BOOT_SPL_DATA[16:] +
+        sym_values = struct.pack('<LQLL', 0, 28, 24, 4)
+        expected = (sym_values + U_BOOT_SPL_DATA[20:] +
                     tools.GetBytes(0xff, 1) + U_BOOT_DATA + sym_values +
-                    U_BOOT_SPL_DATA[16:])
+                    U_BOOT_SPL_DATA[20:])
         self.assertEqual(expected, data)
 
     def testPackUnitAddress(self):
@@ -3305,20 +3305,20 @@ class TestFunctional(unittest.TestCase):
         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, 0x1c, 0x34)
+        sym_values = struct.pack('<LQLL', 4, 0x1c, 0x34, 4)
         upto1 = 4 + len(U_BOOT_SPL_DATA)
-        expected1 = tools.GetBytes(0xff, 4) + sym_values + U_BOOT_SPL_DATA[16:]
+        expected1 = tools.GetBytes(0xff, 4) + sym_values + U_BOOT_SPL_DATA[20:]
         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:]
+        expected2 = tools.GetBytes(0xff, 1) + sym_values + U_BOOT_SPL_DATA[20:]
         self.assertEqual(expected2, data[upto1:upto2])
 
         upto3 = 0x34 + len(U_BOOT_DATA)
         expected3 = tools.GetBytes(0xff, 1) + U_BOOT_DATA
         self.assertEqual(expected3, data[upto2:upto3])
 
-        expected4 = sym_values + U_BOOT_TPL_DATA[16:]
+        expected4 = sym_values + U_BOOT_TPL_DATA[20:]
         self.assertEqual(expected4, data[upto3:])
 
     def testPackX86RomIfwiSectiom(self):
index 4898f983e32ceb66564bae80a4b5c6b2a6eadb95..4520b319f16d983be1ecbeded3696aa7843def72 100644 (file)
@@ -11,3 +11,4 @@
 binman_sym_declare(unsigned long, u_boot_spl, offset);
 binman_sym_declare(unsigned long long, u_boot_spl2, offset);
 binman_sym_declare(unsigned long, u_boot_any, image_pos);
+binman_sym_declare(unsigned long, u_boot_any, size);