Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Oct 2010 23:47:41 +0200
From:      Erik Cederstrand <erik@cederstrand.dk>
To:        Erik Trulsson <ertr1013@student.uu.se>
Cc:        FreeBSD Hackers <hackers@FreeBSD.org>
Subject:   Re: Timestamps in static libraries
Message-ID:  <C5C85BF7-3989-461E-A9C8-9D16AE779359@cederstrand.dk>
In-Reply-To: <20101005135906.GA3430@owl.midgard.homeip.net>
References:  <52C32EA5-A380-4237-A27C-9E2DF2D4E022@cederstrand.dk> <20101005135906.GA3430@owl.midgard.homeip.net>

next in thread | previous in thread | raw e-mail | index | archive | help

--Apple-Mail-1468-917900132
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii


Den 05/10/2010 kl. 15.59 skrev Erik Trulsson:

> On Tue, Oct 05, 2010 at 03:28:36PM +0200, Erik Cederstrand wrote:
>> Hello hackers,
>>=20
>> I got reminded of a problem I had a couple of years back compressing
>> FreeBSD jails.  I was using bsdiff for the compression and found out
>> that md5 sums of static libraries (.a files) in /usr/lib and
>> /usr/local/lib didn't match between jails, even though the source
>> code used to create the jails hadn't changed.  One of my goals is to
>> detect which files in a distribution change between two commits.
>>=20
>> It turns out that timestamps are stored in the library:
>=20
> Yes, they are.  That is because the file format used for static
> libraries include a timestamp for each object file stored in the
> archive.
>=20
> You can use 'ar -tv  /PATH/TO/LIBRARY/libfoo.a' to get a list of the
> objects stored in the archive and the corresponding timestamps.
>=20
> See the ar(5) manpage for a description of the file format, and the
> ar(1) manpage for information on how to manage such files.


Thanks, that was very helpful. It seems I can at least normalize the .a =
files using something like the following to weed out timestamps and =
uid/gid:

% ar -x /usr/lib/libfetch.a
% chown 0:0 *
% touch -t 197001010000 *
% ar -r libfetch.a `ar -t /usr/lib/libfetch.a`

The above takes ca. 10 seconds for all static libraries on my aging =
machine, which is OK in my case. Unfortunately it seems there's still a =
creation time of the archive itself that I cant alter using the above, =
so the md5 sums still don't match:

% diff mod.strings orig.strings
2c2
< /               1286312209  0     0     0       958       `
---
> /               1269146263  0     0     0       958       `

Using Python to replace 1286312209 with 1269146263 in the binary file =
now gives me matching md5 sums. It seems a bit complicated just to get =
rid of some timestamps, though.


Thanks,
Erik=

--Apple-Mail-1468-917900132--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C5C85BF7-3989-461E-A9C8-9D16AE779359>