From: guenther Date: Sun, 17 May 2015 20:19:08 +0000 (+0000) Subject: Add -D option for displaying the dynamic symbol table X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=96272ccb0c75542f96e4f4fb662cedf7a53f2446;p=openbsd Add -D option for displaying the dynamic symbol table ok miod@ --- diff --git a/usr.bin/nm/elf.c b/usr.bin/nm/elf.c index 9599b7ec4a2..c1033bb12e7 100644 --- a/usr.bin/nm/elf.c +++ b/usr.bin/nm/elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elf.c,v 1.27 2015/04/09 04:46:18 guenther Exp $ */ +/* $OpenBSD: elf.c,v 1.28 2015/05/17 20:19:08 guenther Exp $ */ /* * Copyright (c) 2003 Michael Shalayeff @@ -550,8 +550,10 @@ elf_symload(const char *name, FILE *fp, off_t foff, Elf_Ehdr *eh, stab = NULL; *pnames = NULL; *psnames = NULL; *pnrawnames = 0; - elf_symloadx(name, fp, foff, eh, shdr, shstr, pnames, - psnames, pstabsize, pnrawnames, ELF_STRTAB, ELF_SYMTAB); + if (!dynamic_only) { + elf_symloadx(name, fp, foff, eh, shdr, shstr, pnames, + psnames, pstabsize, pnrawnames, ELF_STRTAB, ELF_SYMTAB); + } if (stab == NULL) { elf_symloadx(name, fp, foff, eh, shdr, shstr, pnames, psnames, pstabsize, pnrawnames, ELF_DYNSTR, ELF_DYNSYM); diff --git a/usr.bin/nm/nm.1 b/usr.bin/nm/nm.1 index 572342ff62c..0d75aa531e0 100644 --- a/usr.bin/nm/nm.1 +++ b/usr.bin/nm/nm.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: nm.1,v 1.26 2015/04/09 04:46:18 guenther Exp $ +.\" $OpenBSD: nm.1,v 1.27 2015/05/17 20:19:08 guenther Exp $ .\" $NetBSD: nm.1,v 1.3 1995/08/31 23:41:58 jtc Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)nm.1 8.1 (Berkeley) 6/6/93 .\" -.Dd $Mdocdate: April 9 2015 $ +.Dd $Mdocdate: May 17 2015 $ .Dt NM 1 .Os .Sh NAME @@ -38,7 +38,7 @@ .Nd display name list (symbol table) .Sh SYNOPSIS .Nm nm -.Op Fl aCegnoprsuw +.Op Fl aCDegnoprsuw .Op Ar .Sh DESCRIPTION The symbol table (name list) of each object in @@ -63,6 +63,8 @@ Display symbol table entries inserted for use by debuggers. .It Fl C Decode low-level symbol names. This involves removing extra underscores and making C++ function names readable. +.It Fl D +Display the dynamic symbol table instead of the normal symbol table. .It Fl e Output extended information, that is `w' for weak symbols, `f' for function-like symbols, and `o' for object-like symbols. diff --git a/usr.bin/nm/nm.c b/usr.bin/nm/nm.c index fd49c022f01..6444bc23beb 100644 --- a/usr.bin/nm/nm.c +++ b/usr.bin/nm/nm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nm.c,v 1.44 2015/04/09 04:46:18 guenther Exp $ */ +/* $OpenBSD: nm.c,v 1.45 2015/05/17 20:19:08 guenther Exp $ */ /* $NetBSD: nm.c,v 1.7 1996/01/14 23:04:03 pk Exp $ */ /* @@ -71,6 +71,7 @@ int print_file_each_line; int show_extensions; int issize; int usemmap = 1; +int dynamic_only; /* size vars */ unsigned long total_text, total_data, total_bss, total_total; @@ -99,11 +100,11 @@ int show_archive(int, const char *, FILE *); int show_file(int, int, const char *, FILE *fp, off_t, union hdr *); void print_symbol(const char *, struct nlist *); -#define OPTSTRING_NM "aABCegnoprsuvw" +#define OPTSTRING_NM "aABCDegnoprsuvw" const struct option longopts_nm[] = { { "debug-syms", no_argument, 0, 'a' }, { "demangle", no_argument, 0, 'C' }, -/* { "dynamic", no_argument, 0, 'D' }, */ + { "dynamic", no_argument, 0, 'D' }, { "extern-only", no_argument, 0, 'g' }, /* { "line-numbers", no_argument, 0, 'l' }, */ { "no-sort", no_argument, 0, 'p' }, @@ -150,6 +151,9 @@ main(int argc, char *argv[]) case 'C': demangle = 1; break; + case 'D': + dynamic_only = 1; + break; case 'e': show_extensions = 1; break; diff --git a/usr.bin/nm/util.h b/usr.bin/nm/util.h index f0e96073174..8e5553ead86 100644 --- a/usr.bin/nm/util.h +++ b/usr.bin/nm/util.h @@ -1,4 +1,4 @@ -/* $OpenBSD: util.h,v 1.2 2004/10/09 22:11:11 millert Exp $ */ +/* $OpenBSD: util.h,v 1.3 2015/05/17 20:19:08 guenther Exp $ */ /* * Placed in the public domain by Todd C. Miller @@ -29,3 +29,4 @@ } while (0) extern int usemmap; +extern int dynamic_only;