Subject: crunchgen and program names with dash
To: Tech-embed <tech-embed@NetBSD.org>
From: Mikolaj Golub <golub@inec.kharkov.com>
List: tech-embed
Date: 06/02/2006 10:51:44
Hi,

I am new in using crunchgen, but it looks like a bag for me.

crunchgen has problem with linking program that contains dash ('-') in
its name. The simple crunchgen config to reproduce:

test.conf:
----------
srcdirs	/usr/src/usr.bin/ssh
progs	ssh-keygen
libs	-lssh -lcrypto -lcrypt -lz 

% crunchgen -m Makefile test.conf
% make objs exe
......
test.o(.data+0x4): undefined reference to `_crunched_ssh_keygen_stub'
*** Error code 1

If you look at ssh-keygen.cro.syms that is used to redefine symbols in
ssh-keygen obj, you can see that crunchgen generates:

main _crunched_ssh-keygen_stub

instead of:

main _crunched_ssh_keygen_stub

(crunchgen have to remap all '-' to '_')

The problem appears to be in this part of the code:

--- crunchgen.c.orig    2006-05-31 23:36:35.000000000 +0300
+++ crunchgen.c 2006-05-31 23:37:36.000000000 +0300
@@ -1033,7 +1033,7 @@
     for (lst = p->keepsymbols; lst != NULL; lst = lst->next)
        fprintf(outmk, " / %s$$/ { next };", lst->str);
     fprintf(outmk, " / main$$/ { print \"main _crunched_%s_stub\"; next };",
-           p->name);
+           p->ident);
     /* gdb thinks these are C++ and ignores everthing after the first $$. */
     fprintf(outmk, " { print $$3 \" \" $$3 \"$$$$from$$$$%s\" }' "
            "> %s.cro.syms\n", p->name, p->name);

I am using NetBSD 3.0.

-- 
Mikolaj Golub