+#endif
+ }
+ return 0;
+}
+
+int
+gmon_io_read (FILE *ifp, char *buf, size_t n)
+{
+ if (fread (buf, 1, n, ifp) != n)
+ return 1;
+ return 0;
+}
+
+int
+gmon_io_write_32 (FILE *ofp, unsigned int val)
+{
+ char buf[4];
+
+ bfd_put_32 (core_bfd, (bfd_vma) val, buf);
+ if (fwrite (buf, 1, 4, ofp) != 4)
+ return 1;
+ return 0;
+}
+
+#ifdef BFD_HOST_U_64_BIT
+static int
+gmon_io_write_64 (FILE *ofp, BFD_HOST_U_64_BIT val)
+{
+ char buf[8];
+
+ bfd_put_64 (core_bfd, (bfd_vma) val, buf);
+ if (fwrite (buf, 1, 8, ofp) != 8)
+ return 1;
+ return 0;
+}
+#endif
+
+int
+gmon_io_write_vma (FILE *ofp, bfd_vma val)
+{
+
+ switch (gmon_get_ptr_size ())
+ {
+ case ptr_32bit:
+ if (gmon_io_write_32 (ofp, (unsigned int) val))
+ return 1;
+ break;
+
+#ifdef BFD_HOST_U_64_BIT
+ case ptr_64bit:
+ if (gmon_io_write_64 (ofp, (BFD_HOST_U_64_BIT) val))
+ return 1;
+ break;
+#endif
+ }
+ return 0;
+}
+
+int
+gmon_io_write_8 (FILE *ofp, unsigned int val)
+{
+ char buf[1];
+
+ bfd_put_8 (core_bfd, val, buf);
+ if (fwrite (buf, 1, 1, ofp) != 1)
+ return 1;
+ return 0;
+}
+
+int
+gmon_io_write (FILE *ofp, char *buf, size_t n)
+{
+ if (fwrite (buf, 1, n, ofp) != n)
+ return 1;
+ return 0;
+}
+
+static int
+gmon_read_raw_arc (FILE *ifp, bfd_vma *fpc, bfd_vma *spc, unsigned long *cnt)
+{
+#ifdef BFD_HOST_U_64_BIT
+ BFD_HOST_U_64_BIT cnt64;
+#endif
+ unsigned int cnt32;
+
+ if (gmon_io_read_vma (ifp, fpc)
+ || gmon_io_read_vma (ifp, spc))
+ return 1;
+
+ switch (gmon_get_ptr_size ())
+ {
+ case ptr_32bit:
+ if (gmon_io_read_32 (ifp, &cnt32))
+ return 1;
+ *cnt = cnt32;
+ break;
+
+#ifdef BFD_HOST_U_64_BIT
+ case ptr_64bit:
+ if (gmon_io_read_64 (ifp, &cnt64))
+ return 1;
+ *cnt = cnt64;
+ break;
+#endif
+