bfd_put_32 (obfd, from->pr_ppid, to->pr_ppid);
   bfd_put_32 (obfd, from->pr_pgrp, to->pr_pgrp);
   bfd_put_32 (obfd, from->pr_sid, to->pr_sid);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wstringop-truncation"
   strncpy (to->pr_fname, from->pr_fname, sizeof (to->pr_fname));
   strncpy (to->pr_psargs, from->pr_psargs, sizeof (to->pr_psargs));
+#pragma GCC diagnostic pop
 }
 
 /* External 32-bit structure for PRPSINFO.  This structure is
   bfd_put_32 (obfd, from->pr_ppid, to->pr_ppid);
   bfd_put_32 (obfd, from->pr_pgrp, to->pr_pgrp);
   bfd_put_32 (obfd, from->pr_sid, to->pr_sid);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wstringop-truncation"
   strncpy (to->pr_fname, from->pr_fname, sizeof (to->pr_fname));
   strncpy (to->pr_psargs, from->pr_psargs, sizeof (to->pr_psargs));
+#pragma GCC diagnostic pop
 }
 
 /* External 64-bit structure for PRPSINFO.  This structure is
   bfd_put_32 (obfd, from->pr_ppid, to->pr_ppid);
   bfd_put_32 (obfd, from->pr_pgrp, to->pr_pgrp);
   bfd_put_32 (obfd, from->pr_sid, to->pr_sid);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wstringop-truncation"
   strncpy (to->pr_fname, from->pr_fname, sizeof (to->pr_fname));
   strncpy (to->pr_psargs, from->pr_psargs, sizeof (to->pr_psargs));
+#pragma GCC diagnostic pop
 }
 
 /* External 64-bit structure for PRPSINFO.  This structure is
   bfd_put_32 (obfd, from->pr_ppid, to->pr_ppid);
   bfd_put_32 (obfd, from->pr_pgrp, to->pr_pgrp);
   bfd_put_32 (obfd, from->pr_sid, to->pr_sid);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wstringop-truncation"
   strncpy (to->pr_fname, from->pr_fname, sizeof (to->pr_fname));
   strncpy (to->pr_psargs, from->pr_psargs, sizeof (to->pr_psargs));
+#pragma GCC diagnostic pop
 }
 
 #endif
 
 #endif
 
       memset (&data, 0, sizeof (data));
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wstringop-truncation"
       strncpy (data.pr_fname, fname, sizeof (data.pr_fname));
       strncpy (data.pr_psargs, psargs, sizeof (data.pr_psargs));
+#pragma GCC diagnostic pop
       return elfcore_write_note (abfd, buf, bufsiz,
                                 "CORE", note_type, &data, sizeof (data));
     }
 
   while (tmp < file_endp)
     {
       const char *bslash = strchr (tmp, '\\');
-      size_t len = (bslash) ? (size_t) (bslash - tmp + 1) : strlen (tmp);
+      size_t len = bslash != NULL ? bslash - tmp + 1 : file_endp - tmp;
 
       /* Double all backslashes, since demand_copy_C_string (used by
         s_stab to extract the part in quotes) will try to replace them as
         escape sequences.  backslash may appear in a filespec.  */
-      strncpy (bufp, tmp, len);
+      memcpy (bufp, tmp, len);
 
       tmp += len;
       bufp += len;