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