diff options
author | Simon Glass | 2019-07-08 13:18:35 -0600 |
---|---|---|
committer | Simon Glass | 2019-07-23 20:27:57 -0700 |
commit | d8d40748dd6f202948a8173073cf34f3b6468b6d (patch) | |
tree | 301b945ae17e4c90e9e20041ed22e35fbfa7e825 /tools/binman/elf_test.py | |
parent | f58558a5ae785fdbdaadbe172a2bb86158f01d4f (diff) |
binman: Add a function to decode an ELF file
Add a function which decodes an ELF file, working out where in memory each
part of the data should be written.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/elf_test.py')
-rw-r--r-- | tools/binman/elf_test.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/binman/elf_test.py b/tools/binman/elf_test.py index 3172982427d..e2506377f26 100644 --- a/tools/binman/elf_test.py +++ b/tools/binman/elf_test.py @@ -156,6 +156,27 @@ class TestElf(unittest.TestCase): self.assertEqual(expected_text + expected_data, data) shutil.rmtree(outdir) + def testDecodeElf(self): + """Test for the MakeElf function""" + if not elf.ELF_TOOLS: + self.skipTest('Python elftools not available') + outdir = tempfile.mkdtemp(prefix='elf.') + expected_text = b'1234' + expected_data = b'wxyz' + elf_fname = os.path.join(outdir, 'elf') + elf.MakeElf(elf_fname, expected_text, expected_data) + data = tools.ReadFile(elf_fname) + + load = 0xfef20000 + entry = load + 2 + expected = expected_text + expected_data + self.assertEqual(elf.ElfInfo(expected, load, entry, len(expected)), + elf.DecodeElf(data, 0)) + self.assertEqual(elf.ElfInfo(b'\0\0' + expected[2:], + load, entry, len(expected)), + elf.DecodeElf(data, load + 2)) + #shutil.rmtree(outdir) + if __name__ == '__main__': unittest.main() |