[v2,18/49] binman: Allow zero-length entries to overlap

Message ID 20200613205717.v2.18.I901f650cdf1d4df8805e6fe62646327e258f60e2@changeid
State Accepted
Commit 8200d8871a6a87834e26e38ca5cd475f86733dfd
Headers show
Series
  • rockchip: x86: Support building ROM files automatically with binman
Related show

Commit Message

Simon Glass June 14, 2020, 2:56 a.m.
Some binary blobs unfortunately obtain their position in the image from
other binary blobs, such as Intel's 'descriptor'. In this case we cannot
rely on packing to work. It is not possible to produce a valid image in
any case, due to the missing blobs.

Allow zero-length overlaps so that this does not cause any problems.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

 tools/binman/etype/section.py               |  2 +-
 tools/binman/ftest.py                       |  4 ++++
 tools/binman/test/160_pack_overlap_zero.dts | 18 ++++++++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 tools/binman/test/160_pack_overlap_zero.dts

Comments

Bin Meng June 29, 2020, 6:54 a.m. | #1
On Sun, Jun 14, 2020 at 10:57 AM Simon Glass <sjg at chromium.org> wrote:
>
> Some binary blobs unfortunately obtain their position in the image from
> other binary blobs, such as Intel's 'descriptor'. In this case we cannot
> rely on packing to work. It is not possible to produce a valid image in
> any case, due to the missing blobs.
>
> Allow zero-length overlaps so that this does not cause any problems.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> (no changes since v1)
>
>  tools/binman/etype/section.py               |  2 +-
>  tools/binman/ftest.py                       |  4 ++++
>  tools/binman/test/160_pack_overlap_zero.dts | 18 ++++++++++++++++++
>  3 files changed, 23 insertions(+), 1 deletion(-)
>  create mode 100644 tools/binman/test/160_pack_overlap_zero.dts
>

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>

Patch

diff --git a/tools/binman/etype/section.py b/tools/binman/etype/section.py
index 99c505b49b..7563cff5ea 100644
--- a/tools/binman/etype/section.py
+++ b/tools/binman/etype/section.py
@@ -221,7 +221,7 @@  class Entry_section(Entry):
                             "at %#x (%d)" %
                             (entry.offset, entry.offset, self._skip_at_start,
                              self._skip_at_start))
-            if entry.offset < offset:
+            if entry.offset < offset and entry.size:
                 entry.Raise("Offset %#x (%d) overlaps with previous entry '%s' "
                             "ending at %#x (%d)" %
                             (entry.offset, entry.offset, prev_name, offset, offset))
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 146d4c51d3..614ac4ed39 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -3421,6 +3421,10 @@  class TestFunctional(unittest.TestCase):
         err = stderr.getvalue()
         self.assertRegex(err, "Image 'main-section'.*missing.*: intel-ifwi")
 
+    def testPackOverlap(self):
+        """Test that zero-size overlapping regions are ignored"""
+        self._DoTestFile('160_pack_overlap_zero.dts')
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/160_pack_overlap_zero.dts b/tools/binman/test/160_pack_overlap_zero.dts
new file mode 100644
index 0000000000..731aa1cbe6
--- /dev/null
+++ b/tools/binman/test/160_pack_overlap_zero.dts
@@ -0,0 +1,18 @@ 
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		u-boot {
+		};
+
+		fill {
+			size = <0>;
+			offset = <3>;
+		};
+	};
+};