commit 73c5c9f70a0c21a24592ad4270605736c5748de6
parent 5cbba5a759d3d7449e9d66440a435e96baa37c8f
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Tue, 8 Jan 2019 19:51:56 +0000
[ranlib] Ignore non libraries archives
Create the index only if all the members of the archive
are object files and of the same type.
Diffstat:
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/cmd/ranlib.c b/src/cmd/ranlib.c
@@ -19,7 +19,7 @@ struct name {
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,8 +125,13 @@ newmember(FILE *fp, char *name, void *data)
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");
@@ -235,12 +240,17 @@ ranlib(char *fname)
{
static char symdef[] = "__.SYMDEF";
+ nolib = 0;
+ artype = -1;
filename = fname;
freenames();
if (!readsyms(fname))
return;
+ if (nolib)
+ return;
+
if (!writeidx(symdef))
return;