u-boot-brain/tools/binman/etype/section.py
Simon Glass 3ab9598df7 binman: Rename 'position' to 'offset'
After some thought, I believe there is an unfortunate naming flaw in
binman. Entries have a position and size, but now that we support
hierarchical sections it is unclear whether a position should be an
absolute position within the image, or a relative position within its
parent section.

At present 'position' actually means the relative position. This indicates
a need for an 'image position' for code that wants to find the location of
an entry without having to do calculations back through parents to
discover this image position.

A better name for the current 'position' or 'pos' is 'offset'. It is not
always an absolute position, but it is always an offset from its parent
offset.

It is unfortunate to rename this concept now, 18 months after binman was
introduced. However I believe it is the right thing to do. The impact is
mostly limited to binman itself and a few changes to in-tree users to
binman:

   tegra
   sunxi
   x86

The change makes old binman definitions (e.g. downstream or out-of-tree)
incompatible if they use the 'pos = <...>' property. Later work will
adjust binman to generate an error when it is used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2018-08-01 16:30:06 -06:00

71 lines
2.0 KiB
Python

# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2018 Google, Inc
# Written by Simon Glass <sjg@chromium.org>
#
# Entry-type module for sections, which are entries which can contain other
# entries.
#
from entry import Entry
import fdt_util
import tools
import bsection
class Entry_section(Entry):
def __init__(self, image, etype, node):
Entry.__init__(self, image, etype, node)
self._section = bsection.Section(node.name, node)
def ProcessFdt(self, fdt):
return self._section.ProcessFdt(fdt)
def AddMissingProperties(self):
Entry.AddMissingProperties(self)
self._section.AddMissingProperties()
def ObtainContents(self):
return self._section.GetEntryContents()
def GetData(self):
return self._section.GetData()
def GetOffsets(self):
"""Handle entries that want to set the offset/size of other entries
This calls each entry's GetOffsets() method. If it returns a list
of entries to update, it updates them.
"""
self._section.GetEntryOffsets()
return {}
def Pack(self, offset):
"""Pack all entries into the section"""
self._section.PackEntries()
self.size = self._section.CheckSize()
return super(Entry_section, self).Pack(offset)
def WriteSymbols(self, section):
"""Write symbol values into binary files for access at run time"""
self._section.WriteSymbols()
def SetCalculatedProperties(self):
Entry.SetCalculatedProperties(self)
self._section.SetCalculatedProperties()
def ProcessContents(self):
self._section.ProcessEntryContents()
super(Entry_section, self).ProcessContents()
def CheckOffset(self):
self._section.CheckEntries()
def WriteMap(self, fd, indent):
"""Write a map of the section to a .map file
Args:
fd: File to write the map to
"""
super(Entry_section, self).WriteMap(fd, indent)
self._section.WriteMap(fd, indent + 1)