This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch RFA] support 'deterministic mode' in ar


The attached patch adds support for a new 'deterministic mode' in
'ar', which causes uids, gids, and timestamps in archives to be set to
0, and file modes to consistently be set to 0644.

(I suggested the possibility of this feature a month or so ago, with a
prelim patch... and finally got around to finishing the patch.)

I've used this to successfully build a (cross-)gcc which produces
deterministic archives by setting AR_FOR_TARGET and RANLIB_FOR_TARGET
to, respectively:
 * a wrapper script (around the normal target 'ar') that adds the 'D'
flag into the command options, and
 * a wrapper script containing only #!/bin/true.
(if people call ranlib to update the archive map timestamp ... that'll
update the timestamp, defeating use of the new deterministic mode in
ar.)

also built for i686-linux (build/host/target), ran make check, all
tests passed.  Also looked at the resulting 'ar' manual page, it
looked sane.


chris
----
[bfd/ChangeLog]
2009-03-06  Chris Demetriou  <cgd@google.com>

        * bfd.c (BFD_DETERMINISTIC_OUTPUT): New flag.
        * bfd-in2.h: Regenerate.
        * ar.c (bfd_ar_hdr_from_filesystem): If BFD_DETERMINISTIC_OUTPUT flag
        is set, use 0 for uid, gid, and timestamp, and use 0644 for file mode.
        (bsd_write_armap): Likewise.
        (_bfd_archive_bsd_update_armap_timestamp): If BFD_DETERMINISTIC_OUTPUT
        flag is set, do nothing.
[cgd@cdemetriou-corp ~]$ head -50 !$
head -50 bu_deterministic.patch
[bfd/ChangeLog]
2009-03-06  Chris Demetriou  <cgd@google.com>

        * bfd.c (BFD_DETERMINISTIC_OUTPUT): New flag.
        * bfd-in2.h: Regenerate.
        * ar.c (bfd_ar_hdr_from_filesystem): If BFD_DETERMINISTIC_OUTPUT flag
        is set, use 0 for uid, gid, and timestamp, and use 0644 for file mode.
        (bsd_write_armap): Likewise.
        (_bfd_archive_bsd_update_armap_timestamp): If BFD_DETERMINISTIC_OUTPUT
        flag is set, do nothing.
        (coff_write_armap): If BFD_DETERMINISTIC_OUTPUT flag is set, use 0
        for timestamp.

[binutils/ChangeLog]
2009-03-06  Chris Demetriou  <cgd@google.com>

        * ar.c (deterministic): New global variable.
        (main): Recognize new 'D' option, which enables 'deterministic mode'.
        (usage): Document new 'D' option.
        (write_archive): Set BFD_DETERMINISTIC_OUTPUT in output archive's
        flags if deterministic mode was requested.
        * doc/binutils.texi (ar): Document deterministic mode ('D' option).

[binutils/testsuite/ChangeLog]
2009-03-06  Chris Demetriou  <cgd@google.com>

        * binutils-all/ar.exp (deterministic_archive): New test.

Attachment: bu_deterministic.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]