summaryrefslogtreecommitdiffstats
path: root/usr.bin/ldd/ldd.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1996-10-01 01:34:32 +0000
committerpeter <peter@FreeBSD.org>1996-10-01 01:34:32 +0000
commit7ad318175daf080c971b4afb1a9294c3eb579035 (patch)
treefc7a00d9b925e7198c15c76d25d8e6283f465ef3 /usr.bin/ldd/ldd.c
parent23b05888464729710283962cea56a9aa62e4805b (diff)
downloadFreeBSD-src-7ad318175daf080c971b4afb1a9294c3eb579035.zip
FreeBSD-src-7ad318175daf080c971b4afb1a9294c3eb579035.tar.gz
Support for specifying printf-like output specs to control the ldd output
as present in the new rtld version. Obtained from: NetBSD Reviewed by: nate, jdp
Diffstat (limited to 'usr.bin/ldd/ldd.c')
-rw-r--r--usr.bin/ldd/ldd.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/usr.bin/ldd/ldd.c b/usr.bin/ldd/ldd.c
index 2f54806..79a229b 100644
--- a/usr.bin/ldd/ldd.c
+++ b/usr.bin/ldd/ldd.c
@@ -27,7 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: ldd.c,v 1.4 1994/06/15 22:41:03 rich Exp $
+ * $Id: ldd.c,v 1.5 1994/12/23 22:31:31 nate Exp $
*/
#include <sys/types.h>
@@ -58,11 +58,20 @@ main(argc, argv)
int argc;
char *argv[];
{
+ char *fmt1 = NULL, *fmt2 = NULL;
int rval;
int c;
- while ((c = getopt(argc, argv, "")) != EOF) {
+ while ((c = getopt(argc, argv, "f:")) != EOF) {
switch (c) {
+ case 'f':
+ if (fmt1) {
+ if (fmt2)
+ errx(1, "Too many formats");
+ fmt2 = optarg;
+ } else
+ fmt1 = optarg;
+ break;
default:
usage();
/*NOTREACHED*/
@@ -78,6 +87,10 @@ char *argv[];
/* ld.so magic */
setenv("LD_TRACE_LOADED_OBJECTS", "", 1);
+ if (fmt1)
+ setenv("LD_TRACE_LOADED_OBJECTS_FMT1", fmt1, 1);
+ if (fmt2)
+ setenv("LD_TRACE_LOADED_OBJECTS_FMT2", fmt2, 1);
rval = 0;
while (argc--) {
@@ -106,7 +119,11 @@ char *argv[];
}
(void)close(fd);
- printf("%s:\n", *argv);
+ setenv("LD_TRACE_LOADED_OBJECTS_PROGNAME", *argv, 1);
+ if (fmt1 == NULL && fmt2 == NULL)
+ /* Default formats */
+ printf("%s:\n", *argv);
+
fflush(stdout);
switch (fork()) {
OpenPOWER on IntegriCloud