From 868bf42666b74ccfa0e87bb4560801a63f71db83 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Wed, 11 Nov 2020 14:54:25 +0000 Subject: [PATCH] Insert libdeps record as 2nd member of archive instead of last --- binutils/ar.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/binutils/ar.c b/binutils/ar.c index 537b139e98..8bde751168 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; } -- 2.20.1