diff options
author | Simon Glass <sjg@chromium.org> | 2023-01-11 16:10:19 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2023-01-18 14:55:41 -0700 |
commit | 571bc4e67d39e4c376f8bab0d6518ab5ee832d9e (patch) | |
tree | 0d52288bc4298572fa2db76458a6d55eb95e788d /tools/binman/ftest.py | |
parent | 8f5afe21aed8b8ed4d75678a4e8972e7d8a23a6b (diff) |
binman: Support positioning an entry by and ELF symbol
In some cases it is useful to position an entry over the top of a symbol
in an ELF file. For example, if the symbol holds a version string then it
allows the string to be accessed from the fdtmap.
Add support for this.
Suggested-by: Pali Rohár <pali@kernel.org>
Suggested-by: Keith Short <keithshort@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/ftest.py')
-rw-r--r-- | tools/binman/ftest.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 17b0431d4f3..be0aea49ce9 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -6281,6 +6281,34 @@ fdt fdtmap Extract the devicetree blob from the fdtmap expected = sym_values self.assertEqual(expected, data[:len(expected)]) + def testOffsetFromElf(self): + """Test a blob with symbols read from an ELF file""" + elf_fname = self.ElfTestFile('blob_syms') + TestFunctional._MakeInputFile('blob_syms', tools.read_file(elf_fname)) + TestFunctional._MakeInputFile('blob_syms.bin', + tools.read_file(self.ElfTestFile('blob_syms.bin'))) + + data = self._DoReadFile('274_offset_from_elf.dts') + + syms = elf.GetSymbols(elf_fname, ['binman', 'image']) + base = elf.GetSymbolAddress(elf_fname, '__my_start_sym') + + image = control.images['image'] + entries = image.GetEntries() + + self.assertIn('inset', entries) + inset = entries['inset'] + + self.assertEqual(base + 4, inset.offset); + self.assertEqual(base + 4, inset.image_pos); + self.assertEqual(4, inset.size); + + self.assertIn('inset2', entries) + inset = entries['inset2'] + self.assertEqual(base + 8, inset.offset); + self.assertEqual(base + 8, inset.image_pos); + self.assertEqual(4, inset.size); + if __name__ == "__main__": unittest.main() |