ref: a6e22cb9f86b96fff7b25f9cd269f05ff73a7d28
parent: 4effab9743c86099794e0bca4035a59d7405de47
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Jan 8 14:51:56 EST 2019
[ranlib] Ignore non libraries archives Create the index only if all the members of the archive are object files and of the same type.
--- a/src/cmd/ranlib.c
+++ b/src/cmd/ranlib.c
@@ -19,7 +19,7 @@
Name *hash, *next;
};
-static int status, tflag;
+static int status, tflag, artype, nolib;
static char *filename, *membname;
static Name *htab[NR_NAMES], *head;
static long offset;
@@ -125,9 +125,14 @@
return 0;
}
- if ((t = objtype(fp, NULL)) == -1)
- return 1;
+ t = objtype(fp, NULL);
+ if(t == -1 || artype != -1 && artype != t) {
+ nolib = 1;
+ return 0;
+ }
+ artype = t;
+
if ((obj = objnew(t)) == NULL) {
error("out of memory");
return 0;
@@ -235,10 +240,15 @@
{
static char symdef[] = "__.SYMDEF";
+ nolib = 0;
+ artype = -1;
filename = fname;
freenames();
if (!readsyms(fname))
+ return;
+
+ if (nolib)
return;
if (!writeidx(symdef))