CVS commit: src/external/gpl3/binutils/usr.sbin/dbsym
Module Name:src Committed By: joerg Date: Tue Jul 11 21:19:42 UTC 2017 Modified Files: src/external/gpl3/binutils/usr.sbin/dbsym: dbsym.c Log Message: Allocate enough memory. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c diff -u src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c:1.5 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c:1.6 --- src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c:1.5 Thu Jul 6 02:34:00 2017 +++ src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c Tue Jul 11 21:19:42 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: dbsym.c,v 1.5 2017/07/06 02:34:00 chs Exp $ */ +/* $NetBSD: dbsym.c,v 1.6 2017/07/11 21:19:42 joerg Exp $ */ /* * Copyright (c) 2001 Simon Burge (for Wasabi Systems) @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1996 Christopher G. Demetriou.\ Copyright 2001 Simon Burge.\ All rights reserved."); -__RCSID("$NetBSD: dbsym.c,v 1.5 2017/07/06 02:34:00 chs Exp $"); +__RCSID("$NetBSD: dbsym.c,v 1.6 2017/07/11 21:19:42 joerg Exp $"); #endif /* not lint */ #include @@ -426,7 +426,7 @@ load_symtab(bfd *abfd, int fd, char **sy shstridx = (ISELF64 ? bfd_get_16(abfd, e64_hdr.e_shstrndx) : bfd_get_16(abfd, e32_hdr.e_shstrndx)); - shstrtab = malloc(shstridx); + shstrtab = malloc(SH_SIZE(shstridx)); if (shstrtab == NULL) goto out; if (pread(fd, shstrtab, SH_SIZE(shstridx), SH_OFFSET(shstridx)) !=
CVS commit: src/external/gpl3/binutils/usr.sbin/dbsym
Module Name:src Committed By: chs Date: Thu Jul 6 02:34:00 UTC 2017 Modified Files: src/external/gpl3/binutils/usr.sbin/dbsym: dbsym.c Log Message: copy the CTF section too, if there is one. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c diff -u src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c:1.4 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c:1.5 --- src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c:1.4 Sun Aug 17 19:12:59 2014 +++ src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c Thu Jul 6 02:34:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: dbsym.c,v 1.4 2014/08/17 19:12:59 joerg Exp $ */ +/* $NetBSD: dbsym.c,v 1.5 2017/07/06 02:34:00 chs Exp $ */ /* * Copyright (c) 2001 Simon Burge (for Wasabi Systems) @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1996 Christopher G. Demetriou.\ Copyright 2001 Simon Burge.\ All rights reserved."); -__RCSID("$NetBSD: dbsym.c,v 1.4 2014/08/17 19:12:59 joerg Exp $"); +__RCSID("$NetBSD: dbsym.c,v 1.5 2017/07/06 02:34:00 chs Exp $"); #endif /* not lint */ #include @@ -362,8 +362,9 @@ load_symtab(bfd *abfd, int fd, char **sy Elf32_External_Shdr *s32hdr = NULL; Elf64_External_Shdr *s64hdr = NULL; void *shdr; + char *shstrtab = NULL; u_int32_t osymtabsize, sh_offset; - int elftype, e_shnum, i, sh_size; + int elftype, e_shnum, i, sh_size, rv = 1, shstridx; off_t e_shoff; if (lseek(fd, 0, SEEK_SET) < 0) @@ -422,8 +423,19 @@ load_symtab(bfd *abfd, int fd, char **sy if (read(fd, shdr, sh_size) != sh_size) goto out; + shstridx = (ISELF64 + ? bfd_get_16(abfd, e64_hdr.e_shstrndx) + : bfd_get_16(abfd, e32_hdr.e_shstrndx)); + shstrtab = malloc(shstridx); + if (shstrtab == NULL) + goto out; + if (pread(fd, shstrtab, SH_SIZE(shstridx), SH_OFFSET(shstridx)) != + SH_SIZE(shstridx)) + goto out; + for (i = 0; i < e_shnum; i++) { - if (SH_TYPE(i) == SHT_SYMTAB || SH_TYPE(i) == SHT_STRTAB) { + if (SH_TYPE(i) == SHT_SYMTAB || SH_TYPE(i) == SHT_STRTAB || + !strcmp(shstrtab + SH_NAME(i), ".SUNW_ctf")) { osymtabsize = *symtabsize; *symtabsize += roundup(SH_SIZE(i), ISELF64 ? 8 : 4); if ((*symtab = realloc(*symtab, *symtabsize)) == NULL) @@ -467,10 +479,11 @@ load_symtab(bfd *abfd, int fd, char **sy bfd_put_16(abfd, 0, e32_hdr.e_phnum); } memcpy(*symtab, &ehdr, sizeof(ehdr)); + rv = 0; - free(shdr); - return (0); out: + if (shstrtab != NULL) + free(shstrtab); free(shdr); - return (1); + return (rv); }
CVS commit: src/external/gpl3/binutils/usr.sbin/dbsym
Module Name:src Committed By: joerg Date: Sun Aug 17 19:12:59 UTC 2014 Modified Files: src/external/gpl3/binutils/usr.sbin/dbsym: dbsym.8 dbsym.c Log Message: Add new option -P to print only the symbol table size. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8 \ src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8 diff -u src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8:1.3 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8:1.4 --- src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8:1.3 Mon Mar 19 09:13:33 2012 +++ src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8 Sun Aug 17 19:12:59 2014 @@ -1,6 +1,6 @@ -.\" $NetBSD: dbsym.8,v 1.3 2012/03/19 09:13:33 wiz Exp $ +.\" $NetBSD: dbsym.8,v 1.4 2014/08/17 19:12:59 joerg Exp $ .\" -.Dd March 19, 2012 +.Dd August 14, 2014 .Dt DBSYM 8 .Os .Sh NAME @@ -8,7 +8,7 @@ .Nd copy kernel symbol table into db_symtab space .Sh SYNOPSIS .Nm -.Op Fl pv +.Op Fl Ppv .Op Fl b Ar bfdname .Ar kernel .Sh DESCRIPTION @@ -34,6 +34,12 @@ To recognize kernel executable format, t flag specifies BFD name of kernel. .Pp If the +.Fl P +flag is given, +.Nm +will report the size of the kernel symbol table. +.Pp +If the .Fl p flag is given, .Nm Index: src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c diff -u src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c:1.3 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c:1.4 --- src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c:1.3 Mon Mar 19 09:14:15 2012 +++ src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c Sun Aug 17 19:12:59 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: dbsym.c,v 1.3 2012/03/19 09:14:15 wiz Exp $ */ +/* $NetBSD: dbsym.c,v 1.4 2014/08/17 19:12:59 joerg Exp $ */ /* * Copyright (c) 2001 Simon Burge (for Wasabi Systems) @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1996 Christopher G. Demetriou.\ Copyright 2001 Simon Burge.\ All rights reserved."); -__RCSID("$NetBSD: dbsym.c,v 1.3 2012/03/19 09:14:15 wiz Exp $"); +__RCSID("$NetBSD: dbsym.c,v 1.4 2014/08/17 19:12:59 joerg Exp $"); #endif /* not lint */ #include @@ -76,6 +76,7 @@ int load_symtab(bfd *, int fd, char **, int verbose; int printsize; +int printsize2; int main(int argc, char **argv) @@ -91,7 +92,7 @@ main(int argc, char **argv) setprogname(argv[0]); bfdname = NULL; - while ((ch = getopt(argc, argv, "b:pv")) != -1) + while ((ch = getopt(argc, argv, "b:Ppv")) != -1) switch (ch) { case 'b': bfdname = optarg; @@ -102,6 +103,9 @@ main(int argc, char **argv) case 'p': printsize = 1; break; + case 'P': + printsize2 = 1; + break; case '?': default: usage(); @@ -158,6 +162,10 @@ main(int argc, char **argv) printf("%d %d\n", symtabsize, symtab_space); goto done; } + if (printsize2) { + printf("%d\n", symtabsize); + goto done; + } if (symtabsize > symtab_space) errx(1, "symbol table (%u bytes) too big for buffer (%u bytes)\n" @@ -194,7 +202,7 @@ usage(void) const char **list; fprintf(stderr, - "usage: %s [-pv] [-b bfdname] kernel\n", + "usage: %s [-Ppv] [-b bfdname] kernel\n", getprogname()); fprintf(stderr, "supported targets:"); for (list = bfd_target_list(); *list != NULL; list++)
CVS commit: src/external/gpl3/binutils/usr.sbin/dbsym
Module Name:src Committed By: gdt Date: Mon Feb 18 15:29:37 UTC 2013 Modified Files: src/external/gpl3/binutils/usr.sbin/dbsym: Makefile Log Message: Adjust blank lines, add comment about DPADD To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/external/gpl3/binutils/usr.sbin/dbsym/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/gpl3/binutils/usr.sbin/dbsym/Makefile diff -u src/external/gpl3/binutils/usr.sbin/dbsym/Makefile:1.8 src/external/gpl3/binutils/usr.sbin/dbsym/Makefile:1.9 --- src/external/gpl3/binutils/usr.sbin/dbsym/Makefile:1.8 Sun Feb 17 20:36:01 2013 +++ src/external/gpl3/binutils/usr.sbin/dbsym/Makefile Mon Feb 18 15:29:36 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.8 2013/02/17 20:36:01 christos Exp $ +# $NetBSD: Makefile,v 1.9 2013/02/18 15:29:36 gdt Exp $ .include @@ -33,7 +33,8 @@ CPPFLAGS+= -I${TOP}/${BFDSUBDIR}/libbfd/ LDADD+= -lintl DPADD+= ${LIBINTL} .endif # HOSTPROG -LDADD+= -lz -.endif # MKBINUTILS != no +LDADD+= -lz +# No DPADD because we don't know the format and we didn't build it. +.endif # MKBINUTILS != no
CVS commit: src/external/gpl3/binutils/usr.sbin/dbsym
Module Name:src Committed By: wiz Date: Mon Mar 19 09:14:15 UTC 2012 Modified Files: src/external/gpl3/binutils/usr.sbin/dbsym: dbsym.c Log Message: Sync usage with man page. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c diff -u src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c:1.2 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c:1.3 --- src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c:1.2 Mon Mar 19 05:38:26 2012 +++ src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c Mon Mar 19 09:14:15 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: dbsym.c,v 1.2 2012/03/19 05:38:26 bsh Exp $ */ +/* $NetBSD: dbsym.c,v 1.3 2012/03/19 09:14:15 wiz Exp $ */ /* * Copyright (c) 2001 Simon Burge (for Wasabi Systems) @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1996 Christopher G. Demetriou.\ Copyright 2001 Simon Burge.\ All rights reserved."); -__RCSID("$NetBSD: dbsym.c,v 1.2 2012/03/19 05:38:26 bsh Exp $"); +__RCSID("$NetBSD: dbsym.c,v 1.3 2012/03/19 09:14:15 wiz Exp $"); #endif /* not lint */ #include @@ -194,7 +194,7 @@ usage(void) const char **list; fprintf(stderr, - "usage: %s [-b bfdname] [-v] kernel_file\n", + "usage: %s [-pv] [-b bfdname] kernel\n", getprogname()); fprintf(stderr, "supported targets:"); for (list = bfd_target_list(); *list != NULL; list++)
CVS commit: src/external/gpl3/binutils/usr.sbin/dbsym
Module Name:src Committed By: wiz Date: Mon Mar 19 09:13:33 UTC 2012 Modified Files: src/external/gpl3/binutils/usr.sbin/dbsym: dbsym.8 Log Message: New sentence, new line. Sort descriptions. Use simpler markup. Bump date for previous. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8 diff -u src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8:1.2 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8:1.3 --- src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8:1.2 Mon Mar 19 05:38:26 2012 +++ src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8 Mon Mar 19 09:13:33 2012 @@ -1,6 +1,6 @@ -.\" $NetBSD: dbsym.8,v 1.2 2012/03/19 05:38:26 bsh Exp $ +.\" $NetBSD: dbsym.8,v 1.3 2012/03/19 09:13:33 wiz Exp $ .\" -.Dd November 9, 2001 +.Dd March 19, 2012 .Dt DBSYM 8 .Os .Sh NAME @@ -17,15 +17,16 @@ is used to copy the symbol table in a ne .Va db_symtab array (in the data section) so that the .Xr ddb 4 -kernel debugger can find the symbols. This program is only used +kernel debugger can find the symbols. +This program is only used on systems for which the boot program does not load the symbol table -into memory with the kernel. The space for these symbols is +into memory with the kernel. +The space for these symbols is reserved in the data segment using a config option like: -.Pp -.Li options SYMTAB_SPACE=72000 -.Pp +.Dl options SYMTAB_SPACE=72000 The size of the db_symtab array (the value of SYMTAB_SPACE) must be -at least as large as the kernel symbol table. If insufficient space +at least as large as the kernel symbol table. +If insufficient space is reserved, dbsym will refuse to copy the symbol table. .Pp To recognize kernel executable format, the @@ -33,13 +34,6 @@ To recognize kernel executable format, t flag specifies BFD name of kernel. .Pp If the -.Fl v -flag is given, -.Nm -will print out status information as -it is copying the symbol table. -.Pp -If the .Fl p flag is given, .Nm @@ -47,6 +41,13 @@ will report the size of the kernel symbo db_symtab space. Two values are printed out in a line separated by a space. .Pp +If the +.Fl v +flag is given, +.Nm +will print out status information as +it is copying the symbol table. +.Pp Note that debugging symbols are not useful to the .Xr ddb 4 kernel debugger, so to minimize the size of the kernel, one should @@ -56,10 +57,9 @@ flag) or use the .Xr strip 1 command to strip debugging symbols from the kernel before .Nm -is used to copy the symbol table. The command -.Pp -.Li strip -d netbsd -.Pp +is used to copy the symbol table. +The command +.Dl strip -d netbsd will strip out debugging symbols. .Sh SEE ALSO .Xr strip 1 ,