[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-6156-g094ec9b
Török Edvin
edwin at clamav.net
Sun Apr 4 01:27:40 UTC 2010
The following commit has been merged in the debian/unstable branch:
commit 556eaf0442122805c646a9549923a62bafe6f2fa
Author: Török Edvin <edwin at clamav.net>
Date: Tue Mar 30 23:22:23 2010 +0300
Update ClamBCRTChecks.cpp from bytecode compiler:
Check bounds of each pointer passed to/from APIcalls,
forbid recursion.
diff --git a/libclamav/c++/ClamBCRTChecks.cpp b/libclamav/c++/ClamBCRTChecks.cpp
index bac1bda..791cb86 100644
--- a/libclamav/c++/ClamBCRTChecks.cpp
+++ b/libclamav/c++/ClamBCRTChecks.cpp
@@ -21,8 +21,12 @@
*/
#define DEBUG_TYPE "clambc-rtcheck"
#include "ClamBCModule.h"
+#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/PostOrderIterator.h"
+#include "llvm/ADT/SCCIterator.h"
+#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/Verifier.h"
+#include "llvm/Analysis/DebugInfo.h"
#include "llvm/Analysis/Dominators.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/LiveValues.h"
@@ -35,6 +39,7 @@
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/Intrinsics.h"
+#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
@@ -52,9 +57,12 @@ using namespace llvm;
namespace {
class PtrVerifier : public FunctionPass {
+ private:
+ DenseSet<Function*> badFunctions;
+ CallGraphNode *rootNode;
public:
static char ID;
- PtrVerifier() : FunctionPass((intptr_t)&ID) {}
+ PtrVerifier() : FunctionPass((intptr_t)&ID),rootNode(0) {}
virtual bool runOnFunction(Function &F) {
DEBUG(F.dump());
@@ -64,6 +72,32 @@ namespace {
AbrtBB = 0;
valid = true;
+ if (!rootNode) {
+ rootNode = getAnalysis<CallGraph>().getRoot();
+ // No recursive functions for now.
+ // In the future we may insert runtime checks for stack depth.
+ for (scc_iterator<CallGraphNode*> SCCI = scc_begin(rootNode),
+ E = scc_end(rootNode); SCCI != E; ++SCCI) {
+ const std::vector<CallGraphNode*> &nextSCC = *SCCI;
+ if (nextSCC.size() > 1 || SCCI.hasLoop()) {
+ errs() << "INVALID: Recursion detected, callgraph SCC components: ";
+ for (std::vector<CallGraphNode*>::const_iterator I = nextSCC.begin(),
+ E = nextSCC.end(); I != E; ++I) {
+ Function *FF = (*I)->getFunction();
+ if (FF) {
+ errs() << FF->getName() << ", ";
+ badFunctions.insert(FF);
+ }
+ }
+ if (SCCI.hasLoop())
+ errs() << "(self-loop)";
+ errs() << "\n";
+ }
+ // we could also have recursion via function pointers, but we don't
+ // allow calls to unknown functions, see runOnFunction() below
+ }
+ }
+
BasicBlock::iterator It = F.getEntryBlock().begin();
while (isa<AllocaInst>(It) || isa<PHINode>(It)) ++It;
EP = &*It;
@@ -79,6 +113,19 @@ namespace {
Instruction *II = &*I;
if (isa<LoadInst>(II) || isa<StoreInst>(II) || isa<MemIntrinsic>(II))
insns.push_back(II);
+ if (CallInst *CI = dyn_cast<CallInst>(II)) {
+ Value *V = CI->getCalledValue()->stripPointerCasts();
+ Function *F = dyn_cast<Function>(V);
+ if (!F) {
+ printLocation(errs(), CI);
+ errs() << "Could not determine call target\n";
+ valid = 0;
+ continue;
+ }
+ if (!F->isDeclaration())
+ continue;
+ insns.push_back(CI);
+ }
}
while (!insns.empty()) {
Instruction *II = insns.back();
@@ -97,8 +144,46 @@ namespace {
if (MemTransferInst *MTI = dyn_cast<MemTransferInst>(MI)) {
valid &= validateAccess(MTI->getSource(), MI->getLength(), MI);
}
+ } else if (CallInst *CI = dyn_cast<CallInst>(II)) {
+ Value *V = CI->getCalledValue()->stripPointerCasts();
+ Function *F = cast<Function>(V);
+ const FunctionType *FTy = F->getFunctionType();
+ if (F->getName().equals("memcmp") && FTy->getNumParams() == 3) {
+ valid &= validateAccess(CI->getOperand(1), CI->getOperand(3), CI);
+ valid &= validateAccess(CI->getOperand(2), CI->getOperand(3), CI);
+ continue;
+ }
+ unsigned i;
+#ifdef CLAMBC_COMPILER
+ i = 0;
+#else
+ i = 1;// skip hidden ctx*
+#endif
+ for (;i<FTy->getNumParams();i++) {
+ if (isa<PointerType>(FTy->getParamType(i))) {
+ Value *Ptr = CI->getOperand(i+1);
+ if (i+1 >= FTy->getNumParams()) {
+ printLocation(errs(), CI);
+ errs() << "Call to external function with pointer parameter last cannot be analyzed\n";
+ errs() << *CI << "\n";
+ valid = 0;
+ break;
+ }
+ Value *Size = CI->getOperand(i+2);
+ if (!Size->getType()->isIntegerTy()) {
+ printLocation(errs(), CI);
+ errs() << "Pointer argument must be followed by integer argument representing its size\n";
+ errs() << *CI << "\n";
+ valid = 0;
+ break;
+ }
+ valid &= validateAccess(Ptr, Size, CI);
+ }
+ }
}
}
+ if (badFunctions.count(&F))
+ valid = 0;
if (!valid) {
DEBUG(F.dump());
@@ -125,16 +210,20 @@ namespace {
BBI->replaceAllUsesWith(UndefValue::get(BBI->getType()));
BB->getInstList().erase(BBI++);
}
- DEBUG(F.dump());
}
return Changed;
}
+ virtual void releaseMemory() {
+ badFunctions.clear();
+ }
+
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<TargetData>();
AU.addRequired<DominatorTree>();
AU.addRequired<ScalarEvolution>();
AU.addRequired<PointerTracking>();
+ AU.addRequired<CallGraph>();
}
bool isValid() const { return valid; }
@@ -190,6 +279,18 @@ namespace {
}
return newPN;
}
+ if (SelectInst *SI = dyn_cast<SelectInst>(Ptr)) {
+ BasicBlock::iterator It = SI;
+ ++It;
+ Value *TrueB = getPointerBase(SI->getTrueValue());
+ Value *FalseB = getPointerBase(SI->getFalseValue());
+ if (TrueB && FalseB) {
+ SelectInst *NewSI = SelectInst::Create(SI->getCondition(), TrueB,
+ FalseB, ".select.base", &*It);
+ Changed = true;
+ return BaseMap[Ptr] = NewSI;
+ }
+ }
if (Ptr->getType() != P8Ty) {
if (Constant *C = dyn_cast<Constant>(Ptr))
Ptr = ConstantExpr::getPointerCast(C, P8Ty);
@@ -206,6 +307,26 @@ namespace {
return BoundsMap[Base];
const Type *I64Ty =
Type::getInt64Ty(Base->getContext());
+#ifndef CLAMBC_COMPILER
+ // first arg is hidden ctx
+ if (Argument *A = dyn_cast<Argument>(Base)) {
+ if (A->getArgNo() == 0) {
+ const Type *Ty = cast<PointerType>(A->getType())->getElementType();
+ return ConstantInt::get(I64Ty, TD->getTypeAllocSize(Ty));
+ }
+ }
+ if (LoadInst *LI = dyn_cast<LoadInst>(Base)) {
+ Value *V = LI->getPointerOperand()->stripPointerCasts()->getUnderlyingObject();
+ if (Argument *A = dyn_cast<Argument>(V)) {
+ if (A->getArgNo() == 0) {
+ // pointers from hidden ctx are trusted to be at least the
+ // size they say they are
+ const Type *Ty = cast<PointerType>(LI->getType())->getElementType();
+ return ConstantInt::get(I64Ty, TD->getTypeAllocSize(Ty));
+ }
+ }
+ }
+#endif
if (PHINode *PN = dyn_cast<PHINode>(Base)) {
BasicBlock::iterator It = PN;
++It;
@@ -219,7 +340,7 @@ namespace {
Value *B = getPointerBounds(Inc);
if (!B) {
good = false;
- B = ConstantInt::get(PN->getType(), 0);
+ B = ConstantInt::get(newPN->getType(), 0);
DEBUG(dbgs() << "bounds not found while solving phi node: " << *Inc
<< "\n");
}
@@ -229,6 +350,18 @@ namespace {
newPN = 0;
return BoundsMap[Base] = newPN;
}
+ if (SelectInst *SI = dyn_cast<SelectInst>(Base)) {
+ BasicBlock::iterator It = SI;
+ ++It;
+ Value *TrueB = getPointerBounds(SI->getTrueValue());
+ Value *FalseB = getPointerBounds(SI->getFalseValue());
+ if (TrueB && FalseB) {
+ SelectInst *NewSI = SelectInst::Create(SI->getCondition(), TrueB,
+ FalseB, ".select.bounds", &*It);
+ Changed = true;
+ return BoundsMap[Base] = NewSI;
+ }
+ }
const Type *Ty;
Value *V = PT->computeAllocationCountValue(Base, Ty);
@@ -236,20 +369,24 @@ namespace {
Base = Base->stripPointerCasts();
if (CallInst *CI = dyn_cast<CallInst>(Base)) {
Function *F = CI->getCalledFunction();
- if (F && F->getName().equals("malloc") && F->getFunctionType()->getNumParams() == 2) {
- V = CI->getOperand(2);
- }
+ const FunctionType *FTy = F->getFunctionType();
+ // last operand is always size for this API call kind
+ if (F->isDeclaration() && FTy->getNumParams() > 0) {
+ if (FTy->getParamType(FTy->getNumParams()-1)->isIntegerTy())
+ V = CI->getOperand(FTy->getNumParams());
+ }
}
if (!V)
return BoundsMap[Base] = 0;
- }
- unsigned size = TD->getTypeAllocSize(Ty);
- if (size > 1) {
- Constant *C = cast<Constant>(V);
- C = ConstantExpr::getMul(C,
- ConstantInt::get(Type::getInt32Ty(C->getContext()),
- size));
- V = C;
+ } else {
+ unsigned size = TD->getTypeAllocSize(Ty);
+ if (size > 1) {
+ Constant *C = cast<Constant>(V);
+ C = ConstantExpr::getMul(C,
+ ConstantInt::get(Type::getInt32Ty(C->getContext()),
+ size));
+ V = C;
+ }
}
if (V->getType() != I64Ty) {
if (Constant *C = dyn_cast<Constant>(V))
@@ -279,14 +416,23 @@ namespace {
BasicBlock *BB = I->getParent();
BasicBlock::iterator It = I;
BasicBlock *newBB = SplitBlock(BB, &*It, this);
+ PHINode *PN;
//verifyFunction(*BB->getParent());
if (!AbrtBB) {
std::vector<const Type*>args;
FunctionType* abrtTy = FunctionType::get(
Type::getVoidTy(BB->getContext()),args,false);
+ args.push_back(Type::getInt32Ty(BB->getContext()));
+// FunctionType* rterrTy = FunctionType::get(
+// Type::getInt32Ty(BB->getContext()),args,false);
Constant *func_abort =
BB->getParent()->getParent()->getOrInsertFunction("abort", abrtTy);
+// Constant *func_rterr =
+// BB->getParent()->getParent()->getOrInsertFunction("bytecode_rt_error", rterrTy);
AbrtBB = BasicBlock::Create(BB->getContext(), "", BB->getParent());
+ PN = PHINode::Create(Type::getInt32Ty(BB->getContext()),"",
+ AbrtBB);
+// CallInst *RtErrCall = CallInst::Create(func_rterr, PN, "", AbrtBB);
CallInst* AbrtC = CallInst::Create(func_abort, "", AbrtBB);
AbrtC->setCallingConv(CallingConv::C);
AbrtC->setTailCall(true);
@@ -295,10 +441,29 @@ namespace {
new UnreachableInst(BB->getContext(), AbrtBB);
DT->addNewBlock(AbrtBB, BB);
//verifyFunction(*BB->getParent());
+ } else {
+ PN = cast<PHINode>(AbrtBB->begin());
+ }
+ unsigned MDDbgKind = I->getContext().getMDKindID("dbg");
+ unsigned locationid = 0;
+ if (MDNode *Dbg = I->getMetadata(MDDbgKind)) {
+ DILocation Loc(Dbg);
+ locationid = Loc.getLineNumber() << 8;
+ unsigned col = Loc.getColumnNumber();
+ if (col > 255)
+ col = 255;
+ locationid |= col;
+// Loc.getFilename();
}
+ PN->addIncoming(ConstantInt::get(Type::getInt32Ty(BB->getContext()),
+ locationid), BB);
+
TerminatorInst *TI = BB->getTerminator();
SCEVExpander expander(*SE);
- Value *IdxV = expander.expandCodeFor(Idx, Idx->getType(), TI);
+ Value *IdxV = expander.expandCodeFor(Idx, Limit->getType(), TI);
+/* if (isa<PointerType>(IdxV->getType())) {
+ IdxV = new PtrToIntInst(IdxV, Idx->getType(), "", TI);
+ }*/
//verifyFunction(*BB->getParent());
Value *LimitV = expander.expandCodeFor(Limit, Limit->getType(), TI);
//verifyFunction(*BB->getParent());
@@ -352,6 +517,32 @@ namespace {
}
return false;
}
+ static void printValue(llvm::raw_ostream &Out, llvm::Value *V) {
+ std::string DisplayName;
+ std::string Type;
+ unsigned Line;
+ std::string File;
+ std::string Dir;
+ if (!getLocationInfo(V, DisplayName, Type, Line, File, Dir)) {
+ Out << *V << "\n";
+ return;
+ }
+ Out << "'" << DisplayName << "' (" << File << ":" << Line << ")";
+ }
+
+ static void printLocation(llvm::raw_ostream &Out, llvm::Instruction *I) {
+ if (MDNode *N = I->getMetadata("dbg")) {
+ DILocation Loc(N);
+ Out << Loc.getFilename() << ":" << Loc.getLineNumber();
+ if (unsigned Col = Loc.getColumnNumber()) {
+ Out << ":" << Col;
+ }
+ Out << ": ";
+ return;
+ }
+ Out << *I << ":\n";
+ }
+
bool validateAccess(Value *Pointer, Value *Length, Instruction *I)
{
// get base
@@ -361,24 +552,33 @@ namespace {
// get bounds
Value *Bounds = getPointerBounds(SBase);
if (!Bounds) {
- errs() << "No bounds for base " << *SBase << "\n";
- errs() << " while checking access to " << *Pointer << " of length "
- << *Length << " at " << *I << "\n";
+ printLocation(errs(), I);
+ errs() << "no bounds for base ";
+ printValue(errs(), SBase);
+ errs() << " while checking access to ";
+ printValue(errs(), Pointer);
+ errs() << " of length ";
+ printValue(errs(), Length);
+ errs() << "\n";
return false;
}
if (CallInst *CI = dyn_cast<CallInst>(Base->stripPointerCasts())) {
if (I->getParent() == CI->getParent()) {
- errs() << "No null pointer check after function call " << *Base
- << "\n";
- errs() << " before use in same block at " << *I << "\n";
+ printLocation(errs(), I);
+ errs() << "no null pointer check of pointer ";
+ printValue(errs(), Base);
+ errs() << " obtained by function call";
+ errs() << " before use in same block\n";
return false;
}
if (!checkCondition(CI, I)) {
- errs() << "No null pointer check after function call " << *Base
- << "\n";
- errs() << " before use at " << *I << "\n";
+ printLocation(errs(), I);
+ errs() << "no null pointer check of pointer ";
+ printValue(errs(), Base);
+ errs() << " obtained by function call";
+ errs() << " before use\n";
return false;
}
}
diff --git a/libclamav/c++/GenList.pl b/libclamav/c++/GenList.pl
index 9a5eb85..42966c3 100755
--- a/libclamav/c++/GenList.pl
+++ b/libclamav/c++/GenList.pl
@@ -9,7 +9,7 @@ my %compdeps;
my @codegencomponents = ('x86codegen','powerpccodegen','armcodegen');
my @allnonsys = ('support','jit','fullcodegen', at codegencomponents);
my @allcomponents= ('system', at allnonsys);
-my $allJIT="jit core lib/Support/SourceMgr.o lib/Analysis/PointerTracking.o lib/Transforms/Scalar/DCE.o";
+my $allJIT="jit core lib/Support/SourceMgr.o lib/Analysis/PointerTracking.o lib/Transforms/Scalar/DCE.o lib/Analysis/IPA/CallGraph.o";
for my $component (@allcomponents) {
$/ = " ";
$component =~ s/^fullcodegen/codegen interpreter jit target/;
diff --git a/libclamav/c++/Makefile.am b/libclamav/c++/Makefile.am
index 61edaa6..76323ae 100644
--- a/libclamav/c++/Makefile.am
+++ b/libclamav/c++/Makefile.am
@@ -465,6 +465,7 @@ endif
# End of Targets
libllvmjit_la_SOURCES=\
+ llvm/lib/Analysis/IPA/CallGraph.cpp\
llvm/lib/Analysis/AliasAnalysis.cpp\
llvm/lib/Analysis/BasicAliasAnalysis.cpp\
llvm/lib/Analysis/CaptureTracking.cpp\
@@ -758,7 +759,6 @@ llvmunittest_VMCore_CPPFLAGS=$(LLVM_INCLUDES) $(LLVM_DEFS) -I$(top_srcdir)/llvm/
#-Wno-variadic-macros
llvmunittest_VMCore_LDADD=libgoogletest.la libllvmsupport_nodups.la libllvmjit.la libllvmsystem.la
llvmunittest_VMCore_SOURCES=\
- llvm/lib/Analysis/IPA/CallGraph.cpp\
llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp\
llvm/lib/Analysis/LoopInfo.cpp\
llvm/lib/Analysis/LoopPass.cpp\
diff --git a/libclamav/c++/Makefile.in b/libclamav/c++/Makefile.in
index b73834f..af0f8ff 100644
--- a/libclamav/c++/Makefile.in
+++ b/libclamav/c++/Makefile.in
@@ -277,16 +277,16 @@ am_libllvminterpreter_la_OBJECTS = Execution.lo ExternalFunctions.lo \
Interpreter.lo
libllvminterpreter_la_OBJECTS = $(am_libllvminterpreter_la_OBJECTS)
libllvmjit_la_LIBADD =
-am_libllvmjit_la_OBJECTS = AliasAnalysis.lo BasicAliasAnalysis.lo \
- CaptureTracking.lo DebugInfo.lo MemoryBuiltins.lo \
- PointerTracking.lo ValueTracking.lo ELFCodeEmitter.lo \
- ELFWriter.lo MachineBasicBlock.lo MachineFunction.lo \
- MachineFunctionAnalysis.lo MachineFunctionPass.lo \
- MachineInstr.lo MachineModuleInfo.lo MachineRegisterInfo.lo \
- ObjectCodeEmitter.lo PseudoSourceValue.lo \
- TargetInstrInfoImpl.lo ExecutionEngine.lo Intercept.lo JIT.lo \
- JITDebugRegisterer.lo JITDwarfEmitter.lo JITEmitter.lo \
- JITMemoryManager.lo OProfileJITEventListener.lo \
+am_libllvmjit_la_OBJECTS = CallGraph.lo AliasAnalysis.lo \
+ BasicAliasAnalysis.lo CaptureTracking.lo DebugInfo.lo \
+ MemoryBuiltins.lo PointerTracking.lo ValueTracking.lo \
+ ELFCodeEmitter.lo ELFWriter.lo MachineBasicBlock.lo \
+ MachineFunction.lo MachineFunctionAnalysis.lo \
+ MachineFunctionPass.lo MachineInstr.lo MachineModuleInfo.lo \
+ MachineRegisterInfo.lo ObjectCodeEmitter.lo \
+ PseudoSourceValue.lo TargetInstrInfoImpl.lo ExecutionEngine.lo \
+ Intercept.lo JIT.lo JITDebugRegisterer.lo JITDwarfEmitter.lo \
+ JITEmitter.lo JITMemoryManager.lo OProfileJITEventListener.lo \
TargetSelect.lo MCAsmInfo.lo MCContext.lo MCExpr.lo \
MCSection.lo MCSectionELF.lo MCSymbol.lo APFloat.lo APInt.lo \
Allocator.lo CommandLine.lo ConstantRange.lo Debug.lo Dwarf.lo \
@@ -499,7 +499,6 @@ llvmunittest_Support_OBJECTS = $(am_llvmunittest_Support_OBJECTS)
llvmunittest_Support_DEPENDENCIES = libgoogletest.la \
libllvmsupport_nodups.la libllvmjit.la libllvmsystem.la
am_llvmunittest_VMCore_OBJECTS = \
- llvmunittest_VMCore-CallGraph.$(OBJEXT) \
llvmunittest_VMCore-CallGraphSCCPass.$(OBJEXT) \
llvmunittest_VMCore-LoopInfo.$(OBJEXT) \
llvmunittest_VMCore-LoopPass.$(OBJEXT) \
@@ -1235,6 +1234,7 @@ libllvmsupport_nodups_la_SOURCES = \
# End of Targets
libllvmjit_la_SOURCES = \
+ llvm/lib/Analysis/IPA/CallGraph.cpp\
llvm/lib/Analysis/AliasAnalysis.cpp\
llvm/lib/Analysis/BasicAliasAnalysis.cpp\
llvm/lib/Analysis/CaptureTracking.cpp\
@@ -1527,7 +1527,6 @@ llvmunittest_VMCore_CPPFLAGS = $(LLVM_INCLUDES) $(LLVM_DEFS) -I$(top_srcdir)/llv
#-Wno-variadic-macros
llvmunittest_VMCore_LDADD = libgoogletest.la libllvmsupport_nodups.la libllvmjit.la libllvmsystem.la
llvmunittest_VMCore_SOURCES = \
- llvm/lib/Analysis/IPA/CallGraph.cpp\
llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp\
llvm/lib/Analysis/LoopInfo.cpp\
llvm/lib/Analysis/LoopPass.cpp\
@@ -1805,6 +1804,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BranchFolding.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/BreakCriticalEdges.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CalcSpillWeights.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CallGraph.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CallingConvLower.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CaptureTracking.Plo at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/CodeGenPrepare.Plo at am__quote@
@@ -2165,7 +2165,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/llvmunittest_Support-TypeBuilderTest.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/llvmunittest_Support-ValueHandleTest.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/llvmunittest_Support-raw_ostream_test.Po at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/llvmunittest_VMCore-CallGraph.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/llvmunittest_VMCore-CallGraphSCCPass.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/llvmunittest_VMCore-ConstantsTest.Po at am__quote@
@AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/llvmunittest_VMCore-LoopInfo.Po at am__quote@
@@ -3986,6 +3985,14 @@ TargetIntrinsicInfo.lo: llvm/lib/Target/TargetIntrinsicInfo.cpp
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o TargetIntrinsicInfo.lo `test -f 'llvm/lib/Target/TargetIntrinsicInfo.cpp' || echo '$(srcdir)/'`llvm/lib/Target/TargetIntrinsicInfo.cpp
+CallGraph.lo: llvm/lib/Analysis/IPA/CallGraph.cpp
+ at am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT CallGraph.lo -MD -MP -MF $(DEPDIR)/CallGraph.Tpo -c -o CallGraph.lo `test -f 'llvm/lib/Analysis/IPA/CallGraph.cpp' || echo '$(srcdir)/'`llvm/lib/Analysis/IPA/CallGraph.cpp
+ at am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/CallGraph.Tpo $(DEPDIR)/CallGraph.Plo
+ at am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='llvm/lib/Analysis/IPA/CallGraph.cpp' object='CallGraph.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o CallGraph.lo `test -f 'llvm/lib/Analysis/IPA/CallGraph.cpp' || echo '$(srcdir)/'`llvm/lib/Analysis/IPA/CallGraph.cpp
+
AliasAnalysis.lo: llvm/lib/Analysis/AliasAnalysis.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT AliasAnalysis.lo -MD -MP -MF $(DEPDIR)/AliasAnalysis.Tpo -c -o AliasAnalysis.lo `test -f 'llvm/lib/Analysis/AliasAnalysis.cpp' || echo '$(srcdir)/'`llvm/lib/Analysis/AliasAnalysis.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/AliasAnalysis.Tpo $(DEPDIR)/AliasAnalysis.Plo
@@ -5786,22 +5793,6 @@ llvmunittest_Support-raw_ostream_test.obj: llvm/unittests/Support/raw_ostream_te
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(llvmunittest_Support_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o llvmunittest_Support-raw_ostream_test.obj `if test -f 'llvm/unittests/Support/raw_ostream_test.cpp'; then $(CYGPATH_W) 'llvm/unittests/Support/raw_ostream_test.cpp'; else $(CYGPATH_W) '$(srcdir)/llvm/unittests/Support/raw_ostream_test.cpp'; fi`
-llvmunittest_VMCore-CallGraph.o: llvm/lib/Analysis/IPA/CallGraph.cpp
- at am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(llvmunittest_VMCore_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT llvmunittest_VMCore-CallGraph.o -MD -MP -MF $(DEPDIR)/llvmunittest_VMCore-CallGraph.Tpo -c -o llvmunittest_VMCore-CallGraph.o `test -f 'llvm/lib/Analysis/IPA/CallGraph.cpp' || echo '$(srcdir)/'`llvm/lib/Analysis/IPA/CallGraph.cpp
- at am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/llvmunittest_VMCore-CallGraph.Tpo $(DEPDIR)/llvmunittest_VMCore-CallGraph.Po
- at am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='llvm/lib/Analysis/IPA/CallGraph.cpp' object='llvmunittest_VMCore-CallGraph.o' libtool=no @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(llvmunittest_VMCore_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o llvmunittest_VMCore-CallGraph.o `test -f 'llvm/lib/Analysis/IPA/CallGraph.cpp' || echo '$(srcdir)/'`llvm/lib/Analysis/IPA/CallGraph.cpp
-
-llvmunittest_VMCore-CallGraph.obj: llvm/lib/Analysis/IPA/CallGraph.cpp
- at am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(llvmunittest_VMCore_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT llvmunittest_VMCore-CallGraph.obj -MD -MP -MF $(DEPDIR)/llvmunittest_VMCore-CallGraph.Tpo -c -o llvmunittest_VMCore-CallGraph.obj `if test -f 'llvm/lib/Analysis/IPA/CallGraph.cpp'; then $(CYGPATH_W) 'llvm/lib/Analysis/IPA/CallGraph.cpp'; else $(CYGPATH_W) '$(srcdir)/llvm/lib/Analysis/IPA/CallGraph.cpp'; fi`
- at am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/llvmunittest_VMCore-CallGraph.Tpo $(DEPDIR)/llvmunittest_VMCore-CallGraph.Po
- at am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='llvm/lib/Analysis/IPA/CallGraph.cpp' object='llvmunittest_VMCore-CallGraph.obj' libtool=no @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(llvmunittest_VMCore_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o llvmunittest_VMCore-CallGraph.obj `if test -f 'llvm/lib/Analysis/IPA/CallGraph.cpp'; then $(CYGPATH_W) 'llvm/lib/Analysis/IPA/CallGraph.cpp'; else $(CYGPATH_W) '$(srcdir)/llvm/lib/Analysis/IPA/CallGraph.cpp'; fi`
-
llvmunittest_VMCore-CallGraphSCCPass.o: llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(llvmunittest_VMCore_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT llvmunittest_VMCore-CallGraphSCCPass.o -MD -MP -MF $(DEPDIR)/llvmunittest_VMCore-CallGraphSCCPass.Tpo -c -o llvmunittest_VMCore-CallGraphSCCPass.o `test -f 'llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp' || echo '$(srcdir)/'`llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/llvmunittest_VMCore-CallGraphSCCPass.Tpo $(DEPDIR)/llvmunittest_VMCore-CallGraphSCCPass.Po
diff --git a/libclamav/c++/bytecode2llvm.cpp b/libclamav/c++/bytecode2llvm.cpp
index 184155c..003894e 100644
--- a/libclamav/c++/bytecode2llvm.cpp
+++ b/libclamav/c++/bytecode2llvm.cpp
@@ -521,7 +521,7 @@ private:
Module *M;
LLVMContext &Context;
ExecutionEngine *EE;
- FunctionPassManager &PM;
+ PassManager &PM;
LLVMTypeMapper *TypeMap;
Function **apiFuncs;
@@ -718,7 +718,7 @@ private:
public:
LLVMCodegen(const struct cli_bc *bc, Module *M, struct CommonFunctions *CF, FunctionMapTy &cFuncs,
- ExecutionEngine *EE, FunctionPassManager &PM,
+ ExecutionEngine *EE, PassManager &PM,
Function **apiFuncs, LLVMTypeMapper &apiMap)
: bc(bc), M(M), Context(M->getContext()), EE(EE),
PM(PM), apiFuncs(apiFuncs),apiMap(apiMap),
@@ -1386,11 +1386,16 @@ public:
// verification failed
return false;
}
- PM.run(*F);
- AddStackProtect(F);
delete [] Values;
delete [] BB;
}
+
+ PM.run(*M);
+ for (unsigned j=0;j<bc->num_func;j++) {
+ PrettyStackTraceString CrashInfo("Generate LLVM IR2");
+ Function *F = Functions[j];
+ AddStackProtect(F);
+ }
DEBUG(M->dump());
delete TypeMap;
std::vector<const Type*> args;
@@ -1699,7 +1704,7 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
struct CommonFunctions CF;
addFunctionProtos(&CF, EE, M);
- FunctionPassManager OurFPM(M);
+ PassManager OurFPM;
M->setDataLayout(EE->getTargetData()->getStringRepresentation());
M->setTargetTriple(sys::getHostTriple());
// Set up the optimizer pipeline. Start with registering info about how
@@ -1708,7 +1713,6 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
// Promote allocas to registers.
OurFPM.add(createPromoteMemoryToRegisterPass());
OurFPM.add(createDeadCodeEliminationPass());
- OurFPM.doInitialization();
//TODO: create a wrapper that calls pthread_getspecific
unsigned maxh = cli_globals[0].offset + sizeof(struct cli_bc_hooks);
diff --git a/win32/LLVMjit.vcproj b/win32/LLVMjit.vcproj
index 7ec721b..ee51b81 100644
--- a/win32/LLVMjit.vcproj
+++ b/win32/LLVMjit.vcproj
@@ -156,6 +156,10 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
+ RelativePath="..\libclamav\c++\llvm\lib\Analysis\IPA\CallGraph.cpp"
+ >
+ </File>
+ <File
RelativePath="..\libclamav\c++\llvm\lib\VMCore\LLVMContextImpl.cpp"
>
</File>
diff --git a/win32/clamav-config.h b/win32/clamav-config.h
index 3f6f40e..f3513d0 100644
--- a/win32/clamav-config.h
+++ b/win32/clamav-config.h
@@ -496,7 +496,7 @@
/* #undef USE_SYSLOG */
/* Version number of package */
-#define VERSION "devel-clamav-0.96rc1-78-g95fc03d"
+#define VERSION "devel-clamav-0.96rc2-23-gc7a989c"
/* Version suffix for package */
#define VERSION_SUFFIX ""
--
Debian repository for ClamAV
More information about the Pkg-clamav-commits
mailing list