diff --git a/ChangeLog b/ChangeLog
index a084e866f1c0837a746a1662902d996ff87cb159..6ee1bb0aa943444f9e83fee64d6d2bb414b3250f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2014-05-31  Niels Möller  <nisse@lysator.liu.se>
 
+	* configure.ac: Check for COFF type directives.
+	(ASM_COFF_STYLE): New substituted variable.
+	* config.m4.in: Set COFF_STYLE from configure.
+	* asm.m4 (PROLOGUE): Use COFF type directive, if enabled by
+	configure. Fixes problem with windows dll linking.
+
 	* asm.m4: Deleted unused offsets for struct aes_ctx.
 
 2014-05-28  Niels Möller  <nisse@lysator.liu.se>
diff --git a/asm.m4 b/asm.m4
index 97cb6a0e5a8c8dc0181aacb10572e336bd7ee35f..d59191e14119d5fae2e838fbbb7a2f50add265e8 100644
--- a/asm.m4
+++ b/asm.m4
@@ -19,6 +19,13 @@ define(<PROLOGUE>,
 <.globl C_NAME($1)
 .type C_NAME($1),TYPE_FUNCTION
 C_NAME($1):>,
+COFF_STYLE, <yes>,
+<.globl C_NAME($1)
+.def C_NAME($1)
+.scl 2
+.type 32
+.endef
+C_NAME($1):>,
 <.globl C_NAME($1)
 C_NAME($1):>)>)
 
diff --git a/config.m4.in b/config.m4.in
index bcfb95e540692f8f0e795c40d249309db646ac0c..3f7700bbed1d26f287743dd819c6475c25f2f8c1 100644
--- a/config.m4.in
+++ b/config.m4.in
@@ -1,6 +1,7 @@
 define(<srcdir>, <<@srcdir@>>)dnl
 define(<C_NAME>, <@ASM_SYMBOL_PREFIX@><$1>)dnl
 define(<ELF_STYLE>, <@ASM_ELF_STYLE@>)dnl
+define(<COFF_STYLE>, <@ASM_COFF_STYLE@>)dnl
 define(<TYPE_FUNCTION>, <@ASM_TYPE_FUNCTION@>)dnl
 define(<TYPE_PROGBITS>, <@ASM_TYPE_PROGBITS@>)dnl
 define(<ALIGN_LOG>, <@ASM_ALIGN_LOG@>)dnl
diff --git a/configure.ac b/configure.ac
index 34d339ab37a0f184963388bb4b46f657afc7c2e3..31b2839dd1abd4b93270017a9055252e8d217014 100644
--- a/configure.ac
+++ b/configure.ac
@@ -487,6 +487,7 @@ AC_SUBST([CCPIC_MAYBE])
 
 ASM_SYMBOL_PREFIX=''
 ASM_ELF_STYLE='no'
+ASM_COFF_STYLE='no'
 # GNU as default is to use @
 ASM_TYPE_FUNCTION='@function'
 ASM_TYPE_PROGBITS='@progbits'
@@ -554,6 +555,23 @@ foo:
     fi
   fi
 
+  AC_CACHE_CHECK([for COFF-style .type directive],
+    [nettle_cv_asm_coff_type],
+      [GMP_TRY_ASSEMBLE([
+.text
+.globl _foo
+.def _foo
+.scl 2
+.type 32
+.endef
+_foo:
+],
+        [nettle_cv_asm_coff_type=yes],
+        [nettle_cv_asm_coff_type=no])])
+  if test "x$nettle_cv_asm_coff_type" = "xyes" ; then
+    ASM_COFF_STYLE=yes
+  fi
+
   AC_CACHE_CHECK([if we should use a .note.GNU-stack section],
   nettle_cv_asm_gnu_stack,
   [ # Default
@@ -589,6 +607,7 @@ fi
 
 AC_SUBST(ASM_SYMBOL_PREFIX)
 AC_SUBST(ASM_ELF_STYLE)
+AC_SUBST(ASM_COFF_STYLE)
 AC_SUBST(ASM_TYPE_FUNCTION)
 AC_SUBST(ASM_TYPE_PROGBITS)
 AC_SUBST(ASM_MARK_NOEXEC_STACK)