section.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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._section.SetOffset(offset)
  36. self.size = self._section.GetSize()
  37. return super(Entry_section, self).Pack(offset)
  38. def SetImagePos(self, image_pos):
  39. Entry.SetImagePos(self, image_pos)
  40. self._section.SetImagePos(image_pos + self.offset)
  41. def WriteSymbols(self, section):
  42. """Write symbol values into binary files for access at run time"""
  43. self._section.WriteSymbols()
  44. def SetCalculatedProperties(self):
  45. Entry.SetCalculatedProperties(self)
  46. self._section.SetCalculatedProperties()
  47. def ProcessContents(self):
  48. self._section.ProcessEntryContents()
  49. super(Entry_section, self).ProcessContents()
  50. def CheckOffset(self):
  51. self._section.CheckEntries()
  52. def WriteMap(self, fd, indent):
  53. """Write a map of the section to a .map file
  54. Args:
  55. fd: File to write the map to
  56. """
  57. self._section.WriteMap(fd, indent)