Add a patch to produce deterministic binutils archives.

This commit is contained in:
Andrius Štikonas 2021-03-02 22:02:53 +00:00
parent ecb6e4868a
commit ed0f613621
3 changed files with 84 additions and 14 deletions

View File

@ -4,6 +4,8 @@
# SPDX-License-Identifier: GPL-3.0-or-later
src_prepare() {
default_src_prepare
rm configure
autoconf-2.13
for dir in binutils bfd gas ld gprof libiberty opcodes; do

View File

@ -1,19 +1,19 @@
7b1da1994710a9aa36444bc7b407d08e71868d2359961f77d49e66a20af4d87a /after/bin/addr2line
74dd89fbb30b8a1ecbab65239044485a4008c905442b9c1e990c7e8801bb6831 /after/bin/ar
597f7b0e56caba525fdc03bb1d2687c90de56c238cbb57851064a953ca967bb5 /after/bin/as
0bc538abc2e08b42253a8da759e7129db90030694eb2346f582cfd3bde12b758 /after/bin/c++filt
e8fbe83b64a48e3b84a09f2cad2ae0eb386f91e8ab7113d87d018f5a93202737 /after/bin/gprof
a203fff2d5e392b8a594435a58389f6e9a96bc2aad2cc96987589f140bd3ff1a /after/bin/ld
fcdcbbd7b0e110db0af54ffe5f1f23cedce3453b146b9a9acbcaeba7abb09956 /after/bin/nm
9e867d24d0a712ce78f66ac420ea91446615ee95ff2d5d0a116b1eaa88d57ccc /after/bin/objcopy
a2a2aea479cbe6f87fd0d801a9f309715af8b3d7ddfe83419bd0982ae8418cb8 /after/bin/objdump
9d04d6617616fe5cb2cfb3fbc32b9fe9ab891a8f21ecf5fbf9e9570831826ef4 /after/bin/addr2line
8ac5f9c6281a4272bb5329b5d3b73bb744102b0e9c6964ebd5fbc893e56d866f /after/bin/ar
6dc5bf6e40feacd8ea20e7a8a3ded12fe37c2848b6023f284d22e89db09b101f /after/bin/as
4eae20278831c452f01d4a7dde2a795e9e1c0ab60f9d32590c8d77e98a33b39e /after/bin/c++filt
c70b11d11aaebefb92d08e61a18c2a79eb78f63add3a62c2b31fd73d394430ed /after/bin/gprof
20f10bddc981e797943980195794fdb19bfaf679be49c2e1236f0522ed9c07aa /after/bin/ld
e4409a21081ec94abda6c749a9791f68a5bdc35ee77093abb608cf7beefa8020 /after/bin/nm
97fcc442ec3785b1413133c2b4f528a005aa927a4e54f955bc17a07df620f189 /after/bin/objcopy
3d7a99f65f51aca2ec4c526683740637586c9321cf43fc0fc561955615c4d7ad /after/bin/objdump
e49bba1ea6a61fb90f754e8de4692ed0810e7c68429f0b22fbf37670607a7807 /after/bin/od
af1dd1d58e1c2023b2799d1a9653888e0253f285d762ec101d4b175adfcff0fe /after/bin/ranlib
530d1747439ab516ad010d170e2f56ebe2b2049043fb3d5e18a4234b04b96e5c /after/bin/ranlib
978d6cf91009703d14aa2c678b0fd90fa7e417dc4ade9c151986a56bca98a79a /after/bin/readelf
1e4a29fded449aaba9844502a983818babb9535d872f11daa0057e2d651146ed /after/bin/size
32d6fc414d07ef1c5cc51d115730d7e41487459ec735b959a4f0127b779929bc /after/bin/strings
f73212b09ef427ac4708262a23b4d3d24fa2500639902600726af8b7968cc3c5 /after/bin/strip
bf061ebdf7ef24944fcadd2f12583d00b5d174ea30a3b5cb23618b259d3cf0b1 /after/lib/musl/libbfd.a
9d1b1179b67279109e9648368a8ffedd71fdd1c21857ee77058192b0f1dbaeba /after/bin/size
82657d370bca61bf6a6a4cbfb621614582519f2e938be1a4d09c135344c7c889 /after/bin/strings
fe6eaa5cf6e6621356fff3cd047c7cd0051490e895915027b6d4439159707f36 /after/bin/strip
f5934b4f057018b7f14adc197460d8b238cff80294234d771a17a408d5794104 /after/lib/musl/libbfd.a
3c9ab37cff5f732bca1258879fabf3c6c734890de1d7aa6381a5945d38f31c86 /after/lib/musl/libbfd.la
61a03b0d2eafa5ad50242a7ee8ce8664c2ef342bf727f46ceab8999b61a9a61b /after/lib/musl/libiberty.a
6530574bde4f5c57b194ae4229efb9784a97cc89cd45fc0d852e9afb5e103e4f /after/lib/musl/libopcodes.a

View File

@ -0,0 +1,68 @@
SPDX-FileCopyrightText: 2021 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2009 Chris Demetriou <cgd@google.com>
SPDX-License-Identifier: GPL-2.0-or-later
Old binutils do not have support for creating deterministic archives.
Backported from upstream commit 36e4dce69dd23bea9ea2258dea35f034b6d6351c
--- bfd/archive.c 2021-03-01 00:05:54.888301655 +0000
+++ bfd/archive.c 2021-03-02 21:53:51.001617689 +0000
@@ -1396,10 +1396,6 @@
{
/* Assume we just "made" the member, and fake it. */
struct bfd_in_memory *bim = (struct bfd_in_memory *) member->iostream;
- time (&status.st_mtime);
- status.st_uid = getuid ();
- status.st_gid = getgid ();
- status.st_mode = 0644;
status.st_size = bim->size;
}
else if (stat (filename, &status) != 0)
@@ -1408,6 +1404,11 @@
return NULL;
}
+ status.st_mtime = 0;
+ status.st_uid = 0;
+ status.st_gid = 0;
+ status.st_mode = 0644;
+
amt = sizeof (struct ar_hdr) + sizeof (struct areltdata);
ared = (struct areltdata *) bfd_zalloc (abfd, amt);
if (ared == NULL)
@@ -2003,13 +2004,11 @@
stat (arch->filename, &statbuf);
memset ((char *) (&hdr), 0, sizeof (struct ar_hdr));
sprintf (hdr.ar_name, RANLIBMAG);
- /* Remember the timestamp, to keep it holy. But fudge it a little. */
- bfd_ardata (arch)->armap_timestamp = statbuf.st_mtime + ARMAP_TIME_OFFSET;
bfd_ardata (arch)->armap_datepos = (SARMAG
+ offsetof (struct ar_hdr, ar_date[0]));
- sprintf (hdr.ar_date, "%ld", bfd_ardata (arch)->armap_timestamp);
- sprintf (hdr.ar_uid, "%ld", (long) getuid ());
- sprintf (hdr.ar_gid, "%ld", (long) getgid ());
+ sprintf (hdr.ar_date, "%ld", 0);
+ sprintf (hdr.ar_uid, "%ld", 0);
+ sprintf (hdr.ar_gid, "%ld", 0);
sprintf (hdr.ar_size, "%-10d", (int) mapsize);
strncpy (hdr.ar_fmag, ARFMAG, 2);
for (i = 0; i < sizeof (struct ar_hdr); i++)
@@ -2082,6 +2081,8 @@
struct ar_hdr hdr;
unsigned int i;
+ return TRUE;
+
/* Flush writes, get last-write timestamp from file, and compare it
to the timestamp IN the file. */
bfd_flush (arch);
@@ -2169,7 +2170,7 @@
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));
+ sprintf (hdr.ar_date, "%ld", 0);
/* This, at least, is what Intel coff sets the values to. */
sprintf ((hdr.ar_uid), "%d", 0);
sprintf ((hdr.ar_gid), "%d", 0);