View | Details | Raw Unified | Return to bug 30908
Collapse All | Expand All

(-)/tmp/src/libexec/rtld-elf/rtld.1 (+5 lines)
Lines 99-104 Link Here
99
.Nm
99
.Nm
100
to exit after loading the shared objects and printing a summary which includes
100
to exit after loading the shared objects and printing a summary which includes
101
the absolute pathnames of all objects, to standard output.
101
the absolute pathnames of all objects, to standard output.
102
.It Ev LD_TRACE_LOADED_OBJECTS_ALL
103
When set to a nonempty string, causes
104
.Nm
105
to expand the summary to indicate which objects caused each object to
106
be loaded.
102
.It Ev LD_TRACE_LOADED_OBJECTS_FMT1
107
.It Ev LD_TRACE_LOADED_OBJECTS_FMT1
103
.It Ev LD_TRACE_LOADED_OBJECTS_FMT2
108
.It Ev LD_TRACE_LOADED_OBJECTS_FMT2
104
When set, these variables are interpreted as format strings a la
109
When set, these variables are interpreted as format strings a la
(-)/tmp/src/libexec/rtld-elf/rtld.c (-2 / +6 lines)
Lines 1956-1962 Link Here
1956
static void
1956
static void
1957
trace_loaded_objects(Obj_Entry *obj)
1957
trace_loaded_objects(Obj_Entry *obj)
1958
{
1958
{
1959
    char	*fmt1, *fmt2, *fmt, *main_local;
1959
    char	*fmt1, *fmt2, *fmt, *main_local, *list_containers;
1960
    int		c;
1960
    int		c;
1961
1961
1962
    if ((main_local = getenv("LD_TRACE_LOADED_OBJECTS_PROGNAME")) == NULL)
1962
    if ((main_local = getenv("LD_TRACE_LOADED_OBJECTS_PROGNAME")) == NULL)
Lines 1968-1981 Link Here
1968
    if ((fmt2 = getenv("LD_TRACE_LOADED_OBJECTS_FMT2")) == NULL)
1968
    if ((fmt2 = getenv("LD_TRACE_LOADED_OBJECTS_FMT2")) == NULL)
1969
	fmt2 = "\t%o (%x)\n";
1969
	fmt2 = "\t%o (%x)\n";
1970
1970
1971
    list_containers = getenv("LD_TRACE_LOADED_OBJECTS_ALL");
1972
1971
    for (; obj; obj = obj->next) {
1973
    for (; obj; obj = obj->next) {
1972
	Needed_Entry		*needed;
1974
	Needed_Entry		*needed;
1973
	char			*name, *path;
1975
	char			*name, *path;
1974
	bool			is_lib;
1976
	bool			is_lib;
1975
1977
1978
	if (list_containers && obj->needed != NULL)
1979
	    printf("%s:\n", obj->path);
1976
	for (needed = obj->needed; needed; needed = needed->next) {
1980
	for (needed = obj->needed; needed; needed = needed->next) {
1977
	    if (needed->obj != NULL) {
1981
	    if (needed->obj != NULL) {
1978
		if (needed->obj->traced)
1982
		if (needed->obj->traced && !list_containers)
1979
		    continue;
1983
		    continue;
1980
		needed->obj->traced = true;
1984
		needed->obj->traced = true;
1981
		path = needed->obj->path;
1985
		path = needed->obj->path;
(-)/tmp/src/usr.bin/ldd/ldd.1 (+6 lines)
Lines 8-13 Link Here
8
.Nd list dynamic object dependencies
8
.Nd list dynamic object dependencies
9
.Sh SYNOPSIS
9
.Sh SYNOPSIS
10
.Nm
10
.Nm
11
.Op Fl a
11
.Op Fl v
12
.Op Fl v
12
.Op Fl f Ar format
13
.Op Fl f Ar format
13
.Ar program ...
14
.Ar program ...
Lines 32-37 Link Here
32
See
33
See
33
.Xr rtld 1
34
.Xr rtld 1
34
for a list of recognized conversion characters.
35
for a list of recognized conversion characters.
36
.Pp
37
The
38
.Fl a
39
option displays the list of all objects that are needed by each loaded
40
object. This option does not work with a.out binaries.
35
.Pp
41
.Pp
36
The
42
The
37
.Fl v
43
.Fl v
(-)/tmp/src/usr.bin/ldd/ldd.c (-4 / +8 lines)
Lines 48-54 Link Here
48
void
48
void
49
usage()
49
usage()
50
{
50
{
51
	fprintf(stderr, "usage: ldd [-v] [-f format] program ...\n");
51
	fprintf(stderr, "usage: ldd [-a] [-v] [-f format] program ...\n");
52
	exit(1);
52
	exit(1);
53
}
53
}
54
54
Lines 60-69 Link Here
60
	char		*fmt1 = NULL, *fmt2 = NULL;
60
	char		*fmt1 = NULL, *fmt2 = NULL;
61
	int		rval;
61
	int		rval;
62
	int		c;
62
	int		c;
63
	int		vflag = 0;
63
	int		vflag = 0, aflag = 0;
64
64
65
	while ((c = getopt(argc, argv, "vf:")) != -1) {
65
	while ((c = getopt(argc, argv, "avf:")) != -1) {
66
		switch (c) {
66
		switch (c) {
67
		case 'a':
68
		  aflag++;
69
		  break;
67
		case 'v':
70
		case 'v':
68
			vflag++;
71
			vflag++;
69
			break;
72
			break;
Lines 179-185 Link Here
179
		}
182
		}
180
183
181
		setenv("LD_TRACE_LOADED_OBJECTS_PROGNAME", *argv, 1);
184
		setenv("LD_TRACE_LOADED_OBJECTS_PROGNAME", *argv, 1);
182
		if (fmt1 == NULL && fmt2 == NULL)
185
		if (aflag) setenv("LD_TRACE_LOADED_OBJECTS_ALL", "1", 1);
186
		else if (fmt1 == NULL && fmt2 == NULL)
183
			/* Default formats */
187
			/* Default formats */
184
			printf("%s:\n", *argv);
188
			printf("%s:\n", *argv);

Return to bug 30908