--- a/bfd/opncls.c
+++ b/bfd/opncls.c
@@ -635,7 +635,7 @@
   /* If the file was open for writing and is now executable,
      make it so.  */
   if (abfd->direction == write_direction
-      && abfd->flags & EXEC_P)
+      && (abfd->flags & (EXEC_P | DYNAMIC)) != 0)
     {
       struct stat buf;