diff options
author | Simon Glass <sjg@chromium.org> | 2020-10-26 17:40:24 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-10-29 14:42:59 -0600 |
commit | 0ff83da634c4e4a8e510c5b2434cab88cb33c164 (patch) | |
tree | 6c57bb759292d9b3825b17907e4afe6846741e98 /tools/binman | |
parent | b004bf3906e6f80b80558424e4a3ed8767103e37 (diff) | |
download | u-boot-0ff83da634c4e4a8e510c5b2434cab88cb33c164.zip u-boot-0ff83da634c4e4a8e510c5b2434cab88cb33c164.tar.gz u-boot-0ff83da634c4e4a8e510c5b2434cab88cb33c164.tar.bz2 |
binman: Use the actual contents in CheckSize()
At present this function adds up the total size of entries to work out the
size of a section's contents. With compression this is no-longer enough.
We may as well bite the bullet and build the section contents instead.
Call _BuildSectionData() to get the (possibly compressed) contents and
GetPaddedData() to get the same but with padding added.
Note that this is inefficient since the section contents is calculated
twice. Future work will improve this.
This affects testPackOverlapMap() since the error is reported with a
different section size now (enough to hold the contents). Update that at
the same time.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman')
-rw-r--r-- | tools/binman/etype/section.py | 11 | ||||
-rw-r--r-- | tools/binman/ftest.py | 2 |
2 files changed, 5 insertions, 8 deletions
diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py index b146239..570dbfc 100644 --- a/tools/binman/etype/section.py +++ b/tools/binman/etype/section.py @@ -544,16 +544,13 @@ class Entry_section(Entry): def CheckSize(self): - """Check that the section contents does not exceed its size, etc.""" - contents_size = 0 - for entry in self._entries.values(): - contents_size = max(contents_size, entry.offset + entry.size) - - contents_size -= self._skip_at_start + data = self._BuildSectionData() + contents_size = len(data) size = self.size if not size: - size = self.pad_before + contents_size + self.pad_after + data = self.GetPaddedData() + size = len(data) size = tools.Align(size, self.align_size) if self.size and contents_size > self.size: diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 6f47dea..5bcdb70 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -2024,7 +2024,7 @@ class TestFunctional(unittest.TestCase): self.assertTrue(os.path.exists(map_fname)) map_data = tools.ReadFile(map_fname, binary=False) self.assertEqual('''ImagePos Offset Size Name -<none> 00000000 00000007 main-section +<none> 00000000 00000008 main-section <none> 00000000 00000004 u-boot <none> 00000003 00000004 u-boot-align ''', map_data) |