Ejemplo n.º 1
0
    def _allocate(self, size=1, alignment=8, thumb=False, tls=False):
        if tls:
            start = self.tls_next_addr
            limit = self.tls_data_size
        else:
            start = self.next_addr
            limit = self.map_size

        addr = ALIGN_UP(start, alignment) | thumb
        next_start = addr + size
        if next_start >= limit:
            if self._is_mapped:
                return None
            else:
                if tls:
                    self.tls_data_size += next_start - limit
                else:
                    self.map_size += next_start - limit

        if tls:
            self.tls_next_addr = next_start
            return addr
        else:
            self.next_addr = next_start
            return addr
Ejemplo n.º 2
0
    def allocate(self, size=1, alignment=8, thumb=False, tls=False):
        if tls:
            if not self.tls_used:
                self.tls_data_start = self.allocate(
                    self.tls_data_size) - self.mapped_base
                self.tls_used = True
                self.loader.tls_object.register_object(self)
            start = self.tls_next_addr
            limit = self.tls_data_size
        else:
            start = self.next_addr
            limit = self.map_size

        addr = ALIGN_UP(start, alignment) | thumb
        next_start = addr + size
        if next_start >= limit:
            raise CLEOperationError(
                "Ran out of room in the extern object...! Report this as a bug."
            )

        if tls:
            self.tls_next_addr = next_start
            return addr
        else:
            self.next_addr = next_start
            return addr + self.mapped_base