- /* The size of the ranlib is the number of exported symbols in the
- archive * the number of bytes in a int, + an int for the count */
-
- unsigned int ranlibsize = (symbol_count * 4) + 4;
- unsigned int stringsize = stridx;
- unsigned int mapsize = stringsize + ranlibsize;
- file_ptr archive_member_file_ptr;
- bfd *current = arch->archive_head;
- bfd *last_elt = current; /* last element arch seen */
- int count;
- struct ar_hdr hdr;
- unsigned int i;
- int padit = mapsize & 1;
-
- if (padit) mapsize ++;
-
- /* work out where the first object file will go in the archive */
- archive_member_file_ptr = mapsize + elength + sizeof (struct ar_hdr) + SARMAG;
-
- memset ((char *)(&hdr), 0, sizeof (struct ar_hdr));
- hdr.ar_name[0] = '/';
- sprintf (hdr.ar_size, "%-10d", (int) mapsize);
- sprintf (hdr.ar_date, "%ld", (long)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);
- hdr.ar_fmag[0] = '`'; hdr.ar_fmag[1] = '\n';
-
- for (i = 0; i < sizeof (struct ar_hdr); i++)
- if (((char *)(&hdr))[i] == '\0') (((char *)(&hdr))[i]) = ' ';
-
- /* Write the ar header for this item and the number of symbols */
-
-
- bfd_write ((PTR)&hdr, 1, sizeof (struct ar_hdr), arch);
-
- bfd_write_bigendian_4byte_int(arch, symbol_count);
-
- /* Two passes, first write the file offsets for each symbol -
- remembering that each offset is on a two byte boundary
- */
-
- /* Write out the file offset for the file associated with each
- symbol, and remember to keep the offsets padded out */
-
- current = arch->archive_head;
- count = 0;
- while (current != (bfd *)NULL && count < symbol_count) {
- /* For each symbol which is used defined in this object, write out
- the object file's address in the archive */
-
- while (((bfd *)(map[count]).pos) == current) {
- bfd_write_bigendian_4byte_int(arch, archive_member_file_ptr);
- count++;
- }
- /* Add size of this archive entry */
- archive_member_file_ptr += arelt_size (current) + sizeof (struct
- ar_hdr);
- /* remember aboout the even alignment */
- archive_member_file_ptr += archive_member_file_ptr % 2;
- current = current->next;
- }
+ /* The size of the ranlib is the number of exported symbols in the
+ archive * the number of bytes in an int, + an int for the count. */
+ unsigned int ranlibsize = (symbol_count * 4) + 4;
+ unsigned int stringsize = stridx;
+ unsigned int mapsize = stringsize + ranlibsize;
+ unsigned int archive_member_file_ptr;
+ bfd *current = arch->archive_head;
+ unsigned int count;
+ struct ar_hdr hdr;
+ unsigned int i;
+ int padit = mapsize & 1;
+
+ if (padit)
+ mapsize++;
+
+ /* Work out where the first object file will go in the archive. */
+ archive_member_file_ptr = (mapsize
+ + elength
+ + sizeof (struct ar_hdr)
+ + SARMAG);
+
+ memset (&hdr, 0, sizeof (struct ar_hdr));
+ hdr.ar_name[0] = '/';
+ sprintf (hdr.ar_size, "%-10d", (int) mapsize);
+ sprintf (hdr.ar_date, "%ld", (long) 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]) = ' ';