binman: Convert Image to a subclass of Entry

When support for sections (and thus hierarchical images) was added to
binman, the decision was made to create a new Section class which could
be used by both Image and an Entry_section class. The decision between
using inheritance and composition was tricky to make, but in the end it
was decided that Image was different enough from Entry that it made sense
to put the implementation of sections in an entirely separate class. It
also has the advantage that core Image code does have to rely on an entry
class in the etype directory.

This work was mostly completed in commit:

   8f1da50ccc "binman: Refactor much of the image code into 'section'

As a result of this, the Section class has its own version of things like
offset and size and these must be kept in sync with the parent
Entry_section class in some cases.

In the last year it has become apparent that the cost of keeping things in
sync is larger than expected, since more and more code wants to access
these properties.

An alternative approach, previously considered and rejected, now seems
better.

Adjust Image to be a subclass of Entry_section. Move the code from Section
(in bsection.py) to Entry_section and delete Section. Update all tests
accordingly.

This requires substantial changes to Image. Overall the changes reduce
code size by about 240 lines. While much of that is just boilerplate from
Section, there are quite a few functions in Entry_section which now do not
need to be overiden from Entry. This suggests the change is beneficial
even without further functionality being added.

A side benefit is that the properties of sections are now consistent with
other entries. This fixes a problem in testListCmd() where some properties
are missing for sections.

Unfortunately this is a very large commit since it is not feasible to do
the migration piecemeal. Given the substantial tests available and the
100% code coverage of binman, we should be able to do this safely.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/binman/image_test.py b/tools/binman/image_test.py
index 3775e1a..4004f78 100644
--- a/tools/binman/image_test.py
+++ b/tools/binman/image_test.py
@@ -12,28 +12,25 @@
 class TestImage(unittest.TestCase):
     def testInvalidFormat(self):
         image = Image('name', 'node', test=True)
-        section = image._section
         with self.assertRaises(ValueError) as e:
-            section.LookupSymbol('_binman_something_prop_', False, 'msg')
+            image.LookupSymbol('_binman_something_prop_', False, 'msg')
         self.assertIn(
             "msg: Symbol '_binman_something_prop_' has invalid format",
             str(e.exception))
 
     def testMissingSymbol(self):
         image = Image('name', 'node', test=True)
-        section = image._section
-        section._entries = {}
+        image._entries = {}
         with self.assertRaises(ValueError) as e:
-            section.LookupSymbol('_binman_type_prop_pname', False, 'msg')
+            image.LookupSymbol('_binman_type_prop_pname', False, 'msg')
         self.assertIn("msg: Entry 'type' not found in list ()",
                       str(e.exception))
 
     def testMissingSymbolOptional(self):
         image = Image('name', 'node', test=True)
-        section = image._section
-        section._entries = {}
+        image._entries = {}
         with capture_sys_output() as (stdout, stderr):
-            val = section.LookupSymbol('_binman_type_prop_pname', True, 'msg')
+            val = image.LookupSymbol('_binman_type_prop_pname', True, 'msg')
         self.assertEqual(val, None)
         self.assertEqual("Warning: msg: Entry 'type' not found in list ()\n",
                          stderr.getvalue())
@@ -41,8 +38,7 @@
 
     def testBadProperty(self):
         image = Image('name', 'node', test=True)
-        section = image._section
-        section._entries = {'u-boot': 1}
+        image._entries = {'u-boot': 1}
         with self.assertRaises(ValueError) as e:
-            section.LookupSymbol('_binman_u_boot_prop_bad', False, 'msg')
+            image.LookupSymbol('_binman_u_boot_prop_bad', False, 'msg')
         self.assertIn("msg: No such property 'bad", str(e.exception))