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
def make_import(self, name, sym_type): if name not in self.imports: sym = Symbol(self, name, 0, 0, sym_type) sym.is_import = True sym.is_extern = True # this is kind of tricky... normally if you have an import and an export of the same name in the binary # the two symbols are *the same symbol*, usually with a copy relocation. but we don't know ahead of time # whether we will have the symbol here in externs, so we will not expose the import symbol to the rest of # the world. self._import_symbols[name] = sym return sym else: sym = self._import_symbols[name] if sym.type != sym_type: raise CLEOperationError("Created the same extern import %s with two different types. Something isn't right!") return sym
def offset_to_addr(self, offset): raise CLEOperationError("'offset' operations on the extern object are meaningless as it is not mapped from a file")