[docs]classSimData(Symbol):""" A SimData class is used to provide data when there is an unresolved data import symbol. To use it, subclass this class and implement the below attributes and methods. :cvar name: The name of the symbol to provide :cvar libname: The name of the library from which the symbol originally comes (currently unused). :cvar type: The type of the symbol, usually ``SymbolType.TYPE_OBJECT``. Use the below `register` method to register SimData subclasses with CLE. NOTE: SimData.type hides the Symbol.type instance property """name:str=NotImplementedtype:SymbolType=NotImplementedlibname:str=NotImplemented
[docs]@classmethoddefstatic_size(cls,owner)->int:""" Implement me: return the size of the symbol in bytes before it gets constructed :param owner: The ExternObject owning the symbol-to-be. Useful to get at ``owner.arch``. """returnNotImplemented
[docs]defvalue(self)->bytes:""" Implement me: the initial value of the bytes in memory for the symbol. Should return a bytestring of the same length as static_size returned. (owner is ``self.owner`` now) """returnNotImplemented
[docs]defrelocations(self)->list[Relocation]:""" Maybe implement me: If you like, return a list of relocation objects to apply. To create new import symbols, use ``self.owner.make_extern_import``. """return[]
registered_data=defaultdict(list)
[docs]defregister(simdata_cls:type[SimData]):""" Register the given SimData class with CLE so it may be used during loading """ifsimdata_cls.nameisNone:returnregistered_data[simdata_cls.name].append(simdata_cls)