コード例 #1
0
    def GetPaddedDataForEntry(self, entry, entry_data):
        """Get the data for an entry including any padding

        Gets the entry data and uses the section pad-byte value to add padding
        before and after as defined by the pad-before and pad-after properties.
        This does not consider alignment.

        Args:
            entry: Entry to check

        Returns:
            Contents of the entry along with any pad bytes before and
            after it (bytes)
        """
        pad_byte = (entry._pad_byte if isinstance(entry, Entry_section)
                    else self._pad_byte)

        data = bytearray()
        # Handle padding before the entry
        if entry.pad_before:
            data += tools.GetBytes(self._pad_byte, entry.pad_before)

        # Add in the actual entry data
        data += entry_data

        # Handle padding after the entry
        if entry.pad_after:
            data += tools.GetBytes(self._pad_byte, entry.pad_after)

        if entry.size:
            data += tools.GetBytes(pad_byte, entry.size - len(data))

        self.Detail('GetPaddedDataForEntry: size %s' % ToHexSize(self.data))

        return data
コード例 #2
0
    def GetData(self):
        """Get the contents of an entry

        Returns:
            bytes content of the entry, excluding any padding. If the entry is
                compressed, the compressed data is returned
        """
        self.Detail('GetData: size %s' % ToHexSize(self.data))
        return self.data
コード例 #3
0
    def GetData(self, required=True):
        """Get the contents of an entry

        Args:
            required: True if the data must be present, False if it is OK to
                return None

        Returns:
            bytes content of the entry, excluding any padding. If the entry is
                compressed, the compressed data is returned
        """
        self.Detail('GetData: size %s' % ToHexSize(self.data))
        return self.data
コード例 #4
0
ファイル: fmap.py プロジェクト: wildlywasp/u-boot-amlogic
 def _AddEntries(areas, entry):
     entries = entry.GetEntries()
     tout.Debug("fmap: Add entry '%s' type '%s' (%s subentries)" %
                (entry.GetPath(), entry.etype, ToHexSize(entries)))
     if entries and entry.etype != 'cbfs':
         for subentry in entries.values():
             _AddEntries(areas, subentry)
     else:
         pos = entry.image_pos
         if pos is not None:
             pos -= entry.section.GetRootSkipAtStart()
         areas.append(
             fmap_util.FmapArea(pos or 0, entry.size or 0,
                                tools.FromUnicode(entry.name), 0))
コード例 #5
0
        def _AddEntries(areas, entry):
            entries = entry.GetEntries()
            tout.Debug("fmap: Add entry '%s' type '%s' (%s subentries)" %
                       (entry.GetPath(), entry.etype, ToHexSize(entries)))
            if entries and entry.etype != 'cbfs':
                # Create an area for the section, which encompasses all entries
                # within it
                if entry.image_pos is None:
                    pos = 0
                else:
                    pos = entry.image_pos - entry.GetRootSkipAtStart()

                # Drop @ symbols in name
                name = entry.name.replace('@', '')
                areas.append(fmap_util.FmapArea(pos, entry.size or 0, name, 0))
                for subentry in entries.values():
                    _AddEntries(areas, subentry)
            else:
                pos = entry.image_pos
                if pos is not None:
                    pos -= entry.section.GetRootSkipAtStart()
                areas.append(
                    fmap_util.FmapArea(pos or 0, entry.size or 0, entry.name,
                                       0))
コード例 #6
0
 def GetData(self):
     self.Detail('GetData: size %s' % ToHexSize(self.data))
     return self.data