// The EngineState structure encapsulates all of the persistent state
// of the CFM relocation engine virtual machine. I originally defined
// this structure so I could pass the state around between routines
// that implement various virtual opcodes, however I later worked
// out that the relocation was sufficiently simple that I could put it
// in in one routine. Still, I left the state in this structure in
// case I ever need to reverse that decision. It's also a convenient
// instructional design.
structEngineState{
UInt32currentReloc;// Index of current relocation opcodes
UInt32terminatingReloc;// Index of relocation opcodes which terminates relocation
UInt32*sectionBase;// Start of the section
UInt32*relocAddress;// Address within the section where the relocations are to be performed
UInt32importIndex;// Symbol index, which is used to access an imported symbol's address
void*sectionC;// Memory address of an instantiated section within the PEF container; this variable is used by relocation opcodes that relocate section addresses
void*sectionD;// Memory address of an instantiated section within the PEF container; this variable is used by relocation opcodes that relocate section addresses
};
typedefstructEngineStateEngineState;
// Note:
// If I ever have to support the repeat opcodes, I'll probably