u_boot_spl_bss_pad.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # SPDX-License-Identifier: GPL-2.0+
  2. # Copyright (c) 2016 Google, Inc
  3. # Written by Simon Glass <sjg@chromium.org>
  4. #
  5. # Entry-type module for BSS padding for spl/u-boot-spl.bin. This padding
  6. # can be added after the SPL binary to ensure that anything concatenated
  7. # to it will appear to SPL to be at the end of BSS rather than the start.
  8. #
  9. import command
  10. import elf
  11. from entry import Entry
  12. from blob import Entry_blob
  13. import tools
  14. class Entry_u_boot_spl_bss_pad(Entry_blob):
  15. """U-Boot SPL binary padded with a BSS region
  16. Properties / Entry arguments:
  17. None
  18. This is similar to u_boot_spl except that padding is added after the SPL
  19. binary to cover the BSS (Block Started by Symbol) region. This region holds
  20. the various used by SPL. It is set to 0 by SPL when it starts up. If you
  21. want to append data to the SPL image (such as a device tree file), you must
  22. pad out the BSS region to avoid the data overlapping with U-Boot variables.
  23. This entry is useful in that case. It automatically pads out the entry size
  24. to cover both the code, data and BSS.
  25. The ELF file 'spl/u-boot-spl' must also be available for this to work, since
  26. binman uses that to look up the BSS address.
  27. """
  28. def __init__(self, section, etype, node):
  29. Entry_blob.__init__(self, section, etype, node)
  30. def ObtainContents(self):
  31. fname = tools.GetInputFilename('spl/u-boot-spl')
  32. bss_size = elf.GetSymbolAddress(fname, '__bss_size')
  33. if not bss_size:
  34. self.Raise('Expected __bss_size symbol in spl/u-boot-spl')
  35. self.SetContents(tools.GetBytes(0, bss_size))
  36. return True