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