From 71d88b4e5cf084b5b156b23717e9c54fe83646ea Mon Sep 17 00:00:00 2001 From: Zhang Date: Mon, 25 Dec 2017 12:17:52 +0000 Subject: [PATCH] [AntiClassDump]FHandle 64/32bit Method Signature --- lib/Transforms/Obfuscation/AntiClassDump.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/Transforms/Obfuscation/AntiClassDump.cpp b/lib/Transforms/Obfuscation/AntiClassDump.cpp index 2249537bd..316c55712 100644 --- a/lib/Transforms/Obfuscation/AntiClassDump.cpp +++ b/lib/Transforms/Obfuscation/AntiClassDump.cpp @@ -445,7 +445,18 @@ struct AntiClassDump : public ModulePass { //See http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?revision=320954&view=markup //ASTContext::getObjCEncodingForMethodDecl //The one hard-coded here is generated for macOS 64Bit - Constant *MethType=cast(IRB->CreateGlobalStringPtr("v16@0:8")); + Triple tri=Triple(M->getTargetTriple()); + Constant *MethType=NULL; + if(tri.isOSDarwin () && tri.isArch64Bit()){ + MethType=cast(IRB->CreateGlobalStringPtr("v16@0:8")); + } + else if(tri.isOSDarwin () && tri.isArch32Bit()){ + MethType=cast(IRB->CreateGlobalStringPtr("v8@0:4")); + } + else{ + errs()<<"Unknown Platform.Blindly applying method signature for macOS 64Bit\n"; + MethType=cast(IRB->CreateGlobalStringPtr("v16@0:8")); + } Constant *BitCastedIMP=cast(IRB->CreateBitCast(IRB->GetInsertBlock()->getParent(),objc_getClass->getFunctionType()->getParamType(0))); vector methodStructContents;//{GEP(NAME),GEP(TYPE),IMP} methodStructContents.push_back(MethName); @@ -480,7 +491,6 @@ struct AntiClassDump : public ModulePass { values.push_back(metadatacompilerusedlist->getOperand(i)); } } - //values.push_back(ConstantExpr::getBitCast(newMethodStructGV,Type::getInt8PtrTy(M->getContext()))); ArrayType *newmetadatatype=ArrayType::get(oldmetadatatype->getElementType (),values.size()); Constant* newused=ConstantArray::get(newmetadatatype,ArrayRef(values)); metadatacompilerusedGV->dropAllReferences();