Abi Abi::armCdecl(llvm::Module* m, retdec_config::Architecture& a) { auto& ctx = m->getContext(); Abi ret; ret._module = m; ret._arch = a; ret._defaultType = getDefaultType(ret._module); ret._cc = retdec_config::CallingConvention::initCdecl(); ret._defaultAlignType = ret._defaultType; ret._stackDirection = eStackDirection::RIGHT_2_LEFT; ret._stackPointer = ret._module->getNamedGlobal("sp"); ret._parameterStartOffset = 0; ret._parameterStackAlignment = 4; ret._returnAddressReg = ret._module->getNamedGlobal("lr"); ret._typeToRetValInReg.emplace( Type::getInt32Ty(ctx), RegisterCouple( ret._module->getNamedGlobal("r0"))); ret._typeToRetValInReg.emplace( Type::getInt64Ty(ctx), RegisterCouple( ret._module->getNamedGlobal("r0"), ret._module->getNamedGlobal("r1"))); std::vector<RegisterCouple> i32Args = { RegisterCouple(ret._module->getNamedGlobal("r0")), RegisterCouple(ret._module->getNamedGlobal("r1")), RegisterCouple(ret._module->getNamedGlobal("r2")), RegisterCouple(ret._module->getNamedGlobal("r3")), }; ret._typeToArgumentRegs.emplace( Type::getInt32Ty(ctx), i32Args); std::vector<RegisterCouple> floatArgs = i32Args; ret._typeToArgumentRegs.emplace( Type::getFloatTy(ctx), floatArgs); std::vector<RegisterCouple> doubleArgs = { RegisterCouple( ret._module->getNamedGlobal("r0"), ret._module->getNamedGlobal("r1")), RegisterCouple( ret._module->getNamedGlobal("r2"), ret._module->getNamedGlobal("r3")) }; ret._typeToArgumentRegs.emplace( Type::getDoubleTy(ctx), doubleArgs); assert(ret._stackPointer); assert(ret._returnAddressReg); return ret; }
UInt64 ImageFileHandlerBase::store(Image const *pImage, Char8 const *mimeType, UChar8 *buffer, Int32 memSize ) { ImageFileType *type; type = mimeType ? getFileType(mimeType) : getDefaultType(); return type->store(pImage, buffer, memSize); }
UChar8 *ImageFileHandlerBase::store(Image const *pImage, UInt64 &memSize, Char8 const *mimeType) { ImageFileType *type = 0; UChar8 *mem = 0; type = mimeType ? getFileType(mimeType) : getDefaultType(); memSize = type->maxBufferSize(pImage); if(memSize) { mem = new UChar8[size_t(memSize)]; memSize = type->store(pImage, mem, Int32(memSize)); } else { FFATAL(("Can not store the image as %s\n", type->getMimeType())); } return mem; }
Abi Abi::x86Cdecl(llvm::Module* m, retdec_config::Architecture& a) { auto& ctx = m->getContext(); Abi ret; ret._module = m; ret._arch = a; ret._defaultType = getDefaultType(ret._module); ret._cc = retdec_config::CallingConvention::initCdecl(); ret._defaultAlignType = ret._defaultType; ret._stackDirection = eStackDirection::RIGHT_2_LEFT; ret._stackPointer = ret._module->getNamedGlobal("esp"); ret._parameterStartOffset = 0; ret._parameterStackAlignment = 4; ret._returnAddressStackOffset = 0; ret._typeToRetValInReg.emplace( Type::getInt32Ty(ctx), RegisterCouple( ret._module->getNamedGlobal("eax"))); ret._typeToRetValInReg.emplace( Type::getFloatTy(ctx), RegisterCouple( ret._module->getNamedGlobal("eax"))); ret._typeToRetValInReg.emplace( Type::getDoubleTy(ctx), RegisterCouple( ret._module->getNamedGlobal("eax"))); ret._typeToRetValInReg.emplace( Type::getInt64Ty(ctx), RegisterCouple( ret._module->getNamedGlobal("eax"), ret._module->getNamedGlobal("ecx"))); assert(ret._stackPointer); return ret; }