[binutils-gdb] Place the libdeps record in the second archive slot.
Nick Clifton
nickc@sourceware.org
Tue Nov 17 14:00:33 GMT 2020
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0833984dda29c0b363785edb54a2e1cbdf0d129e
commit 0833984dda29c0b363785edb54a2e1cbdf0d129e
Author: Howard Chu <hyc@symas.com>
Date: Tue Nov 17 14:00:08 2020 +0000
Place the libdeps record in the second archive slot.
* ar.c (main): Place the libdeps record in the second archive
slot.
Diff:
---
binutils/ChangeLog | 5 +++++
binutils/ar.c | 19 +++++++++++--------
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 6770c9b97f6..2124c59aa6b 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,8 @@
+2020-11-17 Howard Chu <hyc@symas.com>
+
+ * ar.c (main): Place the libdeps record in the second archive
+ slot.
+
2020-11-13 Nick Clifton <nickc@redhat.com>
PR 26829
diff --git a/binutils/ar.c b/binutils/ar.c
index 537b139e98f..7d279d6722a 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -890,13 +890,16 @@ main (int argc, char **argv)
if (bfd_find_target (plugin_target, libdeps_bfd) == NULL)
fatal (_("Cannot reset libdeps record type."));
- /* Append our libdeps record to the list of files
- being operated on. */
+ /* Insert our libdeps record in 2nd slot of the list of files
+ being operated on. We shouldn't use 1st slot, but we want
+ to avoid having to search all the way to the end of an
+ archive with a large number of members at link time. */
new_files = xmalloc ((file_count + 2) * sizeof (char *));
- for (i = 0; i < file_count; i++)
- new_files[i] = files[i];
- new_files[i++] = LIBDEPS;
- file_count = i;
+ new_files[0] = files[0];
+ new_files[1] = LIBDEPS;
+ for (i = 1; i < file_count; i++)
+ new_files[i+1] = files[i];
+ file_count = ++i;
files = new_files;
files[i] = NULL;
}
@@ -1135,7 +1138,7 @@ open_output_file (bfd * abfd)
output_filename, base);
output_filename = base;
}
-
+
if (output_dir)
{
size_t len = strlen (output_dir);
@@ -1152,7 +1155,7 @@ open_output_file (bfd * abfd)
if (verbose)
printf ("x - %s\n", output_filename);
-
+
FILE * ostream = fopen (output_filename, FOPEN_WB);
if (ostream == NULL)
{
More information about the Binutils-cvs
mailing list