From 7a58a0f319cab0a70d3cffabc2a5b4b322a5b5cf Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Tue, 18 Jul 2023 07:23:56 -0600 Subject: binman: Update elf to return number of written symbols Update the LookupAndWriteSymbols() function to return the number of symbols written. Also add some logging for when debugging is not enabled. Signed-off-by: Simon Glass --- tools/binman/elf_test.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tools/binman/elf_test.py') diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py index c98083961b5..2fb3f6f28ff 100644 --- a/tools/binman/elf_test.py +++ b/tools/binman/elf_test.py @@ -141,7 +141,8 @@ class TestElf(unittest.TestCase): entry = FakeEntry(10) section = FakeSection() elf_fname = self.ElfTestFile('u_boot_binman_syms_bad') - elf.LookupAndWriteSymbols(elf_fname, entry, section) + count = elf.LookupAndWriteSymbols(elf_fname, entry, section) + self.assertEqual(0, count) def testBadSymbolSize(self): """Test that an attempt to use an 8-bit symbol are detected @@ -162,7 +163,7 @@ class TestElf(unittest.TestCase): def testNoValue(self): """Test the case where we have no value for the symbol - This should produce -1 values for all thress symbols, taking up the + This should produce -1 values for all three symbols, taking up the first 16 bytes of the image. """ if not elf.ELF_TOOLS: @@ -170,7 +171,8 @@ class TestElf(unittest.TestCase): entry = FakeEntry(28) section = FakeSection(sym_value=None) elf_fname = self.ElfTestFile('u_boot_binman_syms') - elf.LookupAndWriteSymbols(elf_fname, entry, section) + count = elf.LookupAndWriteSymbols(elf_fname, entry, section) + self.assertEqual(5, count) expected = (struct.pack(' Date: Tue, 18 Jul 2023 07:24:01 -0600 Subject: binman: Correct handling of zero bss size Fix the check for the __bss_size symbol, since it may be 0. Unfortunately there was no test coverage for this. Signed-off-by: Simon Glass --- tools/binman/elf_test.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'tools/binman/elf_test.py') diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py index 2fb3f6f28ff..cc95b424b33 100644 --- a/tools/binman/elf_test.py +++ b/tools/binman/elf_test.py @@ -371,6 +371,11 @@ class TestElf(unittest.TestCase): elf.GetSymbolOffset(fname, 'embed') self.assertIn('__image_copy_start', str(e.exception)) + def test_get_symbol_address(self): + fname = self.ElfTestFile('embed_data') + addr = elf.GetSymbolAddress(fname, 'region_size') + self.assertEqual(0, addr) + if __name__ == '__main__': unittest.main() -- cgit v1.2.3