From 390c0e4288ca46982c7702ec420d277c021032f4 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 11 Mar 2005 16:37:17 +0000 Subject: * libbfd-in.h (_bfd_ar_spacepad): New prototype. * libbfd.h: Rebuilt. * archive.c (_bfd_ar_spacepad): New function. (_bfd_construct_extended_name_table, _bfd_write_archive_contents, bsd_write_armap, _bfd_archive_bsd_update_armap_timestamp, coff_write_armap): Use it. (bfd_ar_hdr_from_filesystem): Likewise. Fix HP-UX large uid/gid support. * archive64.c (bfd_elf64_archive_write_armap): Use _bfd_ar_spacepad. --- bfd/archive64.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'bfd/archive64.c') diff --git a/bfd/archive64.c b/bfd/archive64.c index 1b9f5f3..6ee0d1a 100644 --- a/bfd/archive64.c +++ b/bfd/archive64.c @@ -156,7 +156,6 @@ bfd_elf64_archive_write_armap (bfd *arch, bfd *current = arch->archive_head; unsigned int count; struct ar_hdr hdr; - unsigned int i; int padding; bfd_byte buf[8]; @@ -169,19 +168,17 @@ bfd_elf64_archive_write_armap (bfd *arch, + sizeof (struct ar_hdr) + SARMAG); - memset (&hdr, 0, sizeof (struct ar_hdr)); - strcpy (hdr.ar_name, "/SYM64/"); - sprintf (hdr.ar_size, "%-10d", (int) mapsize); - sprintf (hdr.ar_date, "%ld", (long) time (NULL)); + memset (&hdr, ' ', sizeof (struct ar_hdr)); + 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", + time (NULL)); /* This, at least, is what Intel coff sets the values to.: */ - sprintf ((hdr.ar_uid), "%d", 0); - sprintf ((hdr.ar_gid), "%d", 0); - sprintf ((hdr.ar_mode), "%-7o", (unsigned) 0); - strncpy (hdr.ar_fmag, ARFMAG, 2); - - for (i = 0; i < sizeof (struct ar_hdr); i++) - if (((char *) (&hdr))[i] == '\0') - (((char *) (&hdr))[i]) = ' '; + _bfd_ar_spacepad (hdr.ar_uid, sizeof (hdr.ar_uid), "%ld", 0); + _bfd_ar_spacepad (hdr.ar_gid, sizeof (hdr.ar_gid), "%ld", 0); + _bfd_ar_spacepad (hdr.ar_mode, sizeof (hdr.ar_mode), "%-7lo", 0); + memcpy (hdr.ar_fmag, ARFMAG, 2); /* Write the ar header for this item and the number of symbols */ -- cgit v1.1