def __init__(self, name=None, section_type=SHT_NULL, address=0, data=None, flags=0, addralign=0, entsize=0, info=0, link=None, symbols=None): self.address = address self.type = section_type self._name = name self.flags = flags self.addralign = addralign self.entsize = entsize self.info = info self.link = link self._backlinks = [] self._in_segment_offset = None self._in_segment = False if symbols is None: self.symbols = [] else: self.symbols = symbols for sym in self.symbols: sym.section = self # If the section is a 'NOBITS' section, then it just has size, and # no real data. So _data, may be an integer or a ByteArray depending # on the different circumstance if data is None: if section_type == SHT_NOBITS: self._data = 0 else: self._data = ByteArray() else: self._data = data if section_type == SHT_NOBITS: assert is_integer(self._data) else: assert self._data.__class__ == ByteArray
def set_size(self, size): """Set the size of this section. If this size is greater than the current size then it will be zero-filled. Size can not be extended on prepared files.""" if size > self.get_size(): raise InvalidArgument, "Cannot extend prepared section" if self.type == SHT_NOBITS: assert is_integer(size) self._data = size else: self.data_trim(0, size)
def set_size(self, size): """Set the size of this section. If this size is greater than the current size then it will be zero-filled. Size can not be extended on prepared files.""" if self.type == SHT_NOBITS: assert is_integer(size) self._data = size else: if size < len(self._data): self.data_trim(0, size) else: self.data_append((size - len(self._data))*[0])
def set_size(self, size): """Set the size of this section. If this size is greater than the current size then it will be zero-filled. Size can not be extended on prepared files.""" if self.type == SHT_NOBITS: assert is_integer(size) self._data = size else: if size < len(self._data): self.data_trim(0, size) else: self.data_append((size - len(self._data)) * [0])