From 252f13ab5189b2f1d1202cbdd30e115e61404407 Mon Sep 17 00:00:00 2001 From: Luigi Rizzo Date: Sat, 30 Mar 2002 16:48:30 +0000 Subject: [PATCH] Add a "special progname lib xxx ..." command to crunchgen so the .lo files can be partially linked against libraries which redefine symbols in the standard libs, or which reference symbols in the objects. Submitted by: Sam Leffler MFC After: 3 days --- usr.sbin/crunch/crunchgen/crunchgen.1 | 6 ++++++ usr.sbin/crunch/crunchgen/crunchgen.c | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/usr.sbin/crunch/crunchgen/crunchgen.1 b/usr.sbin/crunch/crunchgen/crunchgen.1 index d925d9809d9..7fe0cadbef4 100644 --- a/usr.sbin/crunch/crunchgen/crunchgen.1 +++ b/usr.sbin/crunch/crunchgen/crunchgen.1 @@ -290,6 +290,12 @@ but some might like to use other conventions or prepend the program's name to the variable, e.g.\& .Va SSHD_OBJS . +.It Ic special Ar progname Ic lib Ar library-name ... +Specifies libraries to be linked with object files to produce +.Ar progname.lo . +This can be useful with libraries which redefine routines in +the standard libraries, or poorly written libraries which +reference symbols in the object files. .It Ic special Ar progname Ic keep Ar symbol-name ... Add specified list of symbols to the keep list for program .Ar progname . diff --git a/usr.sbin/crunch/crunchgen/crunchgen.c b/usr.sbin/crunch/crunchgen/crunchgen.c index 3105883b2a9..8383b66b322 100644 --- a/usr.sbin/crunch/crunchgen/crunchgen.c +++ b/usr.sbin/crunch/crunchgen/crunchgen.c @@ -73,6 +73,7 @@ typedef struct prog { strlst_t *buildopts; strlst_t *keeplist; strlst_t *links; + strlst_t *libs; int goterror; } prog_t; @@ -406,6 +407,7 @@ void add_prog(char *progname) p2->realsrcdir = NULL; p2->objdir = NULL; p2->links = NULL; + p2->libs = NULL; p2->objs = NULL; p2->keeplist = NULL; p2->buildopts = NULL; @@ -506,6 +508,9 @@ void add_special(int argc, char **argv) p->buildopts = NULL; for (i = 3; i < argc; i++) add_string(&p->buildopts, argv[i]); + } else if (!strcmp(argv[2], "lib")) { + for (i = 3; i < argc; i++) + add_string(&p->libs, argv[i]); } else { warnx("%s:%d: bad parameter name `%s', skipping line", curfilename, linenum, argv[2]); @@ -1010,16 +1015,26 @@ void prog_makefile_rules(FILE *outmk, prog_t *p) } fprintf(outmk, "\n"); } + if (p->libs) { + fprintf(outmk, "%s_LIBS=", p->ident); + output_strlst(outmk, p->libs); + } fprintf(outmk, "%s_stub.c:\n", p->name); fprintf(outmk, "\techo \"" "int _crunched_%s_stub(int argc, char **argv, char **envp)" "{return main(argc,argv,envp);}\" >%s_stub.c\n", p->ident, p->name); - fprintf(outmk, "%s.lo: %s_stub.o $(%s_OBJPATHS)\n", + fprintf(outmk, "%s.lo: %s_stub.o $(%s_OBJPATHS)", p->name, p->name, p->ident); - fprintf(outmk, "\tld -dc -r -o %s.lo %s_stub.o $(%s_OBJPATHS)\n", + if (p->libs) + fprintf(outmk, " $(%s_LIBS)", p->ident); + fprintf(outmk, "\n"); + fprintf(outmk, "\tld -dc -r -o %s.lo %s_stub.o $(%s_OBJPATHS)", p->name, p->name, p->ident); + if (p->libs) + fprintf(outmk, " $(%s_LIBS)", p->ident); + fprintf(outmk, "\n"); fprintf(outmk, "\tcrunchide -k _crunched_%s_stub ", p->ident); for (lst = p->keeplist; lst != NULL; lst = lst->next) fprintf(outmk, "-k _%s ", lst->str);