Sun Aug 17 19:12:59 2014 UTC ()
Add new option -P to print only the symbol table size.


(joerg)
diff -r1.3 -r1.4 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8
diff -r1.3 -r1.4 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c

cvs diff -r1.3 -r1.4 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8 (expand / switch to unified diff)

--- src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8 2012/03/19 09:13:33 1.3
+++ src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.8 2014/08/17 19:12:59 1.4
@@ -1,49 +1,55 @@ @@ -1,49 +1,55 @@
1.\" $NetBSD: dbsym.8,v 1.3 2012/03/19 09:13:33 wiz Exp $ 1.\" $NetBSD: dbsym.8,v 1.4 2014/08/17 19:12:59 joerg Exp $
2.\" 2.\"
3.Dd March 19, 2012 3.Dd August 14, 2014
4.Dt DBSYM 8 4.Dt DBSYM 8
5.Os 5.Os
6.Sh NAME 6.Sh NAME
7.Nm dbsym 7.Nm dbsym
8.Nd copy kernel symbol table into db_symtab space 8.Nd copy kernel symbol table into db_symtab space
9.Sh SYNOPSIS 9.Sh SYNOPSIS
10.Nm 10.Nm
11.Op Fl pv 11.Op Fl Ppv
12.Op Fl b Ar bfdname 12.Op Fl b Ar bfdname
13.Ar kernel 13.Ar kernel
14.Sh DESCRIPTION 14.Sh DESCRIPTION
15.Nm 15.Nm
16is used to copy the symbol table in a newly linked kernel into the 16is used to copy the symbol table in a newly linked kernel into the
17.Va db_symtab 17.Va db_symtab
18array (in the data section) so that the 18array (in the data section) so that the
19.Xr ddb 4 19.Xr ddb 4
20kernel debugger can find the symbols. 20kernel debugger can find the symbols.
21This program is only used 21This program is only used
22on systems for which the boot program does not load the symbol table 22on systems for which the boot program does not load the symbol table
23into memory with the kernel. 23into memory with the kernel.
24The space for these symbols is 24The space for these symbols is
25reserved in the data segment using a config option like: 25reserved in the data segment using a config option like:
26.Dl options SYMTAB_SPACE=72000 26.Dl options SYMTAB_SPACE=72000
27The size of the db_symtab array (the value of SYMTAB_SPACE) must be 27The size of the db_symtab array (the value of SYMTAB_SPACE) must be
28at least as large as the kernel symbol table. 28at least as large as the kernel symbol table.
29If insufficient space 29If insufficient space
30is reserved, dbsym will refuse to copy the symbol table. 30is reserved, dbsym will refuse to copy the symbol table.
31.Pp 31.Pp
32To recognize kernel executable format, the 32To recognize kernel executable format, the
33.Fl b 33.Fl b
34flag specifies BFD name of kernel. 34flag specifies BFD name of kernel.
35.Pp 35.Pp
36If the 36If the
 37.Fl P
 38flag is given,
 39.Nm
 40will report the size of the kernel symbol table.
 41.Pp
 42If the
37.Fl p 43.Fl p
38flag is given, 44flag is given,
39.Nm 45.Nm
40will report the size of the kernel symbol table and the size of the 46will report the size of the kernel symbol table and the size of the
41db_symtab space. 47db_symtab space.
42Two values are printed out in a line separated by a space. 48Two values are printed out in a line separated by a space.
43.Pp 49.Pp
44If the 50If the
45.Fl v 51.Fl v
46flag is given, 52flag is given,
47.Nm 53.Nm
48will print out status information as 54will print out status information as
49it is copying the symbol table. 55it is copying the symbol table.

cvs diff -r1.3 -r1.4 src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c (expand / switch to unified diff)

--- src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c 2012/03/19 09:14:15 1.3
+++ src/external/gpl3/binutils/usr.sbin/dbsym/dbsym.c 2014/08/17 19:12:59 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: dbsym.c,v 1.3 2012/03/19 09:14:15 wiz Exp $ */ 1/* $NetBSD: dbsym.c,v 1.4 2014/08/17 19:12:59 joerg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001 Simon Burge (for Wasabi Systems) 4 * Copyright (c) 2001 Simon Burge (for Wasabi Systems)
5 * Copyright (c) 1996 Christopher G. Demetriou 5 * Copyright (c) 1996 Christopher G. Demetriou
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 *  29 *
30 * <<Id: LICENSE_GC,v 1.1 2001/10/01 23:24:05 cgd Exp>> 30 * <<Id: LICENSE_GC,v 1.1 2001/10/01 23:24:05 cgd Exp>>
31 */ 31 */
32 32
33#if HAVE_NBTOOL_CONFIG_H 33#if HAVE_NBTOOL_CONFIG_H
34#include "nbtool_config.h" 34#include "nbtool_config.h"
35#endif 35#endif
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38#if !defined(lint) 38#if !defined(lint)
39__COPYRIGHT("@(#) Copyright (c) 1996 Christopher G. Demetriou.\ 39__COPYRIGHT("@(#) Copyright (c) 1996 Christopher G. Demetriou.\
40 Copyright 2001 Simon Burge.\ 40 Copyright 2001 Simon Burge.\
41 All rights reserved."); 41 All rights reserved.");
42__RCSID("$NetBSD: dbsym.c,v 1.3 2012/03/19 09:14:15 wiz Exp $"); 42__RCSID("$NetBSD: dbsym.c,v 1.4 2014/08/17 19:12:59 joerg Exp $");
43#endif /* not lint */ 43#endif /* not lint */
44 44
45#include <sys/param.h> 45#include <sys/param.h>
46#include <sys/mman.h> 46#include <sys/mman.h>
47#include <sys/stat.h> 47#include <sys/stat.h>
48 48
49#include <bfd.h> 49#include <bfd.h>
50#include <err.h> 50#include <err.h>
51#include <fcntl.h> 51#include <fcntl.h>
52#include <stdio.h> 52#include <stdio.h>
53#include <stdlib.h> 53#include <stdlib.h>
54#include <string.h> 54#include <string.h>
55#include <unistd.h> 55#include <unistd.h>
@@ -66,52 +66,56 @@ struct symbols { @@ -66,52 +66,56 @@ struct symbols {
66 { "_db_symtab", 0 }, 66 { "_db_symtab", 0 },
67#define X_DB_SYMTABSIZE 1 67#define X_DB_SYMTABSIZE 1
68 { "_db_symtabsize", 0 }, 68 { "_db_symtabsize", 0 },
69 { NULL, 0 } 69 { NULL, 0 }
70}; 70};
71 71
72int main(int, char **); 72int main(int, char **);
73void usage(void) __attribute__((noreturn)); 73void usage(void) __attribute__((noreturn));
74int find_symtab(bfd *, struct symbols *); 74int find_symtab(bfd *, struct symbols *);
75int load_symtab(bfd *, int fd, char **, u_int32_t *); 75int load_symtab(bfd *, int fd, char **, u_int32_t *);
76 76
77int verbose; 77int verbose;
78int printsize; 78int printsize;
 79int printsize2;
79 80
80int 81int
81main(int argc, char **argv) 82main(int argc, char **argv)
82{ 83{
83 int ch, kfd; 84 int ch, kfd;
84 struct stat ksb; 85 struct stat ksb;
85 size_t symtab_offset; 86 size_t symtab_offset;
86 u_int32_t symtab_space, symtabsize; 87 u_int32_t symtab_space, symtabsize;
87 const char *kfile; 88 const char *kfile;
88 char *bfdname, *mappedkfile, *symtab; 89 char *bfdname, *mappedkfile, *symtab;
89 bfd *abfd; 90 bfd *abfd;
90 91
91 setprogname(argv[0]); 92 setprogname(argv[0]);
92 93
93 bfdname = NULL; 94 bfdname = NULL;
94 while ((ch = getopt(argc, argv, "b:pv")) != -1) 95 while ((ch = getopt(argc, argv, "b:Ppv")) != -1)
95 switch (ch) { 96 switch (ch) {
96 case 'b': 97 case 'b':
97 bfdname = optarg; 98 bfdname = optarg;
98 break; 99 break;
99 case 'v': 100 case 'v':
100 verbose = 1; 101 verbose = 1;
101 break; 102 break;
102 case 'p': 103 case 'p':
103 printsize = 1; 104 printsize = 1;
104 break; 105 break;
 106 case 'P':
 107 printsize2 = 1;
 108 break;
105 case '?': 109 case '?':
106 default: 110 default:
107 usage(); 111 usage();
108 } 112 }
109 argc -= optind; 113 argc -= optind;
110 argv += optind; 114 argv += optind;
111 115
112 if (argc != 1) 116 if (argc != 1)
113 usage(); 117 usage();
114 kfile = argv[0]; 118 kfile = argv[0];
115 119
116 if ((kfd = open(kfile, O_RDWR, 0)) == -1) 120 if ((kfd = open(kfile, O_RDWR, 0)) == -1)
117 err(1, "open %s", kfile); 121 err(1, "open %s", kfile);
@@ -148,26 +152,30 @@ main(int argc, char **argv) @@ -148,26 +152,30 @@ main(int argc, char **argv)
148 MAP_FILE | MAP_SHARED, kfd, 0)) == (caddr_t)-1) 152 MAP_FILE | MAP_SHARED, kfd, 0)) == (caddr_t)-1)
149 err(1, "mmap %s", kfile); 153 err(1, "mmap %s", kfile);
150 if (verbose) 154 if (verbose)
151 fprintf(stderr, "mapped %s\n", kfile); 155 fprintf(stderr, "mapped %s\n", kfile);
152 156
153 symtab_offset = db_symtab_symbols[X_DB_SYMTAB].offset; 157 symtab_offset = db_symtab_symbols[X_DB_SYMTAB].offset;
154 symtab_space = bfd_get_32(abfd, 158 symtab_space = bfd_get_32(abfd,
155 &mappedkfile[db_symtab_symbols[X_DB_SYMTABSIZE].offset]); 159 &mappedkfile[db_symtab_symbols[X_DB_SYMTABSIZE].offset]);
156 160
157 if (printsize) { 161 if (printsize) {
158 printf("%d %d\n", symtabsize, symtab_space); 162 printf("%d %d\n", symtabsize, symtab_space);
159 goto done; 163 goto done;
160 } 164 }
 165 if (printsize2) {
 166 printf("%d\n", symtabsize);
 167 goto done;
 168 }
161 169
162 if (symtabsize > symtab_space) 170 if (symtabsize > symtab_space)
163 errx(1, "symbol table (%u bytes) too big for buffer (%u bytes)\n" 171 errx(1, "symbol table (%u bytes) too big for buffer (%u bytes)\n"
164 "Increase options SYMTAB_SPACE in your kernel config", 172 "Increase options SYMTAB_SPACE in your kernel config",
165 symtabsize, symtab_space); 173 symtabsize, symtab_space);
166 174
167 if (verbose) 175 if (verbose)
168 fprintf(stderr, "symtab size %d, space available %d\n", 176 fprintf(stderr, "symtab size %d, space available %d\n",
169 symtabsize, symtab_space); 177 symtabsize, symtab_space);
170 178
171 memcpy(mappedkfile + symtab_offset, symtab, symtabsize); 179 memcpy(mappedkfile + symtab_offset, symtab, symtabsize);
172 180
173 if (verbose) 181 if (verbose)
@@ -184,27 +192,27 @@ done: @@ -184,27 +192,27 @@ done:
184 if (verbose) 192 if (verbose)
185 fprintf(stderr, "exiting\n"); 193 fprintf(stderr, "exiting\n");
186 194
187 bfd_close_all_done(abfd); 195 bfd_close_all_done(abfd);
188 exit(0); 196 exit(0);
189} 197}
190 198
191void 199void
192usage(void) 200usage(void)
193{ 201{
194 const char **list; 202 const char **list;
195 203
196 fprintf(stderr, 204 fprintf(stderr,
197 "usage: %s [-pv] [-b bfdname] kernel\n", 205 "usage: %s [-Ppv] [-b bfdname] kernel\n",
198 getprogname()); 206 getprogname());
199 fprintf(stderr, "supported targets:"); 207 fprintf(stderr, "supported targets:");
200 for (list = bfd_target_list(); *list != NULL; list++) 208 for (list = bfd_target_list(); *list != NULL; list++)
201 fprintf(stderr, " %s", *list); 209 fprintf(stderr, " %s", *list);
202 fprintf(stderr, "\n"); 210 fprintf(stderr, "\n");
203 exit(1); 211 exit(1);
204} 212}
205 213
206int 214int
207find_symtab(bfd *abfd, struct symbols *symbols) 215find_symtab(bfd *abfd, struct symbols *symbols)
208{ 216{
209 long i; 217 long i;
210 long storage_needed; 218 long storage_needed;