]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
binman: Refuse to replace sections for now
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>
Sun, 27 Mar 2022 15:31:50 +0000 (18:31 +0300)
committerTom Rini <trini@konsulko.com>
Mon, 25 Apr 2022 14:11:05 +0000 (10:11 -0400)
Binman interfaces allow attempts to replace any entry in the image with
arbitrary data. When trying to replace sections, the changes in the
section entry's data are not propagated to its child entries. This,
combined with how sections rebuild their contents from its children,
eventually causes the replaced contents to be silently overwritten by
rebuilt contents equivalent to the original data.

Add a simple test for replacing a section that is currently failing due
to this behaviour, and mark it as an expected failure. Also, raise an
error when replacing a section instead of silently pretending it was
replaced.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
tools/binman/etype/section.py
tools/binman/ftest.py
tools/binman/test/234_replace_section_simple.dts [new file with mode: 0644]

index ccac658c1831b6813fa688da42fe8bc9ff1e0e9b..bd67238b919963c080b731f4113f078df360e409 100644 (file)
@@ -788,6 +788,9 @@ class Entry_section(Entry):
                 data = new_data
         return data
 
+    def WriteData(self, data, decomp=True):
+        self.Raise("Replacing sections is not implemented yet")
+
     def WriteChildData(self, child):
         return True
 
index 421754b1d0a8f9b2319e721182fcf3c69df3d446..b5cf549703ad2d6ef140b5b13ca44de359a59366 100644 (file)
@@ -5693,6 +5693,15 @@ fdt         fdtmap                Extract the devicetree blob from the fdtmap
         self.assertIsNotNone(path)
         self.assertEqual(expected_fdtmap, fdtmap)
 
+    @unittest.expectedFailure
+    def testReplaceSectionSimple(self):
+        """Test replacing a simple section with arbitrary data"""
+        new_data = b'w' * len(COMPRESS_DATA + U_BOOT_DATA)
+        data, expected_fdtmap, _ = self._RunReplaceCmd(
+            'section', new_data,
+            dts='234_replace_section_simple.dts')
+        self.assertEqual(new_data, data)
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/234_replace_section_simple.dts b/tools/binman/test/234_replace_section_simple.dts
new file mode 100644 (file)
index 0000000..c9d5c32
--- /dev/null
@@ -0,0 +1,23 @@
+// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+
+/ {
+       binman {
+               allow-repack;
+
+               u-boot-dtb {
+               };
+
+               section {
+                       blob {
+                               filename = "compress";
+                       };
+
+                       u-boot {
+                       };
+               };
+
+               fdtmap {
+               };
+       };
+};