10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51618Srie * Common Development and Distribution License (the "License"). 61618Srie * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 21685Srie 220Sstevel@tonic-gate /* 23*3731Srie * Copyright 2007 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> 341618Srie #include <libld.h> 351618Srie #include <rtld.h> 361618Srie #include <conv.h> 370Sstevel@tonic-gate #include "msg.h" 380Sstevel@tonic-gate #include "_debug.h" 390Sstevel@tonic-gate 400Sstevel@tonic-gate void 411618Srie Dbg_file_analyze(Rt_map *lmp) 420Sstevel@tonic-gate { 431618Srie Lm_list *lml = LIST(lmp); 441618Srie 451618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 460Sstevel@tonic-gate return; 470Sstevel@tonic-gate 481618Srie Dbg_util_nl(lml, DBG_NL_STD); 491618Srie dbg_print(lml, MSG_INTL(MSG_FIL_ANALYZE), NAME(lmp), 501618Srie conv_dl_mode(MODE(lmp), 1)); 510Sstevel@tonic-gate } 520Sstevel@tonic-gate 530Sstevel@tonic-gate void 541618Srie Dbg_file_aout(Lm_list *lml, const char *name, ulong_t dynamic, ulong_t base, 551618Srie ulong_t size, const char *lmid, Aliste lmco) 560Sstevel@tonic-gate { 571618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 580Sstevel@tonic-gate return; 590Sstevel@tonic-gate 601618Srie dbg_print(lml, MSG_INTL(MSG_FIL_AOUT), name); 611618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_DB), EC_XWORD(dynamic), 621618Srie EC_ADDR(base)); 631618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_S), EC_XWORD(size)); 641618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_LL), lmid, EC_XWORD(lmco)); 650Sstevel@tonic-gate } 660Sstevel@tonic-gate 670Sstevel@tonic-gate void 681618Srie Dbg_file_elf(Lm_list *lml, const char *name, ulong_t dynamic, ulong_t base, 691618Srie ulong_t size, ulong_t entry, const char *lmid, Aliste lmco) 700Sstevel@tonic-gate { 710Sstevel@tonic-gate const char *str; 720Sstevel@tonic-gate 731618Srie 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 811618Srie dbg_print(lml, MSG_INTL(MSG_FIL_ELF), name, str); 821618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_DB), EC_XWORD(dynamic), 831618Srie EC_ADDR(base)); 841618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_SE), EC_XWORD(size), 851618Srie EC_XWORD(entry)); 861618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_LL), lmid, EC_XWORD(lmco)); 870Sstevel@tonic-gate } 880Sstevel@tonic-gate 890Sstevel@tonic-gate void 901618Srie Dbg_file_ldso(Rt_map *lmp, char **envp, auxv_t *auxv, const char *lmid, 911618Srie Aliste lmco) 920Sstevel@tonic-gate { 931618Srie Lm_list *lml = LIST(lmp); 941618Srie 951618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 960Sstevel@tonic-gate return; 970Sstevel@tonic-gate 981618Srie Dbg_util_nl(lml, DBG_NL_STD); 991618Srie dbg_print(lml, MSG_INTL(MSG_FIL_LDSO), PATHNAME(lmp)); 1001618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_DB), EC_NATPTR(DYN(lmp)), 1011618Srie EC_ADDR(ADDR(lmp))); 1021618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_EA), EC_NATPTR(envp), 1031618Srie EC_NATPTR(auxv)); 1041618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_LL), lmid, EC_XWORD(lmco)); 1051618Srie Dbg_util_nl(lml, DBG_NL_STD); 1061618Srie } 1071618Srie 1081618Srie 1091618Srie void 1101618Srie Dbg_file_prot(Rt_map *lmp, int prot) 1111618Srie { 1121618Srie Lm_list *lml = LIST(lmp); 1131618Srie 1141618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 1151618Srie return; 1161618Srie 1171618Srie Dbg_util_nl(lml, DBG_NL_STD); 1181618Srie dbg_print(lml, MSG_INTL(MSG_FIL_PROT), NAME(lmp), (prot ? '+' : '-')); 1190Sstevel@tonic-gate } 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate void 1221618Srie Dbg_file_delete(Rt_map *lmp) 1230Sstevel@tonic-gate { 1241618Srie Lm_list *lml = LIST(lmp); 1251618Srie 1261618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 1270Sstevel@tonic-gate return; 1280Sstevel@tonic-gate 1291618Srie Dbg_util_nl(lml, DBG_NL_STD); 1301618Srie 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 { 1391618Srie 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 */ 149*3731Srie switch (type) { 150*3731Srie case DBG_DEP_CREATE: 1510Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_CREATE; /* MSG_INTL(MSG_FIL_HDL_CREATE) */ 152*3731Srie break; 153*3731Srie case DBG_DEP_ADD: 1540Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_ADD; /* MSG_INTL(MSG_FIL_HDL_ADD) */ 155*3731Srie break; 156*3731Srie case DBG_DEP_DELETE: 1570Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_DELETE; /* MSG_INTL(MSG_FIL_HDL_DELETE) */ 158*3731Srie break; 159*3731Srie case DBG_DEP_ORPHAN: 1600Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_ORPHAN; /* MSG_INTL(MSG_FIL_HDL_ORPHAN) */ 161*3731Srie break; 162*3731Srie case DBG_DEP_REINST: 1630Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_REINST; /* MSG_INTL(MSG_FIL_HDL_REINST) */ 164*3731Srie break; 165*3731Srie default: 1660Sstevel@tonic-gate hdl_str = 0; 167*3731Srie break; 168*3731Srie } 1690Sstevel@tonic-gate } 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate void 1721618Srie Dbg_file_hdl_collect(Grp_hdl *ghp, const char *name) 1730Sstevel@tonic-gate { 1741618Srie Lm_list *lml = ghp->gh_ownlml; 1751618Srie const char *str; 1760Sstevel@tonic-gate 1771618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 1780Sstevel@tonic-gate return; 1790Sstevel@tonic-gate if (DBG_NOTDETAIL()) 1800Sstevel@tonic-gate return; 1810Sstevel@tonic-gate 1821618Srie if (ghp->gh_ownlmp) 1831618Srie str = NAME(ghp->gh_ownlmp); 1840Sstevel@tonic-gate else 1850Sstevel@tonic-gate str = MSG_INTL(MSG_STR_ORPHAN); 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate if (hdl_title) { 1880Sstevel@tonic-gate hdl_title = 0; 1891618Srie Dbg_util_nl(lml, DBG_NL_STD); 1900Sstevel@tonic-gate } 1910Sstevel@tonic-gate if (name) 1921618Srie dbg_print(lml, MSG_INTL(MSG_FIL_HDL_RETAIN), str, name); 1930Sstevel@tonic-gate else 1941618Srie dbg_print(lml, MSG_INTL(MSG_FIL_HDL_COLLECT), str, 1951618Srie conv_grphdl_flags(ghp->gh_flags)); 1960Sstevel@tonic-gate } 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate void 199*3731Srie Dbg_file_hdl_action(Grp_hdl *ghp, Rt_map *lmp, int type, uint_t flags) 2000Sstevel@tonic-gate { 201*3731Srie const char *mode, *group; 202*3731Srie Lm_list *lml = LIST(lmp); 203*3731Srie Msg str; 2040Sstevel@tonic-gate 2051618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 2060Sstevel@tonic-gate return; 2070Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2080Sstevel@tonic-gate return; 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate if (hdl_title) { 2111618Srie Dbg_util_nl(lml, DBG_NL_STD); 2120Sstevel@tonic-gate if (hdl_str) { 2130Sstevel@tonic-gate const char *name; 2140Sstevel@tonic-gate 2150Sstevel@tonic-gate /* 2160Sstevel@tonic-gate * Protect ourselves in case this handle has no 2170Sstevel@tonic-gate * originating owner. 2180Sstevel@tonic-gate */ 2191618Srie if (ghp->gh_ownlmp) 2201618Srie name = NAME(ghp->gh_ownlmp); 2210Sstevel@tonic-gate else 2220Sstevel@tonic-gate name = MSG_INTL(MSG_STR_UNKNOWN); 2230Sstevel@tonic-gate 2241618Srie dbg_print(lml, MSG_INTL(hdl_str), name); 2250Sstevel@tonic-gate } 2260Sstevel@tonic-gate hdl_title = 0; 2270Sstevel@tonic-gate } 2280Sstevel@tonic-gate 229*3731Srie switch (type) { 230*3731Srie case DBG_DEP_ADD: 2310Sstevel@tonic-gate str = MSG_FIL_DEP_ADD; /* MSG_INTL(MSG_FIL_DEP_ADD) */ 232*3731Srie break; 233*3731Srie case DBG_DEP_DELETE: 2340Sstevel@tonic-gate str = MSG_FIL_DEP_DELETE; /* MSG_INTL(MSG_FIL_DEP_DELETE) */ 235*3731Srie break; 236*3731Srie case DBG_DEP_REMOVE: 2370Sstevel@tonic-gate str = MSG_FIL_DEP_REMOVE; /* MSG_INTL(MSG_FIL_DEP_REMOVE) */ 238*3731Srie break; 239*3731Srie case DBG_DEP_REMAIN: 2400Sstevel@tonic-gate str = MSG_FIL_DEP_REMAIN; /* MSG_INTL(MSG_FIL_DEP_REMAIN) */ 241*3731Srie break; 242*3731Srie case DBG_DEP_ORPHAN: 243*3731Srie str = MSG_FIL_DEP_ORPHAN; /* MSG_INTL(MSG_FIL_DEP_ORPHAN) */ 244*3731Srie break; 245*3731Srie case DBG_DEP_REINST: 246*3731Srie str = MSG_FIL_DEP_REINST; /* MSG_INTL(MSG_FIL_DEP_REINST) */ 247*3731Srie break; 248*3731Srie default: 249*3731Srie return; 250*3731Srie } 2510Sstevel@tonic-gate 252*3731Srie if ((type == DBG_DEP_ADD) && flags) 253*3731Srie group = conv_grpdesc_flags(flags); 254*3731Srie else 255*3731Srie group = MSG_ORIG(MSG_STR_EMPTY); 2560Sstevel@tonic-gate 257*3731Srie if ((MODE(lmp) & (RTLD_GLOBAL | RTLD_NODELETE)) == 258*3731Srie (RTLD_GLOBAL | RTLD_NODELETE)) 259*3731Srie mode = MSG_ORIG(MSG_MODE_GLOBNODEL); 260*3731Srie else if (MODE(lmp) & RTLD_GLOBAL) 261*3731Srie mode = MSG_ORIG(MSG_MODE_GLOB); 2620Sstevel@tonic-gate 263*3731Srie else if (MODE(lmp) & RTLD_NODELETE) 264*3731Srie mode = MSG_ORIG(MSG_MODE_NODEL); 265*3731Srie else 266*3731Srie mode = MSG_ORIG(MSG_STR_EMPTY); 267*3731Srie 268*3731Srie dbg_print(lml, MSG_INTL(str), NAME(lmp), mode, group); 2690Sstevel@tonic-gate } 2700Sstevel@tonic-gate 2710Sstevel@tonic-gate void 2721618Srie Dbg_file_bind_entry(Lm_list *lml, Bnd_desc *bdp) 2730Sstevel@tonic-gate { 2741618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 2750Sstevel@tonic-gate return; 2760Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2770Sstevel@tonic-gate return; 2780Sstevel@tonic-gate 2790Sstevel@tonic-gate /* 2800Sstevel@tonic-gate * Print the dependency together with the modes of the binding. 2810Sstevel@tonic-gate */ 2821618Srie Dbg_util_nl(lml, DBG_NL_STD); 2831618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BND_ADD), NAME(bdp->b_caller)); 2841618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BND_FILE), NAME(bdp->b_depend), 2851618Srie conv_bnd_type(bdp->b_flags)); 286280Srie } 287280Srie 288280Srie void 2891618Srie Dbg_file_bindings(Rt_map *lmp, int flag) 290280Srie { 291280Srie const char *str; 292280Srie Rt_map *tlmp; 2931618Srie Lm_list *lml = LIST(lmp); 294280Srie int next = 0; 295280Srie 2961618Srie if (DBG_NOTCLASS(DBG_C_INIT)) 297280Srie return; 298280Srie if (DBG_NOTDETAIL()) 299280Srie return; 300280Srie 301280Srie if (flag & RT_SORT_REV) 302280Srie str = MSG_ORIG(MSG_SCN_INIT); 303280Srie else 304280Srie str = MSG_ORIG(MSG_SCN_FINI); 305280Srie 3061618Srie Dbg_util_nl(lml, DBG_NL_STD); 3071618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEP_TITLE), str, 3081618Srie conv_bnd_obj(lml->lm_flags)); 309280Srie 310280Srie /* LINTED */ 311280Srie for (tlmp = lmp; tlmp; tlmp = (Rt_map *)NEXT(tlmp)) { 3121618Srie Bnd_desc **bdpp; 313280Srie Aliste off; 314280Srie 315280Srie /* 316280Srie * For .init processing, only collect objects that have been 317280Srie * relocated and haven't already been collected. 318280Srie * For .fini processing, only collect objects that have had 319280Srie * their .init collected, and haven't already been .fini 320280Srie * collected. 321280Srie */ 322280Srie if (flag & RT_SORT_REV) { 323280Srie if ((FLAGS(tlmp) & (FLG_RT_RELOCED | 324280Srie FLG_RT_INITCLCT)) != FLG_RT_RELOCED) 325280Srie continue; 326280Srie 327280Srie } else { 328280Srie if ((flag & RT_SORT_DELETE) && 329280Srie ((FLAGS(tlmp) & FLG_RT_DELETE) == 0)) 330280Srie continue; 331280Srie if (((FLAGS(tlmp) & 332280Srie (FLG_RT_INITCLCT | FLG_RT_FINICLCT)) == 333280Srie FLG_RT_INITCLCT) == 0) 334280Srie continue; 335280Srie } 336280Srie 337280Srie if (next++) 3381618Srie Dbg_util_nl(lml, DBG_NL_STD); 339280Srie 340280Srie if (DEPENDS(tlmp) == 0) 3411618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEP_NONE), NAME(tlmp)); 342280Srie else { 3431618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEP_ENT), NAME(tlmp)); 344280Srie 345280Srie for (ALIST_TRAVERSE(DEPENDS(tlmp), off, bdpp)) { 3461618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BND_FILE), 347280Srie NAME((*bdpp)->b_depend), 3481618Srie conv_bnd_type((*bdpp)->b_flags)); 349280Srie } 350280Srie } 351280Srie } 3521618Srie Dbg_util_nl(lml, DBG_NL_STD); 3530Sstevel@tonic-gate } 3540Sstevel@tonic-gate 3550Sstevel@tonic-gate void 3561618Srie Dbg_file_dlopen(Rt_map *clmp, const char *name, int mode) 3570Sstevel@tonic-gate { 3581618Srie Lm_list *lml = LIST(clmp); 3591618Srie 3601618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 3610Sstevel@tonic-gate return; 3620Sstevel@tonic-gate 3631618Srie Dbg_util_nl(lml, DBG_NL_STD); 3641618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DLOPEN), name, NAME(clmp), 3651618Srie conv_dl_mode(mode, 1)); 3660Sstevel@tonic-gate } 3670Sstevel@tonic-gate 3680Sstevel@tonic-gate void 3691618Srie Dbg_file_dlclose(Lm_list *lml, const char *name, int flag) 3700Sstevel@tonic-gate { 3710Sstevel@tonic-gate const char *str; 3720Sstevel@tonic-gate 3731618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 3740Sstevel@tonic-gate return; 3750Sstevel@tonic-gate 3760Sstevel@tonic-gate if (flag == DBG_DLCLOSE_IGNORE) 3770Sstevel@tonic-gate str = MSG_INTL(MSG_STR_IGNORE); 3780Sstevel@tonic-gate else 3790Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 3800Sstevel@tonic-gate 3811618Srie Dbg_util_nl(lml, DBG_NL_STD); 3821618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DLCLOSE), name, str); 3830Sstevel@tonic-gate } 3840Sstevel@tonic-gate 3850Sstevel@tonic-gate void 3861618Srie Dbg_file_dldump(Rt_map *lmp, const char *path, int flags) 3870Sstevel@tonic-gate { 3881618Srie Lm_list *lml = LIST(lmp); 3891618Srie 3901618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 3910Sstevel@tonic-gate return; 3920Sstevel@tonic-gate 3931618Srie Dbg_util_nl(lml, DBG_NL_STD); 3941618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DLDUMP), NAME(lmp), path, 3951618Srie conv_dl_flag(flags, 0)); 3960Sstevel@tonic-gate } 3970Sstevel@tonic-gate 3980Sstevel@tonic-gate void 3991618Srie Dbg_file_lazyload(Rt_map *clmp, const char *fname, const char *sname) 4000Sstevel@tonic-gate { 4011618Srie Lm_list *lml = LIST(clmp); 4021618Srie 4031618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4040Sstevel@tonic-gate return; 4050Sstevel@tonic-gate 4061618Srie Dbg_util_nl(lml, DBG_NL_STD); 4071618Srie dbg_print(lml, MSG_INTL(MSG_FIL_LAZYLOAD), fname, NAME(clmp), 4081618Srie Dbg_demangle_name(sname)); 4090Sstevel@tonic-gate } 4100Sstevel@tonic-gate 4110Sstevel@tonic-gate void 4121618Srie Dbg_file_preload(Lm_list *lml, const char *name) 4130Sstevel@tonic-gate { 4141618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4150Sstevel@tonic-gate return; 4160Sstevel@tonic-gate 4171618Srie Dbg_util_nl(lml, DBG_NL_STD); 4181618Srie dbg_print(lml, MSG_INTL(MSG_FIL_PRELOAD), name); 4190Sstevel@tonic-gate } 4200Sstevel@tonic-gate 4210Sstevel@tonic-gate void 4221618Srie Dbg_file_needed(Rt_map *lmp, const char *name) 4230Sstevel@tonic-gate { 4241618Srie Lm_list *lml = LIST(lmp); 4251618Srie 4261618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4270Sstevel@tonic-gate return; 4280Sstevel@tonic-gate 4291618Srie Dbg_util_nl(lml, DBG_NL_STD); 4301618Srie dbg_print(lml, MSG_INTL(MSG_FIL_NEEDED), name, NAME(lmp)); 4310Sstevel@tonic-gate } 4320Sstevel@tonic-gate 4330Sstevel@tonic-gate void 4341618Srie Dbg_file_filter(Lm_list *lml, const char *filter, const char *filtee, 4351618Srie int config) 4360Sstevel@tonic-gate { 4371618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4380Sstevel@tonic-gate return; 4390Sstevel@tonic-gate 4401618Srie Dbg_util_nl(lml, DBG_NL_STD); 4410Sstevel@tonic-gate if (config) 4421618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTER_1), filter, filtee); 4430Sstevel@tonic-gate else 4441618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTER_2), filter, filtee); 4450Sstevel@tonic-gate } 4460Sstevel@tonic-gate 4470Sstevel@tonic-gate void 4481618Srie Dbg_file_filtee(Lm_list *lml, const char *filter, const char *filtee, int audit) 4490Sstevel@tonic-gate { 4500Sstevel@tonic-gate if (audit) { 4511618Srie if (DBG_NOTCLASS(DBG_C_AUDITING | DBG_C_FILES)) 4520Sstevel@tonic-gate return; 4530Sstevel@tonic-gate 4541618Srie Dbg_util_nl(lml, DBG_NL_STD); 4551618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTEE_3), filtee); 4560Sstevel@tonic-gate } else { 4571618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4580Sstevel@tonic-gate return; 4590Sstevel@tonic-gate 4601618Srie Dbg_util_nl(lml, DBG_NL_STD); 4610Sstevel@tonic-gate if (filter) 4621618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTEE_1), filtee, 4631618Srie filter); 4640Sstevel@tonic-gate else 4651618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTEE_2), filtee); 4660Sstevel@tonic-gate } 4670Sstevel@tonic-gate } 4680Sstevel@tonic-gate 4690Sstevel@tonic-gate void 4701618Srie Dbg_file_fixname(Lm_list *lml, const char *oname, const char *nname) 4710Sstevel@tonic-gate { 4721618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4730Sstevel@tonic-gate return; 4740Sstevel@tonic-gate 4751618Srie Dbg_util_nl(lml, DBG_NL_STD); 4761618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FIXNAME), oname, nname); 4770Sstevel@tonic-gate } 4780Sstevel@tonic-gate 4790Sstevel@tonic-gate void 4800Sstevel@tonic-gate Dbg_file_output(Ofl_desc *ofl) 4810Sstevel@tonic-gate { 4820Sstevel@tonic-gate const char *prefix = MSG_ORIG(MSG_PTH_OBJECT); 4830Sstevel@tonic-gate char *oname, *nname, *ofile; 4840Sstevel@tonic-gate int fd; 4850Sstevel@tonic-gate 4861618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4870Sstevel@tonic-gate return; 4880Sstevel@tonic-gate if (DBG_NOTDETAIL()) 4890Sstevel@tonic-gate return; 4900Sstevel@tonic-gate 4910Sstevel@tonic-gate /* 4920Sstevel@tonic-gate * Obtain the present input object filename for concatenation to the 4930Sstevel@tonic-gate * prefix name. 4940Sstevel@tonic-gate */ 4950Sstevel@tonic-gate oname = (char *)ofl->ofl_name; 4960Sstevel@tonic-gate if ((ofile = strrchr(oname, '/')) == NULL) 4970Sstevel@tonic-gate ofile = oname; 4980Sstevel@tonic-gate else 4990Sstevel@tonic-gate ofile++; 5000Sstevel@tonic-gate 5010Sstevel@tonic-gate /* 5020Sstevel@tonic-gate * Concatenate the prefix with the object filename, open the file and 5030Sstevel@tonic-gate * write out the present Elf memory image. As this is debugging we 5040Sstevel@tonic-gate * ignore all errors. 5050Sstevel@tonic-gate */ 5061618Srie if ((nname = malloc(strlen(prefix) + strlen(ofile) + 1)) != 0) { 5070Sstevel@tonic-gate (void) strcpy(nname, prefix); 5080Sstevel@tonic-gate (void) strcat(nname, ofile); 5090Sstevel@tonic-gate if ((fd = open(nname, O_RDWR | O_CREAT | O_TRUNC, 5100Sstevel@tonic-gate 0666)) != -1) { 5111618Srie (void) write(fd, ofl->ofl_nehdr, ofl->ofl_size); 5121618Srie (void) close(fd); 5130Sstevel@tonic-gate } 5140Sstevel@tonic-gate free(nname); 5150Sstevel@tonic-gate } 5160Sstevel@tonic-gate } 5170Sstevel@tonic-gate 5180Sstevel@tonic-gate void 5191618Srie Dbg_file_config_dis(Lm_list *lml, const char *config, int features) 5200Sstevel@tonic-gate { 5210Sstevel@tonic-gate const char *str; 5220Sstevel@tonic-gate 5231976Sab196087 switch (features & ~CONF_FEATMSK) { 5241976Sab196087 case DBG_CONF_IGNORE: 5250Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_1); 5261976Sab196087 break; 5271976Sab196087 case DBG_CONF_VERSION: 5280Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_2); 5291976Sab196087 break; 5301976Sab196087 case DBG_CONF_PRCFAIL: 5310Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_3); 5321976Sab196087 break; 5331976Sab196087 case DBG_CONF_CORRUPT: 5340Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_4); 5351976Sab196087 break; 5361976Sab196087 case DBG_CONF_ABIMISMATCH: 5371976Sab196087 str = MSG_INTL(MSG_FIL_CONFIG_ERR_5); 5381976Sab196087 break; 5391976Sab196087 default: 5401618Srie str = conv_config_feat(features); 5411976Sab196087 break; 5421976Sab196087 } 5430Sstevel@tonic-gate 5441618Srie Dbg_util_nl(lml, DBG_NL_FRC); 5451618Srie dbg_print(lml, MSG_INTL(MSG_FIL_CONFIG_ERR), config, str); 5461618Srie Dbg_util_nl(lml, DBG_NL_FRC); 5470Sstevel@tonic-gate } 5480Sstevel@tonic-gate 5490Sstevel@tonic-gate void 5501618Srie Dbg_file_config_obj(Lm_list *lml, const char *dir, const char *file, 5511618Srie const char *config) 5520Sstevel@tonic-gate { 5530Sstevel@tonic-gate char *name, _name[PATH_MAX]; 5540Sstevel@tonic-gate 5551618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 5560Sstevel@tonic-gate return; 5570Sstevel@tonic-gate 5580Sstevel@tonic-gate if (file) { 5590Sstevel@tonic-gate (void) snprintf(_name, PATH_MAX, MSG_ORIG(MSG_FMT_PATH), 5600Sstevel@tonic-gate dir, file); 5610Sstevel@tonic-gate name = _name; 5620Sstevel@tonic-gate } else 5630Sstevel@tonic-gate name = (char *)dir; 5640Sstevel@tonic-gate 5651618Srie dbg_print(lml, MSG_INTL(MSG_FIL_CONFIG), name, config); 5661618Srie } 5671618Srie 5681618Srie void 5691618Srie Dbg_file_del_rescan(Lm_list *lml) 5701618Srie { 5711618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 5721618Srie return; 5731618Srie 5741618Srie Dbg_util_nl(lml, DBG_NL_STD); 5751618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEL_RESCAN)); 5761618Srie } 5771618Srie 5781618Srie void 5791618Srie Dbg_file_mode_promote(Rt_map *lmp, int mode) 5801618Srie { 5811618Srie Lm_list *lml = LIST(lmp); 5821618Srie 5831618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 5841618Srie return; 5851618Srie 5861618Srie Dbg_util_nl(lml, DBG_NL_STD); 5871618Srie dbg_print(lml, MSG_INTL(MSG_FIL_PROMOTE), NAME(lmp), 5881618Srie conv_dl_mode(mode, 0)); 5891618Srie Dbg_util_nl(lml, DBG_NL_STD); 5900Sstevel@tonic-gate } 5910Sstevel@tonic-gate 5921618Srie void 5931618Srie Dbg_file_cntl(Lm_list *lml, Aliste flmco, Aliste tlmco) 5941618Srie { 5951618Srie Lm_cntl *lmc; 5961618Srie Aliste off; 5971618Srie 5981618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 5991618Srie return; 6001618Srie if (DBG_NOTDETAIL()) 6011618Srie return; 6021618Srie 6031618Srie Dbg_util_nl(lml, DBG_NL_STD); 6041618Srie dbg_print(lml, MSG_INTL(MSG_CNTL_TITLE), EC_XWORD(flmco), 6051618Srie EC_XWORD(tlmco)); 6061618Srie 6071618Srie for (ALIST_TRAVERSE(lml->lm_lists, off, lmc)) { 6081618Srie Rt_map *lmp; 6091618Srie 6101618Srie /* LINTED */ 6111618Srie for (lmp = lmc->lc_head; lmp; lmp = (Rt_map *)NEXT(lmp)) 6121618Srie dbg_print(lml, MSG_ORIG(MSG_CNTL_ENTRY), EC_XWORD(off), 6131618Srie NAME(lmp)); 6141618Srie } 6151618Srie Dbg_util_nl(lml, DBG_NL_STD); 6161618Srie } 6171618Srie 6181618Srie void 6191618Srie Dbg_file_ar_rescan(Lm_list *lml) 6201618Srie { 6211618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6221618Srie return; 6230Sstevel@tonic-gate 6241618Srie Dbg_util_nl(lml, DBG_NL_STD); 6251618Srie dbg_print(lml, MSG_INTL(MSG_FIL_AR_RESCAN)); 6261618Srie Dbg_util_nl(lml, DBG_NL_STD); 6271618Srie } 6281618Srie 6291618Srie void 6301618Srie Dbg_file_ar(Lm_list *lml, const char *name, int again) 6311618Srie { 6321618Srie const char *str; 6331618Srie 6341618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6351618Srie return; 6361618Srie 6371618Srie if (again) 6381618Srie str = MSG_INTL(MSG_STR_AGAIN); 6391618Srie else 6401618Srie str = MSG_ORIG(MSG_STR_EMPTY); 6411618Srie 6421618Srie Dbg_util_nl(lml, DBG_NL_STD); 6431618Srie dbg_print(lml, MSG_INTL(MSG_FIL_ARCHIVE), name, str); 6441618Srie } 6451618Srie 6461618Srie void 6471618Srie Dbg_file_generic(Lm_list *lml, Ifl_desc *ifl) 6481618Srie { 6491618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6501618Srie return; 6511618Srie 6521618Srie Dbg_util_nl(lml, DBG_NL_STD); 6531618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BASIC), ifl->ifl_name, 6541976Sab196087 conv_ehdr_type(ifl->ifl_ehdr->e_type, 0)); 6551618Srie } 6561618Srie 6571618Srie static const Msg 6580Sstevel@tonic-gate reject[] = { 6590Sstevel@tonic-gate MSG_STR_EMPTY, 6600Sstevel@tonic-gate MSG_REJ_MACH, /* MSG_INTL(MSG_REJ_MACH) */ 6610Sstevel@tonic-gate MSG_REJ_CLASS, /* MSG_INTL(MSG_REJ_CLASS) */ 6620Sstevel@tonic-gate MSG_REJ_DATA, /* MSG_INTL(MSG_REJ_DATA) */ 6630Sstevel@tonic-gate MSG_REJ_TYPE, /* MSG_INTL(MSG_REJ_TYPE) */ 6640Sstevel@tonic-gate MSG_REJ_BADFLAG, /* MSG_INTL(MSG_REJ_BADFLAG) */ 6650Sstevel@tonic-gate MSG_REJ_MISFLAG, /* MSG_INTL(MSG_REJ_MISFLAG) */ 6660Sstevel@tonic-gate MSG_REJ_VERSION, /* MSG_INTL(MSG_REJ_VERSION) */ 6670Sstevel@tonic-gate MSG_REJ_HAL, /* MSG_INTL(MSG_REJ_HAL) */ 6680Sstevel@tonic-gate MSG_REJ_US3, /* MSG_INTL(MSG_REJ_US3) */ 6690Sstevel@tonic-gate MSG_REJ_STR, /* MSG_INTL(MSG_REJ_STR) */ 6700Sstevel@tonic-gate MSG_REJ_UNKFILE, /* MSG_INTL(MSG_REJ_UNKFILE) */ 6710Sstevel@tonic-gate MSG_REJ_HWCAP_1, /* MSG_INTL(MSG_REJ_HWCAP_1) */ 6720Sstevel@tonic-gate }; 6730Sstevel@tonic-gate 6740Sstevel@tonic-gate void 6751618Srie Dbg_file_rejected(Lm_list *lml, Rej_desc *rej) 6760Sstevel@tonic-gate { 6771618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6780Sstevel@tonic-gate return; 6790Sstevel@tonic-gate 6801618Srie Dbg_util_nl(lml, DBG_NL_STD); 6811618Srie dbg_print(lml, MSG_INTL(reject[rej->rej_type]), rej->rej_name ? 6821618Srie rej->rej_name : MSG_INTL(MSG_STR_UNKNOWN), conv_reject_desc(rej)); 6831618Srie Dbg_util_nl(lml, DBG_NL_STD); 6840Sstevel@tonic-gate } 6850Sstevel@tonic-gate 6860Sstevel@tonic-gate void 6871618Srie Dbg_file_reuse(Lm_list *lml, const char *nname, const char *oname) 6880Sstevel@tonic-gate { 6891618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6900Sstevel@tonic-gate return; 6910Sstevel@tonic-gate 6921618Srie dbg_print(lml, MSG_INTL(MSG_FIL_REUSE), nname, oname); 6930Sstevel@tonic-gate } 6940Sstevel@tonic-gate 6950Sstevel@tonic-gate void 6961618Srie Dbg_file_skip(Lm_list *lml, const char *oname, const char *nname) 6970Sstevel@tonic-gate { 6981618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6990Sstevel@tonic-gate return; 7000Sstevel@tonic-gate 7011618Srie if (oname && strcmp(nname, oname)) 7021618Srie dbg_print(lml, MSG_INTL(MSG_FIL_SKIP_1), nname, oname); 7031618Srie else 7041618Srie dbg_print(lml, MSG_INTL(MSG_FIL_SKIP_2), nname); 7050Sstevel@tonic-gate } 7062978Srie 7072978Srie void 7082978Srie Dbg_file_modified(Lm_list *lml, const char *obj, const char *oname, 7092978Srie const char *nname, int ofd, int nfd, Elf *oelf, Elf *nelf) 7102978Srie { 7112978Srie const char *str; 7122978Srie 7132978Srie if (DBG_NOTCLASS(DBG_C_FILES | DBG_C_SUPPORT)) 7142978Srie return; 7152978Srie if (DBG_NOTDETAIL()) 7162978Srie return; 7172978Srie 7182978Srie Dbg_util_nl(lml, DBG_NL_STD); 7192978Srie dbg_print(lml, MSG_INTL(MSG_FIL_MODIFIED), oname, obj); 7202978Srie 7212978Srie if (nname != oname) 7222978Srie dbg_print(lml, MSG_INTL(MSG_FIL_NAMECHANGE), nname); 7232978Srie if (nfd != ofd) { 7242978Srie if (nfd == -1) 7252978Srie str = MSG_INTL(MSG_FIL_IGNORE); 7262978Srie else 7272978Srie str = MSG_ORIG(MSG_STR_EMPTY); 7282978Srie dbg_print(lml, MSG_INTL(MSG_FIL_FDCHANGE), ofd, nfd, str); 7292978Srie } 7302978Srie if (nelf != oelf) { 7312978Srie if (nelf == 0) 7322978Srie str = MSG_INTL(MSG_FIL_IGNORE); 7332978Srie else 7342978Srie str = MSG_ORIG(MSG_STR_EMPTY); 7352978Srie dbg_print(lml, MSG_INTL(MSG_FIL_ELFCHANGE), EC_NATPTR(oelf), 7362978Srie EC_NATPTR(nelf), str); 7372978Srie } 7382978Srie Dbg_util_nl(lml, DBG_NL_STD); 7392978Srie } 740*3731Srie 741*3731Srie void 742*3731Srie Dbg_file_cleanup(Lm_list *lml, const char *name, Aliste lmco) 743*3731Srie { 744*3731Srie if (DBG_NOTCLASS(DBG_C_FILES)) 745*3731Srie return; 746*3731Srie 747*3731Srie Dbg_util_nl(lml, DBG_NL_STD); 748*3731Srie dbg_print(lml, MSG_INTL(MSG_FIL_CLEANUP), name, EC_XWORD(lmco)); 749*3731Srie } 750