Below is a crunchgen diff, which enables a new keyword "proglibs".
This basically allows to specify per-program libraries for the linker.
With that change it is possible to make for example a crunched binary
with ssh, sshd and ssh-keygen ... something I couldn't manage to do
with the default crunchgen tool in base.
Here is an example:
# cat ./ssh.cbin.conf
libs -lgssapi -lkrb5 -lkafs -lcrypto -lutil -lz -ldes
progs ssh sshd ssh-keygen
special ssh srcdir /usr/src/usr.bin/ssh/ssh
special ssh proglibs /usr/src/usr.bin/ssh/lib/obj/libssh.a
special sshd srcdir /usr/src/usr.bin/ssh/sshd
special sshd proglibs /usr/src/usr.bin/ssh/lib/obj/libssh.a /usr/lib/libwrap.a
special ssh-keygen srcdir /usr/src/usr.bin/ssh/ssh-keygen
special ssh-keygen proglibs /usr/src/usr.bin/ssh/lib/obj/libssh.a
Here is the diff:
Index: usr.sbin/crunchgen/crunchgen.8
===================================================================
RCS file: /cvs/src/usr.sbin/crunchgen/crunchgen.8,v
retrieving revision 1.4
diff -u usr.sbin/crunchgen/crunchgen.8
--- usr.sbin/crunchgen/crunchgen.8 24 Nov 2008 18:03:22 -0000 1.4
+++ usr.sbin/crunchgen/crunchgen.8 1 Dec 2009 22:52:54 -0000
@@ -237,6 +237,10 @@
.Ar progname .
This is normally calculated by prepending the objdir
pathname to each file in the objs list.
+.It special Ar progname No proglibs Ar full-pathname-to-libraries ...
+Sets the libraries necessary for program
+.Ar progname .
+These libraries are used by the linker.
.El
.Pp
Only the objpaths parameter is actually needed by
Index: usr.sbin/crunchgen/crunchgen.c
===================================================================
RCS file: /cvs/src/usr.sbin/crunchgen/crunchgen.c,v
retrieving revision 1.5
diff -u usr.sbin/crunchgen/crunchgen.c
--- usr.sbin/crunchgen/crunchgen.c 7 Oct 2009 13:55:38 -0000 1.5
+++ usr.sbin/crunchgen/crunchgen.c 1 Dec 2009 22:52:54 -0000
@@ -74,7 +74,7 @@
struct prog *next;
char *name, *ident, *mf_name;
char *srcdir, *objdir;
- strlst_t *objs, *objpaths;
+ strlst_t *objs, *objpaths, *proglibs;
strlst_t *links;
int goterror;
} prog_t;
@@ -521,6 +521,10 @@
goto argcount;
if ((p->objdir = strdup(argv[3])) == NULL)
out_of_memory();
+ } else if (!strcmp(argv[2], "proglibs")) {
+ p->proglibs = NULL;
+ for (i = 3; i < argc; i++)
+ add_string(&p->proglibs, argv[i]);
} else if (!strcmp(argv[2], "objs")) {
p->objs = NULL;
for (i = 3; i < argc; i++)
@@ -923,6 +927,8 @@
if (p->srcdir && p->objs) {
fprintf(outmk, "%s_SRCDIR=%s\n", p->ident, p->srcdir);
+ fprintf(outmk, "%s_PROGLIBS=", p->ident);
+ output_strlst(outmk, p->proglibs);
fprintf(outmk, "%s_OBJS=", p->ident);
output_strlst(outmk, p->objs);
fprintf(outmk, "%s_make:\n", p->ident);
@@ -942,8 +948,8 @@
p->ident);
fprintf(outmk, "%s.lo: %s_stub.o $(%s_OBJPATHS)\n",
p->name, p->name, p->ident);
- fprintf(outmk, "\t$(LINK) -o $@ %s_stub.o $(%s_OBJPATHS)\n",
- p->name, p->ident);
+ fprintf(outmk, "\t$(LINK) -o $@ %s_stub.o $(%s_OBJPATHS) $(%s_PROGLIBS)
\n",
+ p->name, p->ident, p->ident);
fprintf(outmk, "\tcrunchgen %s -h -k %s_crunched_%s_stub $...@\n",
elf_mangle ? "-M" : "",
elf_names ? "" : "_", p->ident);
Regards,
Holger
;-se