diff --git a/ChangeLog b/ChangeLog
index 6165ca6638d3a072822ed85aa319a210a8a3dd3a..f9445b296eb7bd8b87b83a229f1d6a97db38b877 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2013-02-06  Niels Möller  <nisse@lysator.liu.se>
 
+	* config.m4.in: Substitute ASM_TYPE_PROGBITS as TYPE_PROGBITS.
+
 	* config.make.in: Added .s to the suffix list.
 
 	* Makefile.in (.asm.s): Use a separate make target for .asm
@@ -11,6 +13,10 @@
 	(asm.d): Make config.status write dependencies for .s files into
 	asm.d.
 	(ASM_ALIGN_LOG): Set to "no" when appropriate.
+	(ASM_TYPE_FUNCTION): Default to "@function".
+	(ASM_TYPE_PROGBITS): New substituted variable, set in the same way
+	as ASM_TYPE_FUNCTION.
+	(ASM_MARK_NOEXEC_STACK): Use TYPE_PROGBITS.
 
 	* asm.m4: Use changecom to disable m4 quoting. Use divert to
 	suppress output.
diff --git a/config.m4.in b/config.m4.in
index 666cf82588e5accf72d46ec0e03379af755cdc95..4c6565f5c2bb196d7bc3569e6b7903a0c5fe2e98 100644
--- a/config.m4.in
+++ b/config.m4.in
@@ -2,6 +2,7 @@ define(<srcdir>, <<@srcdir@>>)dnl
 define(<C_NAME>, <@ASM_SYMBOL_PREFIX@><$1>)dnl
 define(<ELF_STYLE>, <@ASM_ELF_STYLE@>)dnl
 define(<TYPE_FUNCTION>, <@ASM_TYPE_FUNCTION@>)dnl
+define(<TYPE_PROGBITS>, <@ASM_TYPE_PROGBITS@>)dnl
 define(<ALIGN_LOG>, <@ASM_ALIGN_LOG@>)dnl
 define(<ALIGNOF_UINT64_T>, <@ALIGNOF_UINT64_T@>)dnl
 define(<W64_ABI>, <@W64_ABI@>)dnl
diff --git a/configure.ac b/configure.ac
index 934926454861e46d5dd752537ffc9fb14886a92e..577b29dc17bb871eba63dd835218d65a1ba6836a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -386,7 +386,9 @@ AC_SUBST([CCPIC_MAYBE])
 
 ASM_SYMBOL_PREFIX=''
 ASM_ELF_STYLE='no'
-ASM_TYPE_FUNCTION=''
+# GNU as default is to use @
+ASM_TYPE_FUNCTION='@function'
+ASM_TYPE_PROGBITS='@progbits'
 ASM_MARK_NOEXEC_STACK=''
 ASM_ALIGN_LOG=''
 
@@ -410,29 +412,6 @@ if test x$enable_assembler = xyes ; then
     ASM_SYMBOL_PREFIX='_'
   fi
 
-  AC_CACHE_CHECK([if we should use a .note.GNU-stack section],
-  nettle_cv_asm_gnu_stack,
-  [ # Default
-    nettle_cv_asm_gnu_stack=no
-
-    cat >conftest.c <<EOF
-int foo() { return 0; }
-EOF
-    nettle_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >conftest.out 2>&1"
-    if AC_TRY_EVAL(nettle_compile); then
-      cat conftest.out >&AC_FD_CC
-      $OBJDUMP -x conftest.o | grep '\.note\.GNU-stack' > /dev/null \
-      && nettle_cv_asm_gnu_stack=yes
-    else
-      cat conftest.out >&AC_FD_CC
-      echo "configure: failed program was:" >&AC_FD_CC
-      cat conftest.s >&AC_FD_CC
-    fi
-    rm -f conftest.*])
-  if test x$nettle_cv_asm_gnu_stack = xyes ; then
-    ASM_MARK_NOEXEC_STACK='.section .note.GNU-stack,"",@progbits'
-  fi
-
   AC_CACHE_CHECK([for ELF-style .type,%function pseudo-ops],
     [nettle_cv_asm_type_percent_function],
     [GMP_TRY_ASSEMBLE([
@@ -465,12 +444,38 @@ foo:
   if test x$nettle_cv_asm_type_percent_function = xyes ; then
     ASM_ELF_STYLE='yes'
     ASM_TYPE_FUNCTION='%function'
+    ASM_TYPE_PROGBITS='%progbits'
   else
     if test x$nettle_cv_asm_type_hash_function = xyes ; then
       ASM_ELF_STYLE='yes'
       ASM_TYPE_FUNCTION='#function'
+      ASM_TYPE_PROGBITS='#progbits'
     fi
   fi
+
+  AC_CACHE_CHECK([if we should use a .note.GNU-stack section],
+  nettle_cv_asm_gnu_stack,
+  [ # Default
+    nettle_cv_asm_gnu_stack=no
+
+    cat >conftest.c <<EOF
+int foo() { return 0; }
+EOF
+    nettle_compile="$CC $CFLAGS $CPPFLAGS -c conftest.c >conftest.out 2>&1"
+    if AC_TRY_EVAL(nettle_compile); then
+      cat conftest.out >&AC_FD_CC
+      $OBJDUMP -x conftest.o | grep '\.note\.GNU-stack' > /dev/null \
+      && nettle_cv_asm_gnu_stack=yes
+    else
+      cat conftest.out >&AC_FD_CC
+      echo "configure: failed program was:" >&AC_FD_CC
+      cat conftest.s >&AC_FD_CC
+    fi
+    rm -f conftest.*])
+  if test x$nettle_cv_asm_gnu_stack = xyes ; then
+    ASM_MARK_NOEXEC_STACK='.section .note.GNU-stack,"",TYPE_PROGBITS'
+  fi
+
   AC_CACHE_CHECK([if .align assembly directive is logarithmic],
     [nettle_cv_asm_align_log],
     [GMP_TRY_ASSEMBLE([
@@ -484,6 +489,7 @@ fi
 AC_SUBST(ASM_SYMBOL_PREFIX)
 AC_SUBST(ASM_ELF_STYLE)
 AC_SUBST(ASM_TYPE_FUNCTION)
+AC_SUBST(ASM_TYPE_PROGBITS)
 AC_SUBST(ASM_MARK_NOEXEC_STACK)
 AC_SUBST(ASM_ALIGN_LOG)
 AC_SUBST(W64_ABI)