Add an -o option that behaves like nm -o. Implementation from a suggestion

by jmcneill (thanks!); ok mrg. Closes PR 41994.
This commit is contained in:
dholland 2009-09-07 17:56:52 +00:00
parent cd5a3748ef
commit 15a88044ca
2 changed files with 22 additions and 6 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ldd.1,v 1.16 2009/08/23 15:37:39 wiz Exp $
.\" $NetBSD: ldd.1,v 1.17 2009/09/07 17:56:52 dholland Exp $
.\"
.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd August 23, 2009
.Dd September 7, 2009
.Dt LDD 1
.Os
.Sh NAME
@ -35,6 +35,7 @@
.Nd list dynamic object dependencies
.Sh SYNOPSIS
.Nm
.Op Fl o
.Op Fl f Ar format
.Ar program ...
.Sh DESCRIPTION
@ -93,6 +94,16 @@ Additionally,
and
.Sy \et
are recognized and have their usual meaning.
.Pp
The
.Fl o
option is an alias for
.Fl f
.Ar \&%a:-l\&%o.\&%m =\*[Gt] \&%p\en ,
which makes
.Nm
behave analogously to
.Ic nm Fl o .
.Sh SEE ALSO
.Xr ld 1 ,
.Xr ld.elf_so 1 ,

View File

@ -1,4 +1,4 @@
/* $NetBSD: ldd.c,v 1.9 2009/08/22 06:52:16 mrg Exp $ */
/* $NetBSD: ldd.c,v 1.10 2009/09/07 17:56:52 dholland Exp $ */
/*-
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@ -62,7 +62,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: ldd.c,v 1.9 2009/08/22 06:52:16 mrg Exp $");
__RCSID("$NetBSD: ldd.c,v 1.10 2009/09/07 17:56:52 dholland Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -114,13 +114,13 @@ usage(void)
int
main(int argc, char **argv)
{
char *fmt1 = NULL, *fmt2 = NULL;
const char *fmt1 = NULL, *fmt2 = NULL;
int c;
#ifdef DEBUG
debug = 1;
#endif
while ((c = getopt(argc, argv, "f:")) != -1) {
while ((c = getopt(argc, argv, "f:o")) != -1) {
switch (c) {
case 'f':
if (fmt1) {
@ -130,6 +130,11 @@ main(int argc, char **argv)
} else
fmt1 = optarg;
break;
case 'o':
if (fmt1 || fmt2)
errx(1, "Cannot use -o and -f together");
fmt1 = "%a:-l%o.%m => %p\n";
break;
default:
usage();
/*NOTREACHED*/