]> git.sur5r.net Git - u-boot/blob - tools/binman/etype/section.py
binman: Add support for outputing a map file
[u-boot] / tools / binman / etype / section.py
1 # SPDX-License-Identifier:      GPL-2.0+
2 # Copyright (c) 2018 Google, Inc
3 # Written by Simon Glass <sjg@chromium.org>
4 #
5 # Entry-type module for sections, which are entries which can contain other
6 # entries.
7 #
8
9 from entry import Entry
10 import fdt_util
11 import tools
12
13 import bsection
14
15 class Entry_section(Entry):
16     def __init__(self, image, etype, node):
17         Entry.__init__(self, image, etype, node)
18         self._section = bsection.Section(node.name, node)
19
20     def ObtainContents(self):
21         self._section.GetEntryContents()
22
23     def GetData(self):
24         return self._section.GetData()
25
26     def GetPositions(self):
27         """Handle entries that want to set the position/size of other entries
28
29         This calls each entry's GetPositions() method. If it returns a list
30         of entries to update, it updates them.
31         """
32         self._section.GetEntryPositions()
33         return {}
34
35     def Pack(self, pos):
36         """Pack all entries into the section"""
37         self._section.PackEntries()
38         self.size = self._section.CheckSize()
39         return super(Entry_section, self).Pack(pos)
40
41     def WriteSymbols(self, section):
42         """Write symbol values into binary files for access at run time"""
43         self._section.WriteSymbols()
44
45     def ProcessContents(self):
46         self._section.ProcessEntryContents()
47         super(Entry_section, self).ProcessContents()
48
49     def CheckPosition(self):
50         self._section.CheckEntries()
51
52     def WriteMap(self, fd, indent):
53         """Write a map of the section to a .map file
54
55         Args:
56             fd: File to write the map to
57         """
58         super(Entry_section, self).WriteMap(fd, indent)
59         self._section.WriteMap(fd, indent + 1)