Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 mono (2.10.8.1-3) unstable; urgency=low
 .
   * [c934e01] Remove unused File::Basename import from runtime script.
     Having this present causes failures on release upgrades where perl-base
     and perl-modules are not in a consistent state (e.g. this can happen
     when upgrading across major Perl versions). (Closes: #665335) (LP:
     #948848)
   * [9e3cc40] Remove monodoc-base trigger.
     This trigger updated the monodoc search index. It ended up calling
     /usr/bin/monodoc, which is shipped in the monodoc-browser package
     (source package mono-tools). The script attempted to check that
     monodoc-browser was configured, but didn't get this right. This led to
     numerous upgrade failures when Depends of monodoc-browser were not
     satisfied when the trigger was invoked and calling monodoc to update the
     search index bombed out due to this. It's more correct to just have
     monodoc-browser ship this trigger itself. (LP: #972751)
   * [dd2925c] Standards-Version bump to 3.9.3, no changes required
   * [8299ee0] Remove duplicate Depends in mono-complete
   * [508c4f5] Revert "Merge branch 'master-patches/fix_crash_in_fixup_cattrs'"
     This reverts commit 86127dcf508213eac5b50a65c989cf5971b57378, reversing
     changes made to 55a1a20a4d858346ed8a8d840abc3f9230ea816e.
     This branch introduced regressions which caused both nant and mono-upnp
     (at least) to FTBFS. (Closes: #666623)
   * [61fbbe4] Fix ARM printf format problems.
     When building with -Werror=format-security on ARM, mono fails to build
     due to incorrect format strings in arm-dis.c
     (cherry picked from commit 32c1b70ad164640ff0a2739e66884d0279cfe7c7)
     Signed-off-by: Iain Lane <laney@debian.org>
   * [9883116] Pass CFLAGS and CPPFLAGS when building binfmt-detector.
     Ensures hardening support is enabled for this binary.
     Thanks to Simon Ruderich <simon@ruderich.org> (Closes: #657518)
   * [4bb0138] Ensure compiler flags are passed into build system.
     This issue was discovered when it was noted that Debian's hardening
     buildflags weren't being propogated to all binaries.
     The patch is from Simon Ruderich <simon@ruderich.org>
     (cherry picked from commit d6dcfb27fc6252352f6ad6f8bd9ef5cff206fd46)
     Also Closes: #657518
Author: Iain Lane <laney@debian.org>
Bug-Debian: http://bugs.debian.org/657518
Bug-Debian: http://bugs.debian.org/665335
Bug-Debian: http://bugs.debian.org/666623
Bug-Ubuntu: https://bugs.launchpad.net/bugs/948848
Bug-Ubuntu: https://bugs.launchpad.net/bugs/972751

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- mono-2.10.8.1.orig/configure.in
+++ mono-2.10.8.1/configure.in
@@ -128,6 +128,17 @@ case "$host" in
 		with_sigaltstack=no
 		use_sigposix=yes
 		;;
+	*-*-kfreebsd*-gnu)
+		platform_win32=no
+		CPPFLAGS="$CPPFLAGS -DGC_FREEBSD_THREADS -D_GNU_SOURCE -D_REENTRANT -DUSE_MMAP -DUSE_MUNMAP -DTHREAD_LOCAL_ALLOC -pthread"
+		libmono_cflags="-D_REENTRANT -DTHREAD_LOCAL_ALLOC -pthread"
+		libmono_ldflags="-lpthread -pthread"
+		libdl="-ldl"
+		libgc_threads=pthreads
+		need_link_unlink=yes
+		with_sigaltstack=no
+		use_sigposix=yes
+		;;
 	*-*-*freebsd*)
 		host_win32=no
 		if test "x$PTHREAD_CFLAGS" = "x"; then
@@ -2213,7 +2224,7 @@ case "$host" in
 			sgen_supported=true
 			AOT_SUPPORTED="yes"
 			;;
-		  darwin*|openbsd*|freebsd*)
+		  darwin*|openbsd*|freebsd*|kfreebsd-gnu*)
 			sgen_supported=true
 		        ;;
 		esac
@@ -2228,7 +2239,7 @@ case "$host" in
 			sgen_supported=true
 			AOT_SUPPORTED="yes"
 			;;
-		  darwin*|openbsd*|freebsd*)
+		  darwin*|openbsd*|freebsd*|kfreebsd-gnu*)
 			sgen_supported=true
 			;;
 		esac
@@ -2559,6 +2570,11 @@ case "$host" in
 	LIBC="libc.so.12"
 	INTL="libintl.so.0"
 	;;
+     *-*-kfreebsd*-gnu)
+	LIBC="libc.so.0.1"
+	INTL="libc.so.0.1"
+	X11="libX11.so.6"
+	;;
     *-*-*freebsd*)
     	LIBC="libc.so"
 	INTL="libintl.so"
@@ -2655,15 +2671,24 @@ if test "x$with_tls" = "x__thread"; then
 	])
 fi
 
-if test ${TARGET} = ARM && test x$cross_compiling = xno && test x$enable_mcs_build != xno; then
+AC_ARG_WITH(fpu, [ --with-fpu=FPA,VFP,NONE    Select fpu to use on arm],[fpu=$withval])
+
+if test ${TARGET} = ARM; then
 	dnl ******************************************
 	dnl *** Check to see what FPU is available ***
 	dnl ******************************************
 	AC_MSG_CHECKING(which FPU to use)
 
-	AC_TRY_COMPILE([], [
-		__asm__ ("ldfd f0, [r0]");
-		], fpu=FPA, fpu=NONE)
+	if test "x$fpu" = "x"; then
+
+		AC_TRY_COMPILE([], [
+			__asm__ ("ldfd f0, [r0]");
+		], fpu=FPA, [
+				AC_TRY_COMPILE([], [
+					__asm__ ("fldd d0, [r0]");
+				], fpu=VFP, fpu=NONE)
+		])
+	fi
 
 	AC_MSG_RESULT($fpu)
 	CPPFLAGS="$CPPFLAGS -DARM_FPU_$fpu=1"
--- mono-2.10.8.1.orig/Makefile.am
+++ mono-2.10.8.1/Makefile.am
@@ -4,7 +4,7 @@ ACLOCAL_AMFLAGS = -I .
 MOONLIGHT_SUBDIRS = $(libgc_dir) eglib/src mono
 
 if CROSS_COMPILING
-SUBDIRS = po $(libgc_dir) eglib mono $(ikvm_native_dir) data runtime scripts man samples msvc $(docs_dir)
+SUBDIRS = po $(libgc_dir) eglib mono $(ikvm_native_dir) data runtime scripts man samples msvc
 # Keep in sync with SUBDIRS
 ## 'tools' is not normally built
 DIST_SUBDIRS = po libgc eglib mono ikvm-native         data runtime scripts man samples tools msvc docs
@@ -12,7 +12,7 @@ else
 if ONLY_MOONLIGHT
 SUBDIRS = $(MOONLIGHT_SUBDIRS) runtime
 else
-SUBDIRS = po $(libgc_dir) eglib mono $(ikvm_native_dir) support data runtime scripts man samples msvc $(docs_dir)
+SUBDIRS = po $(libgc_dir) eglib mono $(ikvm_native_dir) support data runtime scripts man samples msvc
 # Keep in sync with SUBDIRS
 ## 'tools' is not normally built
 DIST_SUBDIRS = po libgc eglib mono ikvm-native support data runtime scripts man samples tools msvc docs
--- mono-2.10.8.1.orig/data/mono.pc.in
+++ mono-2.10.8.1/data/mono.pc.in
@@ -1,5 +1,5 @@
-prefix=${pcfiledir}/../..
-exec_prefix=${pcfiledir}/../..
+prefix=@prefix@
+exec_prefix=${prefix}
 libdir=${prefix}/@reloc_libdir@
 includedir=${prefix}/include/mono-@API_VER@
 sysconfdir=@sysconfdir@
--- mono-2.10.8.1.orig/data/mono-cairo.pc.in
+++ mono-2.10.8.1/data/mono-cairo.pc.in
@@ -1,5 +1,5 @@
-prefix=${pcfiledir}/../..
-exec_prefix=${pcfiledir}/../..
+prefix=@prefix@
+exec_prefix=${prefix}
 libdir=${prefix}/@reloc_libdir@
 includedir=${prefix}/include
 
--- mono-2.10.8.1.orig/data/net_2_0/machine.config
+++ mono-2.10.8.1/data/net_2_0/machine.config
@@ -197,12 +197,16 @@
 			<cryptoNameMapping>
 				<cryptoClasses>
 					<cryptoClass monoMD2="Mono.Security.Cryptography.MD2Managed, Mono.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
+					<cryptoClass monoMD4="Mono.Security.Cryptography.MD4Managed, Mono.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
 				</cryptoClasses>
 				<nameEntry name="MD2" class="monoMD2" />
+				<nameEntry name="MD4" class="monoMD4" />
 			</cryptoNameMapping>
 			<oidMap>
 				<oidEntry OID="1.2.840.113549.2.2" name="MD2" />
 				<oidEntry OID="1.2.840.113549.2.2" name="Mono.Security.Cryptography.MD2Managed" />
+				<oidEntry OID="1.2.840.113549.2.4" name="MD4" />
+				<oidEntry OID="1.2.840.113549.2.4" name="Mono.Security.Cryptography.MD4Managed" />
 			</oidMap>
 		</cryptographySettings>
 	</mscorlib>
--- mono-2.10.8.1.orig/data/net_4_0/machine.config
+++ mono-2.10.8.1/data/net_4_0/machine.config
@@ -214,12 +214,16 @@
 			<cryptoNameMapping>
 				<cryptoClasses>
 					<cryptoClass monoMD2="Mono.Security.Cryptography.MD2Managed, Mono.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
+					<cryptoClass monoMD4="Mono.Security.Cryptography.MD4Managed, Mono.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
 				</cryptoClasses>
 				<nameEntry name="MD2" class="monoMD2" />
+				<nameEntry name="MD4" class="monoMD4" />
 			</cryptoNameMapping>
 			<oidMap>
 				<oidEntry OID="1.2.840.113549.2.2" name="MD2" />
 				<oidEntry OID="1.2.840.113549.2.2" name="Mono.Security.Cryptography.MD2Managed" />
+				<oidEntry OID="1.2.840.113549.2.4" name="MD4" />
+				<oidEntry OID="1.2.840.113549.2.4" name="Mono.Security.Cryptography.MD4Managed" />
 			</oidMap>
 		</cryptographySettings>
 	</mscorlib>
--- mono-2.10.8.1.orig/data/net_1_1/machine.config
+++ mono-2.10.8.1/data/net_1_1/machine.config
@@ -214,12 +214,16 @@
 			<cryptoNameMapping>
 				<cryptoClasses>
 					<cryptoClass monoMD2="Mono.Security.Cryptography.MD2Managed, Mono.Security, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
+					<cryptoClass monoMD4="Mono.Security.Cryptography.MD4Managed, Mono.Security, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
 				</cryptoClasses>
 				<nameEntry name="MD2" class="monoMD2" />
+				<nameEntry name="MD4" class="monoMD4" />
 			</cryptoNameMapping>
 			<oidMap>
 				<oidEntry OID="1.2.840.113549.2.2" name="MD2" />
 				<oidEntry OID="1.2.840.113549.2.2" name="Mono.Security.Cryptography.MD2Managed" />
+				<oidEntry OID="1.2.840.113549.2.4" name="MD4" />
+				<oidEntry OID="1.2.840.113549.2.4" name="Mono.Security.Cryptography.MD4Managed" />
 			</oidMap>
 		</cryptographySettings>
 	</mscorlib>
--- mono-2.10.8.1.orig/mcs/class/System/System.Security.Cryptography.X509Certificates/X509ExtensionCollection.cs
+++ mono-2.10.8.1/mcs/class/System/System.Security.Cryptography.X509Certificates/X509ExtensionCollection.cs
@@ -39,6 +39,7 @@ namespace System.Security.Cryptography.X
 
 	public sealed class X509ExtensionCollection : ICollection, IEnumerable {
 
+		static byte[] Empty = new byte [0];
 		private ArrayList _list;
 
 		// constructors
@@ -84,13 +85,13 @@ namespace System.Security.Cryptography.X
 					break;
 				}
 #else
-				parameters [0] = new AsnEncodedData (oid, raw_data);
+				parameters [0] = new AsnEncodedData (oid, raw_data ?? Empty);
 				parameters [1] = critical;
 				newt = (X509Extension) CryptoConfig.CreateFromName (oid, parameters);
 #endif
 				if (newt == null) {
 					// not registred in CryptoConfig, using default
-					newt = new X509Extension (oid, raw_data, critical);
+					newt = new X509Extension (oid, raw_data ?? Empty, critical);
 				}
 				_list.Add (newt);
 			}
--- mono-2.10.8.1.orig/mcs/class/System/System.Security.Cryptography.X509Certificates/X500DistinguishedName.cs
+++ mono-2.10.8.1/mcs/class/System/System.Security.Cryptography.X509Certificates/X500DistinguishedName.cs
@@ -179,10 +179,11 @@ namespace System.Security.Cryptography.X
 
 		private static string Canonize (string s)
 		{
-			int i = s.IndexOf ('=');
-			StringBuilder r = new StringBuilder (s.Substring (0, i + 1));
+			int i = s.IndexOf ('=') + 1;
+			StringBuilder r = new StringBuilder (s.Substring (0, i));
 			// skip any white space starting the value
-			while (Char.IsWhiteSpace (s, ++i));
+			while (i < s.Length && Char.IsWhiteSpace (s, i))
+				i++;
 			// ensure we skip white spaces at the end of the value
 			s = s.TrimEnd ();
 			// keep track of internal multiple spaces
--- mono-2.10.8.1.orig/mcs/class/System/System.Security.Cryptography.X509Certificates/PublicKey.cs
+++ mono-2.10.8.1/mcs/class/System/System.Security.Cryptography.X509Certificates/PublicKey.cs
@@ -47,6 +47,8 @@ namespace System.Security.Cryptography.X
 		private AsnEncodedData _params;
 		private Oid _oid;
 
+		static byte[] Empty = new byte [0];
+
 		public PublicKey (Oid oid, AsnEncodedData parameters, AsnEncodedData keyValue)
 		{
 			if (oid == null)
@@ -108,7 +110,7 @@ namespace System.Security.Cryptography.X
 
 			_oid = new Oid (certificate.KeyAlgorithm);
 			_keyValue = new AsnEncodedData (_oid, certificate.PublicKey);
-			_params = new AsnEncodedData (_oid, certificate.KeyAlgorithmParameters);
+			_params = new AsnEncodedData (_oid, certificate.KeyAlgorithmParameters ?? Empty);
 		}
 
 		// properties
--- mono-2.10.8.1.orig/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
+++ mono-2.10.8.1/mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/Engine.cs
@@ -555,14 +555,16 @@ namespace Microsoft.Build.BuildEngine {
 
 		public string DefaultToolsVersion {
 			get {
-				// This is used as the fall back version if the
-				// project can't find a version to use
-				// Hard-coded to 2.0, so it allows even vs2005 projects
-				// to build correctly, as they won't have a ToolsVersion
-				// set!
-				return String.IsNullOrEmpty (defaultToolsVersion)
-						? "2.0"
-						: defaultToolsVersion;
+				if (String.IsNullOrEmpty (defaultToolsVersion))
+#if NET_4_0
+					return "4.0";
+#elif NET_3_5
+					return "3.5";
+#else
+					return "2.0";
+#endif
+				
+				return defaultToolsVersion;
 			}
 			set {
 				if (Toolsets [value] == null)
--- mono-2.10.8.1.orig/mcs/class/Mono.Security/Mono.Security.X509/X509Certificate.cs
+++ mono-2.10.8.1/mcs/class/Mono.Security/Mono.Security.X509/X509Certificate.cs
@@ -295,6 +295,14 @@ namespace Mono.Security.X509 {
 							hash = Mono.Security.Cryptography.MD2.Create ();
 #endif
 							break;
+						case "1.2.840.113549.1.1.3":	// MD4 with RSA encryption 
+							// maybe someone installed MD4 ?
+#if INSIDE_CORLIB
+							hash = HashAlgorithm.Create ("MD4");
+#else
+							hash = Mono.Security.Cryptography.MD4.Create ();
+#endif
+							break;
 						case "1.2.840.113549.1.1.4":	// MD5 with RSA encryption 
 							hash = MD5.Create ();
 							break;
@@ -303,6 +311,15 @@ namespace Mono.Security.X509 {
 						case "1.2.840.10040.4.3":	// SHA1-1 with DSA
 							hash = SHA1.Create ();
 							break;
+						case "1.2.840.113549.1.1.11":	// SHA-256 with RSA Encryption
+							hash = SHA256.Create ();
+							break;
+						case "1.2.840.113549.1.1.12":	// SHA-384 with RSA Encryption
+							hash = SHA384.Create ();
+							break;
+						case "1.2.840.113549.1.1.13":	// SHA-512 with RSA Encryption
+							hash = SHA512.Create ();
+							break;
 						default:
 							return null;
 					}
@@ -397,9 +414,13 @@ namespace Mono.Security.X509 {
 
 				switch (m_signaturealgo) {
 					case "1.2.840.113549.1.1.2":	// MD2 with RSA encryption 
+					case "1.2.840.113549.1.1.3":	// MD4 with RSA encryption 
 					case "1.2.840.113549.1.1.4":	// MD5 with RSA encryption 
 					case "1.2.840.113549.1.1.5":	// SHA-1 with RSA Encryption 
 					case "1.3.14.3.2.29":		// SHA1 with RSA signature
+					case "1.2.840.113549.1.1.11":	// SHA-256 with RSA Encryption
+					case "1.2.840.113549.1.1.12":	// SHA-384 with RSA Encryption
+					case "1.2.840.113549.1.1.13":	// SHA-512 with RSA Encryption
 						return (byte[]) signature.Clone ();
 
 					case "1.2.840.10040.4.3":	// SHA-1 with DSA
@@ -498,6 +519,11 @@ namespace Mono.Security.X509 {
 					// maybe someone installed MD2 ?
 					v.SetHashAlgorithm ("MD2");
 					break;
+				// MD4 with RSA encryption 
+				case "1.2.840.113549.1.1.3":
+					// maybe someone installed MD4 ?
+					v.SetHashAlgorithm ("MD4");
+					break;
 				// MD5 with RSA encryption 
 				case "1.2.840.113549.1.1.4":
 					v.SetHashAlgorithm ("MD5");
@@ -507,6 +533,23 @@ namespace Mono.Security.X509 {
 				case "1.3.14.3.2.29":
 					v.SetHashAlgorithm ("SHA1");
 					break;
+				// SHA-256 with RSA Encryption 
+				case "1.2.840.113549.1.1.11":
+					v.SetHashAlgorithm ("SHA256");
+					break;
+				// SHA-384 with RSA Encryption 
+				case "1.2.840.113549.1.1.12":
+					v.SetHashAlgorithm ("SHA384");
+					break;
+				// SHA-512 with RSA Encryption 
+				case "1.2.840.113549.1.1.13":
+					v.SetHashAlgorithm ("SHA512");
+					break;
+				// SHA1-1 with DSA
+				case "1.2.840.10040.4.3":
+					// invalid but this can occurs when building a bad chain - e.g. missing certificate(s)
+					// we return false so we can report the "chain" error to the user (not an exception)
+					return false;
 				default:
 					throw new CryptographicException ("Unsupported hash algorithm: " + m_signaturealgo);
 			}
--- mono-2.10.8.1.orig/mcs/class/corlib/System/Console.cs
+++ mono-2.10.8.1/mcs/class/corlib/System/Console.cs
@@ -126,8 +126,7 @@ namespace System
 				int code_page = 0;
 				Encoding.InternalCodePage (ref code_page);
 
-				if (code_page != -1 && ((code_page & 0x0fffffff) == 3 // UTF8Encoding.UTF8_CODE_PAGE
-					|| ((code_page & 0x10000000) != 0)))
+				if (code_page == UTF8Encoding.UTF8_CODE_PAGE || ((code_page & 0x10000000) != 0))
 					inputEncoding = outputEncoding = Encoding.UTF8Unmarked;
 				else
 					inputEncoding = outputEncoding = Encoding.Default;
--- mono-2.10.8.1.orig/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
+++ mono-2.10.8.1/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
@@ -277,11 +277,6 @@ namespace System.Reflection.Emit
 					"Argument value {0} is not valid.", (int) access),
 					"access");
 
-#if NET_4_0
-			if ((access & AssemblyBuilderAccess.RunAndCollect) == AssemblyBuilderAccess.RunAndCollect)
-				throw new NotSupportedException ("RunAndCollect not yet supported.");
-#endif
-
 			name = n.Name;
 			this.access = (uint)access;
 			flags = (uint) n.Flags;
@@ -884,7 +879,13 @@ namespace System.Reflection.Emit
 
 			}
 		}
-
+/*
+		internal bool IsCollectible {
+			get {
+				return access == (uint)AssemblyBuilderAccess.RunAndCollect;
+			}
+		}
+*/
 		internal string AssemblyDir {
 			get {
 				return dir;
--- mono-2.10.8.1.orig/mcs/build/rules.make
+++ mono-2.10.8.1/mcs/build/rules.make
@@ -26,7 +26,7 @@ Q_MCS=$(if $(V),,@echo "MCS     [$(PROFI
 
 USE_MCS_FLAGS = /codepage:$(CODEPAGE) $(LOCAL_MCS_FLAGS) $(PLATFORM_MCS_FLAGS) $(PROFILE_MCS_FLAGS) $(MCS_FLAGS)
 USE_MBAS_FLAGS = /codepage:$(CODEPAGE) $(LOCAL_MBAS_FLAGS) $(PLATFORM_MBAS_FLAGS) $(PROFILE_MBAS_FLAGS) $(MBAS_FLAGS)
-USE_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS)
+USE_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS) $(CPPFLAGS)
 CSCOMPILE = $(Q_MCS) $(MCS) $(USE_MCS_FLAGS)
 BASCOMPILE = $(MBAS) $(USE_MBAS_FLAGS)
 CCOMPILE = $(CC) $(USE_CFLAGS)
--- mono-2.10.8.1.orig/mcs/jay/Makefile
+++ mono-2.10.8.1/mcs/jay/Makefile
@@ -46,7 +46,7 @@ dist-local: dist-default
 test-local run-test-local run-test-ondotnet-local doc-update-local:
 
 jay: $(sources:.c=.o)
-	$(CCOMPILE) -o $@ $^
+	$(CCOMPILE) $(LDFLAGS) -o $@ $^
 
 %.o: %.c
 	$(CCOMPILE) -c -o $@ $^
--- mono-2.10.8.1.orig/mcs/tools/corcompare/mono-api-info.cs
+++ mono-2.10.8.1/mcs/tools/corcompare/mono-api-info.cs
@@ -130,8 +130,12 @@ namespace CorCompare
 		AssemblyDefinition LoadAssembly (string assembly)
 		{
 			try {
+				if (File.Exists (assembly))
+					return TypeHelper.Resolver.ResolveFile (assembly);
+
 				return TypeHelper.Resolver.Resolve (assembly);
-			} catch {
+			} catch (Exception e) {
+				Console.WriteLine (e);
 				return null;
 			}
 		}
--- mono-2.10.8.1.orig/libgc/configure.in
+++ mono-2.10.8.1/libgc/configure.in
@@ -112,6 +112,17 @@ case "$THREADS" in
 	AC_DEFINE(THREAD_LOCAL_ALLOC)
 	THREADDLLIBS="-lpthread -lrt"
 	;;
+     *-*-kfreebsd*-gnu)
+	AC_DEFINE(GC_FREEBSD_THREADS)
+	INCLUDES="$INCLUDES -pthread"
+	THREADDLLIBS=-pthread
+	AC_DEFINE(_REENTRANT)
+	if test "${enable_parallel_mark}" = yes; then
+		AC_DEFINE(PARALLEL_MARK)
+	fi
+	AC_DEFINE(THREAD_LOCAL_ALLOC)
+	AC_DEFINE(USE_COMPILER_TLS)
+	;;
       *-*-freebsd*)
 	AC_DEFINE(GC_FREEBSD_THREADS)
 	if test "x$PTHREAD_CFLAGS" != "x"; then
--- mono-2.10.8.1.orig/libgc/dyn_load.c
+++ mono-2.10.8.1/libgc/dyn_load.c
@@ -26,7 +26,7 @@
  * None of this is safe with dlclose and incremental collection.
  * But then not much of anything is safe in the presence of dlclose.
  */
-#if defined(__linux__) && !defined(_GNU_SOURCE)
+#if (defined(__linux__) || defined(__GLIBC__)) && !defined(_GNU_SOURCE)
     /* Can't test LINUX, since this must be define before other includes */
 #   define _GNU_SOURCE
 #endif
@@ -394,7 +394,7 @@ GC_bool GC_register_main_static_data()
 /* For glibc 2.2.4+.  Unfortunately, it doesn't work for older	*/
 /* versions.  Thanks to Jakub Jelinek for most of the code.	*/
 
-# if defined(LINUX) /* Are others OK here, too? */ \
+# if (defined(LINUX) || defined (__GLIBC__)) /* Are others OK here, too? */ \
      && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \
          || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) 
 
--- mono-2.10.8.1.orig/libgc/include/gc.h
+++ mono-2.10.8.1/libgc/include/gc.h
@@ -492,7 +492,7 @@ GC_API GC_PTR GC_malloc_atomic_ignore_of
 #   define GC_RETURN_ADDR (GC_word)__return_address
 #endif
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__GLIBC__)
 # include <features.h>
 # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1 || __GLIBC__ > 2) \
      && !defined(__ia64__)
--- mono-2.10.8.1.orig/libgc/include/private/gcconfig.h
+++ mono-2.10.8.1/libgc/include/private/gcconfig.h
@@ -55,7 +55,7 @@
 # endif
 
 /* And one for FreeBSD: */
-# if defined(__FreeBSD__) && !defined(FREEBSD)
+# if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__)) && !defined(FREEBSD)
 #    define FREEBSD
 # endif
 
@@ -1362,8 +1362,15 @@
 #	ifndef GC_FREEBSD_THREADS
 #	    define MPROTECT_VDB
 #	endif
-#      define SIG_SUSPEND SIGTSTP
-#      define SIG_THR_RESTART SIGCONT
+#       ifdef __GLIBC__
+#           define SIG_SUSPEND          (32+6)
+#           define SIG_THR_RESTART      (32+5)
+            extern int _end[];
+#           define DATAEND (_end)
+#       else
+#           define SIG_SUSPEND SIGTSTP
+#           define SIG_THR_RESTART SIGCONT
+#       endif
 #	define FREEBSD_STACKBOTTOM
 #	ifdef __ELF__
 #	    define DYNAMIC_LOADING
@@ -2129,6 +2136,28 @@
 	extern char * GC_FreeBSDGetDataStart();
 #	define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
 #   endif
+#   ifdef FREEBSD
+#	define OS_TYPE "FREEBSD"
+#	ifndef GC_FREEBSD_THREADS
+#	    define MPROTECT_VDB
+#	endif
+#	ifdef __GLIBC__
+#	    define SIG_SUSPEND		(32+6)
+#	    define SIG_THR_RESTART	(32+5)
+	    extern int _end[];
+#	    define DATAEND (_end)
+#	else
+#	    define SIG_SUSPEND SIGUSR1
+#	    define SIG_THR_RESTART SIGUSR2
+#	endif
+#	define FREEBSD_STACKBOTTOM
+#	ifdef __ELF__
+#	    define DYNAMIC_LOADING
+#	endif
+	extern char etext[];
+	extern char * GC_FreeBSDGetDataStart();
+#	define DATASTART GC_FreeBSDGetDataStart(0x1000, &etext)
+#   endif
 #   ifdef NETBSD
 #	define OS_TYPE "NETBSD"
 #	ifdef __ELF__
@@ -2216,7 +2245,7 @@
 #   define SUNOS5SIGS
 # endif
 
-# if defined(FREEBSD) && (__FreeBSD__ >= 4)
+# if defined(FREEBSD) && ((__FreeBSD__ >= 4) || (__FreeBSD_kernel__ >= 4))
 #   define SUNOS5SIGS
 # endif
 
@@ -2279,7 +2308,7 @@
 #   define CACHE_LINE_SIZE 32	/* Wild guess	*/
 # endif
 
-# ifdef LINUX
+# if defined(LINUX) || defined(__GLIBC__)
 #   define REGISTER_LIBRARIES_EARLY
     /* We sometimes use dl_iterate_phdr, which may acquire an internal	*/
     /* lock.  This isn't safe after the world has stopped.  So we must	*/
@@ -2360,7 +2389,7 @@
 #if defined(SPARC)
 # define CAN_SAVE_CALL_ARGS
 #endif
-#if (defined(I386) || defined(X86_64)) && defined(LINUX)
+#if (defined(I386) || defined(X86_64)) && (defined(LINUX) || defined(__GLIBC__))
 	    /* SAVE_CALL_CHAIN is supported if the code is compiled to save	*/
 	    /* frame pointers by default, i.e. no -fomit-frame-pointer flag.	*/
 # define CAN_SAVE_CALL_ARGS
--- mono-2.10.8.1.orig/mono/arch/arm/arm-dis.c
+++ mono-2.10.8.1/mono/arch/arm/arm-dis.c
@@ -95,7 +95,7 @@ void dump_reg(ARMDis* dis, int reg) {
 	if (!use_reg_alias || (reg > 3 && reg < 11)) {
 		fprintf(dis->dis_out, "r%d", reg);
 	} else {
-		fprintf(dis->dis_out, reg_alias[reg]);
+		fprintf(dis->dis_out, "%s", reg_alias[reg]);
 	}
 }
 
@@ -137,7 +137,7 @@ void dump_reglist(ARMDis* dis, int reg_l
 
 
 void dump_br(ARMDis* dis, ARMInstr i) {
-	fprintf(dis->dis_out, "b%s%s\t%x\t; %p -> %p",
+	fprintf(dis->dis_out, "b%s%s\t%x\t; %p -> %#x",
 	    (i.br.link == 1) ? "l" : "",
 	    cond[i.br.cond], i.br.offset, dis->pi, (int)dis->pi + 4*2 + ((int)(i.br.offset << 8) >> 6));
 }
@@ -376,7 +376,7 @@ void dump_swi(ARMDis* dis, ARMInstr i) {
 
 
 void dump_clz(ARMDis* dis, ARMInstr i) {
-	fprintf(dis->dis_out, "clz%s\t");
+	fprintf(dis->dis_out, "clz\t");
 	dump_reg(dis, i.clz.rd);
 	fprintf(dis->dis_out, ", ");
 	dump_reg(dis, i.clz.rm);
--- mono-2.10.8.1.orig/mono/utils/mono-sigcontext.h
+++ mono-2.10.8.1/mono/utils/mono-sigcontext.h
@@ -8,14 +8,14 @@
 
 #if defined(__i386__)
 
-#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__DragonFly__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__DragonFly__)
 #include <ucontext.h>
 #endif
 #if defined(__APPLE__)
 #include <AvailabilityMacros.h>
 #endif
 
-#if defined(__FreeBSD__) || defined(__DragonFly__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
 	#define UCONTEXT_REG_EAX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_eax)
 	#define UCONTEXT_REG_EBX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_ebx)
 	#define UCONTEXT_REG_ECX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_ecx)
@@ -112,6 +112,24 @@
 	#define UCONTEXT_REG_R12(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r12)
 	#define UCONTEXT_REG_R13(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r13)
 	#define UCONTEXT_REG_R14(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r14)
+	#define UCONTEXT_REG_R15(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r15)
+#elif defined(__FreeBSD_kernel__)
+	#define UCONTEXT_REG_RAX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rax)
+	#define UCONTEXT_REG_RBX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rbx)
+	#define UCONTEXT_REG_RCX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rcx)
+	#define UCONTEXT_REG_RDX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rdx)
+	#define UCONTEXT_REG_RBP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rbp)
+	#define UCONTEXT_REG_RSP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rsp)
+	#define UCONTEXT_REG_RSI(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rsi)
+	#define UCONTEXT_REG_RDI(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rdi)
+	#define UCONTEXT_REG_RIP(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_rip)
+	#define UCONTEXT_REG_R8(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r8)
+	#define UCONTEXT_REG_R9(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r9)
+	#define UCONTEXT_REG_R10(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r10)
+	#define UCONTEXT_REG_R11(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r11)
+	#define UCONTEXT_REG_R12(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r12)
+	#define UCONTEXT_REG_R13(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r13)
+	#define UCONTEXT_REG_R14(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r14)
 	#define UCONTEXT_REG_R15(ctx) (((ucontext_t*)(ctx))->uc_mcontext.mc_r15)
 #elif defined(__NetBSD__)
 	#define UCONTEXT_REG_RAX(ctx) (((ucontext_t*)(ctx))->uc_mcontext.__gregs [_REG_RAX])
--- mono-2.10.8.1.orig/mono/metadata/sgen-gc.h
+++ mono-2.10.8.1/mono/metadata/sgen-gc.h
@@ -199,7 +199,7 @@ struct _GCMemSection {
 
 typedef struct _SgenPinnedChunk SgenPinnedChunk;
 
-#if defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__)
+#if defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 const static int suspend_signal_num = SIGXFSZ;
 #else
 const static int suspend_signal_num = SIGPWR;
--- mono-2.10.8.1.orig/mono/metadata/security.c
+++ mono-2.10.8.1/mono/metadata/security.c
@@ -13,6 +13,7 @@
 
 #include <mono/metadata/assembly.h>
 #include <mono/metadata/appdomain.h>
+#include <mono/metadata/assembly.h>
 #include <mono/metadata/image.h>
 #include <mono/metadata/exception.h>
 #include <mono/metadata/object-internals.h>
--- mono-2.10.8.1.orig/mono/mini/Makefile.am
+++ mono-2.10.8.1/mono/mini/Makefile.am
@@ -147,7 +147,7 @@ mono_sgen_CFLAGS = $(SGEN_DEFINES) $(AM_
 # We build this after libmono was built so it contains the date when the final
 # link was done
 buildver.h: libmono-static.la
-	@echo "const char *build_date = \"`date`\";" > buildver.h
+	@echo "const char *build_date;" > buildver.h
 
 mono-main.$(OBJEXT): buildver.h
 mono_sgen-main.$(OBJEXT): buildver.h
@@ -708,16 +708,7 @@ EXTRA_DIST = $(common_BURGSRC) TestDrive
 	$(posix_sources)
 
 version.h: Makefile
-	if test -d $(top_srcdir)/.git; then \
-		(cd $(top_srcdir); \
-			LANG=C; export LANG; \
-			branch=`git branch | grep '^\*' | cut -d ' ' -f 2`; \
-			version=`git log --no-color --first-parent -n1 --pretty=format:%h`; \
-			echo "#define FULL_VERSION \"$$branch/$$version\""; \
-		); \
-	else \
-		echo "#define FULL_VERSION \"tarball\""; \
-	fi > version.h
+	echo "#define FULL_VERSION \"Debian $$(dpkg-parsechangelog -l$(top_srcdir)/debian/changelog | grep ^Vers | cut -d\  -f2)\"" > version.h
 
 # Utility target for patching libtool to speed up linking
 patch-libtool:
--- mono-2.10.8.1.orig/mono/mini/mini-x86.h
+++ mono-2.10.8.1/mono/mini/mini-x86.h
@@ -60,7 +60,7 @@ struct sigcontext {
 #endif /* __HAIKU__ */
 
 #if defined( __linux__) || defined(__sun) || defined(__APPLE__) || defined(__NetBSD__) || \
-       defined(__FreeBSD__) || defined(__OpenBSD__)
+       defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
 #define MONO_ARCH_USE_SIGACTION
 #endif
 
@@ -178,7 +178,7 @@ typedef struct {
 	gboolean need_stack_frame;
 } MonoCompileArch;
 
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) || defined(__FreeBSD_kernel__)
 # define SC_EAX sc_eax
 # define SC_EBX sc_ebx
 # define SC_ECX sc_ecx
--- mono-2.10.8.1.orig/mono/mini/mini-amd64.h
+++ mono-2.10.8.1/mono/mini/mini-amd64.h
@@ -302,7 +302,7 @@ typedef struct {
 
 #define MONO_ARCH_NOMAP32BIT
 
-#elif defined (__FreeBSD__)
+#elif defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
 
 #define REG_RAX 7
 #define REG_RCX 4
--- mono-2.10.8.1.orig/mono/tests/Makefile.am
+++ mono-2.10.8.1/mono/tests/Makefile.am
@@ -338,7 +338,6 @@ BASE_TEST_CS_SRC=		\
 	modules.cs	\
 	bug-81673.cs	\
 	bug-81691.cs	\
-	bug-80307.cs	\
 	bug-415577.cs	\
 	filter-stack.cs	\
 	vararg2.cs	\
