1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-03 06:45:37 -08:00

Add -D option for displaying the dynamic symbol table

ok miod@
This commit is contained in:
guenther 2015-05-17 20:19:08 +00:00
parent 3303745ec6
commit 96272ccb0c
4 changed files with 19 additions and 10 deletions

View File

@ -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);

View File

@ -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.

View File

@ -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;

View File

@ -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 <Todd.Miller@courtesan.com>
@ -29,3 +29,4 @@
} while (0)
extern int usemmap;
extern int dynamic_only;