Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/crunch/crunchgen Use new the --redefine-syms-file op...



details:   https://anonhg.NetBSD.org/src/rev/3f12abd338cf
branches:  trunk
changeset: 542447:3f12abd338cf
user:      simonb <simonb%NetBSD.org@localhost>
date:      Wed Jan 29 10:32:34 2003 +0000

description:
Use new the --redefine-syms-file option to objcopy to rename the symbols
we want to hide instead of making global symbols local (which doesn't
work on MIPS).

diffstat:

 usr.bin/crunch/crunchgen/crunchgen.c |  23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diffs (69 lines):

diff -r e236f534481c -r 3f12abd338cf usr.bin/crunch/crunchgen/crunchgen.c
--- a/usr.bin/crunch/crunchgen/crunchgen.c      Wed Jan 29 10:26:22 2003 +0000
+++ b/usr.bin/crunch/crunchgen/crunchgen.c      Wed Jan 29 10:32:34 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: crunchgen.c,v 1.40 2002/08/20 01:52:58 lukem Exp $     */
+/*     $NetBSD: crunchgen.c,v 1.41 2003/01/29 10:32:34 simonb Exp $    */
 /*
  * Copyright (c) 1994 University of Maryland
  * All Rights Reserved.
@@ -33,7 +33,7 @@
  */
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: crunchgen.c,v 1.40 2002/08/20 01:52:58 lukem Exp $");
+__RCSID("$NetBSD: crunchgen.c,v 1.41 2003/01/29 10:32:34 simonb Exp $");
 #endif
 
 #if HAVE_CONFIG_H
@@ -56,6 +56,11 @@
 #define MAXLINELEN     16384
 #define MAXFIELDS       2048
 
+/*
+ * Define RENAME_SYMS to rename symbols using objcopy --redefine-syms-file.
+ * Undef RENAME_SYMS to hide globals symbols using objcopy --keep-global-symbol.
+ */
+#define        RENAME_SYMS
 
 /* internal representation of conf file: */
 
@@ -829,6 +834,7 @@
     fprintf(outmk, "MAKE?=make\n");
 #ifdef NEW_TOOLCHAIN
     fprintf(outmk, "OBJCOPY?=objcopy\n");
+    fprintf(outmk, "NM?=nm\n");
 #else
     fprintf(outmk, "CRUNCHIDE?=crunchide\n");
 #endif
@@ -852,7 +858,7 @@
     fprintf(outmk, "all: ${PROG}\n\t${STRIP} ${PROG}\n");
     fprintf(outmk, "objs: $(SUBMAKE_TARGETS)\n");
     fprintf(outmk, "exe: %s\n", execfname);
-    fprintf(outmk, "clean:\n\trm -rf %s *.cro *.o *_stub.c ${CRUNCHEDOBJSDIRS}\n",
+    fprintf(outmk, "clean:\n\trm -rf %s *.cro *.cro.syms *.o *_stub.c ${CRUNCHEDOBJSDIRS}\n",
            execfname);
 }
 
@@ -903,10 +909,21 @@
     fprintf(outmk, "\t${LD} -dc -r -o %s.cro %s_stub.o $(%s_OBJPATHS)\n", 
            p->name, p->name, p->ident);
 #ifdef NEW_TOOLCHAIN
+#ifdef RENAME_SYMS
+    fprintf(outmk, "\t${NM} -ng %s.cro | grep -wv U | ", p->name);
+    fprintf(outmk, "egrep -vw _crunched_%s_stub | ", p->ident);
+    for (lst = p->keepsymbols; lst != NULL; lst = lst->next)
+       fprintf(outmk, "egrep -vw %s | ", lst->str);
+    fprintf(outmk, "env CRO=%s.cro awk "
+       "'{ print $$3 \" _$$$$hide$$$$\" ENVIRON[\"CRO\"] \"$$$$\" $$3 }' "
+       "> %s.cro.syms\n", p->name, p->name);
+    fprintf(outmk, "\t${OBJCOPY} --redefine-syms-file %s.cro.syms ", p->name);
+#else
     fprintf(outmk, "\t${OBJCOPY} --keep-global-symbol _crunched_%s_stub ",
            p->ident);
     for (lst = p->keepsymbols; lst != NULL; lst = lst->next)
        fprintf(outmk, "--keep-global-symbol %s ", lst->str);
+#endif
 #else
     fprintf(outmk, "\t${CRUNCHIDE} -k _crunched_%s_stub ", p->ident);
     for (lst = p->keepsymbols; lst != NULL; lst = lst->next)



Home | Main Index | Thread Index | Old Index