diff --git a/LLVM/ExecutionEngine.hs b/LLVM/ExecutionEngine.hs
--- a/LLVM/ExecutionEngine.hs
+++ b/LLVM/ExecutionEngine.hs
@@ -11,6 +11,7 @@
     runStaticDestructors,
 -}
     getPointerToFunction,
+    getFreePointers, FreePointers,
     -- * Translation
     Translatable, Generic,
     generateFunction,
diff --git a/LLVM/ExecutionEngine/Engine.hs b/LLVM/ExecutionEngine/Engine.hs
--- a/LLVM/ExecutionEngine/Engine.hs
+++ b/LLVM/ExecutionEngine/Engine.hs
@@ -9,6 +9,7 @@
        {- runStaticConstructors, runStaticDestructors, -}
        getExecutionEngineTargetData,
        getPointerToFunction,
+       getFreePointers, FreePointers,
        runFunction, getRunFunction,
        GenericValue, Generic(..)
        ) where
@@ -31,6 +32,7 @@
 import LLVM.Core.Util(Module, ModuleProvider, withModuleProvider, createModule, createModuleProviderForExistingModule)
 import qualified LLVM.FFI.ExecutionEngine as FFI
 import qualified LLVM.FFI.Target as FFI
+import qualified LLVM.FFI.Core as FFI(ModuleProviderRef, ValueRef)
 import qualified LLVM.Core.Util(Function)
 import LLVM.Core.Type(IsFirstClass, typeRef)
 
@@ -156,6 +158,16 @@
 addModule m = do
     mp <- liftIO $ createModuleProviderForExistingModule m
     addModuleProvider mp
+
+-- | Get all the information needed to free a function.
+-- Freeing code might have to be done from a (C) finalizer, so it has to done from C.
+-- The function c_freeFunctionObject take these pointers as arguments and frees the function.
+type FreePointers = (Ptr FFI.ExecutionEngine, FFI.ModuleProviderRef, FFI.ValueRef)
+getFreePointers :: Function f -> EngineAccess FreePointers
+getFreePointers (Value f) = do
+    ea <- get
+    liftIO $ withModuleProvider (head $ ea_providers ea) $ \ mpp ->
+        return (ea_engine ea, mpp, f)
 
 --------------------------------------
 
diff --git a/cbits/free.c b/cbits/free.c
new file mode 100644
--- /dev/null
+++ b/cbits/free.c
@@ -0,0 +1,15 @@
+#include <llvm-c/Core.h>
+#include <llvm-c/ExecutionEngine.h>
+
+/* C function to free function object resources.  Can be called from a finalizer. */
+void
+c_freeFunctionObject(LLVMExecutionEngineRef execEngine,
+		     LLVMModuleProviderRef moduleProvider,
+		     LLVMValueRef f)
+{
+  LLVMModuleRef mod;
+  LLVMFreeMachineCodeForFunction(execEngine, f);
+  if (!LLVMRemoveModuleProvider(execEngine, moduleProvider, &mod, 0)) {
+    LLVMDisposeModule(mod);
+  }
+}
diff --git a/llvm.cabal b/llvm.cabal
--- a/llvm.cabal
+++ b/llvm.cabal
@@ -1,9 +1,10 @@
 name: llvm
-version: 0.6.7.0
+version: 0.6.8.0
 license: BSD3
 license-file: LICENSE
 synopsis: Bindings to the LLVM compiler toolkit.
 description: Bindings to the LLVM compiler toolkit.
+             New in 0.6.8.0: Add functions to allow freeing function resources;
              New in 0.6.7.0: Struct types;
              New in 0.6.6.0: Bug fixes;
 	     New in 0.6.5.0: Adapted to LLVM 2.5;
@@ -83,3 +84,5 @@
       LLVM.Core.Vector
       LLVM.ExecutionEngine.Engine
       LLVM.ExecutionEngine.Target
+
+  C-Sources: cbits/free.c
