1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #include <msg.h> 28 #include <_rtld.h> 29 #include <conv.h> 30 #include <sys/mdb_modapi.h> 31 #include <sys/param.h> 32 #include <stdlib.h> 33 34 /* 35 * Data structure for walkers. 36 */ 37 typedef struct { 38 uint_t w_flags; 39 } W_desc; 40 41 /* 42 * Flags values for dcmds 43 */ 44 45 #define RTLD_FLG_VERBOSE 0x0001 /* verbose output */ 46 47 static const mdb_bitmask_t rtflags_bits[] = { 48 { MSG_ORIG(MSG_FLG_ISMAIN), FLG_RT_ISMAIN, FLG_RT_ISMAIN}, 49 { MSG_ORIG(MSG_FLG_IMGALLOC), FLG_RT_IMGALLOC, FLG_RT_IMGALLOC}, 50 { MSG_ORIG(MSG_FLG_RELOCED), FLG_RT_RELOCED, FLG_RT_RELOCED}, 51 { MSG_ORIG(MSG_FLG_SETGROUP), FLG_RT_SETGROUP, FLG_RT_SETGROUP}, 52 { MSG_ORIG(MSG_FLG_HWCAP), FLG_RT_HWCAP, FLG_RT_HWCAP}, 53 { MSG_ORIG(MSG_FLG_OBJECT), FLG_RT_OBJECT, FLG_RT_OBJECT}, 54 { MSG_ORIG(MSG_FLG_NEWLOAD), FLG_RT_NEWLOAD, FLG_RT_NEWLOAD}, 55 { MSG_ORIG(MSG_FLG_NODUMP), FLG_RT_NODUMP, FLG_RT_NODUMP}, 56 { MSG_ORIG(MSG_FLG_DELETE), FLG_RT_DELETE, FLG_RT_DELETE}, 57 { MSG_ORIG(MSG_FLG_ANALYZED), FLG_RT_ANALYZED, FLG_RT_ANALYZED}, 58 { MSG_ORIG(MSG_FLG_INITDONE), FLG_RT_INITDONE, FLG_RT_INITDONE}, 59 { MSG_ORIG(MSG_FLG_TRANS), FLG_RT_TRANS, FLG_RT_TRANS}, 60 { MSG_ORIG(MSG_FLG_FIXED), FLG_RT_FIXED, FLG_RT_FIXED}, 61 { MSG_ORIG(MSG_FLG_PRELOAD), FLG_RT_PRELOAD, FLG_RT_PRELOAD}, 62 { MSG_ORIG(MSG_FLG_ALTER), FLG_RT_ALTER, FLG_RT_ALTER}, 63 { MSG_ORIG(MSG_FLG_LOADFLTR), FLG_RT_LOADFLTR, FLG_RT_LOADFLTR}, 64 { MSG_ORIG(MSG_FLG_AUDIT), FLG_RT_AUDIT, FLG_RT_AUDIT}, 65 { MSG_ORIG(MSG_FLG_MODESET), FLG_RT_MODESET, FLG_RT_MODESET}, 66 { MSG_ORIG(MSG_FLG_ANALZING), FLG_RT_ANALZING, FLG_RT_ANALZING}, 67 { MSG_ORIG(MSG_FLG_INITFRST), FLG_RT_INITFRST, FLG_RT_INITFRST}, 68 { MSG_ORIG(MSG_FLG_NOOPEN), FLG_RT_NOOPEN, FLG_RT_NOOPEN}, 69 { MSG_ORIG(MSG_FLG_FINICLCT), FLG_RT_FINICLCT, FLG_RT_FINICLCT}, 70 { MSG_ORIG(MSG_FLG_INITCALL), FLG_RT_INITCALL, FLG_RT_INITCALL}, 71 { MSG_ORIG(MSG_FLG_OBJINTPO), FLG_RT_OBJINTPO, FLG_RT_OBJINTPO}, 72 { MSG_ORIG(MSG_FLG_SYMINTPO), FLG_RT_SYMINTPO, FLG_RT_SYMINTPO}, 73 { MSG_ORIG(MSG_FLG_MOVE), FLG_RT_MOVE, FLG_RT_MOVE}, 74 { MSG_ORIG(MSG_FLG_TMPLIST), FLG_RT_TMPLIST, FLG_RT_TMPLIST}, 75 { MSG_ORIG(MSG_FLG_REGSYMS), FLG_RT_REGSYMS, FLG_RT_REGSYMS}, 76 { MSG_ORIG(MSG_FLG_INITCLCT), FLG_RT_INITCLCT, FLG_RT_INITCLCT}, 77 { MSG_ORIG(MSG_FLG_HANDLE), FLG_RT_HANDLE, FLG_RT_HANDLE}, 78 { MSG_ORIG(MSG_FLG_RELOCING), FLG_RT_RELOCING, FLG_RT_RELOCING}, 79 { NULL, 0, 0} 80 }; 81 82 static const mdb_bitmask_t rtflags1_bits[] = { 83 { MSG_ORIG(MSG_FL1_COPYTOOK), FL1_RT_COPYTOOK, FL1_RT_COPYTOOK}, 84 { MSG_ORIG(MSG_FL1_CONFSET), FL1_RT_CONFSET, FL1_RT_CONFSET }, 85 { MSG_ORIG(MSG_FL1_NODEFLIB), FL1_RT_NODEFLIB, FL1_RT_NODEFLIB }, 86 { MSG_ORIG(MSG_FL1_ENDFILTE), FL1_RT_ENDFILTE, FL1_RT_ENDFILTE }, 87 { MSG_ORIG(MSG_FL1_DISPREL), FL1_RT_DISPREL, FL1_RT_DISPREL }, 88 { MSG_ORIG(MSG_FL1_DTFLAGS), FL1_RT_DTFLAGS, FL1_RT_DTFLAGS}, 89 { MSG_ORIG(MSG_FL1_LDDSTUB), FL1_RT_LDDSTUB, FL1_RT_LDDSTUB}, 90 { MSG_ORIG(MSG_FL1_NOINIFIN), FL1_RT_NOINIFIN, FL1_RT_NOINIFIN }, 91 { MSG_ORIG(MSG_FL1_USED), FL1_RT_USED, FL1_RT_USED }, 92 { MSG_ORIG(MSG_FL1_SYMBOLIC), FL1_RT_SYMBOLIC, FL1_RT_SYMBOLIC }, 93 { MSG_ORIG(MSG_FL1_OBJSFLTR), FL1_RT_OBJSFLTR, FL1_RT_OBJSFLTR }, 94 { MSG_ORIG(MSG_FL1_OBJAFLTR), FL1_RT_OBJAFLTR, FL1_RT_OBJAFLTR }, 95 { MSG_ORIG(MSG_FL1_SYMSFLTR), FL1_RT_SYMSFLTR, FL1_RT_SYMSFLTR }, 96 { MSG_ORIG(MSG_FL1_SYMAFLTR), FL1_RT_SYMAFLTR, FL1_RT_SYMAFLTR }, 97 { MSG_ORIG(MSG_FL1_TLSADD), FL1_RT_TLSADD, FL1_RT_TLSADD }, 98 { MSG_ORIG(MSG_FL1_TLSSTAT), FL1_RT_TLSSTAT, FL1_RT_TLSSTAT }, 99 { MSG_ORIG(MSG_FL1_DIRECT), FL1_RT_DIRECT, FL1_RT_DIRECT}, 100 { MSG_ORIG(MSG_FL1_GLOBAUD), FL1_RT_GLOBAUD, FL1_RT_GLOBAUD}, 101 { NULL, 0, 0} 102 }; 103 104 static const mdb_bitmask_t rtaflags_bits[] = { 105 { MSG_ORIG(MSG_LTFL_AUD_PREINIT), LML_TFLG_AUD_PREINIT, 106 LML_TFLG_AUD_PREINIT }, 107 { MSG_ORIG(MSG_LTFL_AUD_OBJSEARCH), LML_TFLG_AUD_OBJSEARCH, 108 LML_TFLG_AUD_OBJSEARCH }, 109 { MSG_ORIG(MSG_LTFL_AUD_OBJOPEN), LML_TFLG_AUD_OBJOPEN, 110 LML_TFLG_AUD_OBJOPEN }, 111 { MSG_ORIG(MSG_LTFL_AUD_OBJFILTER), LML_TFLG_AUD_OBJFILTER, 112 LML_TFLG_AUD_OBJFILTER }, 113 { MSG_ORIG(MSG_LTFL_AUD_OBJCLOSE), LML_TFLG_AUD_OBJCLOSE, 114 LML_TFLG_AUD_OBJCLOSE }, 115 { MSG_ORIG(MSG_LTFL_AUD_SYMBIND), LML_TFLG_AUD_SYMBIND, 116 LML_TFLG_AUD_SYMBIND }, 117 { MSG_ORIG(MSG_LTFL_AUD_PLTENTER), LML_TFLG_AUD_PLTENTER, 118 LML_TFLG_AUD_PLTENTER }, 119 { MSG_ORIG(MSG_LTFL_AUD_PLTEXIT), LML_TFLG_AUD_PLTEXIT, 120 LML_TFLG_AUD_PLTEXIT }, 121 { MSG_ORIG(MSG_LTFL_AUD_ACTIVITY), LML_TFLG_AUD_ACTIVITY, 122 LML_TFLG_AUD_ACTIVITY }, 123 { NULL, 0, 0} 124 }; 125 126 static const mdb_bitmask_t rtmode_bits[] = { 127 { MSG_ORIG(MSG_MODE_LAZY), RTLD_LAZY, RTLD_LAZY }, 128 { MSG_ORIG(MSG_MODE_NOW), RTLD_NOW, RTLD_NOW }, 129 { MSG_ORIG(MSG_MODE_NOLOAD), RTLD_NOLOAD, RTLD_NOLOAD }, 130 { MSG_ORIG(MSG_MODE_GLOBAL), RTLD_GLOBAL, RTLD_GLOBAL }, 131 { MSG_ORIG(MSG_MODE_PARENT), RTLD_PARENT, RTLD_PARENT }, 132 { MSG_ORIG(MSG_MODE_GROUP), RTLD_GROUP, RTLD_GROUP }, 133 { MSG_ORIG(MSG_MODE_WORLD), RTLD_WORLD, RTLD_WORLD }, 134 { MSG_ORIG(MSG_MODE_NODELETE), RTLD_NODELETE, RTLD_NODELETE }, 135 { MSG_ORIG(MSG_MODE_FIRST), RTLD_FIRST, RTLD_FIRST }, 136 { MSG_ORIG(MSG_MODE_CONFGEN), RTLD_CONFGEN, RTLD_CONFGEN }, 137 { NULL, 0, 0} 138 }; 139 140 static const mdb_bitmask_t bndflags_bits[] = { 141 { MSG_ORIG(MSG_BFL_NEEDED), BND_NEEDED, BND_NEEDED }, 142 { MSG_ORIG(MSG_BFL_REFER), BND_REFER, BND_REFER }, 143 { MSG_ORIG(MSG_BFL_FILTER), BND_FILTER, BND_FILTER }, 144 { NULL, 0, 0} 145 }; 146 147 static const mdb_bitmask_t grhflags_bits[] = { 148 { MSG_ORIG(MSG_GPH_ZERO), GPH_ZERO, GPH_ZERO }, 149 { MSG_ORIG(MSG_GPH_LDSO), GPH_LDSO, GPH_LDSO }, 150 { MSG_ORIG(MSG_GPH_FIRST), GPH_FIRST, GPH_FIRST }, 151 { MSG_ORIG(MSG_GPH_FILTEE), GPH_FILTEE, GPH_FILTEE }, 152 { MSG_ORIG(MSG_GPH_INITIAL), GPH_INITIAL, GPH_INITIAL }, 153 { MSG_ORIG(MSG_GPH_NOPENDLAZY), GPH_NOPENDLAZY, GPH_NOPENDLAZY }, 154 { NULL, 0, 0} 155 }; 156 157 static const mdb_bitmask_t grdflags_bits[] = { 158 { MSG_ORIG(MSG_GPD_DLSYM), GPD_DLSYM, GPD_DLSYM }, 159 { MSG_ORIG(MSG_GPD_RELOC), GPD_RELOC, GPD_RELOC }, 160 { MSG_ORIG(MSG_GPD_ADDEPS), GPD_ADDEPS, GPD_ADDEPS }, 161 { MSG_ORIG(MSG_GPD_PARENT), GPD_PARENT, GPD_PARENT }, 162 { MSG_ORIG(MSG_GPD_FILTER), GPD_FILTER, GPD_FILTER }, 163 { MSG_ORIG(MSG_GPD_PROMOTE), GPD_PROMOTE, GPD_PROMOTE }, 164 { MSG_ORIG(MSG_GPD_REMOVE), GPD_REMOVE, GPD_REMOVE }, 165 { NULL, 0, 0} 166 }; 167 168 static const mdb_bitmask_t lmc_bits[] = { 169 { MSG_ORIG(MSG_LMC_ANALYZING), LMC_FLG_ANALYZING, LMC_FLG_ANALYZING}, 170 { MSG_ORIG(MSG_LMC_RELOCATING), LMC_FLG_RELOCATING, LMC_FLG_RELOCATING}, 171 { MSG_ORIG(MSG_LMC_REANALYZE), LMC_FLG_REANALYZE, LMC_FLG_REANALYZE}, 172 { NULL, 0, 0} 173 }; 174 175 /* 176 * Obtain a string - typically a link-map name. 177 */ 178 static char * 179 String(uintptr_t addr, const char *name) 180 { 181 static char str[MAXPATHLEN]; 182 183 if (addr) { 184 if (mdb_readstr(str, MAXPATHLEN, addr) == -1) { 185 mdb_warn(MSG_ORIG(MSG_ERR_READ), name, addr); 186 return (0); 187 } 188 return (str); 189 } 190 return ((char *)MSG_ORIG(MSG_STR_EMPTY)); 191 } 192 193 /* 194 * Obtain a link-map name. 195 */ 196 static char * 197 Rtmap_Name(uintptr_t addr) 198 { 199 Rt_map rtmap; 200 201 if (addr) { 202 if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) { 203 mdb_warn(MSG_ORIG(MSG_ERR_READ), 204 MSG_ORIG(MSG_RTMAP_STR), addr); 205 return (0); 206 } 207 return (String((uintptr_t)NAME(&rtmap), 208 MSG_ORIG(MSG_STR_NAME))); 209 } 210 return ((char *)MSG_ORIG(MSG_STR_EMPTY)); 211 } 212 213 void 214 dcmd_Bind_help(void) 215 { 216 mdb_printf(MSG_ORIG(MSG_BND_HELP)); 217 } 218 219 static int 220 /* ARGSUSED2 */ 221 dcmd_Bind(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 222 { 223 Bnd_desc bnd; 224 char *str; 225 226 /* 227 * Insure we have a valid address. 228 */ 229 if ((flags & DCMD_ADDRSPEC) == 0) { 230 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_BND_STR)); 231 return (DCMD_USAGE); 232 } 233 234 /* 235 * Obtain the binding descriptor. 236 */ 237 if (mdb_vread(&bnd, sizeof (Bnd_desc), addr) == -1) { 238 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_BND_STR), addr); 239 return (DCMD_ERR); 240 } 241 mdb_printf(MSG_ORIG(MSG_BND_TITLE), addr); 242 243 /* 244 * Establish the identity of the caller. 245 */ 246 if ((str = Rtmap_Name((uintptr_t)bnd.b_caller)) == 0) 247 return (DCMD_ERR); 248 mdb_printf(MSG_ORIG(MSG_BND_LINE1), bnd.b_caller, str); 249 250 /* 251 * Establish the identity of the dependency. 252 */ 253 if ((str = Rtmap_Name((uintptr_t)bnd.b_depend)) == 0) 254 return (DCMD_ERR); 255 mdb_printf(MSG_ORIG(MSG_BND_LINE2), bnd.b_depend, str); 256 257 /* 258 * Display any flags. 259 */ 260 mdb_printf(MSG_ORIG(MSG_BND_LINE3), bnd.b_flags, bnd.b_flags, 261 bndflags_bits); 262 263 return (DCMD_OK); 264 } 265 266 static void 267 dcmd_Depends_help(void) 268 { 269 mdb_printf(MSG_ORIG(MSG_DEPENDS_HELP)); 270 } 271 272 static int 273 Depends(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv, 274 uint_t flg, const char *msg) 275 { 276 APlist apl; 277 uintptr_t datap, nitems; 278 Bnd_desc *bdp; 279 280 /* 281 * Obtain the APlist and determine its number of elements and those 282 * that are in use. 283 */ 284 if (mdb_vread(&apl, sizeof (APlist), addr) == -1) { 285 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_APLIST), 286 addr); 287 return (DCMD_ERR); 288 } 289 290 mdb_printf(msg, addr, (size_t)apl.apl_nitems, 291 (size_t)apl.apl_arritems); 292 293 if (((flg & RTLD_FLG_VERBOSE) == 0) || (apl.apl_nitems == 0)) 294 return (DCMD_OK); 295 296 /* 297 * Under verbose mode print the name of each dependency. An APlist can 298 * have a variable number of data items, so read each individual entry. 299 */ 300 datap = APLIST_OFF_DATA + (uintptr_t)addr; 301 if (mdb_vread(&bdp, sizeof (Bnd_desc *), datap) == -1) { 302 mdb_warn(MSG_ORIG(MSG_ERR_READ), 303 MSG_ORIG(MSG_BNDDESC_STR), datap); 304 return (DCMD_ERR); 305 } 306 307 mdb_inc_indent(4); 308 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 309 310 if (dcmd_Bind((uintptr_t)bdp, flags, argc, argv) == DCMD_ERR) { 311 mdb_dec_indent(4); 312 return (DCMD_ERR); 313 } 314 315 for (nitems = 1; nitems < apl.apl_nitems; nitems++) { 316 datap += sizeof (void *); 317 if (mdb_vread(&bdp, sizeof (Bnd_desc *), datap) == -1) { 318 mdb_warn(MSG_ORIG(MSG_ERR_READ), 319 MSG_ORIG(MSG_BNDDESC_STR), datap); 320 return (DCMD_ERR); 321 } 322 323 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 324 if (dcmd_Bind((uintptr_t)bdp, flags, argc, argv) == DCMD_ERR) { 325 mdb_dec_indent(4); 326 return (DCMD_ERR); 327 } 328 } 329 mdb_dec_indent(4); 330 return (DCMD_OK); 331 } 332 333 static int 334 dcmd_Depends(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 335 { 336 Rt_map rtmap; 337 char *str; 338 uint_t flg = 0; 339 340 /* 341 * Insure we have a valid address, and provide for a -v option. 342 */ 343 if ((flags & DCMD_ADDRSPEC) == 0) { 344 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_DEPENDS_STR)); 345 return (DCMD_USAGE); 346 } 347 if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE, 348 &flg, NULL) != argc) 349 return (DCMD_USAGE); 350 351 /* 352 * Read the Rt_map contents. 353 */ 354 if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) { 355 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_RTMAP_STR), addr); 356 return (DCMD_ERR); 357 } 358 if ((str = String((uintptr_t)NAME(&rtmap), 359 MSG_ORIG(MSG_STR_NAME))) == 0) 360 return (DCMD_ERR); 361 362 mdb_printf(MSG_ORIG(MSG_DEPENDS_LINE1), str); 363 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 364 365 if (DEPENDS(&rtmap) == NULL) 366 return (DCMD_OK); 367 368 return (Depends((uintptr_t)DEPENDS(&rtmap), flags, argc, argv, flg, 369 MSG_ORIG(MSG_DEPENDS_LINE2))); 370 } 371 372 static void 373 dcmd_Callers_help(void) 374 { 375 mdb_printf(MSG_ORIG(MSG_CALLERS_HELP)); 376 } 377 378 static int 379 dcmd_Callers(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 380 { 381 Rt_map rtmap; 382 char *str; 383 uint_t flg = 0; 384 385 /* 386 * Insure we have a valid address, and provide for a -v option. 387 */ 388 if ((flags & DCMD_ADDRSPEC) == 0) { 389 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_DEPENDS_STR)); 390 return (DCMD_USAGE); 391 } 392 if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE, 393 &flg, NULL) != argc) 394 return (DCMD_USAGE); 395 396 /* 397 * Read the Rt_map contents. 398 */ 399 if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) { 400 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_RTMAP_STR), addr); 401 return (DCMD_ERR); 402 } 403 if ((str = String((uintptr_t)NAME(&rtmap), 404 MSG_ORIG(MSG_STR_NAME))) == 0) 405 return (DCMD_ERR); 406 407 mdb_printf(MSG_ORIG(MSG_CALLERS_LINE1), str); 408 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 409 410 if (CALLERS(&rtmap) == NULL) 411 return (DCMD_OK); 412 413 return (Depends((uintptr_t)CALLERS(&rtmap), flags, argc, argv, flg, 414 MSG_ORIG(MSG_CALLERS_LINE2))); 415 } 416 417 void 418 dcmd_rtmap_help(void) 419 { 420 mdb_printf(MSG_ORIG(MSG_RTMAP_HELP)); 421 } 422 423 static int 424 /* ARGSUSED2 */ 425 dcmd_rtmap(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 426 { 427 Rt_map rtmap; 428 char *str; 429 430 if ((flags & DCMD_ADDRSPEC) == 0) { 431 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_RTMAP_STR)); 432 return (DCMD_USAGE); 433 } 434 435 if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) { 436 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_RTMAP_STR), addr); 437 return (DCMD_ERR); 438 } 439 440 mdb_printf(MSG_ORIG(MSG_RTMAP_TITLE), addr); 441 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 442 443 /* 444 * Determine the objects name. NAME() is the name by which the object 445 * has been opened, typically from adding a search path to a file name. 446 * PATHNAME() is the fully resolve name, which is displayed by the proc 447 * tools and debuggers. If the two names differ, print the PATHNAME(). 448 */ 449 if ((str = String((uintptr_t)NAME(&rtmap), 450 MSG_ORIG(MSG_STR_NAME))) == 0) 451 return (DCMD_ERR); 452 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE1), str); 453 if (NAME(&rtmap) != PATHNAME(&rtmap)) { 454 if ((str = String((uintptr_t)PATHNAME(&rtmap), 455 MSG_ORIG(MSG_STR_PATHNAME))) == 0) 456 return (DCMD_ERR); 457 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE2), str); 458 } 459 460 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE3), ADDR(&rtmap), DYN(&rtmap)); 461 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE4), NEXT(&rtmap), PREV(&rtmap)); 462 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE5), rtmap.rt_fct, TLSMODID(&rtmap)); 463 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE6), INIT(&rtmap), FINI(&rtmap)); 464 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE7), GROUPS(&rtmap), HANDLES(&rtmap)); 465 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE8), DEPENDS(&rtmap), CALLERS(&rtmap)); 466 467 if ((str = String((uintptr_t)REFNAME(&rtmap), 468 MSG_ORIG(MSG_STR_REFNAME))) == 0) 469 return (DCMD_ERR); 470 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE9), DYNINFO(&rtmap), str); 471 472 if ((str = String((uintptr_t)RPATH(&rtmap), 473 MSG_ORIG(MSG_STR_RPATH))) == 0) 474 return (DCMD_ERR); 475 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE10), RLIST(&rtmap), str); 476 477 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE11), LIST(&rtmap), LIST(&rtmap)); 478 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE12), FLAGS(&rtmap)); 479 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE20), FLAGS(&rtmap), rtflags_bits); 480 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE13), FLAGS1(&rtmap)); 481 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE20), FLAGS1(&rtmap), rtflags1_bits); 482 if (AFLAGS(&rtmap)) { 483 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE14), AFLAGS(&rtmap)); 484 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE20), AFLAGS(&rtmap), 485 rtaflags_bits); 486 } 487 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE15), MODE(&rtmap)); 488 mdb_printf(MSG_ORIG(MSG_RTMAP_LINE20), MODE(&rtmap), rtmode_bits); 489 490 return (DCMD_OK); 491 } 492 493 static int 494 rtmap_format(uintptr_t addr, const void *data, void *private) 495 { 496 const Rt_map *lmp = (const Rt_map *)data; 497 W_desc *wdp = (W_desc *)private; 498 char *str; 499 500 if (wdp && (wdp->w_flags & RTLD_FLG_VERBOSE)) { 501 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 502 mdb_call_dcmd(MSG_ORIG(MSG_RTMAP_STR), addr, DCMD_ADDRSPEC, 503 NULL, NULL); 504 return (0); 505 } 506 507 if ((str = String((uintptr_t)NAME(lmp), 508 MSG_ORIG(MSG_STR_NAME))) == 0) 509 return (DCMD_ERR); 510 511 mdb_printf(MSG_ORIG(MSG_FMT_RT), CNTL(lmp), addr, ADDR(lmp), str); 512 return (0); 513 } 514 515 void 516 dcmd_Rtmaps_help(void) 517 { 518 mdb_printf(MSG_ORIG(MSG_RTMAPS_HELP)); 519 } 520 521 static int 522 dcmd_Rtmaps(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 523 { 524 uint_t flg = 0; 525 GElf_Sym gsym; 526 APlist *aplp, apl; 527 uintptr_t datap, nitems; 528 const char *str; 529 W_desc wdesc; 530 531 /* 532 * '-v' - Verbose output of rtmap 533 */ 534 if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE, 535 &flg, NULL) != argc) 536 return (DCMD_USAGE); 537 538 /* 539 * If an address was provided use it. 540 */ 541 if (flags & DCMD_ADDRSPEC) { 542 if (((flags & DCMD_LOOPFIRST) || !(flags & DCMD_LOOP)) && 543 !(flg & RTLD_FLG_VERBOSE)) { 544 mdb_printf(MSG_ORIG(MSG_RTMAPS_TITLE0)); 545 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 546 } 547 548 wdesc.w_flags = flg; 549 if (mdb_pwalk(MSG_ORIG(MSG_RTMAPS_STR), rtmap_format, 550 (void *)&wdesc, addr) == -1) 551 return (DCMD_ERR); 552 return (DCMD_OK); 553 } 554 555 /* 556 * Otherwise traverse the dynlm_list and display each link-map. 557 */ 558 if (mdb_lookup_by_obj(MSG_ORIG(MSG_STR_LDSO1), 559 MSG_ORIG(MSG_STR_DYNLMLIST), &gsym) == -1) { 560 mdb_warn(MSG_ORIG(MSG_ERR_SYMFAILED), MSG_ORIG(MSG_STR_LDSO1), 561 MSG_ORIG(MSG_STR_DYNLMLIST)); 562 return (DCMD_ERR); 563 } 564 if (mdb_vread(&aplp, sizeof (APlist *), 565 (uintptr_t)gsym.st_value) == -1) { 566 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_APLIST), 567 gsym.st_value); 568 return (DCMD_ERR); 569 } 570 571 if (aplp == NULL) { 572 mdb_printf(MSG_ORIG(MSG_LMLIST_TITLE0), 573 MSG_ORIG(MSG_STR_DYNLMLIST)); 574 return (DCMD_OK); 575 } 576 577 if (mdb_vread(&apl, sizeof (APlist), (uintptr_t)aplp) == -1) { 578 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_APLIST), 579 aplp); 580 } 581 mdb_printf(MSG_ORIG(MSG_LMLIST_TITLE1), MSG_ORIG(MSG_STR_DYNLMLIST), 582 aplp, (size_t)apl.apl_nitems, (size_t)apl.apl_arritems); 583 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 584 585 flags |= (DCMD_LOOP | DCMD_LOOPFIRST); 586 for (datap = (uintptr_t)aplp + APLIST_OFF_DATA, nitems = 0; 587 nitems < apl.apl_nitems; nitems++, datap += sizeof (void *)) { 588 Lm_list *lml, lm; 589 590 if (mdb_vread(&lml, sizeof (Lm_list *), datap) == -1) { 591 mdb_warn(MSG_ORIG(MSG_ERR_READ), 592 MSG_ORIG(MSG_LMLIST_STR), datap); 593 return (DCMD_ERR); 594 } 595 if (mdb_vread(&lm, sizeof (Lm_list), (uintptr_t)lml) == -1) { 596 mdb_warn(MSG_ORIG(MSG_ERR_READ), 597 MSG_ORIG(MSG_LMLIST_STR), lml); 598 return (DCMD_ERR); 599 } 600 601 mdb_inc_indent(2); 602 if (lm.lm_flags & LML_FLG_BASELM) 603 str = MSG_ORIG(MSG_LMLIST_BASE); 604 else if (lm.lm_flags & LML_FLG_RTLDLM) 605 str = MSG_ORIG(MSG_LMLIST_LDSO); 606 else 607 str = MSG_ORIG(MSG_LMLIST_NEWLM); 608 609 if ((flags & DCMD_LOOP) && ((flags & DCMD_LOOPFIRST) == 0)) 610 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 611 612 mdb_printf(MSG_ORIG(MSG_LMLIST_TITLE2), datap, str); 613 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 614 615 mdb_inc_indent(2); 616 617 if (((flags & DCMD_LOOPFIRST) || !(flags & DCMD_LOOP)) && 618 !(flg & RTLD_FLG_VERBOSE)) { 619 mdb_printf(MSG_ORIG(MSG_RTMAPS_TITLE0)); 620 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 621 } 622 623 wdesc.w_flags = flg; 624 if (mdb_pwalk(MSG_ORIG(MSG_RTMAPS_STR), rtmap_format, 625 (void *)&wdesc, (uintptr_t)lm.lm_head) == -1) { 626 mdb_dec_indent(4); 627 return (DCMD_ERR); 628 } 629 mdb_dec_indent(4); 630 flags &= ~DCMD_LOOPFIRST; 631 } 632 return (DCMD_OK); 633 } 634 635 void 636 dcmd_Setenv_help(void) 637 { 638 mdb_printf(MSG_ORIG(MSG_SETENV_HELP)); 639 } 640 641 /* 642 * As of s10, mdb provides its own setenv command. This command allows the 643 * environment of the process being controlled to be changed at any time. 644 * Prior to this, ld.so.1 provided it's own, more primitive implementation. 645 * This allowed for changing mdb's environment only, which if it was changed 646 * before the application ws executed, would be copied to the applications 647 * environment. Thus, we could start mdb, set an LD_ variable within its 648 * environment (which it's own ld.so.1 had already finished processing), and 649 * have this setting be inherited by the application. 650 */ 651 static int 652 /* ARGSUSED */ 653 dcmd_Setenv(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 654 { 655 char *str; 656 657 if (mdb_call_dcmd(MSG_ORIG(MSG_STR_SETENV), addr, flags, argc, 658 argv) == 0) 659 return (DCMD_OK); 660 661 if (((flags & DCMD_ADDRSPEC) != 0) || (argc == 0) || (argc > 1) || 662 (argv->a_type != MDB_TYPE_STRING)) 663 return (DCMD_USAGE); 664 665 str = mdb_alloc((strlen(argv->a_un.a_str) + 1), UM_NOSLEEP); 666 if (str == NULL) 667 return (DCMD_ERR); 668 669 (void) strcpy(str, argv->a_un.a_str); 670 (void) putenv(str); 671 return (DCMD_OK); 672 } 673 674 /* 675 * Walk Rt_map lists 676 */ 677 static int 678 walk_rtmap_init(mdb_walk_state_t *wsp) 679 { 680 if (wsp->walk_addr == NULL) { 681 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_RTMAP_STR)); 682 return (WALK_ERR); 683 } 684 return (WALK_NEXT); 685 } 686 687 static int 688 walk_rtmap_step(mdb_walk_state_t *wsp) 689 { 690 int status; 691 Rt_map lmp; 692 693 if (wsp->walk_addr == NULL) 694 return (WALK_DONE); 695 if (mdb_vread(&lmp, sizeof (Rt_map), wsp->walk_addr) == -1) { 696 mdb_warn(MSG_ORIG(MSG_ERR_READ), 697 MSG_ORIG(MSG_RTMAP_STR), wsp->walk_addr); 698 return (WALK_DONE); 699 } 700 701 status = wsp->walk_callback(wsp->walk_addr, &lmp, wsp->walk_cbdata); 702 wsp->walk_addr = (uintptr_t)(NEXT(&lmp)); 703 return (status); 704 } 705 706 static const mdb_bitmask_t lml_flags_bit[] = { 707 { MSG_ORIG(MSG_LFL_BASELM), LML_FLG_BASELM, LML_FLG_BASELM }, 708 { MSG_ORIG(MSG_LFL_RTLDLM), LML_FLG_RTLDLM, LML_FLG_RTLDLM }, 709 { MSG_ORIG(MSG_LFL_NOAUDIT), LML_FLG_NOAUDIT, LML_FLG_NOAUDIT }, 710 { MSG_ORIG(MSG_LFL_PLTREL), LML_FLG_PLTREL, LML_FLG_PLTREL }, 711 { MSG_ORIG(MSG_LFL_HOLDLOCK), LML_FLG_HOLDLOCK, LML_FLG_HOLDLOCK }, 712 { MSG_ORIG(MSG_LFL_ENVIRON), LML_FLG_ENVIRON, LML_FLG_ENVIRON }, 713 { MSG_ORIG(MSG_LFL_INTRPOSE), LML_FLG_INTRPOSE, LML_FLG_INTRPOSE }, 714 { MSG_ORIG(MSG_LFL_LOCAUDIT), LML_FLG_LOCAUDIT, LML_FLG_LOCAUDIT }, 715 { MSG_ORIG(MSG_LFL_LOADAVAIL), LML_FLG_LOADAVAIL, LML_FLG_LOADAVAIL }, 716 { MSG_ORIG(MSG_LFL_IGNRELERR), LML_FLG_IGNRELERR, LML_FLG_IGNRELERR }, 717 { MSG_ORIG(MSG_LFL_DBNOTIF), LML_FLG_DBNOTIF, LML_FLG_DBNOTIF }, 718 { MSG_ORIG(MSG_LFL_STARTREL), LML_FLG_STARTREL, LML_FLG_STARTREL }, 719 { MSG_ORIG(MSG_LFL_ATEXIT), LML_FLG_ATEXIT, LML_FLG_ATEXIT }, 720 { MSG_ORIG(MSG_LFL_OBJADDED), LML_FLG_OBJADDED, LML_FLG_OBJADDED }, 721 { MSG_ORIG(MSG_LFL_OBJDELETED), LML_FLG_OBJDELETED, 722 LML_FLG_OBJDELETED }, 723 { MSG_ORIG(MSG_LFL_OBJREEVAL), LML_FLG_OBJREEVAL, LML_FLG_OBJREEVAL }, 724 { MSG_ORIG(MSG_LFL_NOPENDGLBLAZY), LML_FLG_NOPENDGLBLAZY, 725 LML_FLG_NOPENDGLBLAZY }, 726 { MSG_ORIG(MSG_LFL_INTRPOSETSORT), LML_FLG_INTRPOSETSORT, 727 LML_FLG_INTRPOSETSORT }, 728 { MSG_ORIG(MSG_LFL_AUDITNOTIFY), LML_FLG_AUDITNOTIFY, 729 LML_FLG_AUDITNOTIFY }, 730 { MSG_ORIG(MSG_LFL_GROUPSEXIST), LML_FLG_GROUPSEXIST, 731 LML_FLG_GROUPSEXIST }, 732 733 { MSG_ORIG(MSG_LFL_TRC_LDDSTUB), LML_FLG_TRC_LDDSTUB, 734 LML_FLG_TRC_LDDSTUB }, 735 { MSG_ORIG(MSG_LFL_TRC_ENABLE), LML_FLG_TRC_ENABLE, 736 LML_FLG_TRC_ENABLE }, 737 { MSG_ORIG(MSG_LFL_TRC_WARN), LML_FLG_TRC_WARN, LML_FLG_TRC_WARN }, 738 { MSG_ORIG(MSG_LFL_TRC_VERBOSE), LML_FLG_TRC_VERBOSE, 739 LML_FLG_TRC_VERBOSE }, 740 { MSG_ORIG(MSG_LFL_TRC_SEARCH), LML_FLG_TRC_SEARCH, 741 LML_FLG_TRC_SEARCH }, 742 { MSG_ORIG(MSG_LFL_TRC_UNREF), LML_FLG_TRC_UNREF, LML_FLG_TRC_UNREF }, 743 { MSG_ORIG(MSG_LFL_TRC_UNUSED), LML_FLG_TRC_UNUSED, 744 LML_FLG_TRC_UNUSED }, 745 { MSG_ORIG(MSG_LFL_TRC_INIT), LML_FLG_TRC_INIT, LML_FLG_TRC_INIT }, 746 { MSG_ORIG(MSG_LFL_TRC_NOUNRESWEAK), LML_FLG_TRC_NOUNRESWEAK, 747 LML_FLG_TRC_NOUNRESWEAK }, 748 { MSG_ORIG(MSG_LFL_TRC_NOPAREXT), LML_FLG_TRC_NOPAREXT, 749 LML_FLG_TRC_NOPAREXT }, 750 { NULL, 0, 0} 751 }; 752 753 static const mdb_bitmask_t lml_tflags_bit[] = { 754 { MSG_ORIG(MSG_LTFL_NOLAZYLD), LML_TFLG_NOLAZYLD, LML_TFLG_NOLAZYLD }, 755 { MSG_ORIG(MSG_LTFL_NODIRECT), LML_TFLG_NODIRECT, LML_TFLG_NODIRECT }, 756 { MSG_ORIG(MSG_LTFL_LOADFLTR), LML_TFLG_LOADFLTR, LML_TFLG_LOADFLTR }, 757 758 { MSG_ORIG(MSG_LTFL_AUD_PREINIT), LML_TFLG_AUD_PREINIT, 759 LML_TFLG_AUD_PREINIT }, 760 { MSG_ORIG(MSG_LTFL_AUD_OBJSEARCH), LML_TFLG_AUD_OBJSEARCH, 761 LML_TFLG_AUD_OBJSEARCH }, 762 { MSG_ORIG(MSG_LTFL_AUD_OBJOPEN), LML_TFLG_AUD_OBJOPEN, 763 LML_TFLG_AUD_OBJOPEN }, 764 { MSG_ORIG(MSG_LTFL_AUD_OBJFILTER), LML_TFLG_AUD_OBJFILTER, 765 LML_TFLG_AUD_OBJFILTER }, 766 { MSG_ORIG(MSG_LTFL_AUD_OBJCLOSE), LML_TFLG_AUD_OBJCLOSE, 767 LML_TFLG_AUD_OBJCLOSE }, 768 { MSG_ORIG(MSG_LTFL_AUD_SYMBIND), LML_TFLG_AUD_SYMBIND, 769 LML_TFLG_AUD_SYMBIND }, 770 { MSG_ORIG(MSG_LTFL_AUD_PLTENTER), LML_TFLG_AUD_PLTENTER, 771 LML_TFLG_AUD_PLTENTER }, 772 { MSG_ORIG(MSG_LTFL_AUD_PLTEXIT), LML_TFLG_AUD_PLTEXIT, 773 LML_TFLG_AUD_PLTEXIT }, 774 { MSG_ORIG(MSG_LTFL_AUD_ACTIVITY), LML_TFLG_AUD_ACTIVITY, 775 LML_TFLG_AUD_ACTIVITY }, 776 { NULL, 0, 0} 777 }; 778 779 void 780 dcmd_Lm_list_help(void) 781 { 782 mdb_printf(MSG_ORIG(MSG_LMLIST_HELP)); 783 } 784 785 static int 786 /* ARGSUSED1 */ 787 _dcmd_Lm_list(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 788 { 789 Lm_list lml; 790 const char *str; 791 uint_t flg = 0; 792 793 if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE, 794 &flg, NULL) != argc) 795 return (DCMD_USAGE); 796 797 if (mdb_vread(&lml, sizeof (lml), addr) == -1) { 798 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_LMLIST_STR), 799 addr); 800 return (DCMD_ERR); 801 } 802 803 if (lml.lm_flags & LML_FLG_BASELM) 804 str = MSG_ORIG(MSG_LMLIST_BASE); 805 else if (lml.lm_flags & LML_FLG_RTLDLM) 806 str = MSG_ORIG(MSG_LMLIST_LDSO); 807 else 808 str = MSG_ORIG(MSG_LMLIST_NEWLM); 809 810 if ((flags & DCMD_LOOP) && ((flags & DCMD_LOOPFIRST) == 0)) 811 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 812 813 mdb_printf(MSG_ORIG(MSG_LMLIST_TITLE2), addr, str); 814 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 815 816 if (lml.lm_lists) { 817 Alist al; 818 Lm_cntl lmc; 819 uintptr_t datap; 820 821 addr = (uintptr_t)lml.lm_lists; 822 if (mdb_vread(&al, sizeof (Alist), addr) == -1) { 823 mdb_warn(MSG_ORIG(MSG_ERR_READ), 824 MSG_ORIG(MSG_STR_ALIST), addr); 825 return (DCMD_ERR); 826 } 827 828 /* 829 * Determine whether the Alist has been populated. Note, the 830 * implementation first reserves an alist entry, and initializes 831 * this element when the first link-map is processed. Thus, 832 * there's a window when nitems is updated, but before the next 833 * element has been initialized. 834 */ 835 if (al.al_nitems && (flg & RTLD_FLG_VERBOSE)) { 836 datap = ALIST_OFF_DATA + (uintptr_t)addr; 837 838 if (mdb_vread(&lmc, sizeof (Lm_cntl), 839 datap) == -1) { 840 mdb_warn(MSG_ORIG(MSG_ERR_READ), 841 MSG_ORIG(MSG_LMLIST_STR), datap); 842 return (DCMD_ERR); 843 } 844 } 845 846 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE0), addr, 847 (size_t)al.al_nitems, (size_t)al.al_arritems); 848 mdb_inc_indent(2); 849 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 850 851 if (al.al_nitems && (flg & RTLD_FLG_VERBOSE)) { 852 uintptr_t nitems; 853 854 mdb_inc_indent(2); 855 mdb_printf(MSG_ORIG(MSG_LMC_LINE1), datap); 856 mdb_printf(MSG_ORIG(MSG_LMC_LINE2), lmc.lc_head, 857 lmc.lc_tail); 858 mdb_printf(MSG_ORIG(MSG_LMC_LINE3), lmc.lc_flags, 859 lmc.lc_now); 860 mdb_printf(MSG_ORIG(MSG_LMC_LINE4), lmc.lc_flags, 861 lmc_bits); 862 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 863 mdb_printf(MSG_ORIG(MSG_RTMAPS_TITLE0)); 864 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 865 866 if (lmc.lc_head) { 867 if (mdb_pwalk(MSG_ORIG(MSG_RTMAPS_STR), 868 rtmap_format, (void *)0, 869 (uintptr_t)lmc.lc_head) == -1) { 870 mdb_dec_indent(4); 871 return (DCMD_ERR); 872 } 873 } else 874 mdb_printf(MSG_ORIG(MSG_FMT_RT), 0, 0, 0, 875 MSG_ORIG(MSG_STR_EMPTY)); 876 877 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 878 879 for (nitems = 1; nitems < al.al_nitems; nitems++) { 880 datap += al.al_size; 881 if (mdb_vread(&lmc, sizeof (Lm_cntl), 882 datap) == -1) { 883 mdb_warn(MSG_ORIG(MSG_ERR_READ), 884 MSG_ORIG(MSG_LMLIST_STR), datap); 885 mdb_dec_indent(4); 886 return (DCMD_ERR); 887 } 888 889 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 890 mdb_printf(MSG_ORIG(MSG_LMC_LINE1), datap); 891 mdb_printf(MSG_ORIG(MSG_LMC_LINE2), 892 lmc.lc_head, lmc.lc_tail); 893 mdb_printf(MSG_ORIG(MSG_LMC_LINE3), 894 lmc.lc_flags, lmc.lc_now); 895 mdb_printf(MSG_ORIG(MSG_LMC_LINE4), 896 lmc.lc_flags, lmc_bits); 897 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 898 mdb_printf(MSG_ORIG(MSG_RTMAPS_TITLE0)); 899 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 900 901 if (lmc.lc_head) { 902 if (mdb_pwalk(MSG_ORIG(MSG_RTMAPS_STR), 903 rtmap_format, (void *)0, 904 (uintptr_t)lmc.lc_head) == -1) { 905 mdb_dec_indent(4); 906 return (DCMD_ERR); 907 } 908 } else 909 mdb_printf(MSG_ORIG(MSG_FMT_RT), 0, 0, 910 0, MSG_ORIG(MSG_STR_EMPTY)); 911 912 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 913 } 914 mdb_dec_indent(2); 915 } 916 mdb_dec_indent(2); 917 } 918 919 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE1), lml.lm_head, lml.lm_tail); 920 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE2), lml.lm_alp, lml.lm_rti); 921 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE3), lml.lm_handle, lml.lm_obj, 922 lml.lm_init, lml.lm_lazy); 923 924 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE4), lml.lm_flags); 925 if (lml.lm_flags) 926 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE6), lml.lm_flags, 927 lml_flags_bit); 928 929 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE5), lml.lm_tflags); 930 if (lml.lm_tflags) 931 mdb_printf(MSG_ORIG(MSG_LMLIST_LINE6), lml.lm_tflags, 932 lml_tflags_bit); 933 934 return (DCMD_OK); 935 } 936 937 static int 938 /* ARGSUSED2 */ 939 dcmd_Lm_list(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 940 { 941 GElf_Sym gsym; 942 APlist *aplp, apl; 943 uintptr_t datap, nitems; 944 945 /* 946 * If an address was provided us it. 947 */ 948 if (flags & DCMD_ADDRSPEC) 949 return (_dcmd_Lm_list(addr, flags, argc, argv)); 950 951 /* 952 * Otherwise traverse the dynlm_list and display each link-map list. 953 */ 954 if (mdb_lookup_by_obj(MSG_ORIG(MSG_STR_LDSO1), 955 MSG_ORIG(MSG_STR_DYNLMLIST), &gsym) == -1) { 956 mdb_warn(MSG_ORIG(MSG_ERR_SYMFAILED), MSG_ORIG(MSG_STR_LDSO1), 957 MSG_ORIG(MSG_STR_DYNLMLIST)); 958 return (DCMD_ERR); 959 } 960 if (mdb_vread(&aplp, sizeof (APlist *), 961 (uintptr_t)gsym.st_value) == -1) { 962 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_APLIST), 963 gsym.st_value); 964 return (DCMD_ERR); 965 } 966 if (aplp == NULL) { 967 mdb_printf(MSG_ORIG(MSG_LMLIST_TITLE0), 968 MSG_ORIG(MSG_STR_DYNLMLIST)); 969 return (DCMD_OK); 970 } 971 972 if (mdb_vread(&apl, sizeof (APlist), (uintptr_t)aplp) == -1) { 973 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_APLIST), 974 aplp); 975 return (DCMD_ERR); 976 } 977 978 mdb_printf(MSG_ORIG(MSG_LMLIST_TITLE1), MSG_ORIG(MSG_STR_DYNLMLIST), 979 aplp, (size_t)apl.apl_nitems, (size_t)apl.apl_arritems); 980 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 981 982 flags |= (DCMD_LOOP | DCMD_LOOPFIRST); 983 for (datap = (uintptr_t)aplp + APLIST_OFF_DATA, nitems = 0; 984 nitems < apl.apl_nitems; nitems++, datap += sizeof (void *)) { 985 Lm_list *lml; 986 987 if (mdb_vread(&lml, sizeof (Lm_list *), datap) == -1) { 988 mdb_warn(MSG_ORIG(MSG_ERR_READ), 989 MSG_ORIG(MSG_LMLIST_STR), datap); 990 return (DCMD_ERR); 991 } 992 993 mdb_inc_indent(2); 994 if (_dcmd_Lm_list((uintptr_t)lml, flags, argc, 995 argv) == DCMD_ERR) { 996 mdb_dec_indent(2); 997 return (DCMD_ERR); 998 } 999 mdb_dec_indent(2); 1000 flags &= ~DCMD_LOOPFIRST; 1001 } 1002 return (DCMD_OK); 1003 } 1004 1005 void 1006 dcmd_GrpDesc_help(void) 1007 { 1008 mdb_printf(MSG_ORIG(MSG_GRPDESC_HELP)); 1009 } 1010 1011 static int 1012 /* ARGSUSED2 */ 1013 dcmd_GrpDesc(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1014 { 1015 Grp_desc gd; 1016 char *str; 1017 1018 /* 1019 * Insure we have a valid address. 1020 */ 1021 if ((flags & DCMD_ADDRSPEC) == 0) { 1022 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_GRPDESC_STR)); 1023 return (DCMD_USAGE); 1024 } 1025 1026 mdb_printf(MSG_ORIG(MSG_GRPDESC_LINE1), addr); 1027 if (mdb_vread(&gd, sizeof (Grp_desc), addr) == -1) { 1028 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_GRPDESC_STR), 1029 addr); 1030 return (DCMD_ERR); 1031 } 1032 1033 if ((str = Rtmap_Name((uintptr_t)gd.gd_depend)) == 0) 1034 return (DCMD_ERR); 1035 1036 mdb_printf(MSG_ORIG(MSG_GRPDESC_LINE2), gd.gd_depend, str); 1037 mdb_printf(MSG_ORIG(MSG_GRPDESC_LINE3), gd.gd_flags, gd.gd_flags, 1038 grdflags_bits); 1039 1040 return (DCMD_OK); 1041 } 1042 1043 void 1044 dcmd_GrpHdl_help(void) 1045 { 1046 mdb_printf(MSG_ORIG(MSG_GRPHDL_HELP)); 1047 } 1048 1049 static int 1050 /* ARGSUSED2 */ 1051 dcmd_GrpHdl(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1052 { 1053 Grp_hdl gh; 1054 Alist al; 1055 uintptr_t datap, listidx; 1056 char *str; 1057 uint_t flg = 0; 1058 1059 /* 1060 * Insure we have a valid address, and provide for a -v option. 1061 */ 1062 if ((flags & DCMD_ADDRSPEC) == 0) { 1063 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_GRPHDL_STR)); 1064 return (DCMD_USAGE); 1065 } 1066 if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE, 1067 &flg, NULL) != argc) 1068 return (DCMD_USAGE); 1069 1070 mdb_printf(MSG_ORIG(MSG_GRPHDL_LINE1), addr); 1071 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1072 1073 if (mdb_vread(&gh, sizeof (Grp_hdl), addr) == -1) { 1074 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_GRPHDL_STR), 1075 addr); 1076 return (DCMD_ERR); 1077 } 1078 1079 /* 1080 * Determine the handles owner. Note that an orphaned handle may no 1081 * longer contain its originating owner. 1082 */ 1083 if (gh.gh_ownlmp) { 1084 if ((str = Rtmap_Name((uintptr_t)gh.gh_ownlmp)) == 0) 1085 return (DCMD_ERR); 1086 } else 1087 str = (char *)MSG_ORIG(MSG_STR_ORPHANED); 1088 1089 mdb_printf(MSG_ORIG(MSG_GRPHDL_LINE2), str); 1090 mdb_printf(MSG_ORIG(MSG_GRPHDL_LINE3), gh.gh_flags, gh.gh_flags, 1091 grhflags_bits); 1092 1093 if (gh.gh_depends == 0) { 1094 mdb_printf(MSG_ORIG(MSG_GRPHDL_LINE4), gh.gh_refcnt); 1095 return (DCMD_OK); 1096 } 1097 1098 addr = (uintptr_t)gh.gh_depends; 1099 if (mdb_vread(&al, sizeof (Alist), addr) == -1) { 1100 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_ALIST), addr); 1101 return (DCMD_ERR); 1102 } 1103 1104 mdb_printf(MSG_ORIG(MSG_GRPHDL_LINE5), gh.gh_refcnt, addr, 1105 (size_t)al.al_nitems, (size_t)al.al_arritems); 1106 1107 if (((flg & RTLD_FLG_VERBOSE) == 0) || (al.al_nitems == 0)) 1108 return (DCMD_OK); 1109 1110 mdb_inc_indent(4); 1111 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1112 1113 /* 1114 * Under verbose mode print the name of each dependency. An Alist can 1115 * have a variable number of data items, so read each individual entry. 1116 */ 1117 datap = ALIST_OFF_DATA + (uintptr_t)addr; 1118 if (dcmd_GrpDesc(datap, flags, argc, argv) == DCMD_ERR) { 1119 mdb_dec_indent(4); 1120 return (DCMD_ERR); 1121 } 1122 1123 for (listidx = 1; listidx < al.al_nitems; listidx++) { 1124 datap += al.al_size; 1125 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1126 if (dcmd_GrpDesc(datap, flags, argc, argv) == DCMD_ERR) { 1127 mdb_dec_indent(4); 1128 return (DCMD_ERR); 1129 } 1130 } 1131 1132 mdb_dec_indent(4); 1133 return (DCMD_OK); 1134 } 1135 1136 static void 1137 dcmd_Handles_help(void) 1138 { 1139 mdb_printf(MSG_ORIG(MSG_HANDLES_HELP)); 1140 } 1141 1142 static int 1143 dcmd_Handles(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1144 { 1145 Rt_map rtmap; 1146 char *str; 1147 uint_t flg = 0; 1148 APlist apl; 1149 uintptr_t datap, nitems; 1150 Grp_hdl *ghp; 1151 1152 /* 1153 * Insure we have a valid address, and provide for a -v option. 1154 */ 1155 if ((flags & DCMD_ADDRSPEC) == 0) { 1156 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_HANDLES_STR)); 1157 return (DCMD_USAGE); 1158 } 1159 if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE, 1160 &flg, NULL) != argc) 1161 return (DCMD_USAGE); 1162 1163 /* 1164 * Read the Rt_map contents. 1165 */ 1166 if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) { 1167 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_RTMAP_STR), addr); 1168 return (DCMD_ERR); 1169 } 1170 if ((str = String((uintptr_t)NAME(&rtmap), 1171 MSG_ORIG(MSG_STR_NAME))) == 0) 1172 return (DCMD_ERR); 1173 1174 mdb_printf(MSG_ORIG(MSG_HANDLES_LINE1), str); 1175 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1176 1177 if (HANDLES(&rtmap) == 0) 1178 return (DCMD_OK); 1179 1180 addr = (uintptr_t)HANDLES(&rtmap); 1181 if (mdb_vread(&apl, sizeof (APlist), addr) == -1) { 1182 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_APLIST), 1183 addr); 1184 return (DCMD_ERR); 1185 } 1186 1187 mdb_printf(MSG_ORIG(MSG_HANDLES_LINE2), addr, (size_t)apl.apl_nitems, 1188 (size_t)apl.apl_arritems); 1189 1190 if (((flg & RTLD_FLG_VERBOSE) == 0) || (apl.apl_nitems == 0)) 1191 return (DCMD_OK); 1192 1193 /* 1194 * Under verbose mode print the name of each dependency. An APlist can 1195 * have a variable number of data items, so read each individual entry. 1196 */ 1197 datap = addr + APLIST_OFF_DATA; 1198 if (mdb_vread(&ghp, sizeof (Grp_hdl *), datap) == -1) { 1199 mdb_warn(MSG_ORIG(MSG_ERR_READ), 1200 MSG_ORIG(MSG_GRPHDL_STR), datap); 1201 return (DCMD_ERR); 1202 } 1203 1204 mdb_inc_indent(4); 1205 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1206 1207 if (dcmd_GrpHdl((uintptr_t)ghp, flags, argc, argv) == DCMD_ERR) { 1208 mdb_dec_indent(4); 1209 return (DCMD_ERR); 1210 } 1211 1212 nitems = 1; 1213 for (nitems = 1; nitems < apl.apl_nitems; nitems++) { 1214 datap += sizeof (void *); 1215 if (mdb_vread(&ghp, sizeof (Grp_hdl *), datap) == -1) { 1216 mdb_warn(MSG_ORIG(MSG_ERR_READ), 1217 MSG_ORIG(MSG_GRPHDL_STR), datap); 1218 return (DCMD_ERR); 1219 } 1220 1221 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1222 if (dcmd_GrpHdl((uintptr_t)ghp, flags, argc, 1223 argv) == DCMD_ERR) { 1224 mdb_dec_indent(4); 1225 return (DCMD_ERR); 1226 } 1227 } 1228 mdb_dec_indent(4); 1229 return (DCMD_OK); 1230 } 1231 1232 static void 1233 dcmd_Groups_help(void) 1234 { 1235 mdb_printf(MSG_ORIG(MSG_GROUPS_HELP)); 1236 } 1237 1238 1239 static int 1240 dcmd_Groups(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1241 { 1242 Rt_map rtmap; 1243 char *str; 1244 APlist apl; 1245 uint_t flg = 0; 1246 uintptr_t datap, nitems; 1247 Grp_hdl *ghp; 1248 1249 /* 1250 * Insure we have a valid address, and provide for a -v option. 1251 */ 1252 if ((flags & DCMD_ADDRSPEC) == 0) { 1253 mdb_warn(MSG_ORIG(MSG_ERR_NAS), MSG_ORIG(MSG_GROUPS_STR)); 1254 return (DCMD_USAGE); 1255 } 1256 if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, RTLD_FLG_VERBOSE, 1257 &flg, NULL) != argc) 1258 return (DCMD_USAGE); 1259 1260 /* 1261 * Read the Rt_map contents. 1262 */ 1263 if (mdb_vread(&rtmap, sizeof (Rt_map), addr) == -1) { 1264 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_RTMAP_STR), addr); 1265 return (DCMD_ERR); 1266 } 1267 if ((str = String((uintptr_t)NAME(&rtmap), 1268 MSG_ORIG(MSG_STR_NAME))) == 0) 1269 return (DCMD_ERR); 1270 1271 mdb_printf(MSG_ORIG(MSG_GROUPS_LINE1), str); 1272 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1273 1274 if (GROUPS(&rtmap) == 0) 1275 return (DCMD_OK); 1276 1277 addr = (uintptr_t)GROUPS(&rtmap); 1278 if (mdb_vread(&apl, sizeof (APlist), addr) == -1) { 1279 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_STR_APLIST), 1280 addr); 1281 return (DCMD_ERR); 1282 } 1283 1284 mdb_printf(MSG_ORIG(MSG_GROUPS_LINE2), addr, (size_t)apl.apl_nitems, 1285 (size_t)apl.apl_arritems); 1286 1287 if (((flg & RTLD_FLG_VERBOSE) == 0) || (apl.apl_nitems == 0)) 1288 return (DCMD_OK); 1289 1290 /* 1291 * Under verbose mode print the name of each dependency. An APlist can 1292 * have a variable number of data items, so read each individual entry. 1293 */ 1294 datap = addr + APLIST_OFF_DATA; 1295 if (mdb_vread(&ghp, sizeof (Grp_hdl *), datap) == -1) { 1296 mdb_warn(MSG_ORIG(MSG_ERR_READ), 1297 MSG_ORIG(MSG_GRPHDL_STR), datap); 1298 return (DCMD_ERR); 1299 } 1300 1301 mdb_inc_indent(4); 1302 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1303 1304 if (dcmd_GrpHdl((uintptr_t)ghp, flags, argc, argv) == DCMD_ERR) { 1305 mdb_dec_indent(4); 1306 return (DCMD_ERR); 1307 } 1308 1309 for (nitems = 1; nitems < apl.apl_nitems; nitems++) { 1310 datap += sizeof (void *); 1311 if (mdb_vread(&ghp, sizeof (Grp_hdl *), datap) == -1) { 1312 mdb_warn(MSG_ORIG(MSG_ERR_READ), 1313 MSG_ORIG(MSG_GRPHDL_STR), datap); 1314 return (DCMD_ERR); 1315 } 1316 1317 mdb_printf(MSG_ORIG(MSG_STR_DASHES)); 1318 if (dcmd_GrpHdl((uintptr_t)ghp, flags, argc, 1319 argv) == DCMD_ERR) { 1320 mdb_dec_indent(4); 1321 return (DCMD_ERR); 1322 } 1323 } 1324 mdb_dec_indent(4); 1325 return (DCMD_OK); 1326 } 1327 static void 1328 dcmd_ElfDyn_help(void) 1329 { 1330 mdb_printf(MSG_ORIG(MSG_ELFDYN_HELP)); 1331 } 1332 1333 static int 1334 /* ARGSUSED2 */ 1335 dcmd_ElfDyn(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1336 { 1337 Dyn dyn; 1338 const char *dynstr; 1339 Conv_inv_buf_t inv_buf; 1340 1341 if ((flags & DCMD_ADDRSPEC) == 0) 1342 return (DCMD_USAGE); 1343 if (mdb_vread(&dyn, sizeof (dyn), addr) == -1) { 1344 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_ELFDYN_STR), 1345 addr); 1346 return (DCMD_ERR); 1347 } 1348 1349 mdb_printf(MSG_ORIG(MSG_ELFDYN_TITLE), addr); 1350 dynstr = conv_dyn_tag(dyn.d_tag, ELFOSABI_SOLARIS, M_MACH, 0, &inv_buf); 1351 mdb_printf(MSG_ORIG(MSG_ELFDYN_LINE1), addr, dynstr, dyn.d_un.d_ptr); 1352 1353 mdb_set_dot(addr + sizeof (Dyn)); 1354 1355 return (DCMD_OK); 1356 } 1357 1358 static void 1359 dcmd_ElfEhdr_help(void) 1360 { 1361 mdb_printf(MSG_ORIG(MSG_EHDR_HELP)); 1362 } 1363 1364 static int 1365 /* ARGSUSED2 */ 1366 dcmd_ElfEhdr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1367 { 1368 Ehdr ehdr; 1369 Byte *byte; 1370 const char *flgs; 1371 Conv_inv_buf_t inv_buf1, inv_buf2; 1372 Conv_ehdr_flags_buf_t ehdr_flags_buf; 1373 1374 1375 if ((flags & DCMD_ADDRSPEC) == 0) 1376 return (DCMD_USAGE); 1377 1378 if (mdb_vread(&ehdr, sizeof (ehdr), addr) == -1) { 1379 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_EHDR_STR), 1380 addr); 1381 return (DCMD_ERR); 1382 } 1383 1384 mdb_printf(MSG_ORIG(MSG_EHDR_TITLE), addr); 1385 byte = &ehdr.e_ident[0]; 1386 mdb_printf(MSG_ORIG(MSG_EHDR_LINE1), byte[EI_MAG0], 1387 (byte[EI_MAG1] ? byte[EI_MAG1] : '0'), 1388 (byte[EI_MAG2] ? byte[EI_MAG2] : '0'), 1389 (byte[EI_MAG3] ? byte[EI_MAG3] : '0')); 1390 mdb_printf(MSG_ORIG(MSG_EHDR_LINE2), 1391 conv_ehdr_class(ehdr.e_ident[EI_CLASS], 0, &inv_buf1), 1392 conv_ehdr_data(ehdr.e_ident[EI_DATA], 0, &inv_buf2)); 1393 1394 mdb_printf(MSG_ORIG(MSG_EHDR_LINE3), 1395 conv_ehdr_mach(ehdr.e_machine, 0, &inv_buf1), 1396 conv_ehdr_vers(ehdr.e_version, 0, &inv_buf2)); 1397 mdb_printf(MSG_ORIG(MSG_EHDR_LINE4), 1398 conv_ehdr_type(ehdr.e_ident[EI_OSABI], ehdr.e_type, 0, &inv_buf1)); 1399 1400 /* 1401 * Line up the flags differently depending on whether we 1402 * received a numeric (e.g. "0x200") or text representation 1403 * (e.g. "[ EF_SPARC_SUN_US1 ]"). 1404 */ 1405 flgs = conv_ehdr_flags(ehdr.e_machine, ehdr.e_flags, 1406 0, &ehdr_flags_buf); 1407 if (flgs[0] == '[') 1408 mdb_printf(MSG_ORIG(MSG_EHDR_LINE5), flgs); 1409 else 1410 mdb_printf(MSG_ORIG(MSG_EHDR_LINE6), flgs); 1411 1412 mdb_printf(MSG_ORIG(MSG_EHDR_LINE7), ehdr.e_entry, ehdr.e_ehsize, 1413 ehdr.e_shstrndx); 1414 mdb_printf(MSG_ORIG(MSG_EHDR_LINE8), ehdr.e_shoff, ehdr.e_shentsize, 1415 ehdr.e_shnum); 1416 mdb_printf(MSG_ORIG(MSG_EHDR_LINE9), ehdr.e_phoff, ehdr.e_phentsize, 1417 ehdr.e_phnum); 1418 1419 mdb_set_dot(addr + sizeof (Ehdr)); 1420 1421 return (DCMD_OK); 1422 } 1423 1424 static void 1425 dcmd_ElfPhdr_help(void) 1426 { 1427 mdb_printf(MSG_ORIG(MSG_EPHDR_HELP)); 1428 } 1429 1430 static int 1431 /* ARGSUSED2 */ 1432 dcmd_ElfPhdr(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 1433 { 1434 Phdr phdr; 1435 Conv_inv_buf_t inv_buf; 1436 Conv_phdr_flags_buf_t phdr_flags_buf; 1437 1438 if ((flags & DCMD_ADDRSPEC) == 0) 1439 return (DCMD_USAGE); 1440 1441 if (mdb_vread(&phdr, sizeof (phdr), addr) == -1) { 1442 mdb_warn(MSG_ORIG(MSG_ERR_READ), MSG_ORIG(MSG_EPHDR_STR), 1443 addr); 1444 return (DCMD_ERR); 1445 } 1446 1447 mdb_printf(MSG_ORIG(MSG_EPHDR_TITLE), addr); 1448 mdb_printf(MSG_ORIG(MSG_EPHDR_LINE1), phdr.p_vaddr, 1449 conv_phdr_flags(ELFOSABI_SOLARIS, phdr.p_flags, 0, 1450 &phdr_flags_buf)); 1451 mdb_printf(MSG_ORIG(MSG_EPHDR_LINE2), phdr.p_paddr, 1452 conv_phdr_type(ELFOSABI_SOLARIS, M_MACH, phdr.p_type, 0, &inv_buf)); 1453 mdb_printf(MSG_ORIG(MSG_EPHDR_LINE3), phdr.p_filesz, phdr.p_memsz); 1454 mdb_printf(MSG_ORIG(MSG_EPHDR_LINE4), phdr.p_offset, phdr.p_align); 1455 1456 mdb_set_dot(addr + sizeof (Phdr)); 1457 1458 return (DCMD_OK); 1459 } 1460 1461 1462 static const mdb_dcmd_t dcmds[] = { 1463 { MSG_ORIG(MSG_BND_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1464 MSG_ORIG(MSG_BND_DCD), 1465 dcmd_Bind, dcmd_Bind_help}, 1466 { MSG_ORIG(MSG_DEPENDS_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1467 MSG_ORIG(MSG_DEPENDS_DCD), 1468 dcmd_Depends, dcmd_Depends_help}, 1469 { MSG_ORIG(MSG_CALLERS_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1470 MSG_ORIG(MSG_CALLERS_DCD), 1471 dcmd_Callers, dcmd_Callers_help}, 1472 { MSG_ORIG(MSG_GRPHDL_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1473 MSG_ORIG(MSG_GRPHDL_DCD), 1474 dcmd_GrpHdl, dcmd_GrpHdl_help}, 1475 { MSG_ORIG(MSG_GRPDESC_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1476 MSG_ORIG(MSG_GRPDESC_DCD), 1477 dcmd_GrpDesc, dcmd_GrpDesc_help}, 1478 { MSG_ORIG(MSG_HANDLES_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1479 MSG_ORIG(MSG_HANDLES_DCD), 1480 dcmd_Handles, dcmd_Handles_help}, 1481 { MSG_ORIG(MSG_GROUPS_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1482 MSG_ORIG(MSG_GROUPS_DCD), 1483 dcmd_Groups, dcmd_Groups_help}, 1484 { MSG_ORIG(MSG_ELFDYN_STR), MSG_ORIG(MSG_USG_ADDREQ), 1485 MSG_ORIG(MSG_ELFDYN_DCD), 1486 dcmd_ElfDyn, dcmd_ElfDyn_help}, 1487 { MSG_ORIG(MSG_EHDR_STR), MSG_ORIG(MSG_USG_ADDREQ), 1488 MSG_ORIG(MSG_EHDR_DCD), 1489 dcmd_ElfEhdr, dcmd_ElfEhdr_help}, 1490 { MSG_ORIG(MSG_EPHDR_STR), MSG_ORIG(MSG_USG_ADDREQ), 1491 MSG_ORIG(MSG_EPHDR_DCD), 1492 dcmd_ElfPhdr, dcmd_ElfPhdr_help}, 1493 { MSG_ORIG(MSG_LMLIST_STR), MSG_ORIG(MSG_USG_ADDREQ_V), 1494 MSG_ORIG(MSG_LMLIST_DCD), 1495 dcmd_Lm_list, dcmd_Lm_list_help}, 1496 { MSG_ORIG(MSG_RTMAPS_STR), MSG_ORIG(MSG_USG_ADDOPT_V), 1497 MSG_ORIG(MSG_RTMAPS_DCD), 1498 dcmd_Rtmaps, dcmd_Rtmaps_help}, 1499 { MSG_ORIG(MSG_RTMAP_STR), MSG_ORIG(MSG_USG_ADDREQ), 1500 MSG_ORIG(MSG_RTMAP_DCD), 1501 dcmd_rtmap, dcmd_rtmap_help}, 1502 { MSG_ORIG(MSG_SETENV_STR), MSG_ORIG(MSG_USG_SETENV), 1503 MSG_ORIG(MSG_SETENV_DCD), 1504 dcmd_Setenv, dcmd_Setenv_help}, 1505 { NULL } 1506 }; 1507 1508 static const mdb_walker_t walkers[] = { 1509 { MSG_ORIG(MSG_RTMAPS_STR), MSG_ORIG(MSG_WWD_RTMAP), 1510 walk_rtmap_init, walk_rtmap_step, NULL, NULL }, 1511 { NULL } 1512 }; 1513 1514 static const mdb_modinfo_t modinfo = { 1515 MDB_API_VERSION, dcmds, walkers 1516 }; 1517 1518 const mdb_modinfo_t * 1519 _mdb_init(void) 1520 { 1521 return (&modinfo); 1522 } 1523