section.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. from entry import Entry
  9. import fdt_util
  10. import tools
  11. import bsection
  12. class Entry_section(Entry):
  13. def __init__(self, image, etype, node):
  14. Entry.__init__(self, image, etype, node)
  15. self._section = bsection.Section(node.name, node)
  16. def ProcessFdt(self, fdt):
  17. return self._section.ProcessFdt(fdt)
  18. def AddMissingProperties(self):
  19. Entry.AddMissingProperties(self)
  20. self._section.AddMissingProperties()
  21. def ObtainContents(self):
  22. return self._section.GetEntryContents()
  23. def GetData(self):
  24. return self._section.GetData()
  25. def GetOffsets(self):
  26. """Handle entries that want to set the offset/size of other entries
  27. This calls each entry's GetOffsets() method. If it returns a list
  28. of entries to update, it updates them.
  29. """
  30. self._section.GetEntryOffsets()
  31. return {}
  32. def Pack(self, offset):
  33. """Pack all entries into the section"""
  34. self._section.PackEntries()
  35. self.size = self._section.CheckSize()
  36. return super(Entry_section, self).Pack(offset)
  37. def WriteSymbols(self, section):
  38. """Write symbol values into binary files for access at run time"""
  39. self._section.WriteSymbols()
  40. def SetCalculatedProperties(self):
  41. Entry.SetCalculatedProperties(self)
  42. self._section.SetCalculatedProperties()
  43. def ProcessContents(self):
  44. self._section.ProcessEntryContents()
  45. super(Entry_section, self).ProcessContents()
  46. def CheckOffset(self):
  47. self._section.CheckEntries()
  48. def WriteMap(self, fd, indent):
  49. """Write a map of the section to a .map file
  50. Args:
  51. fd: File to write the map to
  52. """
  53. super(Entry_section, self).WriteMap(fd, indent)
  54. self._section.WriteMap(fd, indent + 1)