tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Adjusting SYMTAB_SPACE automatically
Hi folks,
Building evb* kernels often fails because SYMTAB_SPACE options in
config files are too small.
Symtab gets larger as the kernel grows, and we had to adjust
SYMTAB_SPACE for various kernels by hand.
Following patch is to do that job automatically. I have tested it
for evbarm, evbsh3, and amd64.
Opinions?
Index: external/gpl3/binutils/usr.sbin/dbsym/dbsym.c
===================================================================
RCS file: /u0/tnfcvs/src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c,v
retrieving revision 1.1
diff -u -u -r1.1 dbsym.c
--- external/gpl3/binutils/usr.sbin/dbsym/dbsym.c 18 Aug 2009 20:22:20
-0000 1.1
+++ external/gpl3/binutils/usr.sbin/dbsym/dbsym.c 6 Mar 2012 09:16:47
-0000
@@ -75,6 +75,7 @@
int load_symtab(bfd *, int fd, char **, u_int32_t *);
int verbose;
+int printsize;
int
main(int argc, char **argv)
@@ -90,7 +91,7 @@
setprogname(argv[0]);
bfdname = NULL;
- while ((ch = getopt(argc, argv, "b:v")) != -1)
+ while ((ch = getopt(argc, argv, "b:pv")) != -1)
switch (ch) {
case 'b':
bfdname = optarg;
@@ -98,6 +99,9 @@
case 'v':
verbose = 1;
break;
+ case 'p':
+ printsize = 1;
+ break;
case '?':
default:
usage();
@@ -150,6 +154,11 @@
symtab_space = bfd_get_32(abfd,
&mappedkfile[db_symtab_symbols[X_DB_SYMTABSIZE].offset]);
+ if (printsize) {
+ printf("%d %d\n", symtabsize, symtab_space);
+ goto done;
+ }
+
if (symtabsize > symtab_space)
errx(1, "symbol table (%u bytes) too big for buffer (%u
bytes)\n"
"Increase options SYMTAB_SPACE in your kernel config",
@@ -168,6 +177,7 @@
bfd_put_32(abfd, symtabsize,
&mappedkfile[db_symtab_symbols[X_DB_SYMTABSIZE].offset]);
+done:
munmap(mappedkfile, ksb.st_size);
close(kfd);
Index: sys/arch/arm/conf/Makefile.arm
===================================================================
RCS file: /u0/tnfcvs/src/sys/arch/arm/conf/Makefile.arm,v
retrieving revision 1.32
diff -u -u -r1.32 Makefile.arm
--- sys/arch/arm/conf/Makefile.arm 27 Apr 2008 03:23:13 -0000 1.32
+++ sys/arch/arm/conf/Makefile.arm 6 Mar 2012 09:16:47 -0000
@@ -63,7 +63,8 @@
# Strip ARM mapping symbols from the kernel image, as they interfere
# with ddb. Do it differently if 'makeoptions DEBUG="-g"' was specified.
.if !defined(DEBUG) || empty(DEBUG:M-g*)
-SYSTEM_LD_TAIL?= @${OBJCOPY} --strip-symbol='$$a' \
+SYSTEM_LD_TAIL?= @${SYSTEM_LD_TAIL_DBSYM} ; \
+ ${OBJCOPY} --strip-symbol='$$a' \
--strip-symbol='$$t' \
--strip-symbol='$$d' $@ ;\
${SIZE} $@; chmod 755 $@
Index: sys/conf/Makefile.kern.inc
===================================================================
RCS file: /u0/tnfcvs/src/sys/conf/Makefile.kern.inc,v
retrieving revision 1.152
diff -u -u -r1.152 Makefile.kern.inc
--- sys/conf/Makefile.kern.inc 12 Feb 2012 16:34:11 -0000 1.152
+++ sys/conf/Makefile.kern.inc 6 Mar 2012 09:16:47 -0000
@@ -233,9 +233,43 @@
${_MKSHECHO}\
${LD} -Map $@.map --cref ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}'
'$${EXTRA_OBJ}' vers.o; \
${LD} -Map $@.map --cref ${LINKFLAGS} -o $@ ${SYSTEM_OBJ}
${EXTRA_OBJ} vers.o
-SYSTEM_LD_TAIL?=@${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/\\.*//' vers.c;
\
+
+AUTO_SYMTAB_SPACE?= yes
+
+.if empty(AUTO_SYMTAB_SPACE:M[Yy][Ee][Ss]) || defined(_SYMTAB_SPACE_ADJUSTED)
+SYSTEM_LD_TAIL_DBSYM?= true
+.else
+SYSTEM_LD_TAIL_DBSYM?= \
+ if grep '^\#define.*SYMTAB_SPACE' opt_ksyms.h > /dev/null; then \
+ _modify_opt_ksyms_h () { \
+ ${TOOL_SED} \
+ -e 's/^\(\#define.*SYMTAB_SPACE[ ]*\)[0-9]*/\1'$$1/ \
+ -e 's/\(.equiv[
]*_KERNEL_OPT_SYMTAB_SPACE,0x\)[0-9a-f]*/\1'$$(printf %x $$1)/ \
+ opt_ksyms.h > opt_ksyms.h.ADJ && \
+ mv opt_ksyms.h.ADJ opt_ksyms.h && \
+ ${MAKE} ${MFLAGS} _SYMTAB_SPACE_ADJUSTED=1 $@; \
+ }; \
+ _adj_symtab_space () { \
+ set -- $$(${DBSYM} -p $@); \
+ echo Symtab size: $$1, space: $$2; \
+ if [ "$$1" -gt "$$2" ]; then \
+ echo Adjusting symtab space; \
+ rm -f $@; \
+ _modify_opt_ksyms_h $$1; \
+ fi; \
+ }; \
+ _adj_symtab_space; \
+ fi
+.endif
+
+.if defined(_SYMTAB_SPACE_ADJUSTED)
+SYSTEM_LD_TAIL?=true
+.else
+SYSTEM_LD_TAIL?=@${SYSTEM_LD_TAIL_DBSYM} ; \
+ ${TOOL_SED} '/const char sccs/!d;s/.*@(.)//;s/\\.*//' vers.c; \
${SIZE} $@; chmod 755 $@; \
${SYSTEM_CTFMERGE}
+.endif
TEXTADDR?= ${LOADADDRESS} # backwards compatibility
LINKTEXT?= ${TEXTADDR:C/.+/-Ttext &/}
@@ -259,21 +293,24 @@
LINKFLAGS+= ${LINKFLAGS_DEBUG}
EXTRA_KERNELS+= ${KERNELS:@.KERNEL.@${.KERNEL.}.gdb@}
CTFFLAGS+= -g
+.if !defined(_SYMTAB_SPACE_ADJUSTED)
SYSTEM_LD_TAIL+=; \
if grep '^\#define.*SYMTAB_SPACE' opt_ksyms.h > /dev/null; then \
echo "${DBSYM} $@.gdb"; \
${DBSYM} $@.gdb || (rm -f $@ ; exit 1) || exit 1; \
fi
-
+.endif
.elifndef PROF
LINKFLAGS+= ${LINKFLAGS_NORMAL}
.endif
+.if !defined(_SYMTAB_SPACE_ADJUSTED)
SYSTEM_LD_TAIL+=; \
if grep '^\#define.*SYMTAB_SPACE' opt_ksyms.h > /dev/null; then \
echo "${DBSYM} $@"; \
${DBSYM} $@ || (rm -f $@ ; exit 1) || exit 1; \
fi
+.endif
SYSTEM_LD_HEAD+=${SYSTEM_LD_HEAD_EXTRA}
SYSTEM_LD_TAIL+=${SYSTEM_LD_TAIL_EXTRA}
Home |
Main Index |
Thread Index |
Old Index