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 /* 238598SRod.Evans@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 276Srie #include <sys/auxv.h> 280Sstevel@tonic-gate #include <string.h> 290Sstevel@tonic-gate #include <unistd.h> 300Sstevel@tonic-gate #include <fcntl.h> 310Sstevel@tonic-gate #include <limits.h> 320Sstevel@tonic-gate #include <stdio.h> 331618Srie #include <libld.h> 341618Srie #include <rtld.h> 351618Srie #include <conv.h> 360Sstevel@tonic-gate #include "msg.h" 370Sstevel@tonic-gate #include "_debug.h" 380Sstevel@tonic-gate 390Sstevel@tonic-gate void 401618Srie Dbg_file_analyze(Rt_map *lmp) 410Sstevel@tonic-gate { 424734Sab196087 Conv_dl_mode_buf_t dl_mode_buf; 434734Sab196087 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), 504734Sab196087 conv_dl_mode(MODE(lmp), 1, &dl_mode_buf)); 510Sstevel@tonic-gate } 520Sstevel@tonic-gate 530Sstevel@tonic-gate void 548598SRod.Evans@Sun.COM Dbg_file_mmapobj(Lm_list *lml, const char *name, mmapobj_result_t *ompp, 558598SRod.Evans@Sun.COM uint_t onum) 568598SRod.Evans@Sun.COM { 578598SRod.Evans@Sun.COM mmapobj_result_t *mpp; 588598SRod.Evans@Sun.COM uint_t mnum; 598598SRod.Evans@Sun.COM 608598SRod.Evans@Sun.COM if (DBG_NOTCLASS(DBG_C_FILES)) 618598SRod.Evans@Sun.COM return; 628598SRod.Evans@Sun.COM if (DBG_NOTDETAIL()) 638598SRod.Evans@Sun.COM return; 648598SRod.Evans@Sun.COM 658598SRod.Evans@Sun.COM Dbg_util_nl(lml, DBG_NL_STD); 668598SRod.Evans@Sun.COM dbg_print(lml, MSG_INTL(MSG_FIL_MMAPOBJ), name, onum); 678598SRod.Evans@Sun.COM 688598SRod.Evans@Sun.COM for (mnum = 0, mpp = ompp; mnum < onum; mnum++, mpp++) { 698598SRod.Evans@Sun.COM const char *str; 708598SRod.Evans@Sun.COM uint_t type = MR_GET_TYPE(mpp->mr_flags); 718598SRod.Evans@Sun.COM 728598SRod.Evans@Sun.COM if (type == MR_PADDING) 738598SRod.Evans@Sun.COM str = MSG_ORIG(MSG_MR_PADDING); 748598SRod.Evans@Sun.COM else if (type == MR_HDR_ELF) 758598SRod.Evans@Sun.COM str = MSG_ORIG(MSG_MR_HDR_ELF); 768598SRod.Evans@Sun.COM else if (type == MR_HDR_AOUT) 778598SRod.Evans@Sun.COM str = MSG_ORIG(MSG_MR_HDR_AOUT); 788598SRod.Evans@Sun.COM else 798598SRod.Evans@Sun.COM str = MSG_ORIG(MSG_STR_EMPTY); 808598SRod.Evans@Sun.COM 818598SRod.Evans@Sun.COM dbg_print(lml, MSG_INTL(MSG_FIL_MMAPOBJ_1), mnum, 828598SRod.Evans@Sun.COM EC_NATPTR(mpp->mr_addr), EC_OFF(mpp->mr_fsize), str); 838598SRod.Evans@Sun.COM dbg_print(lml, MSG_INTL(MSG_FIL_MMAPOBJ_2), 848598SRod.Evans@Sun.COM EC_OFF(mpp->mr_offset), EC_OFF(mpp->mr_msize)); 858598SRod.Evans@Sun.COM } 868598SRod.Evans@Sun.COM Dbg_util_nl(lml, DBG_NL_STD); 878598SRod.Evans@Sun.COM } 888598SRod.Evans@Sun.COM 898598SRod.Evans@Sun.COM void 908598SRod.Evans@Sun.COM Dbg_file_aout(Lm_list *lml, const char *name, Addr addr, size_t size, 918598SRod.Evans@Sun.COM const char *lmid, Aliste lmco) 920Sstevel@tonic-gate { 931618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 940Sstevel@tonic-gate return; 950Sstevel@tonic-gate 961618Srie dbg_print(lml, MSG_INTL(MSG_FIL_AOUT), name); 978598SRod.Evans@Sun.COM dbg_print(lml, MSG_INTL(MSG_FIL_DATA_AS), EC_ADDR(addr), EC_OFF(size)); 981618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_LL), lmid, EC_XWORD(lmco)); 990Sstevel@tonic-gate } 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate void 1028598SRod.Evans@Sun.COM Dbg_file_elf(Lm_list *lml, const char *name, Addr addr, size_t size, 1038598SRod.Evans@Sun.COM const char *lmid, Aliste lmco) 1040Sstevel@tonic-gate { 1050Sstevel@tonic-gate const char *str; 1060Sstevel@tonic-gate 1071618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 1080Sstevel@tonic-gate return; 1090Sstevel@tonic-gate 1108598SRod.Evans@Sun.COM if (addr == 0) 1110Sstevel@tonic-gate str = MSG_INTL(MSG_STR_TEMPORARY); 1120Sstevel@tonic-gate else 1130Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 1140Sstevel@tonic-gate 1151618Srie dbg_print(lml, MSG_INTL(MSG_FIL_ELF), name, str); 1168598SRod.Evans@Sun.COM dbg_print(lml, MSG_INTL(MSG_FIL_DATA_AS), EC_ADDR(addr), EC_OFF(size)); 1171618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_LL), lmid, EC_XWORD(lmco)); 1180Sstevel@tonic-gate } 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate void 1211618Srie Dbg_file_ldso(Rt_map *lmp, char **envp, auxv_t *auxv, const char *lmid, 1221618Srie Aliste lmco) 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_LDSO), PATHNAME(lmp)); 1318598SRod.Evans@Sun.COM dbg_print(lml, MSG_INTL(MSG_FIL_DATA_AS), EC_ADDR(ADDR(lmp)), 1328598SRod.Evans@Sun.COM EC_OFF(MSIZE(lmp))); 1331618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_EA), EC_NATPTR(envp), 1341618Srie EC_NATPTR(auxv)); 1351618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_LL), lmid, EC_XWORD(lmco)); 1361618Srie Dbg_util_nl(lml, DBG_NL_STD); 1371618Srie } 1381618Srie 1391618Srie 1401618Srie void 1411618Srie Dbg_file_prot(Rt_map *lmp, int prot) 1421618Srie { 1431618Srie Lm_list *lml = LIST(lmp); 1441618Srie 1451618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 1461618Srie return; 1471618Srie 1481618Srie Dbg_util_nl(lml, DBG_NL_STD); 1491618Srie dbg_print(lml, MSG_INTL(MSG_FIL_PROT), NAME(lmp), (prot ? '+' : '-')); 1500Sstevel@tonic-gate } 1510Sstevel@tonic-gate 1520Sstevel@tonic-gate void 1531618Srie Dbg_file_delete(Rt_map *lmp) 1540Sstevel@tonic-gate { 1551618Srie Lm_list *lml = LIST(lmp); 1561618Srie 1571618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 1580Sstevel@tonic-gate return; 1590Sstevel@tonic-gate 1601618Srie Dbg_util_nl(lml, DBG_NL_STD); 1611618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DELETE), NAME(lmp)); 1620Sstevel@tonic-gate } 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate static int hdl_title = 0; 1650Sstevel@tonic-gate static Msg hdl_str = 0; 1660Sstevel@tonic-gate 1670Sstevel@tonic-gate void 1680Sstevel@tonic-gate Dbg_file_hdl_title(int type) 1690Sstevel@tonic-gate { 1705067Srie static const Msg titles[] = { 1715067Srie MSG_FIL_HDL_CREATE, /* MSG_INTL(MSG_FIL_HDL_CREATE) */ 1725067Srie MSG_FIL_HDL_ADD, /* MSG_INTL(MSG_FIL_HDL_ADD) */ 1735067Srie MSG_FIL_HDL_DELETE, /* MSG_INTL(MSG_FIL_HDL_DELETE) */ 1745067Srie MSG_FIL_HDL_ORPHAN, /* MSG_INTL(MSG_FIL_HDL_ORPHAN) */ 1755067Srie MSG_FIL_HDL_REINST, /* MSG_INTL(MSG_FIL_HDL_REINST) */ 1765067Srie }; 1775067Srie 1781618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 1790Sstevel@tonic-gate return; 1800Sstevel@tonic-gate if (DBG_NOTDETAIL()) 1810Sstevel@tonic-gate return; 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate /* 1845067Srie * Establish a binding title for later use in Dbg_file_hdl_action. 1850Sstevel@tonic-gate */ 1865067Srie if (type <= DBG_HDL_REINST) { 1875067Srie hdl_str = titles[type]; 1885067Srie hdl_title = 1; 1895067Srie } else { 1904734Sab196087 hdl_str = 0; 1915067Srie hdl_title = 0; 1923731Srie } 1930Sstevel@tonic-gate } 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate void 1961618Srie Dbg_file_hdl_collect(Grp_hdl *ghp, const char *name) 1970Sstevel@tonic-gate { 1984734Sab196087 Conv_grphdl_flags_buf_t grphdl_flags_buf; 1991618Srie Lm_list *lml = ghp->gh_ownlml; 2001618Srie const char *str; 2010Sstevel@tonic-gate 2021618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 2030Sstevel@tonic-gate return; 2040Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2050Sstevel@tonic-gate return; 2060Sstevel@tonic-gate 2071618Srie if (ghp->gh_ownlmp) 2081618Srie str = NAME(ghp->gh_ownlmp); 2090Sstevel@tonic-gate else 2100Sstevel@tonic-gate str = MSG_INTL(MSG_STR_ORPHAN); 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate if (hdl_title) { 2130Sstevel@tonic-gate hdl_title = 0; 2141618Srie Dbg_util_nl(lml, DBG_NL_STD); 2150Sstevel@tonic-gate } 2160Sstevel@tonic-gate if (name) 2171618Srie dbg_print(lml, MSG_INTL(MSG_FIL_HDL_RETAIN), str, name); 2180Sstevel@tonic-gate else 2191618Srie dbg_print(lml, MSG_INTL(MSG_FIL_HDL_COLLECT), str, 2204734Sab196087 conv_grphdl_flags(ghp->gh_flags, &grphdl_flags_buf)); 2210Sstevel@tonic-gate } 2220Sstevel@tonic-gate 2230Sstevel@tonic-gate void 2243731Srie Dbg_file_hdl_action(Grp_hdl *ghp, Rt_map *lmp, int type, uint_t flags) 2250Sstevel@tonic-gate { 2264734Sab196087 Conv_grpdesc_flags_buf_t grpdesc_flags_buf; 2273731Srie const char *mode, *group; 2283731Srie Lm_list *lml = LIST(lmp); 2293731Srie Msg str; 2300Sstevel@tonic-gate 2315067Srie static const Msg fmt[] = { 2325067Srie MSG_FIL_DEP_ADD, /* MSG_INTL(MSG_FIL_DEP_ADD) */ 2335067Srie MSG_FIL_DEP_UPDATE, /* MSG_INTL(MSG_FIL_DEP_UPDATE) */ 2345067Srie MSG_FIL_DEP_DELETE, /* MSG_INTL(MSG_FIL_DEP_DELETE) */ 2355067Srie MSG_FIL_DEP_REMOVE, /* MSG_INTL(MSG_FIL_DEP_REMOVE) */ 2365067Srie MSG_FIL_DEP_REMAIN, /* MSG_INTL(MSG_FIL_DEP_REMAIN) */ 2375067Srie MSG_FIL_DEP_ORPHAN, /* MSG_INTL(MSG_FIL_DEP_ORPHAN) */ 2385067Srie MSG_FIL_DEP_REINST, /* MSG_INTL(MSG_FIL_DEP_REINST) */ 2395067Srie }; 2401618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 2410Sstevel@tonic-gate return; 2420Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2430Sstevel@tonic-gate return; 2440Sstevel@tonic-gate 2450Sstevel@tonic-gate if (hdl_title) { 2461618Srie Dbg_util_nl(lml, DBG_NL_STD); 2470Sstevel@tonic-gate if (hdl_str) { 2480Sstevel@tonic-gate const char *name; 2490Sstevel@tonic-gate 2500Sstevel@tonic-gate /* 2510Sstevel@tonic-gate * Protect ourselves in case this handle has no 2520Sstevel@tonic-gate * originating owner. 2530Sstevel@tonic-gate */ 2541618Srie if (ghp->gh_ownlmp) 2551618Srie name = NAME(ghp->gh_ownlmp); 2560Sstevel@tonic-gate else 2570Sstevel@tonic-gate name = MSG_INTL(MSG_STR_UNKNOWN); 2580Sstevel@tonic-gate 2598620SRod.Evans@Sun.COM dbg_print(lml, MSG_INTL(hdl_str), name, EC_NATPTR(ghp)); 2600Sstevel@tonic-gate } 2610Sstevel@tonic-gate hdl_title = 0; 2620Sstevel@tonic-gate } 2630Sstevel@tonic-gate 2644734Sab196087 /* 2655067Srie * Establish a binding descriptor format string. 2664734Sab196087 */ 2675067Srie if (type > DBG_DEP_REINST) 2684734Sab196087 return; 2690Sstevel@tonic-gate 2705067Srie str = fmt[type]; 2715067Srie 2725067Srie if (((type == DBG_DEP_ADD) || (type == DBG_DEP_UPDATE)) && flags) 2734734Sab196087 group = conv_grpdesc_flags(flags, &grpdesc_flags_buf); 2743731Srie else 2753731Srie group = MSG_ORIG(MSG_STR_EMPTY); 2760Sstevel@tonic-gate 2773731Srie if ((MODE(lmp) & (RTLD_GLOBAL | RTLD_NODELETE)) == 2783731Srie (RTLD_GLOBAL | RTLD_NODELETE)) 2793731Srie mode = MSG_ORIG(MSG_MODE_GLOBNODEL); 2803731Srie else if (MODE(lmp) & RTLD_GLOBAL) 2813731Srie mode = MSG_ORIG(MSG_MODE_GLOB); 2823731Srie else if (MODE(lmp) & RTLD_NODELETE) 2833731Srie mode = MSG_ORIG(MSG_MODE_NODEL); 2843731Srie else 2853731Srie mode = MSG_ORIG(MSG_STR_EMPTY); 2863731Srie 2873731Srie dbg_print(lml, MSG_INTL(str), NAME(lmp), mode, group); 2880Sstevel@tonic-gate } 2890Sstevel@tonic-gate 2900Sstevel@tonic-gate void 2911618Srie Dbg_file_bind_entry(Lm_list *lml, Bnd_desc *bdp) 2920Sstevel@tonic-gate { 2934734Sab196087 Conv_bnd_type_buf_t bnd_type_buf; 2944734Sab196087 2951618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 2960Sstevel@tonic-gate return; 2970Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2980Sstevel@tonic-gate return; 2990Sstevel@tonic-gate 3000Sstevel@tonic-gate /* 3010Sstevel@tonic-gate * Print the dependency together with the modes of the binding. 3020Sstevel@tonic-gate */ 3031618Srie Dbg_util_nl(lml, DBG_NL_STD); 3041618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BND_ADD), NAME(bdp->b_caller)); 3051618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BND_FILE), NAME(bdp->b_depend), 3064734Sab196087 conv_bnd_type(bdp->b_flags, &bnd_type_buf)); 307280Srie } 308280Srie 309280Srie void 3101618Srie Dbg_file_bindings(Rt_map *lmp, int flag) 311280Srie { 3124734Sab196087 Conv_bnd_obj_buf_t bnd_obj_buf; 3134734Sab196087 Conv_bnd_type_buf_t bnd_type_buf; 314280Srie const char *str; 315280Srie Rt_map *tlmp; 3161618Srie Lm_list *lml = LIST(lmp); 317280Srie int next = 0; 318280Srie 3191618Srie if (DBG_NOTCLASS(DBG_C_INIT)) 320280Srie return; 321280Srie if (DBG_NOTDETAIL()) 322280Srie return; 323280Srie 324280Srie if (flag & RT_SORT_REV) 325280Srie str = MSG_ORIG(MSG_SCN_INIT); 326280Srie else 327280Srie str = MSG_ORIG(MSG_SCN_FINI); 328280Srie 3291618Srie Dbg_util_nl(lml, DBG_NL_STD); 3301618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEP_TITLE), str, 3314734Sab196087 conv_bnd_obj(lml->lm_flags, &bnd_obj_buf)); 332280Srie 333280Srie /* LINTED */ 334280Srie for (tlmp = lmp; tlmp; tlmp = (Rt_map *)NEXT(tlmp)) { 3355892Sab196087 Bnd_desc *bdp; 3365892Sab196087 Aliste idx; 337280Srie 338280Srie /* 339280Srie * For .init processing, only collect objects that have been 340280Srie * relocated and haven't already been collected. 341280Srie * For .fini processing, only collect objects that have had 342280Srie * their .init collected, and haven't already been .fini 343280Srie * collected. 344280Srie */ 345280Srie if (flag & RT_SORT_REV) { 346280Srie if ((FLAGS(tlmp) & (FLG_RT_RELOCED | 347280Srie FLG_RT_INITCLCT)) != FLG_RT_RELOCED) 348280Srie continue; 349280Srie 350280Srie } else { 351280Srie if ((flag & RT_SORT_DELETE) && 352280Srie ((FLAGS(tlmp) & FLG_RT_DELETE) == 0)) 353280Srie continue; 354280Srie if (((FLAGS(tlmp) & 355280Srie (FLG_RT_INITCLCT | FLG_RT_FINICLCT)) == 356280Srie FLG_RT_INITCLCT) == 0) 357280Srie continue; 358280Srie } 359280Srie 360280Srie if (next++) 3611618Srie Dbg_util_nl(lml, DBG_NL_STD); 362280Srie 3635892Sab196087 if (DEPENDS(tlmp) == NULL) 3641618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEP_NONE), NAME(tlmp)); 365280Srie else { 3661618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEP_ENT), NAME(tlmp)); 367280Srie 3685892Sab196087 for (APLIST_TRAVERSE(DEPENDS(tlmp), idx, bdp)) { 3691618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BND_FILE), 3705892Sab196087 NAME(bdp->b_depend), 3715892Sab196087 conv_bnd_type(bdp->b_flags, 3724734Sab196087 &bnd_type_buf)); 373280Srie } 374280Srie } 375280Srie } 3761618Srie Dbg_util_nl(lml, DBG_NL_STD); 3770Sstevel@tonic-gate } 3780Sstevel@tonic-gate 3790Sstevel@tonic-gate void 3806387Srie Dbg_file_dlopen(Rt_map *clmp, const char *name, int *in_nfavl, int mode) 3810Sstevel@tonic-gate { 3824734Sab196087 Conv_dl_mode_buf_t dl_mode_buf; 3834734Sab196087 Lm_list *lml = LIST(clmp); 3846387Srie const char *retry; 3851618Srie 3861618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 3870Sstevel@tonic-gate return; 3880Sstevel@tonic-gate 3896387Srie /* 3906387Srie * The core functionality of dlopen() can be called twice. The first 3916387Srie * attempt can be affected by path names that exist in the "not-found" 3926387Srie * AVL tree. Should a "not-found" path name be found, a second attempt 3936387Srie * is made to locate the required file (in_nfavl is NULL). This fall- 3946387Srie * back provides for file system changes while a process executes. 3956387Srie */ 3966387Srie if (in_nfavl) 3976387Srie retry = MSG_ORIG(MSG_STR_EMPTY); 3986387Srie else 3996387Srie retry = MSG_INTL(MSG_STR_RETRY); 4006387Srie 4011618Srie Dbg_util_nl(lml, DBG_NL_STD); 4026387Srie dbg_print(lml, MSG_INTL(MSG_FIL_DLOPEN), name, NAME(clmp), retry, 4038140SAli.Bahrami@Sun.COM conv_dl_mode(mode, 0, &dl_mode_buf)); 4040Sstevel@tonic-gate } 4050Sstevel@tonic-gate 4060Sstevel@tonic-gate void 4071618Srie Dbg_file_dlclose(Lm_list *lml, const char *name, int flag) 4080Sstevel@tonic-gate { 4090Sstevel@tonic-gate const char *str; 4100Sstevel@tonic-gate 4111618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4120Sstevel@tonic-gate return; 4130Sstevel@tonic-gate 4140Sstevel@tonic-gate if (flag == DBG_DLCLOSE_IGNORE) 4150Sstevel@tonic-gate str = MSG_INTL(MSG_STR_IGNORE); 4160Sstevel@tonic-gate else 4170Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 4180Sstevel@tonic-gate 4191618Srie Dbg_util_nl(lml, DBG_NL_STD); 4201618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DLCLOSE), name, str); 4210Sstevel@tonic-gate } 4220Sstevel@tonic-gate 4230Sstevel@tonic-gate void 4241618Srie Dbg_file_dldump(Rt_map *lmp, const char *path, int flags) 4250Sstevel@tonic-gate { 4264734Sab196087 Conv_dl_flag_buf_t dl_flag_buf; 4274734Sab196087 Lm_list *lml = LIST(lmp); 4281618Srie 4291618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4300Sstevel@tonic-gate return; 4310Sstevel@tonic-gate 4321618Srie Dbg_util_nl(lml, DBG_NL_STD); 4331618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DLDUMP), NAME(lmp), path, 4344734Sab196087 conv_dl_flag(flags, 0, &dl_flag_buf)); 4350Sstevel@tonic-gate } 4360Sstevel@tonic-gate 4370Sstevel@tonic-gate void 4381618Srie Dbg_file_lazyload(Rt_map *clmp, const char *fname, const char *sname) 4390Sstevel@tonic-gate { 4401618Srie Lm_list *lml = LIST(clmp); 4411618Srie 4421618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4430Sstevel@tonic-gate return; 4440Sstevel@tonic-gate 4451618Srie Dbg_util_nl(lml, DBG_NL_STD); 4461618Srie dbg_print(lml, MSG_INTL(MSG_FIL_LAZYLOAD), fname, NAME(clmp), 4471618Srie Dbg_demangle_name(sname)); 4480Sstevel@tonic-gate } 4490Sstevel@tonic-gate 4500Sstevel@tonic-gate void 4511618Srie Dbg_file_preload(Lm_list *lml, const char *name) 4520Sstevel@tonic-gate { 4531618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4540Sstevel@tonic-gate return; 4550Sstevel@tonic-gate 4561618Srie Dbg_util_nl(lml, DBG_NL_STD); 4571618Srie dbg_print(lml, MSG_INTL(MSG_FIL_PRELOAD), name); 4580Sstevel@tonic-gate } 4590Sstevel@tonic-gate 4600Sstevel@tonic-gate void 4611618Srie Dbg_file_needed(Rt_map *lmp, const char *name) 4620Sstevel@tonic-gate { 4631618Srie Lm_list *lml = LIST(lmp); 4641618Srie 4651618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4660Sstevel@tonic-gate return; 4670Sstevel@tonic-gate 4681618Srie Dbg_util_nl(lml, DBG_NL_STD); 4691618Srie dbg_print(lml, MSG_INTL(MSG_FIL_NEEDED), name, NAME(lmp)); 4700Sstevel@tonic-gate } 4710Sstevel@tonic-gate 4720Sstevel@tonic-gate void 4731618Srie Dbg_file_filter(Lm_list *lml, const char *filter, const char *filtee, 4741618Srie int config) 4750Sstevel@tonic-gate { 4761618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4770Sstevel@tonic-gate return; 4780Sstevel@tonic-gate 4791618Srie Dbg_util_nl(lml, DBG_NL_STD); 4800Sstevel@tonic-gate if (config) 4811618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTER_1), filter, filtee); 4820Sstevel@tonic-gate else 4831618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTER_2), filter, filtee); 4840Sstevel@tonic-gate } 4850Sstevel@tonic-gate 4860Sstevel@tonic-gate void 4871618Srie Dbg_file_filtee(Lm_list *lml, const char *filter, const char *filtee, int audit) 4880Sstevel@tonic-gate { 4890Sstevel@tonic-gate if (audit) { 4901618Srie if (DBG_NOTCLASS(DBG_C_AUDITING | DBG_C_FILES)) 4910Sstevel@tonic-gate return; 4920Sstevel@tonic-gate 4931618Srie Dbg_util_nl(lml, DBG_NL_STD); 4941618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTEE_3), filtee); 4950Sstevel@tonic-gate } else { 4961618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4970Sstevel@tonic-gate return; 4980Sstevel@tonic-gate 4991618Srie Dbg_util_nl(lml, DBG_NL_STD); 5000Sstevel@tonic-gate if (filter) 5011618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTEE_1), filtee, 5021618Srie filter); 5030Sstevel@tonic-gate else 5041618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTEE_2), filtee); 5050Sstevel@tonic-gate } 5060Sstevel@tonic-gate } 5070Sstevel@tonic-gate 5080Sstevel@tonic-gate void 5091618Srie Dbg_file_fixname(Lm_list *lml, const char *oname, const char *nname) 5100Sstevel@tonic-gate { 5111618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 5120Sstevel@tonic-gate return; 5130Sstevel@tonic-gate 5141618Srie Dbg_util_nl(lml, DBG_NL_STD); 5151618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FIXNAME), oname, nname); 5160Sstevel@tonic-gate } 5170Sstevel@tonic-gate 5180Sstevel@tonic-gate void 5190Sstevel@tonic-gate Dbg_file_output(Ofl_desc *ofl) 5200Sstevel@tonic-gate { 5210Sstevel@tonic-gate const char *prefix = MSG_ORIG(MSG_PTH_OBJECT); 5220Sstevel@tonic-gate char *oname, *nname, *ofile; 5230Sstevel@tonic-gate int fd; 5240Sstevel@tonic-gate 5251618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 5260Sstevel@tonic-gate return; 5270Sstevel@tonic-gate if (DBG_NOTDETAIL()) 5280Sstevel@tonic-gate return; 5290Sstevel@tonic-gate 5300Sstevel@tonic-gate /* 5310Sstevel@tonic-gate * Obtain the present input object filename for concatenation to the 5320Sstevel@tonic-gate * prefix name. 5330Sstevel@tonic-gate */ 5340Sstevel@tonic-gate oname = (char *)ofl->ofl_name; 5350Sstevel@tonic-gate if ((ofile = strrchr(oname, '/')) == NULL) 5360Sstevel@tonic-gate ofile = oname; 5370Sstevel@tonic-gate else 5380Sstevel@tonic-gate ofile++; 5390Sstevel@tonic-gate 5400Sstevel@tonic-gate /* 5410Sstevel@tonic-gate * Concatenate the prefix with the object filename, open the file and 5420Sstevel@tonic-gate * write out the present Elf memory image. As this is debugging we 5430Sstevel@tonic-gate * ignore all errors. 5440Sstevel@tonic-gate */ 5451618Srie if ((nname = malloc(strlen(prefix) + strlen(ofile) + 1)) != 0) { 5460Sstevel@tonic-gate (void) strcpy(nname, prefix); 5470Sstevel@tonic-gate (void) strcat(nname, ofile); 5480Sstevel@tonic-gate if ((fd = open(nname, O_RDWR | O_CREAT | O_TRUNC, 5490Sstevel@tonic-gate 0666)) != -1) { 5501618Srie (void) write(fd, ofl->ofl_nehdr, ofl->ofl_size); 5511618Srie (void) close(fd); 5520Sstevel@tonic-gate } 5530Sstevel@tonic-gate free(nname); 5540Sstevel@tonic-gate } 5550Sstevel@tonic-gate } 5560Sstevel@tonic-gate 5570Sstevel@tonic-gate void 5581618Srie Dbg_file_config_dis(Lm_list *lml, const char *config, int features) 5590Sstevel@tonic-gate { 5604734Sab196087 Conv_config_feat_buf_t config_feat_buf; 5614734Sab196087 const char *str; 5620Sstevel@tonic-gate 5631976Sab196087 switch (features & ~CONF_FEATMSK) { 5641976Sab196087 case DBG_CONF_IGNORE: 5650Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_1); 5661976Sab196087 break; 5671976Sab196087 case DBG_CONF_VERSION: 5680Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_2); 5691976Sab196087 break; 5701976Sab196087 case DBG_CONF_PRCFAIL: 5710Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_3); 5721976Sab196087 break; 5731976Sab196087 case DBG_CONF_CORRUPT: 5740Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_4); 5751976Sab196087 break; 5761976Sab196087 case DBG_CONF_ABIMISMATCH: 5771976Sab196087 str = MSG_INTL(MSG_FIL_CONFIG_ERR_5); 5781976Sab196087 break; 5791976Sab196087 default: 5804734Sab196087 str = conv_config_feat(features, &config_feat_buf); 5811976Sab196087 break; 5821976Sab196087 } 5830Sstevel@tonic-gate 5841618Srie Dbg_util_nl(lml, DBG_NL_FRC); 5851618Srie dbg_print(lml, MSG_INTL(MSG_FIL_CONFIG_ERR), config, str); 5861618Srie Dbg_util_nl(lml, DBG_NL_FRC); 5870Sstevel@tonic-gate } 5880Sstevel@tonic-gate 5890Sstevel@tonic-gate void 5901618Srie Dbg_file_config_obj(Lm_list *lml, const char *dir, const char *file, 5911618Srie const char *config) 5920Sstevel@tonic-gate { 5930Sstevel@tonic-gate char *name, _name[PATH_MAX]; 5940Sstevel@tonic-gate 5951618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 5960Sstevel@tonic-gate return; 5970Sstevel@tonic-gate 5980Sstevel@tonic-gate if (file) { 5990Sstevel@tonic-gate (void) snprintf(_name, PATH_MAX, MSG_ORIG(MSG_FMT_PATH), 6000Sstevel@tonic-gate dir, file); 6010Sstevel@tonic-gate name = _name; 6020Sstevel@tonic-gate } else 6030Sstevel@tonic-gate name = (char *)dir; 6040Sstevel@tonic-gate 6051618Srie dbg_print(lml, MSG_INTL(MSG_FIL_CONFIG), name, config); 6061618Srie } 6071618Srie 6081618Srie void 6091618Srie Dbg_file_del_rescan(Lm_list *lml) 6101618Srie { 6111618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6121618Srie return; 6131618Srie 6141618Srie Dbg_util_nl(lml, DBG_NL_STD); 6151618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEL_RESCAN)); 6161618Srie } 6171618Srie 6181618Srie void 6191618Srie Dbg_file_mode_promote(Rt_map *lmp, int mode) 6201618Srie { 6214734Sab196087 Conv_dl_mode_buf_t dl_mode_buf; 6224734Sab196087 Lm_list *lml = LIST(lmp); 6231618Srie 6241618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6251618Srie return; 6261618Srie 6271618Srie Dbg_util_nl(lml, DBG_NL_STD); 6281618Srie dbg_print(lml, MSG_INTL(MSG_FIL_PROMOTE), NAME(lmp), 6294734Sab196087 conv_dl_mode(mode, 0, &dl_mode_buf)); 6301618Srie Dbg_util_nl(lml, DBG_NL_STD); 6310Sstevel@tonic-gate } 6320Sstevel@tonic-gate 6331618Srie void 6341618Srie Dbg_file_cntl(Lm_list *lml, Aliste flmco, Aliste tlmco) 6351618Srie { 6361618Srie Lm_cntl *lmc; 6371618Srie Aliste off; 6381618Srie 6391618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6401618Srie return; 6411618Srie if (DBG_NOTDETAIL()) 6421618Srie return; 6431618Srie 6441618Srie Dbg_util_nl(lml, DBG_NL_STD); 6451618Srie dbg_print(lml, MSG_INTL(MSG_CNTL_TITLE), EC_XWORD(flmco), 6461618Srie EC_XWORD(tlmco)); 6471618Srie 6485892Sab196087 for (ALIST_TRAVERSE_BY_OFFSET(lml->lm_lists, off, lmc)) { 6491618Srie Rt_map *lmp; 6501618Srie 6511618Srie /* LINTED */ 6521618Srie for (lmp = lmc->lc_head; lmp; lmp = (Rt_map *)NEXT(lmp)) 6531618Srie dbg_print(lml, MSG_ORIG(MSG_CNTL_ENTRY), EC_XWORD(off), 6541618Srie NAME(lmp)); 6551618Srie } 6561618Srie Dbg_util_nl(lml, DBG_NL_STD); 6571618Srie } 6581618Srie 6597983SAli.Bahrami@Sun.COM /* 6607983SAli.Bahrami@Sun.COM * Report archive rescan operation. 6617983SAli.Bahrami@Sun.COM * argv_start_ndx, argv_end_ndx - Index range of command line arguments 6627983SAli.Bahrami@Sun.COM * from which archives are to be reprocessed. 6637983SAli.Bahrami@Sun.COM */ 6641618Srie void 6657983SAli.Bahrami@Sun.COM Dbg_file_ar_rescan(Lm_list *lml, int argv_start_ndx, int argv_end_ndx) 6661618Srie { 6671618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6681618Srie return; 6690Sstevel@tonic-gate 6701618Srie Dbg_util_nl(lml, DBG_NL_STD); 6717983SAli.Bahrami@Sun.COM dbg_print(lml, MSG_INTL(MSG_FIL_AR_RESCAN), 6727983SAli.Bahrami@Sun.COM argv_start_ndx, argv_end_ndx); 6731618Srie Dbg_util_nl(lml, DBG_NL_STD); 6741618Srie } 6751618Srie 6761618Srie void 6771618Srie Dbg_file_ar(Lm_list *lml, const char *name, int again) 6781618Srie { 6791618Srie const char *str; 6801618Srie 6811618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6821618Srie return; 6831618Srie 6841618Srie if (again) 6851618Srie str = MSG_INTL(MSG_STR_AGAIN); 6861618Srie else 6871618Srie str = MSG_ORIG(MSG_STR_EMPTY); 6881618Srie 6891618Srie Dbg_util_nl(lml, DBG_NL_STD); 6901618Srie dbg_print(lml, MSG_INTL(MSG_FIL_ARCHIVE), name, str); 6911618Srie } 6921618Srie 6931618Srie void 6941618Srie Dbg_file_generic(Lm_list *lml, Ifl_desc *ifl) 6951618Srie { 6964734Sab196087 Conv_inv_buf_t inv_buf; 6974734Sab196087 6981618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6991618Srie return; 7001618Srie 7011618Srie Dbg_util_nl(lml, DBG_NL_STD); 7021618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BASIC), ifl->ifl_name, 703*9273SAli.Bahrami@Sun.COM conv_ehdr_type(ifl->ifl_ehdr->e_ident[EI_OSABI], 704*9273SAli.Bahrami@Sun.COM ifl->ifl_ehdr->e_type, 0, &inv_buf)); 7051618Srie } 7061618Srie 7071618Srie static const Msg 7080Sstevel@tonic-gate reject[] = { 7090Sstevel@tonic-gate MSG_STR_EMPTY, 7100Sstevel@tonic-gate MSG_REJ_MACH, /* MSG_INTL(MSG_REJ_MACH) */ 7110Sstevel@tonic-gate MSG_REJ_CLASS, /* MSG_INTL(MSG_REJ_CLASS) */ 7120Sstevel@tonic-gate MSG_REJ_DATA, /* MSG_INTL(MSG_REJ_DATA) */ 7130Sstevel@tonic-gate MSG_REJ_TYPE, /* MSG_INTL(MSG_REJ_TYPE) */ 7140Sstevel@tonic-gate MSG_REJ_BADFLAG, /* MSG_INTL(MSG_REJ_BADFLAG) */ 7150Sstevel@tonic-gate MSG_REJ_MISFLAG, /* MSG_INTL(MSG_REJ_MISFLAG) */ 7160Sstevel@tonic-gate MSG_REJ_VERSION, /* MSG_INTL(MSG_REJ_VERSION) */ 7170Sstevel@tonic-gate MSG_REJ_HAL, /* MSG_INTL(MSG_REJ_HAL) */ 7180Sstevel@tonic-gate MSG_REJ_US3, /* MSG_INTL(MSG_REJ_US3) */ 7190Sstevel@tonic-gate MSG_REJ_STR, /* MSG_INTL(MSG_REJ_STR) */ 7200Sstevel@tonic-gate MSG_REJ_UNKFILE, /* MSG_INTL(MSG_REJ_UNKFILE) */ 7210Sstevel@tonic-gate MSG_REJ_HWCAP_1, /* MSG_INTL(MSG_REJ_HWCAP_1) */ 7220Sstevel@tonic-gate }; 7230Sstevel@tonic-gate 7240Sstevel@tonic-gate void 7256206Sab196087 Dbg_file_rejected(Lm_list *lml, Rej_desc *rej, Half mach) 7260Sstevel@tonic-gate { 7274734Sab196087 Conv_reject_desc_buf_t rej_buf; 7284734Sab196087 7291618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 7300Sstevel@tonic-gate return; 7310Sstevel@tonic-gate 7321618Srie Dbg_util_nl(lml, DBG_NL_STD); 7331618Srie dbg_print(lml, MSG_INTL(reject[rej->rej_type]), rej->rej_name ? 7344734Sab196087 rej->rej_name : MSG_INTL(MSG_STR_UNKNOWN), 7356206Sab196087 conv_reject_desc(rej, &rej_buf, mach)); 7361618Srie Dbg_util_nl(lml, DBG_NL_STD); 7370Sstevel@tonic-gate } 7380Sstevel@tonic-gate 7390Sstevel@tonic-gate void 7401618Srie Dbg_file_reuse(Lm_list *lml, const char *nname, const char *oname) 7410Sstevel@tonic-gate { 7421618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 7430Sstevel@tonic-gate return; 7440Sstevel@tonic-gate 7451618Srie dbg_print(lml, MSG_INTL(MSG_FIL_REUSE), nname, oname); 7460Sstevel@tonic-gate } 7470Sstevel@tonic-gate 7480Sstevel@tonic-gate void 7491618Srie Dbg_file_skip(Lm_list *lml, const char *oname, const char *nname) 7500Sstevel@tonic-gate { 7511618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 7520Sstevel@tonic-gate return; 7530Sstevel@tonic-gate 7541618Srie if (oname && strcmp(nname, oname)) 7551618Srie dbg_print(lml, MSG_INTL(MSG_FIL_SKIP_1), nname, oname); 7561618Srie else 7571618Srie dbg_print(lml, MSG_INTL(MSG_FIL_SKIP_2), nname); 7580Sstevel@tonic-gate } 7592978Srie 7602978Srie void 7612978Srie Dbg_file_modified(Lm_list *lml, const char *obj, const char *oname, 7622978Srie const char *nname, int ofd, int nfd, Elf *oelf, Elf *nelf) 7632978Srie { 7642978Srie const char *str; 7652978Srie 7662978Srie if (DBG_NOTCLASS(DBG_C_FILES | DBG_C_SUPPORT)) 7672978Srie return; 7682978Srie if (DBG_NOTDETAIL()) 7692978Srie return; 7702978Srie 7712978Srie Dbg_util_nl(lml, DBG_NL_STD); 7722978Srie dbg_print(lml, MSG_INTL(MSG_FIL_MODIFIED), oname, obj); 7732978Srie 7742978Srie if (nname != oname) 7752978Srie dbg_print(lml, MSG_INTL(MSG_FIL_NAMECHANGE), nname); 7762978Srie if (nfd != ofd) { 7772978Srie if (nfd == -1) 7782978Srie str = MSG_INTL(MSG_FIL_IGNORE); 7792978Srie else 7802978Srie str = MSG_ORIG(MSG_STR_EMPTY); 7812978Srie dbg_print(lml, MSG_INTL(MSG_FIL_FDCHANGE), ofd, nfd, str); 7822978Srie } 7832978Srie if (nelf != oelf) { 7842978Srie if (nelf == 0) 7852978Srie str = MSG_INTL(MSG_FIL_IGNORE); 7862978Srie else 7872978Srie str = MSG_ORIG(MSG_STR_EMPTY); 7882978Srie dbg_print(lml, MSG_INTL(MSG_FIL_ELFCHANGE), EC_NATPTR(oelf), 7892978Srie EC_NATPTR(nelf), str); 7902978Srie } 7912978Srie Dbg_util_nl(lml, DBG_NL_STD); 7922978Srie } 7933731Srie 7943731Srie void 7953731Srie Dbg_file_cleanup(Lm_list *lml, const char *name, Aliste lmco) 7963731Srie { 7973731Srie if (DBG_NOTCLASS(DBG_C_FILES)) 7983731Srie return; 7993731Srie 8003731Srie Dbg_util_nl(lml, DBG_NL_STD); 8013731Srie dbg_print(lml, MSG_INTL(MSG_FIL_CLEANUP), name, EC_XWORD(lmco)); 8023731Srie } 803