diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index eb3d7926c..d66c42b78 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -1439,10 +1439,11 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 	   && h->plt.refcount > 0)
     {
       /* Make sure this symbol is output as a dynamic symbol.
-	 Undefined weak syms won't yet be marked as dynamic.  */
+	 Undefined and undefweak syms won't yet be marked as dynamic.  */
       if (h->dynindx == -1
 	  && !h->forced_local
-	  && h->root.type == bfd_link_hash_undefweak
+	  && (h->root.type == bfd_link_hash_undefweak
+	      || h->root.type == bfd_link_hash_undefined)
 	  && !bfd_elf_link_record_dynamic_symbol (info, h))
 	return false;
 
@@ -1500,11 +1501,12 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
       int tls_type = riscv_elf_hash_entry (h)->tls_type;
 
       /* Make sure this symbol is output as a dynamic symbol.
-	 Undefined weak syms won't yet be marked as dynamic.  */
+	 Undefined and undefweak syms won't yet be marked as dynamic.  */
       if (dyn
 	  && h->dynindx == -1
 	  && !h->forced_local
-	  && h->root.type == bfd_link_hash_undefweak
+	  && (h->root.type == bfd_link_hash_undefweak
+	      || h->root.type == bfd_link_hash_undefined)
 	  && !bfd_elf_link_record_dynamic_symbol (info, h))
 	return false;
 
@@ -1611,10 +1613,11 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
 		      || h->root.type == bfd_link_hash_undefined))))
 	{
 	  /* Make sure this symbol is output as a dynamic symbol.
-	     Undefined weak syms won't yet be marked as dynamic.  */
+	     Undefined and undefweak syms won't yet be marked as dynamic.  */
 	  if (h->dynindx == -1
 	      && !h->forced_local
-	      && h->root.type == bfd_link_hash_undefweak
+	      && (h->root.type == bfd_link_hash_undefweak
+		  || h->root.type == bfd_link_hash_undefined)
 	      && !bfd_elf_link_record_dynamic_symbol (info, h))
 	    return false;
 
