ref: 02dd1ce68e196c343ccae71380632300b599b2e2
parent: 0b07caedf14634c43f549bcab131ad34ab4ffed7
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Feb 10 06:37:24 EST 2019
[libmach] Add a parameter to objlookup() It is useful if you only want to check if a set of symbols are defined.
--- a/include/scc/scc/mach.h
+++ b/include/scc/scc/mach.h
@@ -74,7 +74,7 @@
extern int objdel(Obj *obj);
extern int objreset(Obj *obj);
extern int objread(Obj *obj, FILE *fp);
-extern Objsym *objlookup(Obj *obj, char *name);
+extern Objsym *objlookup(Obj *obj, char *name, int install);
extern int objstrip(Obj *obj);
extern long arindex(int type, long nsyms, Objsymdef *def, FILE *fp);
extern int objwrite(Obj *obj, FILE *fp);
--- a/src/cmd/ld/main.c
+++ b/src/cmd/ld/main.c
@@ -197,7 +197,7 @@
if (inlib) {
for (sym = refhead.next; sym != &refhead; sym = sym->next) {
- if (objlookup(obj, sym->name))
+ if (objlookup(obj, sym->name, 0))
break;
}
if (sym == &refhead)
--- a/src/libmach/coff32/coff32read.c
+++ b/src/libmach/coff32/coff32read.c
@@ -386,7 +386,7 @@
if ((s = symname(coff, ent)) == NULL)
return 0;
- if ((sym = objlookup(obj, s)) == NULL)
+ if ((sym = objlookup(obj, s, 1)) == NULL)
return 0;
sym->type = t;
--- a/src/libmach/objlookup.c
+++ b/src/libmach/objlookup.c
@@ -5,7 +5,7 @@
#include <scc/mach.h>
Objsym *
-objlookup(Obj *obj, char *name)
+objlookup(Obj *obj, char *name, int install)
{
unsigned h;
size_t len;
@@ -21,6 +21,8 @@
if (!strcmp(name, sym->name))
return sym;
}
+ if (!install)
+ return NULL;
if ((sym = malloc(sizeof(*sym))) == NULL)
return NULL;