memcpy (p, buf, n);
}
\f
+void
+_bfd_ar_spacepadll (char *p, size_t n, const char *fmt, long long val)
+{
+ static char buf[20];
+ size_t len;
+ snprintf (buf, sizeof (buf), fmt, val);
+ len = strlen (buf);
+ if (len < n)
+ {
+ memcpy (p, buf, len);
+ memset (p + len, ' ', n - len);
+ }
+ else
+ memcpy (p, buf, n);
+}
+\f
bfd_boolean
_bfd_generic_mkarchive (bfd *abfd)
{
/* ar headers are space padded, not null padded! */
memset (hdr, ' ', sizeof (struct ar_hdr));
- _bfd_ar_spacepad (hdr->ar_date, sizeof (hdr->ar_date), "%-12lld",
- (long long)status.st_mtime);
+ _bfd_ar_spacepadll (hdr->ar_date, sizeof (hdr->ar_date), "%-12lld",
+ status.st_mtime);
#ifdef HPUX_LARGE_AR_IDS
/* HP has a very "special" way to handle UID/GID's with numeric values
> 99999. */
status.st_gid);
_bfd_ar_spacepad (hdr->ar_mode, sizeof (hdr->ar_mode), "%-8lo",
status.st_mode);
- _bfd_ar_spacepad (hdr->ar_size, sizeof (hdr->ar_size), "%-10ld",
+ _bfd_ar_spacepadll (hdr->ar_size, sizeof (hdr->ar_size), "%-10lld",
status.st_size);
memcpy (hdr->ar_fmag, ARFMAG, 2);
ared->parsed_size = status.st_size;
bfd_ardata (arch)->armap_timestamp = statbuf.st_mtime + ARMAP_TIME_OFFSET;
bfd_ardata (arch)->armap_datepos = (SARMAG
+ offsetof (struct ar_hdr, ar_date[0]));
- _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
+ _bfd_ar_spacepadll (hdr.ar_date, sizeof (hdr.ar_date), "%lld",
bfd_ardata (arch)->armap_timestamp);
_bfd_ar_spacepad (hdr.ar_uid, sizeof (hdr.ar_uid), "%ld", getuid ());
_bfd_ar_spacepad (hdr.ar_gid, sizeof (hdr.ar_gid), "%ld", getgid ());
/* Prepare an ASCII version suitable for writing. */
memset (hdr.ar_date, ' ', sizeof (hdr.ar_date));
- _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
+ _bfd_ar_spacepadll (hdr.ar_date, sizeof (hdr.ar_date), "%lld",
bfd_ardata (arch)->armap_timestamp);
/* Write it into the file. */
hdr.ar_name[0] = '/';
_bfd_ar_spacepad (hdr.ar_size, sizeof (hdr.ar_size), "%-10ld",
mapsize);
- _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
+ _bfd_ar_spacepadll (hdr.ar_date, sizeof (hdr.ar_date), "%lld",
time (NULL));
/* This, at least, is what Intel coff sets the values to. */
_bfd_ar_spacepad (hdr.ar_uid, sizeof (hdr.ar_uid), "%ld", 0);
memcpy (hdr.ar_name, "/SYM64/", strlen ("/SYM64/"));
_bfd_ar_spacepad (hdr.ar_size, sizeof (hdr.ar_size), "%-10ld",
mapsize);
- _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
+ _bfd_ar_spacepadll (hdr.ar_date, sizeof (hdr.ar_date), "%lld",
time (NULL));
/* This, at least, is what Intel coff sets the values to.: */
_bfd_ar_spacepad (hdr.ar_uid, sizeof (hdr.ar_uid), "%ld", 0);