10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*1618Srie * Common Development and Distribution License (the "License"). 6*1618Srie * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 21685Srie 220Sstevel@tonic-gate /* 23*1618Srie * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 286Srie #include <sys/auxv.h> 290Sstevel@tonic-gate #include <string.h> 300Sstevel@tonic-gate #include <unistd.h> 310Sstevel@tonic-gate #include <fcntl.h> 320Sstevel@tonic-gate #include <limits.h> 330Sstevel@tonic-gate #include <stdio.h> 34*1618Srie #include <libld.h> 35*1618Srie #include <rtld.h> 36*1618Srie #include <conv.h> 370Sstevel@tonic-gate #include "msg.h" 380Sstevel@tonic-gate #include "_debug.h" 390Sstevel@tonic-gate 400Sstevel@tonic-gate void 41*1618Srie Dbg_file_analyze(Rt_map *lmp) 420Sstevel@tonic-gate { 43*1618Srie Lm_list *lml = LIST(lmp); 44*1618Srie 45*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 460Sstevel@tonic-gate return; 470Sstevel@tonic-gate 48*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 49*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_ANALYZE), NAME(lmp), 50*1618Srie conv_dl_mode(MODE(lmp), 1)); 510Sstevel@tonic-gate } 520Sstevel@tonic-gate 530Sstevel@tonic-gate void 54*1618Srie Dbg_file_aout(Lm_list *lml, const char *name, ulong_t dynamic, ulong_t base, 55*1618Srie ulong_t size, const char *lmid, Aliste lmco) 560Sstevel@tonic-gate { 57*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 580Sstevel@tonic-gate return; 590Sstevel@tonic-gate 60*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_AOUT), name); 61*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_DB), EC_XWORD(dynamic), 62*1618Srie EC_ADDR(base)); 63*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_S), EC_XWORD(size)); 64*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_LL), lmid, EC_XWORD(lmco)); 650Sstevel@tonic-gate } 660Sstevel@tonic-gate 670Sstevel@tonic-gate void 68*1618Srie Dbg_file_elf(Lm_list *lml, const char *name, ulong_t dynamic, ulong_t base, 69*1618Srie ulong_t size, ulong_t entry, const char *lmid, Aliste lmco) 700Sstevel@tonic-gate { 710Sstevel@tonic-gate const char *str; 720Sstevel@tonic-gate 73*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 740Sstevel@tonic-gate return; 750Sstevel@tonic-gate 760Sstevel@tonic-gate if (base == 0) 770Sstevel@tonic-gate str = MSG_INTL(MSG_STR_TEMPORARY); 780Sstevel@tonic-gate else 790Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 800Sstevel@tonic-gate 81*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_ELF), name, str); 82*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_DB), EC_XWORD(dynamic), 83*1618Srie EC_ADDR(base)); 84*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_SE), EC_XWORD(size), 85*1618Srie EC_XWORD(entry)); 86*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_LL), lmid, EC_XWORD(lmco)); 870Sstevel@tonic-gate } 880Sstevel@tonic-gate 890Sstevel@tonic-gate void 90*1618Srie Dbg_file_ldso(Rt_map *lmp, char **envp, auxv_t *auxv, const char *lmid, 91*1618Srie Aliste lmco) 920Sstevel@tonic-gate { 93*1618Srie Lm_list *lml = LIST(lmp); 94*1618Srie 95*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 960Sstevel@tonic-gate return; 970Sstevel@tonic-gate 98*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 99*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_LDSO), PATHNAME(lmp)); 100*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_DB), EC_NATPTR(DYN(lmp)), 101*1618Srie EC_ADDR(ADDR(lmp))); 102*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_EA), EC_NATPTR(envp), 103*1618Srie EC_NATPTR(auxv)); 104*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_LL), lmid, EC_XWORD(lmco)); 105*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 106*1618Srie } 107*1618Srie 108*1618Srie 109*1618Srie void 110*1618Srie Dbg_file_prot(Rt_map *lmp, int prot) 111*1618Srie { 112*1618Srie Lm_list *lml = LIST(lmp); 113*1618Srie 114*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 115*1618Srie return; 116*1618Srie 117*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 118*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_PROT), NAME(lmp), (prot ? '+' : '-')); 1190Sstevel@tonic-gate } 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate void 122*1618Srie Dbg_file_delete(Rt_map *lmp) 1230Sstevel@tonic-gate { 124*1618Srie Lm_list *lml = LIST(lmp); 125*1618Srie 126*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 1270Sstevel@tonic-gate return; 1280Sstevel@tonic-gate 129*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 130*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DELETE), NAME(lmp)); 1310Sstevel@tonic-gate } 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate static int hdl_title = 0; 1340Sstevel@tonic-gate static Msg hdl_str = 0; 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate void 1370Sstevel@tonic-gate Dbg_file_hdl_title(int type) 1380Sstevel@tonic-gate { 139*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 1400Sstevel@tonic-gate return; 1410Sstevel@tonic-gate if (DBG_NOTDETAIL()) 1420Sstevel@tonic-gate return; 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate hdl_title = 1; 1450Sstevel@tonic-gate 1460Sstevel@tonic-gate /* 1470Sstevel@tonic-gate * Establish a binding title for later use in Dbg_file_bind_entry. 1480Sstevel@tonic-gate */ 1490Sstevel@tonic-gate if (type == DBG_DEP_CREATE) 1500Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_CREATE; /* MSG_INTL(MSG_FIL_HDL_CREATE) */ 1510Sstevel@tonic-gate else if (type == DBG_DEP_ADD) 1520Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_ADD; /* MSG_INTL(MSG_FIL_HDL_ADD) */ 1530Sstevel@tonic-gate else if (type == DBG_DEP_DELETE) 1540Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_DELETE; /* MSG_INTL(MSG_FIL_HDL_DELETE) */ 1550Sstevel@tonic-gate else if (type == DBG_DEP_ORPHAN) 1560Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_ORPHAN; /* MSG_INTL(MSG_FIL_HDL_ORPHAN) */ 1570Sstevel@tonic-gate else if (type == DBG_DEP_REINST) 1580Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_REINST; /* MSG_INTL(MSG_FIL_HDL_REINST) */ 1590Sstevel@tonic-gate else 1600Sstevel@tonic-gate hdl_str = 0; 1610Sstevel@tonic-gate } 1620Sstevel@tonic-gate 1630Sstevel@tonic-gate void 164*1618Srie Dbg_file_hdl_collect(Grp_hdl *ghp, const char *name) 1650Sstevel@tonic-gate { 166*1618Srie Lm_list *lml = ghp->gh_ownlml; 167*1618Srie const char *str; 1680Sstevel@tonic-gate 169*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 1700Sstevel@tonic-gate return; 1710Sstevel@tonic-gate if (DBG_NOTDETAIL()) 1720Sstevel@tonic-gate return; 1730Sstevel@tonic-gate 174*1618Srie if (ghp->gh_ownlmp) 175*1618Srie str = NAME(ghp->gh_ownlmp); 1760Sstevel@tonic-gate else 1770Sstevel@tonic-gate str = MSG_INTL(MSG_STR_ORPHAN); 1780Sstevel@tonic-gate 1790Sstevel@tonic-gate if (hdl_title) { 1800Sstevel@tonic-gate hdl_title = 0; 181*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 1820Sstevel@tonic-gate } 1830Sstevel@tonic-gate if (name) 184*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_HDL_RETAIN), str, name); 1850Sstevel@tonic-gate else 186*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_HDL_COLLECT), str, 187*1618Srie conv_grphdl_flags(ghp->gh_flags)); 1880Sstevel@tonic-gate } 1890Sstevel@tonic-gate 1900Sstevel@tonic-gate void 191*1618Srie Dbg_file_hdl_action(Grp_hdl *ghp, Rt_map *lmp, int type) 1920Sstevel@tonic-gate { 193*1618Srie Lm_list *lml = LIST(lmp); 1940Sstevel@tonic-gate Msg str; 1950Sstevel@tonic-gate 196*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 1970Sstevel@tonic-gate return; 1980Sstevel@tonic-gate if (DBG_NOTDETAIL()) 1990Sstevel@tonic-gate return; 2000Sstevel@tonic-gate 2010Sstevel@tonic-gate if (hdl_title) { 202*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 2030Sstevel@tonic-gate if (hdl_str) { 2040Sstevel@tonic-gate const char *name; 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate /* 2070Sstevel@tonic-gate * Protect ourselves in case this handle has no 2080Sstevel@tonic-gate * originating owner. 2090Sstevel@tonic-gate */ 210*1618Srie if (ghp->gh_ownlmp) 211*1618Srie name = NAME(ghp->gh_ownlmp); 2120Sstevel@tonic-gate else 2130Sstevel@tonic-gate name = MSG_INTL(MSG_STR_UNKNOWN); 2140Sstevel@tonic-gate 215*1618Srie dbg_print(lml, MSG_INTL(hdl_str), name); 2160Sstevel@tonic-gate } 2170Sstevel@tonic-gate hdl_title = 0; 2180Sstevel@tonic-gate } 2190Sstevel@tonic-gate 2200Sstevel@tonic-gate if (type == DBG_DEP_ADD) 2210Sstevel@tonic-gate str = MSG_FIL_DEP_ADD; /* MSG_INTL(MSG_FIL_DEP_ADD) */ 2220Sstevel@tonic-gate else if (type == DBG_DEP_DELETE) 2230Sstevel@tonic-gate str = MSG_FIL_DEP_DELETE; /* MSG_INTL(MSG_FIL_DEP_DELETE) */ 2240Sstevel@tonic-gate else if (type == DBG_DEP_REMOVE) 2250Sstevel@tonic-gate str = MSG_FIL_DEP_REMOVE; /* MSG_INTL(MSG_FIL_DEP_REMOVE) */ 2260Sstevel@tonic-gate else if (type == DBG_DEP_REMAIN) 2270Sstevel@tonic-gate str = MSG_FIL_DEP_REMAIN; /* MSG_INTL(MSG_FIL_DEP_REMAIN) */ 2280Sstevel@tonic-gate else 2290Sstevel@tonic-gate str = 0; 2300Sstevel@tonic-gate 2310Sstevel@tonic-gate if (str) { 2320Sstevel@tonic-gate const char *mode; 2330Sstevel@tonic-gate 2340Sstevel@tonic-gate if ((MODE(lmp) & (RTLD_GLOBAL | RTLD_NODELETE)) == 2350Sstevel@tonic-gate (RTLD_GLOBAL | RTLD_NODELETE)) 2360Sstevel@tonic-gate mode = MSG_ORIG(MSG_MODE_GLOBNODEL); 2370Sstevel@tonic-gate else if (MODE(lmp) & RTLD_GLOBAL) 2380Sstevel@tonic-gate mode = MSG_ORIG(MSG_MODE_GLOB); 2390Sstevel@tonic-gate 2400Sstevel@tonic-gate else if (MODE(lmp) & RTLD_NODELETE) 2410Sstevel@tonic-gate mode = MSG_ORIG(MSG_MODE_NODEL); 2420Sstevel@tonic-gate else 2430Sstevel@tonic-gate mode = MSG_ORIG(MSG_STR_EMPTY); 2440Sstevel@tonic-gate 245*1618Srie dbg_print(lml, MSG_INTL(str), NAME(lmp), mode); 2460Sstevel@tonic-gate } 2470Sstevel@tonic-gate } 2480Sstevel@tonic-gate 2490Sstevel@tonic-gate void 250*1618Srie Dbg_file_bind_entry(Lm_list *lml, Bnd_desc *bdp) 2510Sstevel@tonic-gate { 252*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 2530Sstevel@tonic-gate return; 2540Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2550Sstevel@tonic-gate return; 2560Sstevel@tonic-gate 2570Sstevel@tonic-gate /* 2580Sstevel@tonic-gate * Print the dependency together with the modes of the binding. 2590Sstevel@tonic-gate */ 260*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 261*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BND_ADD), NAME(bdp->b_caller)); 262*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BND_FILE), NAME(bdp->b_depend), 263*1618Srie conv_bnd_type(bdp->b_flags)); 264280Srie } 265280Srie 266280Srie void 267*1618Srie Dbg_file_bindings(Rt_map *lmp, int flag) 268280Srie { 269280Srie const char *str; 270280Srie Rt_map *tlmp; 271*1618Srie Lm_list *lml = LIST(lmp); 272280Srie int next = 0; 273280Srie 274*1618Srie if (DBG_NOTCLASS(DBG_C_INIT)) 275280Srie return; 276280Srie if (DBG_NOTDETAIL()) 277280Srie return; 278280Srie 279280Srie if (flag & RT_SORT_REV) 280280Srie str = MSG_ORIG(MSG_SCN_INIT); 281280Srie else 282280Srie str = MSG_ORIG(MSG_SCN_FINI); 283280Srie 284*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 285*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEP_TITLE), str, 286*1618Srie conv_bnd_obj(lml->lm_flags)); 287280Srie 288280Srie /* LINTED */ 289280Srie for (tlmp = lmp; tlmp; tlmp = (Rt_map *)NEXT(tlmp)) { 290*1618Srie Bnd_desc **bdpp; 291280Srie Aliste off; 292280Srie 293280Srie /* 294280Srie * For .init processing, only collect objects that have been 295280Srie * relocated and haven't already been collected. 296280Srie * For .fini processing, only collect objects that have had 297280Srie * their .init collected, and haven't already been .fini 298280Srie * collected. 299280Srie */ 300280Srie if (flag & RT_SORT_REV) { 301280Srie if ((FLAGS(tlmp) & (FLG_RT_RELOCED | 302280Srie FLG_RT_INITCLCT)) != FLG_RT_RELOCED) 303280Srie continue; 304280Srie 305280Srie } else { 306280Srie if ((flag & RT_SORT_DELETE) && 307280Srie ((FLAGS(tlmp) & FLG_RT_DELETE) == 0)) 308280Srie continue; 309280Srie if (((FLAGS(tlmp) & 310280Srie (FLG_RT_INITCLCT | FLG_RT_FINICLCT)) == 311280Srie FLG_RT_INITCLCT) == 0) 312280Srie continue; 313280Srie } 314280Srie 315280Srie if (next++) 316*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 317280Srie 318280Srie if (DEPENDS(tlmp) == 0) 319*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEP_NONE), NAME(tlmp)); 320280Srie else { 321*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEP_ENT), NAME(tlmp)); 322280Srie 323280Srie for (ALIST_TRAVERSE(DEPENDS(tlmp), off, bdpp)) { 324*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BND_FILE), 325280Srie NAME((*bdpp)->b_depend), 326*1618Srie conv_bnd_type((*bdpp)->b_flags)); 327280Srie } 328280Srie } 329280Srie } 330*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 3310Sstevel@tonic-gate } 3320Sstevel@tonic-gate 3330Sstevel@tonic-gate void 334*1618Srie Dbg_file_dlopen(Rt_map *clmp, const char *name, int mode) 3350Sstevel@tonic-gate { 336*1618Srie Lm_list *lml = LIST(clmp); 337*1618Srie 338*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 3390Sstevel@tonic-gate return; 3400Sstevel@tonic-gate 341*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 342*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DLOPEN), name, NAME(clmp), 343*1618Srie conv_dl_mode(mode, 1)); 3440Sstevel@tonic-gate } 3450Sstevel@tonic-gate 3460Sstevel@tonic-gate void 347*1618Srie Dbg_file_dlclose(Lm_list *lml, const char *name, int flag) 3480Sstevel@tonic-gate { 3490Sstevel@tonic-gate const char *str; 3500Sstevel@tonic-gate 351*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 3520Sstevel@tonic-gate return; 3530Sstevel@tonic-gate 3540Sstevel@tonic-gate if (flag == DBG_DLCLOSE_IGNORE) 3550Sstevel@tonic-gate str = MSG_INTL(MSG_STR_IGNORE); 3560Sstevel@tonic-gate else 3570Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 3580Sstevel@tonic-gate 359*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 360*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DLCLOSE), name, str); 3610Sstevel@tonic-gate } 3620Sstevel@tonic-gate 3630Sstevel@tonic-gate void 364*1618Srie Dbg_file_dldump(Rt_map *lmp, const char *path, int flags) 3650Sstevel@tonic-gate { 366*1618Srie Lm_list *lml = LIST(lmp); 367*1618Srie 368*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 3690Sstevel@tonic-gate return; 3700Sstevel@tonic-gate 371*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 372*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DLDUMP), NAME(lmp), path, 373*1618Srie conv_dl_flag(flags, 0)); 3740Sstevel@tonic-gate } 3750Sstevel@tonic-gate 3760Sstevel@tonic-gate void 377*1618Srie Dbg_file_lazyload(Rt_map *clmp, const char *fname, const char *sname) 3780Sstevel@tonic-gate { 379*1618Srie Lm_list *lml = LIST(clmp); 380*1618Srie 381*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 3820Sstevel@tonic-gate return; 3830Sstevel@tonic-gate 384*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 385*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_LAZYLOAD), fname, NAME(clmp), 386*1618Srie Dbg_demangle_name(sname)); 3870Sstevel@tonic-gate } 3880Sstevel@tonic-gate 3890Sstevel@tonic-gate void 390*1618Srie Dbg_file_preload(Lm_list *lml, const char *name) 3910Sstevel@tonic-gate { 392*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 3930Sstevel@tonic-gate return; 3940Sstevel@tonic-gate 395*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 396*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_PRELOAD), name); 3970Sstevel@tonic-gate } 3980Sstevel@tonic-gate 3990Sstevel@tonic-gate void 400*1618Srie Dbg_file_needed(Rt_map *lmp, const char *name) 4010Sstevel@tonic-gate { 402*1618Srie Lm_list *lml = LIST(lmp); 403*1618Srie 404*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4050Sstevel@tonic-gate return; 4060Sstevel@tonic-gate 407*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 408*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_NEEDED), name, NAME(lmp)); 4090Sstevel@tonic-gate } 4100Sstevel@tonic-gate 4110Sstevel@tonic-gate void 412*1618Srie Dbg_file_filter(Lm_list *lml, const char *filter, const char *filtee, 413*1618Srie int config) 4140Sstevel@tonic-gate { 415*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4160Sstevel@tonic-gate return; 4170Sstevel@tonic-gate 418*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 4190Sstevel@tonic-gate if (config) 420*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTER_1), filter, filtee); 4210Sstevel@tonic-gate else 422*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTER_2), filter, filtee); 4230Sstevel@tonic-gate } 4240Sstevel@tonic-gate 4250Sstevel@tonic-gate void 426*1618Srie Dbg_file_filtee(Lm_list *lml, const char *filter, const char *filtee, int audit) 4270Sstevel@tonic-gate { 4280Sstevel@tonic-gate if (audit) { 429*1618Srie if (DBG_NOTCLASS(DBG_C_AUDITING | DBG_C_FILES)) 4300Sstevel@tonic-gate return; 4310Sstevel@tonic-gate 432*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 433*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTEE_3), filtee); 4340Sstevel@tonic-gate } else { 435*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4360Sstevel@tonic-gate return; 4370Sstevel@tonic-gate 438*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 4390Sstevel@tonic-gate if (filter) 440*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTEE_1), filtee, 441*1618Srie filter); 4420Sstevel@tonic-gate else 443*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTEE_2), filtee); 4440Sstevel@tonic-gate } 4450Sstevel@tonic-gate } 4460Sstevel@tonic-gate 4470Sstevel@tonic-gate void 448*1618Srie Dbg_file_fixname(Lm_list *lml, const char *oname, const char *nname) 4490Sstevel@tonic-gate { 450*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4510Sstevel@tonic-gate return; 4520Sstevel@tonic-gate 453*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 454*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FIXNAME), oname, nname); 4550Sstevel@tonic-gate } 4560Sstevel@tonic-gate 4570Sstevel@tonic-gate void 4580Sstevel@tonic-gate Dbg_file_output(Ofl_desc *ofl) 4590Sstevel@tonic-gate { 4600Sstevel@tonic-gate const char *prefix = MSG_ORIG(MSG_PTH_OBJECT); 4610Sstevel@tonic-gate char *oname, *nname, *ofile; 4620Sstevel@tonic-gate int fd; 4630Sstevel@tonic-gate 464*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4650Sstevel@tonic-gate return; 4660Sstevel@tonic-gate if (DBG_NOTDETAIL()) 4670Sstevel@tonic-gate return; 4680Sstevel@tonic-gate 4690Sstevel@tonic-gate /* 4700Sstevel@tonic-gate * Obtain the present input object filename for concatenation to the 4710Sstevel@tonic-gate * prefix name. 4720Sstevel@tonic-gate */ 4730Sstevel@tonic-gate oname = (char *)ofl->ofl_name; 4740Sstevel@tonic-gate if ((ofile = strrchr(oname, '/')) == NULL) 4750Sstevel@tonic-gate ofile = oname; 4760Sstevel@tonic-gate else 4770Sstevel@tonic-gate ofile++; 4780Sstevel@tonic-gate 4790Sstevel@tonic-gate /* 4800Sstevel@tonic-gate * Concatenate the prefix with the object filename, open the file and 4810Sstevel@tonic-gate * write out the present Elf memory image. As this is debugging we 4820Sstevel@tonic-gate * ignore all errors. 4830Sstevel@tonic-gate */ 484*1618Srie if ((nname = malloc(strlen(prefix) + strlen(ofile) + 1)) != 0) { 4850Sstevel@tonic-gate (void) strcpy(nname, prefix); 4860Sstevel@tonic-gate (void) strcat(nname, ofile); 4870Sstevel@tonic-gate if ((fd = open(nname, O_RDWR | O_CREAT | O_TRUNC, 4880Sstevel@tonic-gate 0666)) != -1) { 489*1618Srie (void) write(fd, ofl->ofl_nehdr, ofl->ofl_size); 490*1618Srie (void) close(fd); 4910Sstevel@tonic-gate } 4920Sstevel@tonic-gate free(nname); 4930Sstevel@tonic-gate } 4940Sstevel@tonic-gate } 4950Sstevel@tonic-gate 4960Sstevel@tonic-gate void 497*1618Srie Dbg_file_config_dis(Lm_list *lml, const char *config, int features) 4980Sstevel@tonic-gate { 4990Sstevel@tonic-gate const char *str; 5000Sstevel@tonic-gate int error = features & ~CONF_FEATMSK; 5010Sstevel@tonic-gate 5020Sstevel@tonic-gate if (error == DBG_CONF_IGNORE) 5030Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_1); 5040Sstevel@tonic-gate else if (error == DBG_CONF_VERSION) 5050Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_2); 5060Sstevel@tonic-gate else if (error == DBG_CONF_PRCFAIL) 5070Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_3); 5080Sstevel@tonic-gate else if (error == DBG_CONF_CORRUPT) 5090Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_4); 5100Sstevel@tonic-gate else 511*1618Srie str = conv_config_feat(features); 5120Sstevel@tonic-gate 513*1618Srie Dbg_util_nl(lml, DBG_NL_FRC); 514*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_CONFIG_ERR), config, str); 515*1618Srie Dbg_util_nl(lml, DBG_NL_FRC); 5160Sstevel@tonic-gate } 5170Sstevel@tonic-gate 5180Sstevel@tonic-gate void 519*1618Srie Dbg_file_config_obj(Lm_list *lml, const char *dir, const char *file, 520*1618Srie const char *config) 5210Sstevel@tonic-gate { 5220Sstevel@tonic-gate char *name, _name[PATH_MAX]; 5230Sstevel@tonic-gate 524*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 5250Sstevel@tonic-gate return; 5260Sstevel@tonic-gate 5270Sstevel@tonic-gate if (file) { 5280Sstevel@tonic-gate (void) snprintf(_name, PATH_MAX, MSG_ORIG(MSG_FMT_PATH), 5290Sstevel@tonic-gate dir, file); 5300Sstevel@tonic-gate name = _name; 5310Sstevel@tonic-gate } else 5320Sstevel@tonic-gate name = (char *)dir; 5330Sstevel@tonic-gate 534*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_CONFIG), name, config); 535*1618Srie } 536*1618Srie 537*1618Srie void 538*1618Srie Dbg_file_del_rescan(Lm_list *lml) 539*1618Srie { 540*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 541*1618Srie return; 542*1618Srie 543*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 544*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEL_RESCAN)); 545*1618Srie } 546*1618Srie 547*1618Srie void 548*1618Srie Dbg_file_mode_promote(Rt_map *lmp, int mode) 549*1618Srie { 550*1618Srie Lm_list *lml = LIST(lmp); 551*1618Srie 552*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 553*1618Srie return; 554*1618Srie 555*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 556*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_PROMOTE), NAME(lmp), 557*1618Srie conv_dl_mode(mode, 0)); 558*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 5590Sstevel@tonic-gate } 5600Sstevel@tonic-gate 561*1618Srie void 562*1618Srie Dbg_file_cntl(Lm_list *lml, Aliste flmco, Aliste tlmco) 563*1618Srie { 564*1618Srie Lm_cntl *lmc; 565*1618Srie Aliste off; 566*1618Srie 567*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 568*1618Srie return; 569*1618Srie if (DBG_NOTDETAIL()) 570*1618Srie return; 571*1618Srie 572*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 573*1618Srie dbg_print(lml, MSG_INTL(MSG_CNTL_TITLE), EC_XWORD(flmco), 574*1618Srie EC_XWORD(tlmco)); 575*1618Srie 576*1618Srie for (ALIST_TRAVERSE(lml->lm_lists, off, lmc)) { 577*1618Srie Rt_map *lmp; 578*1618Srie 579*1618Srie /* LINTED */ 580*1618Srie for (lmp = lmc->lc_head; lmp; lmp = (Rt_map *)NEXT(lmp)) 581*1618Srie dbg_print(lml, MSG_ORIG(MSG_CNTL_ENTRY), EC_XWORD(off), 582*1618Srie NAME(lmp)); 583*1618Srie } 584*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 585*1618Srie } 586*1618Srie 587*1618Srie void 588*1618Srie Dbg_file_ar_rescan(Lm_list *lml) 589*1618Srie { 590*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 591*1618Srie return; 5920Sstevel@tonic-gate 593*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 594*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_AR_RESCAN)); 595*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 596*1618Srie } 597*1618Srie 598*1618Srie void 599*1618Srie Dbg_file_ar(Lm_list *lml, const char *name, int again) 600*1618Srie { 601*1618Srie const char *str; 602*1618Srie 603*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 604*1618Srie return; 605*1618Srie 606*1618Srie if (again) 607*1618Srie str = MSG_INTL(MSG_STR_AGAIN); 608*1618Srie else 609*1618Srie str = MSG_ORIG(MSG_STR_EMPTY); 610*1618Srie 611*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 612*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_ARCHIVE), name, str); 613*1618Srie } 614*1618Srie 615*1618Srie void 616*1618Srie Dbg_file_generic(Lm_list *lml, Ifl_desc *ifl) 617*1618Srie { 618*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 619*1618Srie return; 620*1618Srie 621*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 622*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BASIC), ifl->ifl_name, 623*1618Srie conv_ehdr_type(ifl->ifl_ehdr->e_type)); 624*1618Srie } 625*1618Srie 626*1618Srie static const Msg 6270Sstevel@tonic-gate reject[] = { 6280Sstevel@tonic-gate MSG_STR_EMPTY, 6290Sstevel@tonic-gate MSG_REJ_MACH, /* MSG_INTL(MSG_REJ_MACH) */ 6300Sstevel@tonic-gate MSG_REJ_CLASS, /* MSG_INTL(MSG_REJ_CLASS) */ 6310Sstevel@tonic-gate MSG_REJ_DATA, /* MSG_INTL(MSG_REJ_DATA) */ 6320Sstevel@tonic-gate MSG_REJ_TYPE, /* MSG_INTL(MSG_REJ_TYPE) */ 6330Sstevel@tonic-gate MSG_REJ_BADFLAG, /* MSG_INTL(MSG_REJ_BADFLAG) */ 6340Sstevel@tonic-gate MSG_REJ_MISFLAG, /* MSG_INTL(MSG_REJ_MISFLAG) */ 6350Sstevel@tonic-gate MSG_REJ_VERSION, /* MSG_INTL(MSG_REJ_VERSION) */ 6360Sstevel@tonic-gate MSG_REJ_HAL, /* MSG_INTL(MSG_REJ_HAL) */ 6370Sstevel@tonic-gate MSG_REJ_US3, /* MSG_INTL(MSG_REJ_US3) */ 6380Sstevel@tonic-gate MSG_REJ_STR, /* MSG_INTL(MSG_REJ_STR) */ 6390Sstevel@tonic-gate MSG_REJ_UNKFILE, /* MSG_INTL(MSG_REJ_UNKFILE) */ 6400Sstevel@tonic-gate MSG_REJ_HWCAP_1, /* MSG_INTL(MSG_REJ_HWCAP_1) */ 6410Sstevel@tonic-gate }; 6420Sstevel@tonic-gate 6430Sstevel@tonic-gate void 644*1618Srie Dbg_file_rejected(Lm_list *lml, Rej_desc *rej) 6450Sstevel@tonic-gate { 646*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6470Sstevel@tonic-gate return; 6480Sstevel@tonic-gate 649*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 650*1618Srie dbg_print(lml, MSG_INTL(reject[rej->rej_type]), rej->rej_name ? 651*1618Srie rej->rej_name : MSG_INTL(MSG_STR_UNKNOWN), conv_reject_desc(rej)); 652*1618Srie Dbg_util_nl(lml, DBG_NL_STD); 6530Sstevel@tonic-gate } 6540Sstevel@tonic-gate 6550Sstevel@tonic-gate void 656*1618Srie Dbg_file_reuse(Lm_list *lml, const char *nname, const char *oname) 6570Sstevel@tonic-gate { 658*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6590Sstevel@tonic-gate return; 6600Sstevel@tonic-gate 661*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_REUSE), nname, oname); 6620Sstevel@tonic-gate } 6630Sstevel@tonic-gate 6640Sstevel@tonic-gate void 665*1618Srie Dbg_file_skip(Lm_list *lml, const char *oname, const char *nname) 6660Sstevel@tonic-gate { 667*1618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6680Sstevel@tonic-gate return; 6690Sstevel@tonic-gate 670*1618Srie if (oname && strcmp(nname, oname)) 671*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_SKIP_1), nname, oname); 672*1618Srie else 673*1618Srie dbg_print(lml, MSG_INTL(MSG_FIL_SKIP_2), nname); 6740Sstevel@tonic-gate } 675