summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/ld
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2001-10-25 22:22:23 +0000
committerMarc Espie <espie@cvs.openbsd.org>2001-10-25 22:22:23 +0000
commit21198d8e2332e49318ca7a847674dd1e214cd92c (patch)
treeca75a459f6bb31ba1fe738527980094b4fd486b9 /gnu/usr.bin/ld
parent55ed41d50089c5d49a9ddbbfd24ed916451a1335 (diff)
Code in scanlib similar to main ldd, to recognize fmt1 and fmt2 and use
them.
Diffstat (limited to 'gnu/usr.bin/ld')
-rw-r--r--gnu/usr.bin/ld/ldd/ldd.c6
-rw-r--r--gnu/usr.bin/ld/ldd/scanlib.c73
2 files changed, 70 insertions, 9 deletions
diff --git a/gnu/usr.bin/ld/ldd/ldd.c b/gnu/usr.bin/ld/ldd/ldd.c
index f578bc11a90..116a1d718a9 100644
--- a/gnu/usr.bin/ld/ldd/ldd.c
+++ b/gnu/usr.bin/ld/ldd/ldd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ldd.c,v 1.8 2001/07/09 07:04:36 deraadt Exp $ */
+/* $OpenBSD: ldd.c,v 1.9 2001/10/25 22:22:22 espie Exp $ */
/* $NetBSD: ldd.c,v 1.12 1995/10/09 00:14:41 pk Exp $ */
/*
* Copyright (c) 1993 Paul Kranenburg
@@ -45,7 +45,7 @@
#include <string.h>
#include <unistd.h>
-extern void scan_library(int, struct exec *, const char *);
+extern void scan_library(int, struct exec *, const char *, const char *, const char *);
void
usage()
@@ -118,7 +118,7 @@ char *argv[];
continue;
}
if ((N_GETFLAG(hdr) & EX_DPMASK) == (EX_DYNAMIC | EX_PIC)) {
- scan_library(fd, &hdr, *argv);
+ scan_library(fd, &hdr, *argv, fmt1, fmt2);
(void)close(fd);
argv++;
continue;
diff --git a/gnu/usr.bin/ld/ldd/scanlib.c b/gnu/usr.bin/ld/ldd/scanlib.c
index e169f6e5aac..cd34da747d6 100644
--- a/gnu/usr.bin/ld/ldd/scanlib.c
+++ b/gnu/usr.bin/ld/ldd/scanlib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scanlib.c,v 1.1 2001/04/17 21:44:38 espie Exp $ */
+/* $OpenBSD: scanlib.c,v 1.2 2001/10/25 22:22:22 espie Exp $ */
/*
* Copyright (c) 2001 Marc Espie.
@@ -36,15 +36,24 @@
#include <link.h>
void
-scan_library(fd, hdr, name)
+scan_library(fd, hdr, name, fmt1, fmt2)
int fd;
struct exec *hdr;
const char *name;
+ const char *fmt1;
+ const char *fmt2;
{
struct _dynamic dyn;
struct section_dispatch_table sdt;
+ const char *fmt;
+ char c;
- printf("%s:\n", name);
+ if (!fmt1 && !fmt2)
+ printf("%s:\n", name);
+ if (!fmt1)
+ fmt1="\t-l%o.%m => %p (%x)\n";
+ if (!fmt2)
+ fmt2="\t%o (%x)\n";
/* Assumes DYNAMIC structure starts data segment */
if (lseek(fd, N_DATOFF(*hdr), SEEK_SET) == -1) {
warn("%s: lseek", name);
@@ -100,10 +109,62 @@ scan_library(fd, hdr, name)
/* make sure this is terminated */
entry[MAXPATHLEN-1] = '\0';
if (sod.sod_library)
- printf("\t-l%s.%d.%d\n", entry,
- sod.sod_major, sod.sod_minor);
+ fmt = fmt1;
else
- printf("\t%s\n", name);
+ fmt = fmt2;
+ while ((c = *fmt++) != '\0') {
+ switch(c) {
+ default:
+ putchar(c);
+ continue;
+ case '\\':
+ switch (c = *fmt) {
+ case '\0':
+ continue;
+ case 'n':
+ putchar('\n');
+ break;
+ case 't':
+ putchar('\t');
+ break;
+ }
+ fmt++;
+ break;
+ case '%':
+ switch (c = *fmt) {
+ case '\0':
+ continue;
+ case '%':
+ default:
+ putchar(c);
+ break;
+ case 'A':
+ printf("%s", name);
+ break;
+ case 'a':
+ printf("%s", name);
+ break;
+ case 'o':
+ printf("%s", entry);
+ break;
+ case 'm':
+ printf("%d", sod.sod_major);
+ break;
+ case 'n':
+ printf("%d", sod.sod_minor);
+ break;
+ case 'p':
+ putchar('?');
+ break;
+ case 'x':
+ putchar('?');
+ break;
+ }
+ ++fmt;
+ break;
+ }
+ }
+
}
}
}