Develop and Download Open Source Software

Browse Subversion Repository

Diff of /trunk/bfd/archive.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 20 by monamour, Thu Dec 4 05:12:56 2008 UTC revision 21 by monamour, Mon Jul 27 20:34:36 2009 UTC
# Line 1652  bfd_ar_hdr_from_filesystem (bfd *abfd, c Line 1652  bfd_ar_hdr_from_filesystem (bfd *abfd, c
1652        return NULL;        return NULL;
1653      }      }
1654    
1655      /* If the caller requested that the BFD generate deterministic output,
1656         fake values for modification time, UID, GID, and file mode.  */
1657      if ((abfd->flags & BFD_DETERMINISTIC_OUTPUT) != 0)
1658        {
1659          status.st_mtime = 0;
1660          status.st_uid = 0;
1661          status.st_gid = 0;
1662          status.st_mode = 0644;
1663        }
1664    
1665    amt = sizeof (struct ar_hdr) + sizeof (struct areltdata);    amt = sizeof (struct ar_hdr) + sizeof (struct areltdata);
1666    ared = bfd_zalloc (abfd, amt);    ared = bfd_zalloc (abfd, amt);
1667    if (ared == NULL)    if (ared == NULL)
# Line 2220  bsd_write_armap (bfd *arch, Line 2230  bsd_write_armap (bfd *arch,
2230    unsigned int count;    unsigned int count;
2231    struct ar_hdr hdr;    struct ar_hdr hdr;
2232    struct stat statbuf;    struct stat statbuf;
2233      long uid, gid;
2234    
2235    firstreal = mapsize + elength + sizeof (struct ar_hdr) + SARMAG;    firstreal = mapsize + elength + sizeof (struct ar_hdr) + SARMAG;
2236    
2237    stat (arch->filename, &statbuf);    stat (arch->filename, &statbuf);
2238      if ((arch->flags & BFD_DETERMINISTIC_OUTPUT) == 0)
2239        {
2240          /* Remember the timestamp, to keep it holy.  But fudge it a little.  */
2241          bfd_ardata (arch)->armap_timestamp = (statbuf.st_mtime
2242                                                + ARMAP_TIME_OFFSET);
2243          uid = getuid();
2244          gid = getgid();
2245        }
2246      else
2247        {
2248          /* If deterministic, we use 0 as the timestamp in the map.
2249             Some linkers may require that the archive filesystem modification
2250             time is less than (or near to) the archive map timestamp.  Those
2251             linkers should not be used with deterministic mode.  (GNU ld and
2252             Gold do not have this restriction.)  */
2253          bfd_ardata (arch)->armap_timestamp = 0;
2254          uid = 0;
2255          gid = 0;
2256        }
2257    
2258    memset (&hdr, ' ', sizeof (struct ar_hdr));    memset (&hdr, ' ', sizeof (struct ar_hdr));
2259    memcpy (hdr.ar_name, RANLIBMAG, strlen (RANLIBMAG));    memcpy (hdr.ar_name, RANLIBMAG, strlen (RANLIBMAG));
   /* Remember the timestamp, to keep it holy.  But fudge it a little.  */  
   bfd_ardata (arch)->armap_timestamp = statbuf.st_mtime + ARMAP_TIME_OFFSET;  
2260    bfd_ardata (arch)->armap_datepos = (SARMAG    bfd_ardata (arch)->armap_datepos = (SARMAG
2261                                        + offsetof (struct ar_hdr, ar_date[0]));                                        + offsetof (struct ar_hdr, ar_date[0]));
2262    _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",    _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
2263                      bfd_ardata (arch)->armap_timestamp);                      bfd_ardata (arch)->armap_timestamp);
2264    _bfd_ar_spacepad (hdr.ar_uid, sizeof (hdr.ar_uid), "%ld", getuid ());    _bfd_ar_spacepad (hdr.ar_uid, sizeof (hdr.ar_uid), "%ld", uid);
2265    _bfd_ar_spacepad (hdr.ar_gid, sizeof (hdr.ar_gid), "%ld", getgid ());    _bfd_ar_spacepad (hdr.ar_gid, sizeof (hdr.ar_gid), "%ld", gid);
2266    _bfd_ar_spacepad (hdr.ar_size, sizeof (hdr.ar_size), "%-10ld", mapsize);    _bfd_ar_spacepad (hdr.ar_size, sizeof (hdr.ar_size), "%-10ld", mapsize);
2267    memcpy (hdr.ar_fmag, ARFMAG, 2);    memcpy (hdr.ar_fmag, ARFMAG, 2);
2268    if (bfd_bwrite (&hdr, sizeof (struct ar_hdr), arch)    if (bfd_bwrite (&hdr, sizeof (struct ar_hdr), arch)
# Line 2301  _bfd_archive_bsd_update_armap_timestamp Line 2330  _bfd_archive_bsd_update_armap_timestamp
2330    struct stat archstat;    struct stat archstat;
2331    struct ar_hdr hdr;    struct ar_hdr hdr;
2332    
2333      /* If creating deterministic archives, just leave the timestamp as-is.  */
2334      if ((arch->flags & BFD_DETERMINISTIC_OUTPUT) != 0)
2335        return TRUE;
2336    
2337    /* Flush writes, get last-write timestamp from file, and compare it    /* Flush writes, get last-write timestamp from file, and compare it
2338       to the timestamp IN the file.  */       to the timestamp IN the file.  */
2339    bfd_flush (arch);    bfd_flush (arch);
# Line 2385  coff_write_armap (bfd *arch, Line 2418  coff_write_armap (bfd *arch,
2418    _bfd_ar_spacepad (hdr.ar_size, sizeof (hdr.ar_size), "%-10ld",    _bfd_ar_spacepad (hdr.ar_size, sizeof (hdr.ar_size), "%-10ld",
2419                      mapsize);                      mapsize);
2420    _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",    _bfd_ar_spacepad (hdr.ar_date, sizeof (hdr.ar_date), "%ld",
2421                      time (NULL));                      ((arch->flags & BFD_DETERMINISTIC_OUTPUT) == 0
2422                         ? time (NULL) : 0));
2423    /* This, at least, is what Intel coff sets the values to.  */    /* This, at least, is what Intel coff sets the values to.  */
2424    _bfd_ar_spacepad (hdr.ar_uid, sizeof (hdr.ar_uid), "%ld", 0);    _bfd_ar_spacepad (hdr.ar_uid, sizeof (hdr.ar_uid), "%ld", 0);
2425    _bfd_ar_spacepad (hdr.ar_gid, sizeof (hdr.ar_gid), "%ld", 0);    _bfd_ar_spacepad (hdr.ar_gid, sizeof (hdr.ar_gid), "%ld", 0);

Legend:
Removed from v.20  
changed lines
  Added in v.21

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26