xref: /onnv-gate/usr/src/cmd/sgs/rtld/mdbmod/common/rtld.c (revision 8598:0867fc633d66)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51618Srie  * Common Development and Distribution License (the "License").
61618Srie  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
211618Srie 
220Sstevel@tonic-gate /*
23*8598SRod.Evans@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
240Sstevel@tonic-gate  * Use is subject to license terms.
250Sstevel@tonic-gate  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #include <msg.h>
280Sstevel@tonic-gate #include <_rtld.h>
290Sstevel@tonic-gate #include <conv.h>
300Sstevel@tonic-gate #include <sys/mdb_modapi.h>
310Sstevel@tonic-gate #include <sys/param.h>
320Sstevel@tonic-gate #include <stdlib.h>
330Sstevel@tonic-gate 
340Sstevel@tonic-gate /*
350Sstevel@tonic-gate  * Data structure for walkers.
360Sstevel@tonic-gate  */
370Sstevel@tonic-gate typedef struct {
380Sstevel@tonic-gate 	uint_t	w_flags;
390Sstevel@tonic-gate } W_desc;
400Sstevel@tonic-gate 
410Sstevel@tonic-gate /*
420Sstevel@tonic-gate  * Flags values for dcmds
430Sstevel@tonic-gate  */
440Sstevel@tonic-gate 
450Sstevel@tonic-gate #define	RTLD_FLG_VERBOSE	0x0001		/* verbose output */
460Sstevel@tonic-gate 
470Sstevel@tonic-gate static const mdb_bitmask_t rtflags_bits[] = {
480Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_ISMAIN), FLG_RT_ISMAIN, FLG_RT_ISMAIN},
490Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_IMGALLOC), FLG_RT_IMGALLOC, FLG_RT_IMGALLOC},
500Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_RELOCED), FLG_RT_RELOCED, FLG_RT_RELOCED},
510Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_SETGROUP), FLG_RT_SETGROUP, FLG_RT_SETGROUP},
520Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_HWCAP), FLG_RT_HWCAP, FLG_RT_HWCAP},
530Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_OBJECT), FLG_RT_OBJECT, FLG_RT_OBJECT},
540Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_NODUMP), FLG_RT_NODUMP, FLG_RT_NODUMP},
550Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_DELETE), FLG_RT_DELETE, FLG_RT_DELETE},
560Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_ANALYZED), FLG_RT_ANALYZED, FLG_RT_ANALYZED},
570Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_INITDONE), FLG_RT_INITDONE, FLG_RT_INITDONE},
580Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_TRANS), FLG_RT_TRANS, FLG_RT_TRANS},
590Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_FIXED), FLG_RT_FIXED, FLG_RT_FIXED},
600Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_PRELOAD), FLG_RT_PRELOAD, FLG_RT_PRELOAD},
610Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_ALTER), FLG_RT_ALTER, FLG_RT_ALTER},
620Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_LOADFLTR), FLG_RT_LOADFLTR, FLG_RT_LOADFLTR},
630Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_AUDIT), FLG_RT_AUDIT, FLG_RT_AUDIT},
640Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_MODESET), FLG_RT_MODESET, FLG_RT_MODESET},
650Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_ANALZING), FLG_RT_ANALZING, FLG_RT_ANALZING},
660Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_INITFRST), FLG_RT_INITFRST, FLG_RT_INITFRST},
670Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_NOOPEN), FLG_RT_NOOPEN, FLG_RT_NOOPEN},
680Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_FINICLCT), FLG_RT_FINICLCT, FLG_RT_FINICLCT},
690Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_INITCALL), FLG_RT_INITCALL, FLG_RT_INITCALL},
703466Srie 	{ MSG_ORIG(MSG_FLG_OBJINTPO), FLG_RT_OBJINTPO, FLG_RT_OBJINTPO},
713466Srie 	{ MSG_ORIG(MSG_FLG_SYMINTPO), FLG_RT_SYMINTPO, FLG_RT_SYMINTPO},
720Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_MOVE), FLG_RT_MOVE, FLG_RT_MOVE},
735950Srie 	{ MSG_ORIG(MSG_FLG_TMPLIST), FLG_RT_TMPLIST, FLG_RT_TMPLIST},
740Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_REGSYMS), FLG_RT_REGSYMS, FLG_RT_REGSYMS},
750Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_INITCLCT), FLG_RT_INITCLCT, FLG_RT_INITCLCT},
760Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_HANDLE), FLG_RT_HANDLE, FLG_RT_HANDLE},
770Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FLG_RELOCING), FLG_RT_RELOCING, FLG_RT_RELOCING},
780Sstevel@tonic-gate 	{ NULL, 0, 0}
790Sstevel@tonic-gate };
800Sstevel@tonic-gate 
810Sstevel@tonic-gate static const mdb_bitmask_t rtflags1_bits[] = {
820Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FL1_COPYTOOK), FL1_RT_COPYTOOK, FL1_RT_COPYTOOK},
830Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FL1_CONFSET), FL1_RT_CONFSET, FL1_RT_CONFSET },
840Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FL1_NODEFLIB), FL1_RT_NODEFLIB, FL1_RT_NODEFLIB },
850Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FL1_ENDFILTE), FL1_RT_ENDFILTE, FL1_RT_ENDFILTE },
860Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FL1_DISPREL), FL1_RT_DISPREL, FL1_RT_DISPREL },
87*8598SRod.Evans@Sun.COM 	{ MSG_ORIG(MSG_FL1_DTFLAGS), FL1_RT_DTFLAGS, FL1_RT_DTFLAGS},
880Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FL1_LDDSTUB), FL1_RT_LDDSTUB, FL1_RT_LDDSTUB},
890Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FL1_NOINIFIN), FL1_RT_NOINIFIN, FL1_RT_NOINIFIN },
900Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FL1_USED), FL1_RT_USED, FL1_RT_USED },
910Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FL1_SYMBOLIC), FL1_RT_SYMBOLIC, FL1_RT_SYMBOLIC },
920Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FL1_OBJSFLTR), FL1_RT_OBJSFLTR, FL1_RT_OBJSFLTR },
930Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FL1_OBJAFLTR), FL1_RT_OBJAFLTR, FL1_RT_OBJAFLTR },
940Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FL1_SYMSFLTR), FL1_RT_SYMSFLTR, FL1_RT_SYMSFLTR },
950Sstevel@tonic-gate 	{ MSG_ORIG(MSG_FL1_SYMAFLTR), FL1_RT_SYMAFLTR, FL1_RT_SYMAFLTR },
963466Srie 	{ MSG_ORIG(MSG_FL1_TLSADD), FL1_RT_TLSADD, FL1_RT_TLSADD },
973466Srie 	{ MSG_ORIG(MSG_FL1_TLSSTAT), FL1_RT_TLSSTAT, FL1_RT_TLSSTAT },
983466Srie 	{ MSG_ORIG(MSG_FL1_DIRECT), FL1_RT_DIRECT, FL1_RT_DIRECT},
994679Srie 	{ MSG_ORIG(MSG_FL1_GLOBAUD), FL1_RT_GLOBAUD, FL1_RT_GLOBAUD},
100*8598SRod.Evans@Sun.COM 	{ NULL, 0, 0}
101*8598SRod.Evans@Sun.COM };
1020Sstevel@tonic-gate 
103*8598SRod.Evans@Sun.COM static const mdb_bitmask_t rtaflags_bits[] = {
1040Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_PREINIT), LML_TFLG_AUD_PREINIT,
1050Sstevel@tonic-gate 	    LML_TFLG_AUD_PREINIT },
1060Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_OBJSEARCH), LML_TFLG_AUD_OBJSEARCH,
1070Sstevel@tonic-gate 	    LML_TFLG_AUD_OBJSEARCH },
1080Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_OBJOPEN), LML_TFLG_AUD_OBJOPEN,
1090Sstevel@tonic-gate 	    LML_TFLG_AUD_OBJOPEN },
1100Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_OBJFILTER), LML_TFLG_AUD_OBJFILTER,
1110Sstevel@tonic-gate 	    LML_TFLG_AUD_OBJFILTER },
1120Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_OBJCLOSE), LML_TFLG_AUD_OBJCLOSE,
1130Sstevel@tonic-gate 	    LML_TFLG_AUD_OBJCLOSE },
1140Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_SYMBIND), LML_TFLG_AUD_SYMBIND,
1150Sstevel@tonic-gate 	    LML_TFLG_AUD_SYMBIND },
1160Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_PLTENTER), LML_TFLG_AUD_PLTENTER,
1170Sstevel@tonic-gate 	    LML_TFLG_AUD_PLTENTER },
1180Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_PLTEXIT), LML_TFLG_AUD_PLTEXIT,
1190Sstevel@tonic-gate 	    LML_TFLG_AUD_PLTEXIT },
1200Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_ACTIVITY), LML_TFLG_AUD_ACTIVITY,
1210Sstevel@tonic-gate 	    LML_TFLG_AUD_ACTIVITY },
1220Sstevel@tonic-gate 	{ NULL, 0, 0}
1230Sstevel@tonic-gate };
1240Sstevel@tonic-gate 
1250Sstevel@tonic-gate static const mdb_bitmask_t rtmode_bits[] = {
1260Sstevel@tonic-gate 	{ MSG_ORIG(MSG_MODE_LAZY), RTLD_LAZY, RTLD_LAZY },
1270Sstevel@tonic-gate 	{ MSG_ORIG(MSG_MODE_NOW), RTLD_NOW, RTLD_NOW },
1280Sstevel@tonic-gate 	{ MSG_ORIG(MSG_MODE_NOLOAD), RTLD_NOLOAD, RTLD_NOLOAD },
1290Sstevel@tonic-gate 	{ MSG_ORIG(MSG_MODE_GLOBAL), RTLD_GLOBAL, RTLD_GLOBAL },
1300Sstevel@tonic-gate 	{ MSG_ORIG(MSG_MODE_PARENT), RTLD_PARENT, RTLD_PARENT },
1310Sstevel@tonic-gate 	{ MSG_ORIG(MSG_MODE_GROUP), RTLD_GROUP, RTLD_GROUP },
1320Sstevel@tonic-gate 	{ MSG_ORIG(MSG_MODE_WORLD), RTLD_WORLD, RTLD_WORLD },
1330Sstevel@tonic-gate 	{ MSG_ORIG(MSG_MODE_NODELETE), RTLD_NODELETE, RTLD_NODELETE },
1340Sstevel@tonic-gate 	{ MSG_ORIG(MSG_MODE_FIRST), RTLD_FIRST, RTLD_FIRST },
1350Sstevel@tonic-gate 	{ MSG_ORIG(MSG_MODE_CONFGEN), RTLD_CONFGEN, RTLD_CONFGEN },
1360Sstevel@tonic-gate 	{ NULL, 0, 0}
1370Sstevel@tonic-gate };
1380Sstevel@tonic-gate 
1390Sstevel@tonic-gate static const mdb_bitmask_t bndflags_bits[] = {
1400Sstevel@tonic-gate 	{ MSG_ORIG(MSG_BFL_NEEDED), BND_NEEDED, BND_NEEDED },
1410Sstevel@tonic-gate 	{ MSG_ORIG(MSG_BFL_REFER), BND_REFER, BND_REFER },
142280Srie 	{ MSG_ORIG(MSG_BFL_FILTER), BND_FILTER, BND_FILTER },
1430Sstevel@tonic-gate 	{ NULL, 0, 0}
1440Sstevel@tonic-gate };
1450Sstevel@tonic-gate 
1460Sstevel@tonic-gate static const mdb_bitmask_t grhflags_bits[] = {
1470Sstevel@tonic-gate 	{ MSG_ORIG(MSG_GPH_ZERO), GPH_ZERO, GPH_ZERO },
1480Sstevel@tonic-gate 	{ MSG_ORIG(MSG_GPH_LDSO), GPH_LDSO, GPH_LDSO },
1490Sstevel@tonic-gate 	{ MSG_ORIG(MSG_GPH_FIRST), GPH_FIRST, GPH_FIRST },
1500Sstevel@tonic-gate 	{ MSG_ORIG(MSG_GPH_FILTEE), GPH_FILTEE, GPH_FILTEE },
1510Sstevel@tonic-gate 	{ MSG_ORIG(MSG_GPH_INITIAL), GPH_INITIAL, GPH_INITIAL },
1522850Srie 	{ MSG_ORIG(MSG_GPH_NOPENDLAZY), GPH_NOPENDLAZY, GPH_NOPENDLAZY },
1530Sstevel@tonic-gate 	{ NULL, 0, 0}
1540Sstevel@tonic-gate };
1550Sstevel@tonic-gate 
1560Sstevel@tonic-gate static const mdb_bitmask_t grdflags_bits[] = {
1574699Srie 	{ MSG_ORIG(MSG_GPD_DLSYM), GPD_DLSYM, GPD_DLSYM },
1584699Srie 	{ MSG_ORIG(MSG_GPD_RELOC), GPD_RELOC, GPD_RELOC },
1590Sstevel@tonic-gate 	{ MSG_ORIG(MSG_GPD_ADDEPS), GPD_ADDEPS, GPD_ADDEPS },
1600Sstevel@tonic-gate 	{ MSG_ORIG(MSG_GPD_PARENT), GPD_PARENT, GPD_PARENT },
1610Sstevel@tonic-gate 	{ MSG_ORIG(MSG_GPD_FILTER), GPD_FILTER, GPD_FILTER },
1625067Srie 	{ MSG_ORIG(MSG_GPD_PROMOTE), GPD_PROMOTE, GPD_PROMOTE },
1630Sstevel@tonic-gate 	{ MSG_ORIG(MSG_GPD_REMOVE), GPD_REMOVE, GPD_REMOVE },
1640Sstevel@tonic-gate 	{ NULL, 0, 0}
1650Sstevel@tonic-gate };
1660Sstevel@tonic-gate 
1670Sstevel@tonic-gate static const mdb_bitmask_t lmc_bits[] = {
1680Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LMC_ANALYZING), LMC_FLG_ANALYZING, LMC_FLG_ANALYZING},
1690Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LMC_RELOCATING), LMC_FLG_RELOCATING, LMC_FLG_RELOCATING},
1700Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LMC_REANALYZE), LMC_FLG_REANALYZE, LMC_FLG_REANALYZE},
1710Sstevel@tonic-gate 	{ NULL, 0, 0}
1720Sstevel@tonic-gate };
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate /*
1750Sstevel@tonic-gate  * Obtain a string - typically a link-map name.
1760Sstevel@tonic-gate  */
1770Sstevel@tonic-gate static char *
1780Sstevel@tonic-gate String(uintptr_t addr, const char *name)
1790Sstevel@tonic-gate {
1800Sstevel@tonic-gate 	static char	str[MAXPATHLEN];
1810Sstevel@tonic-gate 
1820Sstevel@tonic-gate 	if (addr) {
1830Sstevel@tonic-gate 		if (mdb_readstr(str, MAXPATHLEN, addr) == -1) {
1840Sstevel@tonic-gate 			mdb_warn(MSG_ORIG(MSG_ERR_READ), name, addr);
1850Sstevel@tonic-gate 			return (0);
1860Sstevel@tonic-gate 		}
1870Sstevel@tonic-gate 		return (str);
1880Sstevel@tonic-gate 	}
1890Sstevel@tonic-gate 	return ((char *)MSG_ORIG(MSG_STR_EMPTY));
1900Sstevel@tonic-gate }
1910Sstevel@tonic-gate 
1920Sstevel@tonic-gate /*
1930Sstevel@tonic-gate  * Obtain a link-map name.
1940Sstevel@tonic-gate  */
1950Sstevel@tonic-gate static char *
1960Sstevel@tonic-gate Rtmap_Name(uintptr_t addr)
1970Sstevel@tonic-gate {
1980Sstevel@tonic-gate 	Rt_map	rtmap;
1990Sstevel@tonic-gate 
2000Sstevel@tonic-gate 	if (addr) {
2010Sstevel@tonic-gate 		if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) {
2020Sstevel@tonic-gate 			mdb_warn(MSG_ORIG(MSG_ERR_READ),
2030Sstevel@tonic-gate 			    MSG_ORIG(MSG_RTMAP_STR), addr);
2040Sstevel@tonic-gate 			return (0);
2050Sstevel@tonic-gate 		}
2060Sstevel@tonic-gate 		return (String((uintptr_t)NAME(&rtmap),
2070Sstevel@tonic-gate 		    MSG_ORIG(MSG_STR_NAME)));
2080Sstevel@tonic-gate 	}
2090Sstevel@tonic-gate 	return ((char *)MSG_ORIG(MSG_STR_EMPTY));
2100Sstevel@tonic-gate }
2110Sstevel@tonic-gate 
2120Sstevel@tonic-gate void
2130Sstevel@tonic-gate dcmd_Bind_help(void)
2140Sstevel@tonic-gate {
2150Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_BND_HELP));
2160Sstevel@tonic-gate }
2170Sstevel@tonic-gate 
2180Sstevel@tonic-gate static int
2190Sstevel@tonic-gate /* ARGSUSED2 */
2200Sstevel@tonic-gate dcmd_Bind(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
2210Sstevel@tonic-gate {
2220Sstevel@tonic-gate 	Bnd_desc	bnd;
2230Sstevel@tonic-gate 	char		*str;
2240Sstevel@tonic-gate 
2250Sstevel@tonic-gate 	/*
2260Sstevel@tonic-gate 	 * Insure we have a valid address.
2270Sstevel@tonic-gate 	 */
2280Sstevel@tonic-gate 	if ((flags & DCMD_ADDRSPEC) == 0) {
2290Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_BND_STR));
2300Sstevel@tonic-gate 		return (DCMD_USAGE);
2310Sstevel@tonic-gate 	}
2320Sstevel@tonic-gate 
2330Sstevel@tonic-gate 	/*
2340Sstevel@tonic-gate 	 * Obtain the binding descriptor.
2350Sstevel@tonic-gate 	 */
2360Sstevel@tonic-gate 	if (mdb_vread(&bnd, sizeof (Bnd_desc), addr) == -1) {
2370Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_BND_STR), addr);
2380Sstevel@tonic-gate 		return (DCMD_ERR);
2390Sstevel@tonic-gate 	}
2400Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_BND_TITLE), addr);
2410Sstevel@tonic-gate 
2420Sstevel@tonic-gate 	/*
2430Sstevel@tonic-gate 	 * Establish the identity of the caller.
2440Sstevel@tonic-gate 	 */
2450Sstevel@tonic-gate 	if ((str = Rtmap_Name((uintptr_t)bnd.b_caller)) == 0)
2460Sstevel@tonic-gate 		return (DCMD_ERR);
2470Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_BND_LINE1), bnd.b_caller, str);
2480Sstevel@tonic-gate 
2490Sstevel@tonic-gate 	/*
2500Sstevel@tonic-gate 	 * Establish the identity of the dependency.
2510Sstevel@tonic-gate 	 */
2520Sstevel@tonic-gate 	if ((str = Rtmap_Name((uintptr_t)bnd.b_depend)) == 0)
2530Sstevel@tonic-gate 		return (DCMD_ERR);
2540Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_BND_LINE2), bnd.b_depend, str);
2550Sstevel@tonic-gate 
2560Sstevel@tonic-gate 	/*
2570Sstevel@tonic-gate 	 * Display any flags.
2580Sstevel@tonic-gate 	 */
2590Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_BND_LINE3), bnd.b_flags, bnd.b_flags,
2600Sstevel@tonic-gate 	    bndflags_bits);
2610Sstevel@tonic-gate 
2620Sstevel@tonic-gate 	return (DCMD_OK);
2630Sstevel@tonic-gate }
2640Sstevel@tonic-gate 
2650Sstevel@tonic-gate static void
2660Sstevel@tonic-gate dcmd_Depends_help(void)
2670Sstevel@tonic-gate {
2680Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_DEPENDS_HELP));
2690Sstevel@tonic-gate }
2700Sstevel@tonic-gate 
2710Sstevel@tonic-gate static int
2720Sstevel@tonic-gate Depends(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv,
2730Sstevel@tonic-gate     uint_t flg, const char *msg)
2740Sstevel@tonic-gate {
2755892Sab196087 	APlist		apl;
2765892Sab196087 	uintptr_t	listcalc, listndx;
277*8598SRod.Evans@Sun.COM 	Bnd_desc	*bdp;
2780Sstevel@tonic-gate 
2790Sstevel@tonic-gate 	/*
2805892Sab196087 	 * Obtain the APlist and determine its number of elements and those
2810Sstevel@tonic-gate 	 * that are in use.
2820Sstevel@tonic-gate 	 */
2835892Sab196087 	if (mdb_vread(&apl, sizeof (APlist), addr) == -1) {
2845892Sab196087 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_APLIST),
2855892Sab196087 		    addr);
2864679Srie 		return (DCMD_ERR);
2870Sstevel@tonic-gate 	}
2880Sstevel@tonic-gate 
2895892Sab196087 	mdb_printf(msg, addr, (size_t)apl.apl_nitems,
2905892Sab196087 	    (size_t)apl.apl_arritems);
2910Sstevel@tonic-gate 
2925892Sab196087 	if (((flg & RTLD_FLG_VERBOSE) == 0) || (apl.apl_nitems == 0))
2930Sstevel@tonic-gate 		return (DCMD_OK);
2940Sstevel@tonic-gate 
2950Sstevel@tonic-gate 	/*
2965892Sab196087 	 * Under verbose mode print the name of each dependency.  An APlist can
2970Sstevel@tonic-gate 	 * have a variable number of data items, so read each individual entry.
2980Sstevel@tonic-gate 	 */
2995892Sab196087 	listcalc = APLIST_OFF_DATA + (uintptr_t)addr;
3000Sstevel@tonic-gate 	if (mdb_vread(&bdp, sizeof (Bnd_desc *), listcalc) == -1) {
3010Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ),
3020Sstevel@tonic-gate 		    MSG_ORIG(MSG_BNDDESC_STR), listcalc);
3030Sstevel@tonic-gate 		return (DCMD_ERR);
3040Sstevel@tonic-gate 	}
3050Sstevel@tonic-gate 
3060Sstevel@tonic-gate 	mdb_inc_indent(4);
3070Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_STR_DASHES));
3080Sstevel@tonic-gate 
3090Sstevel@tonic-gate 	if (dcmd_Bind((uintptr_t)bdp, flags, argc, argv) == DCMD_ERR) {
3100Sstevel@tonic-gate 		mdb_dec_indent(4);
3110Sstevel@tonic-gate 		return (DCMD_ERR);
3120Sstevel@tonic-gate 	}
3130Sstevel@tonic-gate 
3145892Sab196087 	for (listndx = 1; listndx < apl.apl_nitems; listndx++) {
3155892Sab196087 		listcalc += sizeof (void *);
3160Sstevel@tonic-gate 		if (mdb_vread(&bdp, sizeof (Bnd_desc *), listcalc) == -1) {
3170Sstevel@tonic-gate 			mdb_warn(MSG_ORIG(MSG_ERR_READ),
3180Sstevel@tonic-gate 			    MSG_ORIG(MSG_BNDDESC_STR), listcalc);
3190Sstevel@tonic-gate 			return (DCMD_ERR);
3200Sstevel@tonic-gate 		}
3210Sstevel@tonic-gate 
3220Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_STR_DASHES));
3230Sstevel@tonic-gate 		if (dcmd_Bind((uintptr_t)bdp, flags, argc, argv) == DCMD_ERR) {
3240Sstevel@tonic-gate 			mdb_dec_indent(4);
3250Sstevel@tonic-gate 			return (DCMD_ERR);
3260Sstevel@tonic-gate 		}
3270Sstevel@tonic-gate 	}
3280Sstevel@tonic-gate 	mdb_dec_indent(4);
3290Sstevel@tonic-gate 	return (DCMD_OK);
3300Sstevel@tonic-gate }
3310Sstevel@tonic-gate 
3320Sstevel@tonic-gate static int
3330Sstevel@tonic-gate dcmd_Depends(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
3340Sstevel@tonic-gate {
3350Sstevel@tonic-gate 	Rt_map		rtmap;
3360Sstevel@tonic-gate 	char		*str;
3370Sstevel@tonic-gate 	uint_t		flg = 0;
3380Sstevel@tonic-gate 
3390Sstevel@tonic-gate 	/*
3400Sstevel@tonic-gate 	 * Insure we have a valid address, and provide for a -v option.
3410Sstevel@tonic-gate 	 */
3420Sstevel@tonic-gate 	if ((flags & DCMD_ADDRSPEC) == 0) {
3430Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_DEPENDS_STR));
3440Sstevel@tonic-gate 		return (DCMD_USAGE);
3450Sstevel@tonic-gate 	}
3460Sstevel@tonic-gate 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE,
3470Sstevel@tonic-gate 	    &flg, NULL) != argc)
3480Sstevel@tonic-gate 		return (DCMD_USAGE);
3490Sstevel@tonic-gate 
3500Sstevel@tonic-gate 	/*
3510Sstevel@tonic-gate 	 * Read the Rt_map contents.
3520Sstevel@tonic-gate 	 */
3530Sstevel@tonic-gate 	if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) {
3540Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_RTMAP_STR), addr);
3550Sstevel@tonic-gate 		return (DCMD_ERR);
3560Sstevel@tonic-gate 	}
3570Sstevel@tonic-gate 	if ((str = String((uintptr_t)NAME(&rtmap),
3580Sstevel@tonic-gate 	    MSG_ORIG(MSG_STR_NAME))) == 0)
3590Sstevel@tonic-gate 		return (DCMD_ERR);
3600Sstevel@tonic-gate 
3610Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_DEPENDS_LINE1), str);
3620Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_STR_DASHES));
3630Sstevel@tonic-gate 
3645892Sab196087 	if (DEPENDS(&rtmap) == NULL)
3650Sstevel@tonic-gate 		return (DCMD_OK);
3660Sstevel@tonic-gate 
3670Sstevel@tonic-gate 	return (Depends((uintptr_t)DEPENDS(&rtmap), flags, argc, argv, flg,
3680Sstevel@tonic-gate 	    MSG_ORIG(MSG_DEPENDS_LINE2)));
3690Sstevel@tonic-gate }
3700Sstevel@tonic-gate 
3710Sstevel@tonic-gate static void
3720Sstevel@tonic-gate dcmd_Callers_help(void)
3730Sstevel@tonic-gate {
3740Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_CALLERS_HELP));
3750Sstevel@tonic-gate }
3760Sstevel@tonic-gate 
3770Sstevel@tonic-gate static int
3780Sstevel@tonic-gate dcmd_Callers(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
3790Sstevel@tonic-gate {
3800Sstevel@tonic-gate 	Rt_map		rtmap;
3810Sstevel@tonic-gate 	char		*str;
3820Sstevel@tonic-gate 	uint_t		flg = 0;
3830Sstevel@tonic-gate 
3840Sstevel@tonic-gate 	/*
3850Sstevel@tonic-gate 	 * Insure we have a valid address, and provide for a -v option.
3860Sstevel@tonic-gate 	 */
3870Sstevel@tonic-gate 	if ((flags & DCMD_ADDRSPEC) == 0) {
3880Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_DEPENDS_STR));
3890Sstevel@tonic-gate 		return (DCMD_USAGE);
3900Sstevel@tonic-gate 	}
3910Sstevel@tonic-gate 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE,
3920Sstevel@tonic-gate 	    &flg, NULL) != argc)
3930Sstevel@tonic-gate 		return (DCMD_USAGE);
3940Sstevel@tonic-gate 
3950Sstevel@tonic-gate 	/*
3960Sstevel@tonic-gate 	 * Read the Rt_map contents.
3970Sstevel@tonic-gate 	 */
3980Sstevel@tonic-gate 	if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) {
3990Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_RTMAP_STR), addr);
4000Sstevel@tonic-gate 		return (DCMD_ERR);
4010Sstevel@tonic-gate 	}
4020Sstevel@tonic-gate 	if ((str = String((uintptr_t)NAME(&rtmap),
4030Sstevel@tonic-gate 	    MSG_ORIG(MSG_STR_NAME))) == 0)
4040Sstevel@tonic-gate 		return (DCMD_ERR);
4050Sstevel@tonic-gate 
4060Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_CALLERS_LINE1), str);
4070Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_STR_DASHES));
4080Sstevel@tonic-gate 
4095892Sab196087 	if (CALLERS(&rtmap) == NULL)
4100Sstevel@tonic-gate 		return (DCMD_OK);
4110Sstevel@tonic-gate 
4120Sstevel@tonic-gate 	return (Depends((uintptr_t)CALLERS(&rtmap), flags, argc, argv, flg,
4130Sstevel@tonic-gate 	    MSG_ORIG(MSG_CALLERS_LINE2)));
4140Sstevel@tonic-gate }
4150Sstevel@tonic-gate 
4160Sstevel@tonic-gate void
4170Sstevel@tonic-gate dcmd_rtmap_help(void)
4180Sstevel@tonic-gate {
4190Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_HELP));
4200Sstevel@tonic-gate }
4210Sstevel@tonic-gate 
4220Sstevel@tonic-gate static int
4230Sstevel@tonic-gate /* ARGSUSED2 */
4240Sstevel@tonic-gate dcmd_rtmap(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
4250Sstevel@tonic-gate {
4260Sstevel@tonic-gate 	Rt_map		rtmap;
4270Sstevel@tonic-gate 	char		*str;
4280Sstevel@tonic-gate 
4290Sstevel@tonic-gate 	if ((flags & DCMD_ADDRSPEC) == 0) {
4300Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_RTMAP_STR));
4310Sstevel@tonic-gate 		return (DCMD_USAGE);
4320Sstevel@tonic-gate 	}
4330Sstevel@tonic-gate 
4340Sstevel@tonic-gate 	if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) {
4350Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_RTMAP_STR), addr);
4360Sstevel@tonic-gate 		return (DCMD_ERR);
4370Sstevel@tonic-gate 	}
4380Sstevel@tonic-gate 
4390Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_TITLE), addr);
4400Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_STR_DASHES));
4410Sstevel@tonic-gate 
4420Sstevel@tonic-gate 	/*
4430Sstevel@tonic-gate 	 * Determine the objects name.  NAME() is the name by which the object
4440Sstevel@tonic-gate 	 * has been opened, typically from adding a search path to a file name.
4450Sstevel@tonic-gate 	 * PATHNAME() is the fully resolve name, which is displayed by the proc
4460Sstevel@tonic-gate 	 * tools and debuggers.  If the two names differ, print the PATHNAME().
4470Sstevel@tonic-gate 	 */
4480Sstevel@tonic-gate 	if ((str = String((uintptr_t)NAME(&rtmap),
4490Sstevel@tonic-gate 	    MSG_ORIG(MSG_STR_NAME))) == 0)
4500Sstevel@tonic-gate 		return (DCMD_ERR);
4510Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE1), str);
4520Sstevel@tonic-gate 	if (NAME(&rtmap) != PATHNAME(&rtmap)) {
4530Sstevel@tonic-gate 		if ((str = String((uintptr_t)PATHNAME(&rtmap),
4540Sstevel@tonic-gate 		    MSG_ORIG(MSG_STR_PATHNAME))) == 0)
4550Sstevel@tonic-gate 			return (DCMD_ERR);
4560Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_RTMAP_LINE2), str);
4570Sstevel@tonic-gate 	}
4580Sstevel@tonic-gate 
4590Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE3), ADDR(&rtmap), DYN(&rtmap));
4600Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE4), NEXT(&rtmap), PREV(&rtmap));
4610Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE5), rtmap.rt_fct, TLSMODID(&rtmap));
4620Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE6), INIT(&rtmap), FINI(&rtmap));
4630Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE7), GROUPS(&rtmap), HANDLES(&rtmap));
4640Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE8), DEPENDS(&rtmap), CALLERS(&rtmap));
4650Sstevel@tonic-gate 
4660Sstevel@tonic-gate 	if ((str = String((uintptr_t)REFNAME(&rtmap),
4670Sstevel@tonic-gate 	    MSG_ORIG(MSG_STR_REFNAME))) == 0)
4680Sstevel@tonic-gate 		return (DCMD_ERR);
4690Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE9), DYNINFO(&rtmap), str);
4700Sstevel@tonic-gate 
4710Sstevel@tonic-gate 	if ((str = String((uintptr_t)RPATH(&rtmap),
4720Sstevel@tonic-gate 	    MSG_ORIG(MSG_STR_RPATH))) == 0)
4730Sstevel@tonic-gate 		return (DCMD_ERR);
4740Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE10), RLIST(&rtmap), str);
4750Sstevel@tonic-gate 
4760Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE11), LIST(&rtmap), LIST(&rtmap));
4770Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE12), FLAGS(&rtmap));
4780Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE20), FLAGS(&rtmap), rtflags_bits);
4790Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE13), FLAGS1(&rtmap));
4800Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE20), FLAGS1(&rtmap), rtflags1_bits);
481*8598SRod.Evans@Sun.COM 	if (AFLAGS(&rtmap)) {
482*8598SRod.Evans@Sun.COM 		mdb_printf(MSG_ORIG(MSG_RTMAP_LINE14), AFLAGS(&rtmap));
483*8598SRod.Evans@Sun.COM 		mdb_printf(MSG_ORIG(MSG_RTMAP_LINE20), AFLAGS(&rtmap),
484*8598SRod.Evans@Sun.COM 		    rtaflags_bits);
485*8598SRod.Evans@Sun.COM 	}
486*8598SRod.Evans@Sun.COM 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE15), MODE(&rtmap));
4870Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAP_LINE20), MODE(&rtmap), rtmode_bits);
4880Sstevel@tonic-gate 
4890Sstevel@tonic-gate 	return (DCMD_OK);
4900Sstevel@tonic-gate }
4910Sstevel@tonic-gate 
4920Sstevel@tonic-gate static int
493*8598SRod.Evans@Sun.COM rtmap_format(uintptr_t addr, const void *data, void *private)
4940Sstevel@tonic-gate {
4950Sstevel@tonic-gate 	const Rt_map	*lmp = (const Rt_map *)data;
4960Sstevel@tonic-gate 	W_desc		*wdp = (W_desc *)private;
4970Sstevel@tonic-gate 	char		*str;
4980Sstevel@tonic-gate 
4990Sstevel@tonic-gate 	if (wdp && (wdp->w_flags & RTLD_FLG_VERBOSE)) {
5000Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_STR_DASHES));
5010Sstevel@tonic-gate 		mdb_call_dcmd(MSG_ORIG(MSG_RTMAP_STR), addr, DCMD_ADDRSPEC,
5020Sstevel@tonic-gate 		    NULL, NULL);
5030Sstevel@tonic-gate 		return (0);
5040Sstevel@tonic-gate 	}
5050Sstevel@tonic-gate 
5060Sstevel@tonic-gate 	if ((str = String((uintptr_t)NAME(lmp),
5070Sstevel@tonic-gate 	    MSG_ORIG(MSG_STR_NAME))) == 0)
5080Sstevel@tonic-gate 		return (DCMD_ERR);
5090Sstevel@tonic-gate 
5100Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_FMT_RT), CNTL(lmp), addr, ADDR(lmp), str);
5110Sstevel@tonic-gate 	return (0);
5120Sstevel@tonic-gate }
5130Sstevel@tonic-gate 
5140Sstevel@tonic-gate void
5150Sstevel@tonic-gate dcmd_Rtmaps_help(void)
5160Sstevel@tonic-gate {
5170Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_RTMAPS_HELP));
5180Sstevel@tonic-gate }
5190Sstevel@tonic-gate 
5200Sstevel@tonic-gate static int
5210Sstevel@tonic-gate dcmd_Rtmaps(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
5220Sstevel@tonic-gate {
5230Sstevel@tonic-gate 	uint_t		flg = 0;
5240Sstevel@tonic-gate 	GElf_Sym	gsym;
5250Sstevel@tonic-gate 	List		l;
5260Sstevel@tonic-gate 	Listnode	ln;
5270Sstevel@tonic-gate 	uintptr_t	naddr;
5280Sstevel@tonic-gate 	const char	*str;
5290Sstevel@tonic-gate 	W_desc		wdesc;
5300Sstevel@tonic-gate 
5310Sstevel@tonic-gate 	/*
5320Sstevel@tonic-gate 	 * '-v' - Verbose output of rtmap
5330Sstevel@tonic-gate 	 */
5340Sstevel@tonic-gate 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE,
5350Sstevel@tonic-gate 	    &flg, NULL) != argc)
5360Sstevel@tonic-gate 		return (DCMD_USAGE);
5370Sstevel@tonic-gate 
5380Sstevel@tonic-gate 	/*
5390Sstevel@tonic-gate 	 * If an address was provided use it.
5400Sstevel@tonic-gate 	 */
5410Sstevel@tonic-gate 	if (flags & DCMD_ADDRSPEC) {
5420Sstevel@tonic-gate 		if (((flags & DCMD_LOOPFIRST) || !(flags & DCMD_LOOP)) &&
5430Sstevel@tonic-gate 		    !(flg & RTLD_FLG_VERBOSE)) {
5440Sstevel@tonic-gate 			mdb_printf(MSG_ORIG(MSG_RTMAPS_TITLE0));
5450Sstevel@tonic-gate 			mdb_printf(MSG_ORIG(MSG_STR_DASHES));
5460Sstevel@tonic-gate 		}
5470Sstevel@tonic-gate 
5480Sstevel@tonic-gate 		wdesc.w_flags = flg;
5490Sstevel@tonic-gate 		if (mdb_pwalk(MSG_ORIG(MSG_RTMAPS_STR), rtmap_format,
5500Sstevel@tonic-gate 		    (void *)&wdesc, addr) == -1)
5510Sstevel@tonic-gate 			return (DCMD_ERR);
5520Sstevel@tonic-gate 		return (DCMD_OK);
5530Sstevel@tonic-gate 	}
5540Sstevel@tonic-gate 
5550Sstevel@tonic-gate 	/*
5560Sstevel@tonic-gate 	 * Otherwise traverse the dynlm_list and display each link-map.
5570Sstevel@tonic-gate 	 */
5580Sstevel@tonic-gate 	if (mdb_lookup_by_obj(MSG_ORIG(MSG_STR_LDSO1),
5590Sstevel@tonic-gate 	    MSG_ORIG(MSG_STR_DYNLMLIST), &gsym) == -1) {
5600Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_SYMFAILED), MSG_ORIG(MSG_STR_LDSO1),
5610Sstevel@tonic-gate 		    MSG_ORIG(MSG_STR_DYNLMLIST));
5620Sstevel@tonic-gate 		return (DCMD_ERR);
5630Sstevel@tonic-gate 	}
5640Sstevel@tonic-gate 	if (mdb_vread((void *)&l, sizeof (l), (uintptr_t)gsym.st_value) == -1) {
5650Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_LIST_STR),
5660Sstevel@tonic-gate 		    gsym.st_value);
5670Sstevel@tonic-gate 		return (DCMD_ERR);
5680Sstevel@tonic-gate 	}
5690Sstevel@tonic-gate 
5700Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_LMLIST_TITLE1), MSG_ORIG(MSG_STR_DYNLMLIST),
5714031Srie 	    gsym.st_value);
5720Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_STR_DASHES));
5730Sstevel@tonic-gate 
5740Sstevel@tonic-gate 	flags |= (DCMD_LOOP | DCMD_LOOPFIRST);
5750Sstevel@tonic-gate 	for (naddr = (uintptr_t)l.head; naddr; naddr = (uintptr_t)ln.next) {
5760Sstevel@tonic-gate 		Lm_list	lml;
5770Sstevel@tonic-gate 
5780Sstevel@tonic-gate 		if (mdb_vread(&ln, sizeof (ln), naddr) == -1) {
5790Sstevel@tonic-gate 			mdb_warn(MSG_ORIG(MSG_ERR_READ),
5800Sstevel@tonic-gate 			    MSG_ORIG(MSG_STR_LISTNODE), naddr);
5810Sstevel@tonic-gate 			return (DCMD_ERR);
5820Sstevel@tonic-gate 		}
5830Sstevel@tonic-gate 		if (mdb_vread(&lml, sizeof (lml), (uintptr_t)ln.data) == -1) {
5840Sstevel@tonic-gate 			mdb_warn(MSG_ORIG(MSG_ERR_READ),
5850Sstevel@tonic-gate 			    MSG_ORIG(MSG_LMLIST_STR), ln.data);
5860Sstevel@tonic-gate 			return (DCMD_ERR);
5870Sstevel@tonic-gate 		}
5880Sstevel@tonic-gate 
5890Sstevel@tonic-gate 		mdb_inc_indent(2);
5900Sstevel@tonic-gate 		if (lml.lm_flags & LML_FLG_BASELM)
5910Sstevel@tonic-gate 			str = MSG_ORIG(MSG_LMLIST_BASE);
5920Sstevel@tonic-gate 		else if (lml.lm_flags & LML_FLG_RTLDLM)
5930Sstevel@tonic-gate 			str = MSG_ORIG(MSG_LMLIST_LDSO);
5940Sstevel@tonic-gate 		else
5950Sstevel@tonic-gate 			str = MSG_ORIG(MSG_LMLIST_NEWLM);
5960Sstevel@tonic-gate 
5970Sstevel@tonic-gate 		if ((flags & DCMD_LOOP) && ((flags & DCMD_LOOPFIRST) == 0))
5980Sstevel@tonic-gate 			mdb_printf(MSG_ORIG(MSG_STR_DASHES));
5990Sstevel@tonic-gate 
6000Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_LMLIST_TITLE2), ln.data, str);
6010Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_STR_DASHES));
6020Sstevel@tonic-gate 
6030Sstevel@tonic-gate 		mdb_inc_indent(2);
6040Sstevel@tonic-gate 
6050Sstevel@tonic-gate 		if (((flags & DCMD_LOOPFIRST) || !(flags & DCMD_LOOP)) &&
6060Sstevel@tonic-gate 		    !(flg & RTLD_FLG_VERBOSE)) {
6070Sstevel@tonic-gate 			mdb_printf(MSG_ORIG(MSG_RTMAPS_TITLE0));
6080Sstevel@tonic-gate 			mdb_printf(MSG_ORIG(MSG_STR_DASHES));
6090Sstevel@tonic-gate 		}
6100Sstevel@tonic-gate 
6110Sstevel@tonic-gate 		wdesc.w_flags = flg;
6120Sstevel@tonic-gate 		if (mdb_pwalk(MSG_ORIG(MSG_RTMAPS_STR), rtmap_format,
6130Sstevel@tonic-gate 		    (void *)&wdesc, (uintptr_t)lml.lm_head) == -1) {
6140Sstevel@tonic-gate 			mdb_dec_indent(4);
6150Sstevel@tonic-gate 			return (DCMD_ERR);
6160Sstevel@tonic-gate 		}
6170Sstevel@tonic-gate 		mdb_dec_indent(4);
6180Sstevel@tonic-gate 		flags &= ~DCMD_LOOPFIRST;
6190Sstevel@tonic-gate 	}
6200Sstevel@tonic-gate 	return (DCMD_OK);
6210Sstevel@tonic-gate }
6220Sstevel@tonic-gate 
6230Sstevel@tonic-gate static int
6240Sstevel@tonic-gate /* ARGSUSED2 */
625*8598SRod.Evans@Sun.COM format_listnode(uintptr_t addr, const void *data, void *private)
6260Sstevel@tonic-gate {
627*8598SRod.Evans@Sun.COM 	Listnode	*lnp = (Listnode *)data;
6280Sstevel@tonic-gate 
6290Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_FMT_LN), addr, lnp->data, lnp->next);
6300Sstevel@tonic-gate 	return (0);
6310Sstevel@tonic-gate }
6320Sstevel@tonic-gate 
6330Sstevel@tonic-gate void
6340Sstevel@tonic-gate dcmd_List_help(void)
6350Sstevel@tonic-gate {
6360Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_LIST_HELP));
6370Sstevel@tonic-gate }
6380Sstevel@tonic-gate 
6390Sstevel@tonic-gate static int
6400Sstevel@tonic-gate /* ARGSUSED2 */
6410Sstevel@tonic-gate dcmd_List(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
6420Sstevel@tonic-gate {
6430Sstevel@tonic-gate 	if ((flags & DCMD_ADDRSPEC) == 0)
6440Sstevel@tonic-gate 		return (DCMD_USAGE);
6450Sstevel@tonic-gate 	if ((flags & DCMD_LOOPFIRST) || !(flags & DCMD_LOOP)) {
6460Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_LIST_TITLE));
6470Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_STR_DASHES));
6480Sstevel@tonic-gate 	}
6490Sstevel@tonic-gate 	if (mdb_pwalk(MSG_ORIG(MSG_LIST_STR), format_listnode,
6500Sstevel@tonic-gate 	    (void *)0, addr) == -1)
6510Sstevel@tonic-gate 		return (DCMD_ERR);
6520Sstevel@tonic-gate 	return (DCMD_OK);
6530Sstevel@tonic-gate }
6540Sstevel@tonic-gate 
6550Sstevel@tonic-gate void
6560Sstevel@tonic-gate dcmd_Setenv_help(void)
6570Sstevel@tonic-gate {
6580Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_SETENV_HELP));
6590Sstevel@tonic-gate }
6600Sstevel@tonic-gate 
6610Sstevel@tonic-gate /*
6620Sstevel@tonic-gate  * As of s10, mdb provides its own setenv command.  This command allows the
6630Sstevel@tonic-gate  * environment of the process being controlled to be changed at any time.
6640Sstevel@tonic-gate  * Prior to this, ld.so.1 provided it's own, more primitive implementation.
6650Sstevel@tonic-gate  * This allowed for changing mdb's environment only, which if it was changed
6660Sstevel@tonic-gate  * before the application ws executed, would be copied to the applications
6670Sstevel@tonic-gate  * environment.  Thus, we could start mdb, set an LD_ variable within its
6680Sstevel@tonic-gate  * environment (which it's own ld.so.1 had already finished processing), and
6690Sstevel@tonic-gate  * have this setting be inherited by the application.
6700Sstevel@tonic-gate  */
6710Sstevel@tonic-gate static int
6720Sstevel@tonic-gate /* ARGSUSED */
6730Sstevel@tonic-gate dcmd_Setenv(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
6740Sstevel@tonic-gate {
6750Sstevel@tonic-gate 	char	*str;
6760Sstevel@tonic-gate 
6770Sstevel@tonic-gate 	if (mdb_call_dcmd(MSG_ORIG(MSG_STR_SETENV), addr, flags, argc,
6780Sstevel@tonic-gate 	    argv) == 0)
6790Sstevel@tonic-gate 		return (DCMD_OK);
6800Sstevel@tonic-gate 
6810Sstevel@tonic-gate 	if (((flags & DCMD_ADDRSPEC) != 0) || (argc == 0) || (argc > 1) ||
6820Sstevel@tonic-gate 	    (argv->a_type != MDB_TYPE_STRING))
6830Sstevel@tonic-gate 		return (DCMD_USAGE);
6840Sstevel@tonic-gate 
6850Sstevel@tonic-gate 	str = mdb_alloc((strlen(argv->a_un.a_str) + 1), UM_NOSLEEP);
6860Sstevel@tonic-gate 	if (str == NULL)
6870Sstevel@tonic-gate 		return (DCMD_ERR);
6880Sstevel@tonic-gate 
6890Sstevel@tonic-gate 	(void) strcpy(str, argv->a_un.a_str);
6900Sstevel@tonic-gate 	(void) putenv(str);
6910Sstevel@tonic-gate 	return (DCMD_OK);
6920Sstevel@tonic-gate }
6930Sstevel@tonic-gate 
6940Sstevel@tonic-gate int
6950Sstevel@tonic-gate walk_List_init(mdb_walk_state_t *wsp)
6960Sstevel@tonic-gate {
6970Sstevel@tonic-gate 	List	lst;
6980Sstevel@tonic-gate 
6990Sstevel@tonic-gate 	if (wsp->walk_addr == NULL) {
7000Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_LIST_STR));
7010Sstevel@tonic-gate 		return (WALK_ERR);
7020Sstevel@tonic-gate 	}
7030Sstevel@tonic-gate 
7040Sstevel@tonic-gate 	if (mdb_vread(&lst, sizeof (List), wsp->walk_addr) == -1) {
7050Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ),
7060Sstevel@tonic-gate 		    MSG_ORIG(MSG_LIST_STR), wsp->walk_addr);
7070Sstevel@tonic-gate 		return (WALK_DONE);
7080Sstevel@tonic-gate 	}
7090Sstevel@tonic-gate 
7100Sstevel@tonic-gate 	wsp->walk_addr = (uintptr_t)lst.head;
7110Sstevel@tonic-gate 	return (WALK_NEXT);
7120Sstevel@tonic-gate }
7130Sstevel@tonic-gate 
7140Sstevel@tonic-gate 
7150Sstevel@tonic-gate static int
7160Sstevel@tonic-gate walk_List_step(mdb_walk_state_t *wsp)
7170Sstevel@tonic-gate {
7180Sstevel@tonic-gate 	Listnode	lnp;
7190Sstevel@tonic-gate 	int		status;
7200Sstevel@tonic-gate 
7210Sstevel@tonic-gate 	if (wsp->walk_addr == NULL)
7220Sstevel@tonic-gate 		return (WALK_DONE);
7230Sstevel@tonic-gate 
7240Sstevel@tonic-gate 	if (mdb_vread(&lnp, sizeof (Listnode), wsp->walk_addr) == -1) {
7250Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ),
7260Sstevel@tonic-gate 		    MSG_ORIG(MSG_STR_LISTNODE), wsp->walk_addr);
7270Sstevel@tonic-gate 		return (WALK_DONE);
7280Sstevel@tonic-gate 	}
7290Sstevel@tonic-gate 
7300Sstevel@tonic-gate 	status = wsp->walk_callback(wsp->walk_addr, &lnp, wsp->walk_cbdata);
7310Sstevel@tonic-gate 	wsp->walk_addr = (uintptr_t)lnp.next;
7320Sstevel@tonic-gate 	return (status);
7330Sstevel@tonic-gate }
7340Sstevel@tonic-gate 
7350Sstevel@tonic-gate /*
7360Sstevel@tonic-gate  * Walk Rt_map lists
7370Sstevel@tonic-gate  */
7380Sstevel@tonic-gate static int
7390Sstevel@tonic-gate walk_rtmap_init(mdb_walk_state_t *wsp)
7400Sstevel@tonic-gate {
7410Sstevel@tonic-gate 	if (wsp->walk_addr == NULL) {
7420Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_RTMAP_STR));
7430Sstevel@tonic-gate 		return (WALK_ERR);
7440Sstevel@tonic-gate 	}
7450Sstevel@tonic-gate 	return (WALK_NEXT);
7460Sstevel@tonic-gate }
7470Sstevel@tonic-gate 
7480Sstevel@tonic-gate static int
7490Sstevel@tonic-gate walk_rtmap_step(mdb_walk_state_t *wsp)
7500Sstevel@tonic-gate {
7510Sstevel@tonic-gate 	int	status;
7520Sstevel@tonic-gate 	Rt_map	lmp;
7530Sstevel@tonic-gate 
7540Sstevel@tonic-gate 	if (wsp->walk_addr == NULL)
7550Sstevel@tonic-gate 		return (WALK_DONE);
7560Sstevel@tonic-gate 	if (mdb_vread(&lmp, sizeof (Rt_map), wsp->walk_addr) == -1) {
7570Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ),
7580Sstevel@tonic-gate 		    MSG_ORIG(MSG_RTMAP_STR), wsp->walk_addr);
7590Sstevel@tonic-gate 		return (WALK_DONE);
7600Sstevel@tonic-gate 	}
7610Sstevel@tonic-gate 
7620Sstevel@tonic-gate 	status = wsp->walk_callback(wsp->walk_addr, &lmp, wsp->walk_cbdata);
7630Sstevel@tonic-gate 	wsp->walk_addr = (uintptr_t)(NEXT(&lmp));
7640Sstevel@tonic-gate 	return (status);
7650Sstevel@tonic-gate }
7660Sstevel@tonic-gate 
7670Sstevel@tonic-gate static const mdb_bitmask_t lml_flags_bit[] = {
7680Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_BASELM), LML_FLG_BASELM, LML_FLG_BASELM },
7690Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_RTLDLM), LML_FLG_RTLDLM, LML_FLG_RTLDLM },
7700Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_NOAUDIT), LML_FLG_NOAUDIT, LML_FLG_NOAUDIT },
7710Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_PLTREL), LML_FLG_PLTREL, LML_FLG_PLTREL },
7720Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_HOLDLOCK), LML_FLG_HOLDLOCK, LML_FLG_HOLDLOCK },
7730Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_ENVIRON), LML_FLG_ENVIRON, LML_FLG_ENVIRON },
7740Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_INTRPOSE), LML_FLG_INTRPOSE, LML_FLG_INTRPOSE },
7750Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_LOCAUDIT), LML_FLG_LOCAUDIT, LML_FLG_LOCAUDIT },
7760Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_LOADAVAIL), LML_FLG_LOADAVAIL, LML_FLG_LOADAVAIL },
7770Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_IGNRELERR), LML_FLG_IGNRELERR, LML_FLG_IGNRELERR },
7780Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_DBNOTIF), LML_FLG_DBNOTIF, LML_FLG_DBNOTIF },
7790Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_STARTREL), LML_FLG_STARTREL, LML_FLG_STARTREL },
780280Srie 	{ MSG_ORIG(MSG_LFL_ATEXIT), LML_FLG_ATEXIT, LML_FLG_ATEXIT },
781280Srie 	{ MSG_ORIG(MSG_LFL_OBJADDED), LML_FLG_OBJADDED, LML_FLG_OBJADDED },
782280Srie 	{ MSG_ORIG(MSG_LFL_OBJDELETED), LML_FLG_OBJDELETED,
783280Srie 	    LML_FLG_OBJDELETED },
784280Srie 	{ MSG_ORIG(MSG_LFL_OBJREEVAL), LML_FLG_OBJREEVAL, LML_FLG_OBJREEVAL },
7852850Srie 	{ MSG_ORIG(MSG_LFL_NOPENDGLBLAZY), LML_FLG_NOPENDGLBLAZY,
7862850Srie 	    LML_FLG_NOPENDGLBLAZY },
787*8598SRod.Evans@Sun.COM 	{ MSG_ORIG(MSG_LFL_INTRPOSETSORT), LML_FLG_INTRPOSETSORT,
788*8598SRod.Evans@Sun.COM 	    LML_FLG_INTRPOSETSORT },
789*8598SRod.Evans@Sun.COM 	{ MSG_ORIG(MSG_LFL_AUDITNOTIFY), LML_FLG_AUDITNOTIFY,
790*8598SRod.Evans@Sun.COM 	    LML_FLG_AUDITNOTIFY },
791*8598SRod.Evans@Sun.COM 	{ MSG_ORIG(MSG_LFL_GROUPSEXIST), LML_FLG_GROUPSEXIST,
792*8598SRod.Evans@Sun.COM 	    LML_FLG_GROUPSEXIST },
7930Sstevel@tonic-gate 
7940Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_TRC_LDDSTUB), LML_FLG_TRC_LDDSTUB,
7950Sstevel@tonic-gate 	    LML_FLG_TRC_LDDSTUB },
7960Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_TRC_ENABLE), LML_FLG_TRC_ENABLE,
7970Sstevel@tonic-gate 	    LML_FLG_TRC_ENABLE },
7980Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_TRC_WARN), LML_FLG_TRC_WARN, LML_FLG_TRC_WARN },
7990Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_TRC_VERBOSE), LML_FLG_TRC_VERBOSE,
8000Sstevel@tonic-gate 	    LML_FLG_TRC_VERBOSE },
8010Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_TRC_SEARCH), LML_FLG_TRC_SEARCH,
8020Sstevel@tonic-gate 	    LML_FLG_TRC_SEARCH },
8030Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_TRC_UNREF), LML_FLG_TRC_UNREF, LML_FLG_TRC_UNREF },
8040Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_TRC_UNUSED), LML_FLG_TRC_UNUSED,
8050Sstevel@tonic-gate 	    LML_FLG_TRC_UNUSED },
8060Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LFL_TRC_INIT), LML_FLG_TRC_INIT, LML_FLG_TRC_INIT },
807*8598SRod.Evans@Sun.COM 	{ MSG_ORIG(MSG_LFL_TRC_NOUNRESWEAK), LML_FLG_TRC_NOUNRESWEAK,
808*8598SRod.Evans@Sun.COM 	    LML_FLG_TRC_NOUNRESWEAK },
809*8598SRod.Evans@Sun.COM 	{ MSG_ORIG(MSG_LFL_TRC_NOPAREXT), LML_FLG_TRC_NOPAREXT,
810*8598SRod.Evans@Sun.COM 	    LML_FLG_TRC_NOPAREXT },
8110Sstevel@tonic-gate 	{ NULL, 0, 0}
8120Sstevel@tonic-gate };
8130Sstevel@tonic-gate 
8140Sstevel@tonic-gate static const mdb_bitmask_t lml_tflags_bit[] = {
8150Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_NOLAZYLD), LML_TFLG_NOLAZYLD, LML_TFLG_NOLAZYLD },
8160Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_NODIRECT), LML_TFLG_NODIRECT, LML_TFLG_NODIRECT },
8170Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_LOADFLTR), LML_TFLG_LOADFLTR, LML_TFLG_LOADFLTR },
8180Sstevel@tonic-gate 
8190Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_PREINIT), LML_TFLG_AUD_PREINIT,
8200Sstevel@tonic-gate 	    LML_TFLG_AUD_PREINIT },
8210Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_OBJSEARCH), LML_TFLG_AUD_OBJSEARCH,
8220Sstevel@tonic-gate 	    LML_TFLG_AUD_OBJSEARCH },
8230Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_OBJOPEN), LML_TFLG_AUD_OBJOPEN,
8240Sstevel@tonic-gate 	    LML_TFLG_AUD_OBJOPEN },
8250Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_OBJFILTER), LML_TFLG_AUD_OBJFILTER,
8260Sstevel@tonic-gate 	    LML_TFLG_AUD_OBJFILTER },
8270Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_OBJCLOSE), LML_TFLG_AUD_OBJCLOSE,
8280Sstevel@tonic-gate 	    LML_TFLG_AUD_OBJCLOSE },
8290Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_SYMBIND), LML_TFLG_AUD_SYMBIND,
8300Sstevel@tonic-gate 	    LML_TFLG_AUD_SYMBIND },
8310Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_PLTENTER), LML_TFLG_AUD_PLTENTER,
8320Sstevel@tonic-gate 	    LML_TFLG_AUD_PLTENTER },
8330Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_PLTEXIT), LML_TFLG_AUD_PLTEXIT,
8340Sstevel@tonic-gate 	    LML_TFLG_AUD_PLTEXIT },
8350Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LTFL_AUD_ACTIVITY), LML_TFLG_AUD_ACTIVITY,
8360Sstevel@tonic-gate 	    LML_TFLG_AUD_ACTIVITY },
8370Sstevel@tonic-gate 	{ NULL, 0, 0}
8380Sstevel@tonic-gate };
8390Sstevel@tonic-gate 
8400Sstevel@tonic-gate void
8410Sstevel@tonic-gate dcmd_Lm_list_help(void)
8420Sstevel@tonic-gate {
8430Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_LMLIST_HELP));
8440Sstevel@tonic-gate }
8450Sstevel@tonic-gate 
8460Sstevel@tonic-gate static int
8470Sstevel@tonic-gate /* ARGSUSED1 */
8480Sstevel@tonic-gate _dcmd_Lm_list(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
8490Sstevel@tonic-gate {
8500Sstevel@tonic-gate 	Lm_list		lml;
8510Sstevel@tonic-gate 	const char	*str;
8520Sstevel@tonic-gate 	uint_t		flg = 0;
8530Sstevel@tonic-gate 
8540Sstevel@tonic-gate 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE,
8550Sstevel@tonic-gate 	    &flg, NULL) != argc)
8560Sstevel@tonic-gate 		return (DCMD_USAGE);
8570Sstevel@tonic-gate 
8580Sstevel@tonic-gate 	if (mdb_vread(&lml, sizeof (lml), addr) == -1) {
8590Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_LMLIST_STR),
8600Sstevel@tonic-gate 		    addr);
8610Sstevel@tonic-gate 		return (DCMD_ERR);
8620Sstevel@tonic-gate 	}
8630Sstevel@tonic-gate 
8640Sstevel@tonic-gate 	if (lml.lm_flags & LML_FLG_BASELM)
8650Sstevel@tonic-gate 		str = MSG_ORIG(MSG_LMLIST_BASE);
8660Sstevel@tonic-gate 	else if (lml.lm_flags & LML_FLG_RTLDLM)
8670Sstevel@tonic-gate 		str = MSG_ORIG(MSG_LMLIST_LDSO);
8680Sstevel@tonic-gate 	else
8690Sstevel@tonic-gate 		str = MSG_ORIG(MSG_LMLIST_NEWLM);
8700Sstevel@tonic-gate 
8710Sstevel@tonic-gate 	if ((flags & DCMD_LOOP) && ((flags & DCMD_LOOPFIRST) == 0))
8720Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_STR_DASHES));
8730Sstevel@tonic-gate 
8740Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_LMLIST_TITLE2), addr, str);
8750Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_STR_DASHES));
8760Sstevel@tonic-gate 
8770Sstevel@tonic-gate 	if (lml.lm_lists) {
8780Sstevel@tonic-gate 		Alist		al;
8790Sstevel@tonic-gate 		Lm_cntl		lmc;
8800Sstevel@tonic-gate 		uintptr_t	listcalc;
8810Sstevel@tonic-gate 
8820Sstevel@tonic-gate 		addr = (uintptr_t)lml.lm_lists;
8830Sstevel@tonic-gate 		if (mdb_vread(&al, sizeof (Alist), addr) == -1) {
8840Sstevel@tonic-gate 			mdb_warn(MSG_ORIG(MSG_ERR_READ),
8850Sstevel@tonic-gate 			    MSG_ORIG(MSG_STR_ALIST), addr);
8860Sstevel@tonic-gate 			return (DCMD_ERR);
8870Sstevel@tonic-gate 		}
8880Sstevel@tonic-gate 
8890Sstevel@tonic-gate 		/*
8900Sstevel@tonic-gate 		 * Determine whether the Alist has been populated.  Note, the
8910Sstevel@tonic-gate 		 * implementation first reserves an alist entry, and initializes
8920Sstevel@tonic-gate 		 * this element when the first link-map is processed.  Thus,
8935892Sab196087 		 * there's a window when nitems is updated, but before the next
8940Sstevel@tonic-gate 		 * element has been initialized.
8950Sstevel@tonic-gate 		 */
8965892Sab196087 		if (al.al_nitems && (flg & RTLD_FLG_VERBOSE)) {
8975892Sab196087 			listcalc = ALIST_OFF_DATA + (uintptr_t)addr;
8980Sstevel@tonic-gate 
8990Sstevel@tonic-gate 			if (mdb_vread(&lmc, sizeof (Lm_cntl),
9000Sstevel@tonic-gate 			    listcalc) == -1) {
9010Sstevel@tonic-gate 				mdb_warn(MSG_ORIG(MSG_ERR_READ),
9020Sstevel@tonic-gate 				    MSG_ORIG(MSG_LMLIST_STR), listcalc);
9030Sstevel@tonic-gate 				return (DCMD_ERR);
9040Sstevel@tonic-gate 			}
9050Sstevel@tonic-gate 		}
9060Sstevel@tonic-gate 
9075892Sab196087 		mdb_printf(MSG_ORIG(MSG_LMLIST_LINE0), addr,
9085892Sab196087 		    (size_t)al.al_nitems, (size_t)al.al_arritems);
9090Sstevel@tonic-gate 		mdb_inc_indent(2);
9100Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_STR_DASHES));
9110Sstevel@tonic-gate 
9125892Sab196087 		if (al.al_nitems && (flg & RTLD_FLG_VERBOSE)) {
9135892Sab196087 			uintptr_t	listndx;
9140Sstevel@tonic-gate 
9150Sstevel@tonic-gate 			mdb_inc_indent(2);
9160Sstevel@tonic-gate 			mdb_printf(MSG_ORIG(MSG_LMC_LINE1), listcalc);
9170Sstevel@tonic-gate 			mdb_printf(MSG_ORIG(MSG_LMC_LINE2), lmc.lc_head,
9180Sstevel@tonic-gate 			    lmc.lc_tail);
9190Sstevel@tonic-gate 			mdb_printf(MSG_ORIG(MSG_LMC_LINE3), lmc.lc_flags,
9200Sstevel@tonic-gate 			    lmc.lc_now);
9210Sstevel@tonic-gate 			mdb_printf(MSG_ORIG(MSG_LMC_LINE4), lmc.lc_flags,
9220Sstevel@tonic-gate 			    lmc_bits);
9230Sstevel@tonic-gate 			mdb_printf(MSG_ORIG(MSG_STR_DASHES));
9240Sstevel@tonic-gate 			mdb_printf(MSG_ORIG(MSG_RTMAPS_TITLE0));
9250Sstevel@tonic-gate 			mdb_printf(MSG_ORIG(MSG_STR_DASHES));
9260Sstevel@tonic-gate 
9270Sstevel@tonic-gate 			if (lmc.lc_head) {
9280Sstevel@tonic-gate 				if (mdb_pwalk(MSG_ORIG(MSG_RTMAPS_STR),
9290Sstevel@tonic-gate 				    rtmap_format, (void *)0,
9300Sstevel@tonic-gate 				    (uintptr_t)lmc.lc_head) == -1) {
9310Sstevel@tonic-gate 					mdb_dec_indent(4);
9320Sstevel@tonic-gate 					return (DCMD_ERR);
9330Sstevel@tonic-gate 				}
9340Sstevel@tonic-gate 			} else
9350Sstevel@tonic-gate 				mdb_printf(MSG_ORIG(MSG_FMT_RT), 0, 0, 0,
9360Sstevel@tonic-gate 				    MSG_ORIG(MSG_STR_EMPTY));
9370Sstevel@tonic-gate 
9380Sstevel@tonic-gate 			mdb_printf(MSG_ORIG(MSG_STR_DASHES));
9390Sstevel@tonic-gate 
9405892Sab196087 			for (listndx = 1; listndx < al.al_nitems; listndx++) {
9415892Sab196087 				listcalc += al.al_size;
9420Sstevel@tonic-gate 				if (mdb_vread(&lmc, sizeof (Lm_cntl),
9430Sstevel@tonic-gate 				    listcalc) == -1) {
9440Sstevel@tonic-gate 					mdb_warn(MSG_ORIG(MSG_ERR_READ),
9450Sstevel@tonic-gate 					    MSG_ORIG(MSG_LMLIST_STR), listcalc);
9460Sstevel@tonic-gate 					mdb_dec_indent(4);
9470Sstevel@tonic-gate 					return (DCMD_ERR);
9480Sstevel@tonic-gate 				}
9490Sstevel@tonic-gate 
9500Sstevel@tonic-gate 				mdb_printf(MSG_ORIG(MSG_STR_DASHES));
9510Sstevel@tonic-gate 				mdb_printf(MSG_ORIG(MSG_LMC_LINE1), listcalc);
9520Sstevel@tonic-gate 				mdb_printf(MSG_ORIG(MSG_LMC_LINE2),
9530Sstevel@tonic-gate 				    lmc.lc_head, lmc.lc_tail);
9540Sstevel@tonic-gate 				mdb_printf(MSG_ORIG(MSG_LMC_LINE3),
9550Sstevel@tonic-gate 				    lmc.lc_flags, lmc.lc_now);
9560Sstevel@tonic-gate 				mdb_printf(MSG_ORIG(MSG_LMC_LINE4),
9570Sstevel@tonic-gate 				    lmc.lc_flags, lmc_bits);
9580Sstevel@tonic-gate 				mdb_printf(MSG_ORIG(MSG_STR_DASHES));
9590Sstevel@tonic-gate 				mdb_printf(MSG_ORIG(MSG_RTMAPS_TITLE0));
9600Sstevel@tonic-gate 				mdb_printf(MSG_ORIG(MSG_STR_DASHES));
9610Sstevel@tonic-gate 
9620Sstevel@tonic-gate 				if (lmc.lc_head) {
9630Sstevel@tonic-gate 					if (mdb_pwalk(MSG_ORIG(MSG_RTMAPS_STR),
9640Sstevel@tonic-gate 					    rtmap_format, (void *)0,
9650Sstevel@tonic-gate 					    (uintptr_t)lmc.lc_head) == -1) {
9660Sstevel@tonic-gate 						mdb_dec_indent(4);
9670Sstevel@tonic-gate 						return (DCMD_ERR);
9680Sstevel@tonic-gate 					}
9690Sstevel@tonic-gate 				} else
9700Sstevel@tonic-gate 					mdb_printf(MSG_ORIG(MSG_FMT_RT), 0, 0,
9710Sstevel@tonic-gate 					    0, MSG_ORIG(MSG_STR_EMPTY));
9720Sstevel@tonic-gate 
9730Sstevel@tonic-gate 				mdb_printf(MSG_ORIG(MSG_STR_DASHES));
9740Sstevel@tonic-gate 			}
9750Sstevel@tonic-gate 			mdb_dec_indent(2);
9760Sstevel@tonic-gate 		}
9770Sstevel@tonic-gate 		mdb_dec_indent(2);
9780Sstevel@tonic-gate 	}
9790Sstevel@tonic-gate 
9800Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_LMLIST_LINE1), lml.lm_head, lml.lm_tail);
9811824Srie 	mdb_printf(MSG_ORIG(MSG_LMLIST_LINE2), lml.lm_alp, lml.lm_rti);
9820Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_LMLIST_LINE3), lml.lm_handle, lml.lm_obj,
9830Sstevel@tonic-gate 	    lml.lm_init, lml.lm_lazy);
9840Sstevel@tonic-gate 
9850Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_LMLIST_LINE4), lml.lm_flags);
9860Sstevel@tonic-gate 	if (lml.lm_flags)
9870Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_LMLIST_LINE6), lml.lm_flags,
9880Sstevel@tonic-gate 		    lml_flags_bit);
9890Sstevel@tonic-gate 
9900Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_LMLIST_LINE5), lml.lm_tflags);
9910Sstevel@tonic-gate 	if (lml.lm_tflags)
9920Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_LMLIST_LINE6), lml.lm_tflags,
9930Sstevel@tonic-gate 		    lml_tflags_bit);
9940Sstevel@tonic-gate 
9950Sstevel@tonic-gate 	return (DCMD_OK);
9960Sstevel@tonic-gate }
9970Sstevel@tonic-gate 
9980Sstevel@tonic-gate static int
9990Sstevel@tonic-gate /* ARGSUSED2 */
10000Sstevel@tonic-gate dcmd_Lm_list(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
10010Sstevel@tonic-gate {
10020Sstevel@tonic-gate 	GElf_Sym	gsym;
10030Sstevel@tonic-gate 	List		l;
10040Sstevel@tonic-gate 	Listnode	ln;
10050Sstevel@tonic-gate 	uintptr_t	naddr;
10060Sstevel@tonic-gate 
10070Sstevel@tonic-gate 	/*
10080Sstevel@tonic-gate 	 * If an address was provided us it.
10090Sstevel@tonic-gate 	 */
10100Sstevel@tonic-gate 	if (flags & DCMD_ADDRSPEC)
10110Sstevel@tonic-gate 		return (_dcmd_Lm_list(addr, flags, argc, argv));
10120Sstevel@tonic-gate 
10130Sstevel@tonic-gate 	/*
10140Sstevel@tonic-gate 	 * Otherwise traverse the dynlm_list and display each link-map list.
10150Sstevel@tonic-gate 	 */
10160Sstevel@tonic-gate 	if (mdb_lookup_by_obj(MSG_ORIG(MSG_STR_LDSO1),
10170Sstevel@tonic-gate 	    MSG_ORIG(MSG_STR_DYNLMLIST), &gsym) == -1) {
10180Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_SYMFAILED), MSG_ORIG(MSG_STR_LDSO1),
10194679Srie 		    MSG_ORIG(MSG_STR_DYNLMLIST));
10200Sstevel@tonic-gate 		return (DCMD_ERR);
10210Sstevel@tonic-gate 	}
10220Sstevel@tonic-gate 	if (mdb_vread((void *)&l, sizeof (l), (uintptr_t)gsym.st_value) == -1) {
10230Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_LIST_STR),
10240Sstevel@tonic-gate 		    gsym.st_value);
10250Sstevel@tonic-gate 		return (DCMD_ERR);
10260Sstevel@tonic-gate 	}
10270Sstevel@tonic-gate 
10280Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_LMLIST_TITLE1), MSG_ORIG(MSG_STR_DYNLMLIST),
10294031Srie 	    gsym.st_value);
10300Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_STR_DASHES));
10310Sstevel@tonic-gate 
10320Sstevel@tonic-gate 	flags |= (DCMD_LOOP | DCMD_LOOPFIRST);
10330Sstevel@tonic-gate 	for (naddr = (uintptr_t)l.head; naddr; naddr = (uintptr_t)ln.next) {
10340Sstevel@tonic-gate 		if (mdb_vread(&ln, sizeof (ln), naddr) == -1) {
10350Sstevel@tonic-gate 			mdb_warn(MSG_ORIG(MSG_ERR_READ),
10360Sstevel@tonic-gate 			    MSG_ORIG(MSG_STR_LISTNODE), naddr);
10370Sstevel@tonic-gate 			return (DCMD_ERR);
10380Sstevel@tonic-gate 		}
10390Sstevel@tonic-gate 
10400Sstevel@tonic-gate 		mdb_inc_indent(2);
10410Sstevel@tonic-gate 		if (_dcmd_Lm_list((uintptr_t)ln.data, flags,
10420Sstevel@tonic-gate 		    argc, argv) == DCMD_ERR) {
10430Sstevel@tonic-gate 			mdb_dec_indent(2);
10440Sstevel@tonic-gate 			return (DCMD_ERR);
10450Sstevel@tonic-gate 		}
10460Sstevel@tonic-gate 		mdb_dec_indent(2);
10470Sstevel@tonic-gate 		flags &= ~DCMD_LOOPFIRST;
10480Sstevel@tonic-gate 	}
10490Sstevel@tonic-gate 	return (DCMD_OK);
10500Sstevel@tonic-gate }
10510Sstevel@tonic-gate 
10520Sstevel@tonic-gate void
10530Sstevel@tonic-gate dcmd_GrpDesc_help(void)
10540Sstevel@tonic-gate {
10550Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_GRPDESC_HELP));
10560Sstevel@tonic-gate }
10570Sstevel@tonic-gate 
10580Sstevel@tonic-gate static int
10590Sstevel@tonic-gate /* ARGSUSED2 */
10600Sstevel@tonic-gate dcmd_GrpDesc(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
10610Sstevel@tonic-gate {
10620Sstevel@tonic-gate 	Grp_desc	gd;
10630Sstevel@tonic-gate 	char		*str;
10640Sstevel@tonic-gate 
10650Sstevel@tonic-gate 	/*
10660Sstevel@tonic-gate 	 * Insure we have a valid address.
10670Sstevel@tonic-gate 	 */
10680Sstevel@tonic-gate 	if ((flags & DCMD_ADDRSPEC) == 0) {
10690Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_GRPDESC_STR));
10700Sstevel@tonic-gate 		return (DCMD_USAGE);
10710Sstevel@tonic-gate 	}
10720Sstevel@tonic-gate 
10730Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_GRPDESC_LINE1), addr);
10740Sstevel@tonic-gate 	if (mdb_vread(&gd, sizeof (Grp_desc), addr) == -1) {
10750Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_GRPDESC_STR),
10760Sstevel@tonic-gate 		    addr);
10770Sstevel@tonic-gate 		return (DCMD_ERR);
10780Sstevel@tonic-gate 	}
10790Sstevel@tonic-gate 
10800Sstevel@tonic-gate 	if ((str = Rtmap_Name((uintptr_t)gd.gd_depend)) == 0)
10810Sstevel@tonic-gate 		return (DCMD_ERR);
10820Sstevel@tonic-gate 
10830Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_GRPDESC_LINE2), gd.gd_depend, str);
10840Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_GRPDESC_LINE3), gd.gd_flags, gd.gd_flags,
10850Sstevel@tonic-gate 	    grdflags_bits);
10860Sstevel@tonic-gate 
10870Sstevel@tonic-gate 	return (DCMD_OK);
10880Sstevel@tonic-gate }
10890Sstevel@tonic-gate 
10900Sstevel@tonic-gate void
10910Sstevel@tonic-gate dcmd_GrpHdl_help(void)
10920Sstevel@tonic-gate {
10930Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_GRPHDL_HELP));
10940Sstevel@tonic-gate }
10950Sstevel@tonic-gate 
10960Sstevel@tonic-gate static int
10970Sstevel@tonic-gate /* ARGSUSED2 */
10980Sstevel@tonic-gate dcmd_GrpHdl(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
10990Sstevel@tonic-gate {
11000Sstevel@tonic-gate 	Grp_hdl		gh;
11010Sstevel@tonic-gate 	Alist		al;
11025892Sab196087 	uintptr_t	listcalc, listidx;
11030Sstevel@tonic-gate 	char		*str;
11040Sstevel@tonic-gate 	uint_t		flg = 0;
11050Sstevel@tonic-gate 
11060Sstevel@tonic-gate 	/*
11070Sstevel@tonic-gate 	 * Insure we have a valid address, and provide for a -v option.
11080Sstevel@tonic-gate 	 */
11090Sstevel@tonic-gate 	if ((flags & DCMD_ADDRSPEC) == 0) {
11100Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_GRPHDL_STR));
11110Sstevel@tonic-gate 		return (DCMD_USAGE);
11120Sstevel@tonic-gate 	}
11130Sstevel@tonic-gate 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE,
11140Sstevel@tonic-gate 	    &flg, NULL) != argc)
11150Sstevel@tonic-gate 		return (DCMD_USAGE);
11160Sstevel@tonic-gate 
11170Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_GRPHDL_LINE1), addr);
11180Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_STR_DASHES));
11190Sstevel@tonic-gate 
11200Sstevel@tonic-gate 	if (mdb_vread(&gh, sizeof (Grp_hdl), addr) == -1) {
11210Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_GRPHDL_STR),
11220Sstevel@tonic-gate 		    addr);
11230Sstevel@tonic-gate 		return (DCMD_ERR);
11240Sstevel@tonic-gate 	}
11250Sstevel@tonic-gate 
11260Sstevel@tonic-gate 	/*
11270Sstevel@tonic-gate 	 * Determine the handles owner.  Note that an orphaned handle may no
11280Sstevel@tonic-gate 	 * longer contain its originating owner.
11290Sstevel@tonic-gate 	 */
11301618Srie 	if (gh.gh_ownlmp) {
11311618Srie 		if ((str = Rtmap_Name((uintptr_t)gh.gh_ownlmp)) == 0)
11320Sstevel@tonic-gate 			return (DCMD_ERR);
11330Sstevel@tonic-gate 	} else
11340Sstevel@tonic-gate 		str = (char *)MSG_ORIG(MSG_STR_ORPHANED);
11350Sstevel@tonic-gate 
11360Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_GRPHDL_LINE2), str);
11370Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_GRPHDL_LINE3), gh.gh_flags, gh.gh_flags,
11380Sstevel@tonic-gate 	    grhflags_bits);
11390Sstevel@tonic-gate 
11400Sstevel@tonic-gate 	if (gh.gh_depends == 0) {
11410Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_GRPHDL_LINE4), gh.gh_refcnt);
11420Sstevel@tonic-gate 		return (DCMD_OK);
11430Sstevel@tonic-gate 	}
11440Sstevel@tonic-gate 
11450Sstevel@tonic-gate 	addr = (uintptr_t)gh.gh_depends;
11460Sstevel@tonic-gate 	if (mdb_vread(&al, sizeof (Alist), addr) == -1) {
11474679Srie 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_ALIST), addr);
11484679Srie 		return (DCMD_ERR);
11490Sstevel@tonic-gate 	}
11500Sstevel@tonic-gate 
11515892Sab196087 	mdb_printf(MSG_ORIG(MSG_GRPHDL_LINE5), gh.gh_refcnt, addr,
11525892Sab196087 	    (size_t)al.al_nitems, (size_t)al.al_arritems);
11530Sstevel@tonic-gate 
11545892Sab196087 	if (((flg & RTLD_FLG_VERBOSE) == 0) || (al.al_nitems == 0))
11550Sstevel@tonic-gate 		return (DCMD_OK);
11560Sstevel@tonic-gate 
11570Sstevel@tonic-gate 	mdb_inc_indent(4);
11580Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_STR_DASHES));
11590Sstevel@tonic-gate 
11600Sstevel@tonic-gate 	/*
11610Sstevel@tonic-gate 	 * Under verbose mode print the name of each dependency.  An Alist can
11620Sstevel@tonic-gate 	 * have a variable number of data items, so read each individual entry.
11630Sstevel@tonic-gate 	 */
11645892Sab196087 	listcalc = ALIST_OFF_DATA + (uintptr_t)addr;
11650Sstevel@tonic-gate 	if (dcmd_GrpDesc(listcalc, flags, argc, argv) == DCMD_ERR) {
11660Sstevel@tonic-gate 		mdb_dec_indent(4);
11670Sstevel@tonic-gate 		return (DCMD_ERR);
11680Sstevel@tonic-gate 	}
11690Sstevel@tonic-gate 
11705892Sab196087 	for (listidx = 1; listidx < al.al_nitems; listidx++) {
11715892Sab196087 		listcalc += al.al_size;
11720Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_STR_DASHES));
11730Sstevel@tonic-gate 		if (dcmd_GrpDesc(listcalc, flags, argc, argv) == DCMD_ERR) {
11740Sstevel@tonic-gate 			mdb_dec_indent(4);
11750Sstevel@tonic-gate 			return (DCMD_ERR);
11760Sstevel@tonic-gate 		}
11770Sstevel@tonic-gate 	}
11780Sstevel@tonic-gate 
11790Sstevel@tonic-gate 	mdb_dec_indent(4);
11800Sstevel@tonic-gate 	return (DCMD_OK);
11810Sstevel@tonic-gate }
11820Sstevel@tonic-gate 
11830Sstevel@tonic-gate static void
11840Sstevel@tonic-gate dcmd_Handles_help(void)
11850Sstevel@tonic-gate {
11860Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_HANDLES_HELP));
11870Sstevel@tonic-gate }
11880Sstevel@tonic-gate 
11890Sstevel@tonic-gate static int
11900Sstevel@tonic-gate dcmd_Handles(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
11910Sstevel@tonic-gate {
11920Sstevel@tonic-gate 	Rt_map		rtmap;
11930Sstevel@tonic-gate 	char		*str;
11940Sstevel@tonic-gate 	uint_t		flg = 0;
11955892Sab196087 	APlist		apl;
11965892Sab196087 	uintptr_t	listcalc, listndx;
1197*8598SRod.Evans@Sun.COM 	Grp_hdl		*ghp;
11980Sstevel@tonic-gate 
11990Sstevel@tonic-gate 	/*
12000Sstevel@tonic-gate 	 * Insure we have a valid address, and provide for a -v option.
12010Sstevel@tonic-gate 	 */
12020Sstevel@tonic-gate 	if ((flags & DCMD_ADDRSPEC) == 0) {
12030Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_HANDLES_STR));
12040Sstevel@tonic-gate 		return (DCMD_USAGE);
12050Sstevel@tonic-gate 	}
12060Sstevel@tonic-gate 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE,
12070Sstevel@tonic-gate 	    &flg, NULL) != argc)
12080Sstevel@tonic-gate 		return (DCMD_USAGE);
12090Sstevel@tonic-gate 
12100Sstevel@tonic-gate 	/*
12110Sstevel@tonic-gate 	 * Read the Rt_map contents.
12120Sstevel@tonic-gate 	 */
12130Sstevel@tonic-gate 	if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) {
12140Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_RTMAP_STR), addr);
12150Sstevel@tonic-gate 		return (DCMD_ERR);
12160Sstevel@tonic-gate 	}
12170Sstevel@tonic-gate 	if ((str = String((uintptr_t)NAME(&rtmap),
12180Sstevel@tonic-gate 	    MSG_ORIG(MSG_STR_NAME))) == 0)
12190Sstevel@tonic-gate 		return (DCMD_ERR);
12200Sstevel@tonic-gate 
12210Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_HANDLES_LINE1), str);
12220Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_STR_DASHES));
12230Sstevel@tonic-gate 
12240Sstevel@tonic-gate 	if (HANDLES(&rtmap) == 0)
12250Sstevel@tonic-gate 		return (DCMD_OK);
12260Sstevel@tonic-gate 
12270Sstevel@tonic-gate 	addr = (uintptr_t)HANDLES(&rtmap);
12285892Sab196087 	if (mdb_vread(&apl, sizeof (APlist), addr) == -1) {
12295892Sab196087 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_APLIST),
12305892Sab196087 		    addr);
12310Sstevel@tonic-gate 		return (DCMD_ERR);
12320Sstevel@tonic-gate 	}
12330Sstevel@tonic-gate 
12345892Sab196087 	mdb_printf(MSG_ORIG(MSG_HANDLES_LINE2), addr, (size_t)apl.apl_nitems,
12355892Sab196087 	    (size_t)apl.apl_arritems);
12360Sstevel@tonic-gate 
12375892Sab196087 	if (((flg & RTLD_FLG_VERBOSE) == 0) || (apl.apl_nitems == 0))
12380Sstevel@tonic-gate 		return (DCMD_OK);
12390Sstevel@tonic-gate 
12400Sstevel@tonic-gate 	/*
12415892Sab196087 	 * Under verbose mode print the name of each dependency.  An APlist can
12420Sstevel@tonic-gate 	 * have a variable number of data items, so read each individual entry.
12430Sstevel@tonic-gate 	 */
12445892Sab196087 	listcalc = addr + APLIST_OFF_DATA;
12450Sstevel@tonic-gate 	if (mdb_vread(&ghp, sizeof (Grp_hdl *), listcalc) == -1) {
12460Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ),
12470Sstevel@tonic-gate 		    MSG_ORIG(MSG_GRPHDL_STR), listcalc);
12480Sstevel@tonic-gate 		return (DCMD_ERR);
12490Sstevel@tonic-gate 	}
12500Sstevel@tonic-gate 
12510Sstevel@tonic-gate 	mdb_inc_indent(4);
12520Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_STR_DASHES));
12530Sstevel@tonic-gate 
12540Sstevel@tonic-gate 	if (dcmd_GrpHdl((uintptr_t)ghp, flags, argc, argv) == DCMD_ERR) {
12550Sstevel@tonic-gate 		mdb_dec_indent(4);
12560Sstevel@tonic-gate 		return (DCMD_ERR);
12570Sstevel@tonic-gate 	}
12580Sstevel@tonic-gate 
12595892Sab196087 	listndx = 1;
12605892Sab196087 	for (listndx = 1; listndx < apl.apl_nitems; listndx++) {
12615892Sab196087 		listcalc += sizeof (void *);
12620Sstevel@tonic-gate 		if (mdb_vread(&ghp, sizeof (Grp_hdl *), listcalc) == -1) {
12630Sstevel@tonic-gate 			mdb_warn(MSG_ORIG(MSG_ERR_READ),
12640Sstevel@tonic-gate 			    MSG_ORIG(MSG_GRPHDL_STR), listcalc);
12650Sstevel@tonic-gate 			return (DCMD_ERR);
12660Sstevel@tonic-gate 		}
12670Sstevel@tonic-gate 
12680Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_STR_DASHES));
12690Sstevel@tonic-gate 		if (dcmd_GrpHdl((uintptr_t)ghp, flags, argc,
12700Sstevel@tonic-gate 		    argv) == DCMD_ERR) {
12710Sstevel@tonic-gate 			mdb_dec_indent(4);
12720Sstevel@tonic-gate 			return (DCMD_ERR);
12730Sstevel@tonic-gate 		}
12740Sstevel@tonic-gate 	}
12750Sstevel@tonic-gate 	mdb_dec_indent(4);
12760Sstevel@tonic-gate 	return (DCMD_OK);
12770Sstevel@tonic-gate }
12780Sstevel@tonic-gate 
12790Sstevel@tonic-gate static void
12800Sstevel@tonic-gate dcmd_Groups_help(void)
12810Sstevel@tonic-gate {
12820Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_GROUPS_HELP));
12830Sstevel@tonic-gate }
12840Sstevel@tonic-gate 
12850Sstevel@tonic-gate 
12860Sstevel@tonic-gate static int
12870Sstevel@tonic-gate dcmd_Groups(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
12880Sstevel@tonic-gate {
12890Sstevel@tonic-gate 	Rt_map		rtmap;
12900Sstevel@tonic-gate 	char		*str;
12915892Sab196087 	APlist		apl;
12920Sstevel@tonic-gate 	uint_t		flg = 0;
12935892Sab196087 	uintptr_t	listcalc, listndx;
1294*8598SRod.Evans@Sun.COM 	Grp_hdl		*ghp;
12950Sstevel@tonic-gate 
12960Sstevel@tonic-gate 	/*
12970Sstevel@tonic-gate 	 * Insure we have a valid address, and provide for a -v option.
12980Sstevel@tonic-gate 	 */
12990Sstevel@tonic-gate 	if ((flags & DCMD_ADDRSPEC) == 0) {
13000Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_GROUPS_STR));
13010Sstevel@tonic-gate 		return (DCMD_USAGE);
13020Sstevel@tonic-gate 	}
13030Sstevel@tonic-gate 	if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE,
13040Sstevel@tonic-gate 	    &flg, NULL) != argc)
13050Sstevel@tonic-gate 		return (DCMD_USAGE);
13060Sstevel@tonic-gate 
13070Sstevel@tonic-gate 	/*
13080Sstevel@tonic-gate 	 * Read the Rt_map contents.
13090Sstevel@tonic-gate 	 */
13100Sstevel@tonic-gate 	if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) {
13110Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_RTMAP_STR), addr);
13120Sstevel@tonic-gate 		return (DCMD_ERR);
13130Sstevel@tonic-gate 	}
13140Sstevel@tonic-gate 	if ((str = String((uintptr_t)NAME(&rtmap),
13150Sstevel@tonic-gate 	    MSG_ORIG(MSG_STR_NAME))) == 0)
13160Sstevel@tonic-gate 		return (DCMD_ERR);
13170Sstevel@tonic-gate 
13180Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_GROUPS_LINE1), str);
13190Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_STR_DASHES));
13200Sstevel@tonic-gate 
13210Sstevel@tonic-gate 	if (GROUPS(&rtmap) == 0)
13220Sstevel@tonic-gate 		return (DCMD_OK);
13230Sstevel@tonic-gate 
13240Sstevel@tonic-gate 	addr = (uintptr_t)GROUPS(&rtmap);
13255892Sab196087 	if (mdb_vread(&apl, sizeof (APlist), addr) == -1) {
13265892Sab196087 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_APLIST),
13275892Sab196087 		    addr);
13284679Srie 		return (DCMD_ERR);
13290Sstevel@tonic-gate 	}
13300Sstevel@tonic-gate 
13315892Sab196087 	mdb_printf(MSG_ORIG(MSG_GROUPS_LINE2), addr, (size_t)apl.apl_nitems,
13325892Sab196087 	    (size_t)apl.apl_arritems);
13330Sstevel@tonic-gate 
13345892Sab196087 	if (((flg & RTLD_FLG_VERBOSE) == 0) || (apl.apl_nitems == 0))
13350Sstevel@tonic-gate 		return (DCMD_OK);
13360Sstevel@tonic-gate 
13370Sstevel@tonic-gate 	/*
13385892Sab196087 	 * Under verbose mode print the name of each dependency.  An APlist can
13390Sstevel@tonic-gate 	 * have a variable number of data items, so read each individual entry.
13400Sstevel@tonic-gate 	 */
13415892Sab196087 	listcalc = addr + APLIST_OFF_DATA;
13420Sstevel@tonic-gate 	if (mdb_vread(&ghp, sizeof (Grp_hdl *), listcalc) == -1) {
13430Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ),
13440Sstevel@tonic-gate 		    MSG_ORIG(MSG_GRPHDL_STR), listcalc);
13450Sstevel@tonic-gate 		return (DCMD_ERR);
13460Sstevel@tonic-gate 	}
13470Sstevel@tonic-gate 
13480Sstevel@tonic-gate 	mdb_inc_indent(4);
13490Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_STR_DASHES));
13500Sstevel@tonic-gate 
13510Sstevel@tonic-gate 	if (dcmd_GrpHdl((uintptr_t)ghp, flags, argc, argv) == DCMD_ERR) {
13520Sstevel@tonic-gate 		mdb_dec_indent(4);
13530Sstevel@tonic-gate 		return (DCMD_ERR);
13540Sstevel@tonic-gate 	}
13550Sstevel@tonic-gate 
13565892Sab196087 	for (listndx = 1; listndx < apl.apl_nitems; listndx++) {
13575892Sab196087 		listcalc += sizeof (void *);
13580Sstevel@tonic-gate 		if (mdb_vread(&ghp, sizeof (Grp_hdl *), listcalc) == -1) {
13590Sstevel@tonic-gate 			mdb_warn(MSG_ORIG(MSG_ERR_READ),
13600Sstevel@tonic-gate 			    MSG_ORIG(MSG_GRPHDL_STR), listcalc);
13610Sstevel@tonic-gate 			return (DCMD_ERR);
13620Sstevel@tonic-gate 		}
13630Sstevel@tonic-gate 
13640Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_STR_DASHES));
13650Sstevel@tonic-gate 		if (dcmd_GrpHdl((uintptr_t)ghp, flags, argc,
13660Sstevel@tonic-gate 		    argv) == DCMD_ERR) {
13670Sstevel@tonic-gate 			mdb_dec_indent(4);
13680Sstevel@tonic-gate 			return (DCMD_ERR);
13690Sstevel@tonic-gate 		}
13700Sstevel@tonic-gate 	}
13710Sstevel@tonic-gate 	mdb_dec_indent(4);
13720Sstevel@tonic-gate 	return (DCMD_OK);
13730Sstevel@tonic-gate }
13740Sstevel@tonic-gate static void
13750Sstevel@tonic-gate dcmd_ElfDyn_help(void)
13760Sstevel@tonic-gate {
13770Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_ELFDYN_HELP));
13780Sstevel@tonic-gate }
13790Sstevel@tonic-gate 
13800Sstevel@tonic-gate static int
13810Sstevel@tonic-gate /* ARGSUSED2 */
13820Sstevel@tonic-gate dcmd_ElfDyn(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
13830Sstevel@tonic-gate {
13840Sstevel@tonic-gate 	Dyn		dyn;
13850Sstevel@tonic-gate 	const char	*dynstr;
13864734Sab196087 	Conv_inv_buf_t	inv_buf;
13870Sstevel@tonic-gate 
13880Sstevel@tonic-gate 	if ((flags & DCMD_ADDRSPEC) == 0)
13890Sstevel@tonic-gate 		return (DCMD_USAGE);
13900Sstevel@tonic-gate 	if (mdb_vread(&dyn, sizeof (dyn), addr) == -1) {
13910Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_ELFDYN_STR),
13924679Srie 		    addr);
13930Sstevel@tonic-gate 		return (DCMD_ERR);
13940Sstevel@tonic-gate 	}
13950Sstevel@tonic-gate 
13960Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_ELFDYN_TITLE), addr);
13974734Sab196087 	dynstr = conv_dyn_tag(dyn.d_tag, M_MACH, 0, &inv_buf);
13980Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_ELFDYN_LINE1), addr, dynstr, dyn.d_un.d_ptr);
13990Sstevel@tonic-gate 
14000Sstevel@tonic-gate 	mdb_set_dot(addr + sizeof (Dyn));
14010Sstevel@tonic-gate 
14020Sstevel@tonic-gate 	return (DCMD_OK);
14030Sstevel@tonic-gate }
14040Sstevel@tonic-gate 
14050Sstevel@tonic-gate static void
14060Sstevel@tonic-gate dcmd_ElfEhdr_help(void)
14070Sstevel@tonic-gate {
14080Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_EHDR_HELP));
14090Sstevel@tonic-gate }
14100Sstevel@tonic-gate 
14110Sstevel@tonic-gate static int
14120Sstevel@tonic-gate /* ARGSUSED2 */
14130Sstevel@tonic-gate dcmd_ElfEhdr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
14140Sstevel@tonic-gate {
14154734Sab196087 	Ehdr			ehdr;
14164734Sab196087 	Byte			*byte;
14174734Sab196087 	const char		*flgs;
14184734Sab196087 	Conv_inv_buf_t		inv_buf1, inv_buf2;
14194734Sab196087 	Conv_ehdr_flags_buf_t	ehdr_flags_buf;
14204734Sab196087 
14210Sstevel@tonic-gate 
14220Sstevel@tonic-gate 	if ((flags & DCMD_ADDRSPEC) == 0)
14230Sstevel@tonic-gate 		return (DCMD_USAGE);
14240Sstevel@tonic-gate 
14250Sstevel@tonic-gate 	if (mdb_vread(&ehdr, sizeof (ehdr), addr) == -1) {
14260Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_EHDR_STR),
14274679Srie 		    addr);
14280Sstevel@tonic-gate 		return (DCMD_ERR);
14290Sstevel@tonic-gate 	}
14300Sstevel@tonic-gate 
14310Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_EHDR_TITLE), addr);
14320Sstevel@tonic-gate 	byte = &ehdr.e_ident[0];
14330Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_EHDR_LINE1), byte[EI_MAG0],
14340Sstevel@tonic-gate 	    (byte[EI_MAG1] ? byte[EI_MAG1] : '0'),
14350Sstevel@tonic-gate 	    (byte[EI_MAG2] ? byte[EI_MAG2] : '0'),
14360Sstevel@tonic-gate 	    (byte[EI_MAG3] ? byte[EI_MAG3] : '0'));
14370Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_EHDR_LINE2),
14384734Sab196087 	    conv_ehdr_class(ehdr.e_ident[EI_CLASS], 0, &inv_buf1),
14394734Sab196087 	    conv_ehdr_data(ehdr.e_ident[EI_DATA], 0, &inv_buf2));
14400Sstevel@tonic-gate 
14410Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_EHDR_LINE3),
14424734Sab196087 	    conv_ehdr_mach(ehdr.e_machine, 0, &inv_buf1),
14434734Sab196087 	    conv_ehdr_vers(ehdr.e_version, 0, &inv_buf2));
14444734Sab196087 	mdb_printf(MSG_ORIG(MSG_EHDR_LINE4),
14454734Sab196087 	    conv_ehdr_type(ehdr.e_type, 0, &inv_buf1));
14460Sstevel@tonic-gate 
14470Sstevel@tonic-gate 	/*
14481976Sab196087 	 * Line up the flags differently depending on whether we
14491976Sab196087 	 * received a numeric (e.g. "0x200") or text representation
14501976Sab196087 	 * (e.g. "[ EF_SPARC_SUN_US1 ]").
14510Sstevel@tonic-gate 	 */
14525088Sab196087 	flgs = conv_ehdr_flags(ehdr.e_machine, ehdr.e_flags,
14535088Sab196087 	    0, &ehdr_flags_buf);
14540Sstevel@tonic-gate 	if (flgs[0] == '[')
14550Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_EHDR_LINE5), flgs);
14560Sstevel@tonic-gate 	else
14570Sstevel@tonic-gate 		mdb_printf(MSG_ORIG(MSG_EHDR_LINE6), flgs);
14580Sstevel@tonic-gate 
14590Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_EHDR_LINE7), ehdr.e_entry, ehdr.e_ehsize,
14600Sstevel@tonic-gate 	    ehdr.e_shstrndx);
14610Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_EHDR_LINE8), ehdr.e_shoff, ehdr.e_shentsize,
14620Sstevel@tonic-gate 	    ehdr.e_shnum);
14630Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_EHDR_LINE9), ehdr.e_phoff, ehdr.e_phentsize,
14640Sstevel@tonic-gate 	    ehdr.e_phnum);
14650Sstevel@tonic-gate 
14660Sstevel@tonic-gate 	mdb_set_dot(addr + sizeof (Ehdr));
14670Sstevel@tonic-gate 
14680Sstevel@tonic-gate 	return (DCMD_OK);
14690Sstevel@tonic-gate }
14700Sstevel@tonic-gate 
14710Sstevel@tonic-gate static void
14720Sstevel@tonic-gate dcmd_ElfPhdr_help(void)
14730Sstevel@tonic-gate {
14740Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_EPHDR_HELP));
14750Sstevel@tonic-gate }
14760Sstevel@tonic-gate 
14770Sstevel@tonic-gate static int
14780Sstevel@tonic-gate /* ARGSUSED2 */
14790Sstevel@tonic-gate dcmd_ElfPhdr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
14800Sstevel@tonic-gate {
14814734Sab196087 	Phdr			phdr;
14824734Sab196087 	Conv_inv_buf_t		inv_buf;
14834734Sab196087 	Conv_phdr_flags_buf_t	phdr_flags_buf;
14840Sstevel@tonic-gate 
14850Sstevel@tonic-gate 	if ((flags & DCMD_ADDRSPEC) == 0)
14860Sstevel@tonic-gate 		return (DCMD_USAGE);
14870Sstevel@tonic-gate 
14880Sstevel@tonic-gate 	if (mdb_vread(&phdr, sizeof (phdr), addr) == -1) {
14890Sstevel@tonic-gate 		mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_EPHDR_STR),
14904679Srie 		    addr);
14910Sstevel@tonic-gate 		return (DCMD_ERR);
14920Sstevel@tonic-gate 	}
14930Sstevel@tonic-gate 
14940Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_EPHDR_TITLE), addr);
14950Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_EPHDR_LINE1), phdr.p_vaddr,
14965088Sab196087 	    conv_phdr_flags(phdr.p_flags, 0, &phdr_flags_buf));
14970Sstevel@tonic-gate 	mdb_printf(MSG_ORIG(MSG_EPHDR_LINE2), phdr.p_paddr,
14984734Sab196087 	    conv_phdr_type(M_MACH, phdr.p_type, 0, &inv_buf));
14991618Srie 	mdb_printf(MSG_ORIG(MSG_EPHDR_LINE3), phdr.p_filesz, phdr.p_memsz);
15001618Srie 	mdb_printf(MSG_ORIG(MSG_EPHDR_LINE4), phdr.p_offset, phdr.p_align);
15010Sstevel@tonic-gate 
15020Sstevel@tonic-gate 	mdb_set_dot(addr + sizeof (Phdr));
15030Sstevel@tonic-gate 
15040Sstevel@tonic-gate 	return (DCMD_OK);
15050Sstevel@tonic-gate }
15060Sstevel@tonic-gate 
15070Sstevel@tonic-gate 
15080Sstevel@tonic-gate static const mdb_dcmd_t dcmds[] = {
15090Sstevel@tonic-gate 	{ MSG_ORIG(MSG_BND_STR), MSG_ORIG(MSG_USG_ADDREQ_V),
15100Sstevel@tonic-gate 		MSG_ORIG(MSG_BND_DCD),
15110Sstevel@tonic-gate 		dcmd_Bind, dcmd_Bind_help},
15120Sstevel@tonic-gate 	{ MSG_ORIG(MSG_DEPENDS_STR), MSG_ORIG(MSG_USG_ADDREQ_V),
15130Sstevel@tonic-gate 		MSG_ORIG(MSG_DEPENDS_DCD),
15140Sstevel@tonic-gate 		dcmd_Depends, dcmd_Depends_help},
15150Sstevel@tonic-gate 	{ MSG_ORIG(MSG_CALLERS_STR), MSG_ORIG(MSG_USG_ADDREQ_V),
15160Sstevel@tonic-gate 		MSG_ORIG(MSG_CALLERS_DCD),
15170Sstevel@tonic-gate 		dcmd_Callers, dcmd_Callers_help},
15180Sstevel@tonic-gate 	{ MSG_ORIG(MSG_GRPHDL_STR), MSG_ORIG(MSG_USG_ADDREQ_V),
15190Sstevel@tonic-gate 		MSG_ORIG(MSG_GRPHDL_DCD),
15200Sstevel@tonic-gate 		dcmd_GrpHdl, dcmd_GrpHdl_help},
15210Sstevel@tonic-gate 	{ MSG_ORIG(MSG_GRPDESC_STR), MSG_ORIG(MSG_USG_ADDREQ_V),
15220Sstevel@tonic-gate 		MSG_ORIG(MSG_GRPDESC_DCD),
15230Sstevel@tonic-gate 		dcmd_GrpDesc, dcmd_GrpDesc_help},
15240Sstevel@tonic-gate 	{ MSG_ORIG(MSG_HANDLES_STR), MSG_ORIG(MSG_USG_ADDREQ_V),
15250Sstevel@tonic-gate 		MSG_ORIG(MSG_HANDLES_DCD),
15260Sstevel@tonic-gate 		dcmd_Handles, dcmd_Handles_help},
15270Sstevel@tonic-gate 	{ MSG_ORIG(MSG_GROUPS_STR), MSG_ORIG(MSG_USG_ADDREQ_V),
15280Sstevel@tonic-gate 		MSG_ORIG(MSG_GROUPS_DCD),
15290Sstevel@tonic-gate 		dcmd_Groups, dcmd_Groups_help},
15300Sstevel@tonic-gate 	{ MSG_ORIG(MSG_ELFDYN_STR), MSG_ORIG(MSG_USG_ADDREQ),
15310Sstevel@tonic-gate 		MSG_ORIG(MSG_ELFDYN_DCD),
15320Sstevel@tonic-gate 		dcmd_ElfDyn, dcmd_ElfDyn_help},
15330Sstevel@tonic-gate 	{ MSG_ORIG(MSG_EHDR_STR), MSG_ORIG(MSG_USG_ADDREQ),
15340Sstevel@tonic-gate 		MSG_ORIG(MSG_EHDR_DCD),
15350Sstevel@tonic-gate 		dcmd_ElfEhdr, dcmd_ElfEhdr_help},
15360Sstevel@tonic-gate 	{ MSG_ORIG(MSG_EPHDR_STR), MSG_ORIG(MSG_USG_ADDREQ),
15370Sstevel@tonic-gate 		MSG_ORIG(MSG_EPHDR_DCD),
15380Sstevel@tonic-gate 		dcmd_ElfPhdr, dcmd_ElfPhdr_help},
15390Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LIST_STR), MSG_ORIG(MSG_USG_ADDREQ),
15400Sstevel@tonic-gate 		MSG_ORIG(MSG_LIST_DCD),
15410Sstevel@tonic-gate 		dcmd_List, dcmd_List_help},
15420Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LMLIST_STR), MSG_ORIG(MSG_USG_ADDREQ_V),
15430Sstevel@tonic-gate 		MSG_ORIG(MSG_LMLIST_DCD),
15440Sstevel@tonic-gate 		dcmd_Lm_list, dcmd_Lm_list_help},
15450Sstevel@tonic-gate 	{ MSG_ORIG(MSG_RTMAPS_STR), MSG_ORIG(MSG_USG_ADDOPT_V),
15460Sstevel@tonic-gate 		MSG_ORIG(MSG_RTMAPS_DCD),
15470Sstevel@tonic-gate 		dcmd_Rtmaps, dcmd_Rtmaps_help},
15480Sstevel@tonic-gate 	{ MSG_ORIG(MSG_RTMAP_STR), MSG_ORIG(MSG_USG_ADDREQ),
15490Sstevel@tonic-gate 		MSG_ORIG(MSG_RTMAP_DCD),
15500Sstevel@tonic-gate 		dcmd_rtmap, dcmd_rtmap_help},
15510Sstevel@tonic-gate 	{ MSG_ORIG(MSG_SETENV_STR), MSG_ORIG(MSG_USG_SETENV),
15520Sstevel@tonic-gate 		MSG_ORIG(MSG_SETENV_DCD),
15530Sstevel@tonic-gate 		dcmd_Setenv, dcmd_Setenv_help},
15540Sstevel@tonic-gate 	{ NULL }
15550Sstevel@tonic-gate };
15560Sstevel@tonic-gate 
15570Sstevel@tonic-gate static const mdb_walker_t walkers[] = {
15580Sstevel@tonic-gate 	{ MSG_ORIG(MSG_RTMAPS_STR), MSG_ORIG(MSG_WWD_RTMAP),
15590Sstevel@tonic-gate 		walk_rtmap_init, walk_rtmap_step, NULL, NULL },
15600Sstevel@tonic-gate 	{ MSG_ORIG(MSG_LIST_STR), MSG_ORIG(MSG_WWD_LIST),
15610Sstevel@tonic-gate 		walk_List_init, walk_List_step, NULL, NULL },
15620Sstevel@tonic-gate 	{ NULL }
15630Sstevel@tonic-gate };
15640Sstevel@tonic-gate 
15650Sstevel@tonic-gate static const mdb_modinfo_t modinfo = {
15660Sstevel@tonic-gate 	MDB_API_VERSION, dcmds, walkers
15670Sstevel@tonic-gate };
15680Sstevel@tonic-gate 
15690Sstevel@tonic-gate const	mdb_modinfo_t *
15700Sstevel@tonic-gate _mdb_init(void)
15710Sstevel@tonic-gate {
15720Sstevel@tonic-gate 	return (&modinfo);
15730Sstevel@tonic-gate }
1574