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 /* 233731Srie * 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 { 43*4734Sab196087 Conv_dl_mode_buf_t dl_mode_buf; 44*4734Sab196087 Lm_list *lml = LIST(lmp); 451618Srie 461618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 470Sstevel@tonic-gate return; 480Sstevel@tonic-gate 491618Srie Dbg_util_nl(lml, DBG_NL_STD); 501618Srie dbg_print(lml, MSG_INTL(MSG_FIL_ANALYZE), NAME(lmp), 51*4734Sab196087 conv_dl_mode(MODE(lmp), 1, &dl_mode_buf)); 520Sstevel@tonic-gate } 530Sstevel@tonic-gate 540Sstevel@tonic-gate void 551618Srie Dbg_file_aout(Lm_list *lml, const char *name, ulong_t dynamic, ulong_t base, 561618Srie ulong_t size, const char *lmid, Aliste lmco) 570Sstevel@tonic-gate { 581618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 590Sstevel@tonic-gate return; 600Sstevel@tonic-gate 611618Srie dbg_print(lml, MSG_INTL(MSG_FIL_AOUT), name); 621618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_DB), EC_XWORD(dynamic), 631618Srie EC_ADDR(base)); 641618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_S), EC_XWORD(size)); 651618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_LL), lmid, EC_XWORD(lmco)); 660Sstevel@tonic-gate } 670Sstevel@tonic-gate 680Sstevel@tonic-gate void 691618Srie Dbg_file_elf(Lm_list *lml, const char *name, ulong_t dynamic, ulong_t base, 701618Srie ulong_t size, ulong_t entry, const char *lmid, Aliste lmco) 710Sstevel@tonic-gate { 720Sstevel@tonic-gate const char *str; 730Sstevel@tonic-gate 741618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 750Sstevel@tonic-gate return; 760Sstevel@tonic-gate 770Sstevel@tonic-gate if (base == 0) 780Sstevel@tonic-gate str = MSG_INTL(MSG_STR_TEMPORARY); 790Sstevel@tonic-gate else 800Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 810Sstevel@tonic-gate 821618Srie dbg_print(lml, MSG_INTL(MSG_FIL_ELF), name, str); 831618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_DB), EC_XWORD(dynamic), 841618Srie EC_ADDR(base)); 851618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_SE), EC_XWORD(size), 861618Srie EC_XWORD(entry)); 871618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_LL), lmid, EC_XWORD(lmco)); 880Sstevel@tonic-gate } 890Sstevel@tonic-gate 900Sstevel@tonic-gate void 911618Srie Dbg_file_ldso(Rt_map *lmp, char **envp, auxv_t *auxv, const char *lmid, 921618Srie Aliste lmco) 930Sstevel@tonic-gate { 941618Srie Lm_list *lml = LIST(lmp); 951618Srie 961618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 970Sstevel@tonic-gate return; 980Sstevel@tonic-gate 991618Srie Dbg_util_nl(lml, DBG_NL_STD); 1001618Srie dbg_print(lml, MSG_INTL(MSG_FIL_LDSO), PATHNAME(lmp)); 1011618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_DB), EC_NATPTR(DYN(lmp)), 1021618Srie EC_ADDR(ADDR(lmp))); 1031618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_EA), EC_NATPTR(envp), 1041618Srie EC_NATPTR(auxv)); 1051618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DATA_LL), lmid, EC_XWORD(lmco)); 1061618Srie Dbg_util_nl(lml, DBG_NL_STD); 1071618Srie } 1081618Srie 1091618Srie 1101618Srie void 1111618Srie Dbg_file_prot(Rt_map *lmp, int prot) 1121618Srie { 1131618Srie Lm_list *lml = LIST(lmp); 1141618Srie 1151618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 1161618Srie return; 1171618Srie 1181618Srie Dbg_util_nl(lml, DBG_NL_STD); 1191618Srie dbg_print(lml, MSG_INTL(MSG_FIL_PROT), NAME(lmp), (prot ? '+' : '-')); 1200Sstevel@tonic-gate } 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate void 1231618Srie Dbg_file_delete(Rt_map *lmp) 1240Sstevel@tonic-gate { 1251618Srie Lm_list *lml = LIST(lmp); 1261618Srie 1271618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 1280Sstevel@tonic-gate return; 1290Sstevel@tonic-gate 1301618Srie Dbg_util_nl(lml, DBG_NL_STD); 1311618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DELETE), NAME(lmp)); 1320Sstevel@tonic-gate } 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate static int hdl_title = 0; 1350Sstevel@tonic-gate static Msg hdl_str = 0; 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate void 1380Sstevel@tonic-gate Dbg_file_hdl_title(int type) 1390Sstevel@tonic-gate { 1401618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 1410Sstevel@tonic-gate return; 1420Sstevel@tonic-gate if (DBG_NOTDETAIL()) 1430Sstevel@tonic-gate return; 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate hdl_title = 1; 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate /* 1480Sstevel@tonic-gate * Establish a binding title for later use in Dbg_file_bind_entry. 149*4734Sab196087 * These are to be used with the MSG_INTL() macro. 150*4734Sab196087 * 151*4734Sab196087 * Note: The following are to convince chkmsg.sh that these 152*4734Sab196087 * messages are actually used: 153*4734Sab196087 * 154*4734Sab196087 * MSG_INTL(MSG_FIL_HDL_CREATE) 155*4734Sab196087 * MSG_INTL(MSG_FIL_HDL_ADD) 156*4734Sab196087 * MSG_INTL(MSG_FIL_HDL_DELETE) 157*4734Sab196087 * MSG_INTL(MSG_FIL_HDL_ORPHAN) 158*4734Sab196087 * MSG_INTL(MSG_FIL_HDL_REINST) 1590Sstevel@tonic-gate */ 1603731Srie switch (type) { 1613731Srie case DBG_DEP_CREATE: 162*4734Sab196087 hdl_str = MSG_FIL_HDL_CREATE; 163*4734Sab196087 break; 1643731Srie case DBG_DEP_ADD: 165*4734Sab196087 hdl_str = MSG_FIL_HDL_ADD; 166*4734Sab196087 break; 1673731Srie case DBG_DEP_DELETE: 168*4734Sab196087 hdl_str = MSG_FIL_HDL_DELETE; 169*4734Sab196087 break; 1703731Srie case DBG_DEP_ORPHAN: 171*4734Sab196087 hdl_str = MSG_FIL_HDL_ORPHAN; 172*4734Sab196087 break; 1733731Srie case DBG_DEP_REINST: 174*4734Sab196087 hdl_str = MSG_FIL_HDL_REINST; 175*4734Sab196087 break; 1763731Srie default: 177*4734Sab196087 hdl_str = 0; 178*4734Sab196087 break; 1793731Srie } 1800Sstevel@tonic-gate } 1810Sstevel@tonic-gate 1820Sstevel@tonic-gate void 1831618Srie Dbg_file_hdl_collect(Grp_hdl *ghp, const char *name) 1840Sstevel@tonic-gate { 185*4734Sab196087 Conv_grphdl_flags_buf_t grphdl_flags_buf; 1861618Srie Lm_list *lml = ghp->gh_ownlml; 1871618Srie const char *str; 1880Sstevel@tonic-gate 1891618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 1900Sstevel@tonic-gate return; 1910Sstevel@tonic-gate if (DBG_NOTDETAIL()) 1920Sstevel@tonic-gate return; 1930Sstevel@tonic-gate 1941618Srie if (ghp->gh_ownlmp) 1951618Srie str = NAME(ghp->gh_ownlmp); 1960Sstevel@tonic-gate else 1970Sstevel@tonic-gate str = MSG_INTL(MSG_STR_ORPHAN); 1980Sstevel@tonic-gate 1990Sstevel@tonic-gate if (hdl_title) { 2000Sstevel@tonic-gate hdl_title = 0; 2011618Srie Dbg_util_nl(lml, DBG_NL_STD); 2020Sstevel@tonic-gate } 2030Sstevel@tonic-gate if (name) 2041618Srie dbg_print(lml, MSG_INTL(MSG_FIL_HDL_RETAIN), str, name); 2050Sstevel@tonic-gate else 2061618Srie dbg_print(lml, MSG_INTL(MSG_FIL_HDL_COLLECT), str, 207*4734Sab196087 conv_grphdl_flags(ghp->gh_flags, &grphdl_flags_buf)); 2080Sstevel@tonic-gate } 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate void 2113731Srie Dbg_file_hdl_action(Grp_hdl *ghp, Rt_map *lmp, int type, uint_t flags) 2120Sstevel@tonic-gate { 213*4734Sab196087 Conv_grpdesc_flags_buf_t grpdesc_flags_buf; 2143731Srie const char *mode, *group; 2153731Srie Lm_list *lml = LIST(lmp); 2163731Srie Msg str; 2170Sstevel@tonic-gate 2181618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 2190Sstevel@tonic-gate return; 2200Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2210Sstevel@tonic-gate return; 2220Sstevel@tonic-gate 2230Sstevel@tonic-gate if (hdl_title) { 2241618Srie Dbg_util_nl(lml, DBG_NL_STD); 2250Sstevel@tonic-gate if (hdl_str) { 2260Sstevel@tonic-gate const char *name; 2270Sstevel@tonic-gate 2280Sstevel@tonic-gate /* 2290Sstevel@tonic-gate * Protect ourselves in case this handle has no 2300Sstevel@tonic-gate * originating owner. 2310Sstevel@tonic-gate */ 2321618Srie if (ghp->gh_ownlmp) 2331618Srie name = NAME(ghp->gh_ownlmp); 2340Sstevel@tonic-gate else 2350Sstevel@tonic-gate name = MSG_INTL(MSG_STR_UNKNOWN); 2360Sstevel@tonic-gate 2371618Srie dbg_print(lml, MSG_INTL(hdl_str), name); 2380Sstevel@tonic-gate } 2390Sstevel@tonic-gate hdl_title = 0; 2400Sstevel@tonic-gate } 2410Sstevel@tonic-gate 242*4734Sab196087 /* 243*4734Sab196087 * Note: The following are to convince chkmsg.sh that these 244*4734Sab196087 * messages are actually used: 245*4734Sab196087 * 246*4734Sab196087 * MSG_INTL(MSG_FIL_DEP_ADD) 247*4734Sab196087 * MSG_INTL(MSG_FIL_DEP_DELETE) 248*4734Sab196087 * MSG_INTL(MSG_FIL_DEP_REMOVE) 249*4734Sab196087 * MSG_INTL(MSG_FIL_DEP_REMAIN) 250*4734Sab196087 * MSG_INTL(MSG_FIL_DEP_ORPHAN) 251*4734Sab196087 * MSG_INTL(MSG_FIL_DEP_REINST) 252*4734Sab196087 */ 2533731Srie switch (type) { 2543731Srie case DBG_DEP_ADD: 255*4734Sab196087 str = MSG_FIL_DEP_ADD; 256*4734Sab196087 break; 2573731Srie case DBG_DEP_DELETE: 258*4734Sab196087 str = MSG_FIL_DEP_DELETE; 259*4734Sab196087 break; 2603731Srie case DBG_DEP_REMOVE: 261*4734Sab196087 str = MSG_FIL_DEP_REMOVE; 262*4734Sab196087 break; 2633731Srie case DBG_DEP_REMAIN: 264*4734Sab196087 str = MSG_FIL_DEP_REMAIN; 265*4734Sab196087 break; 2663731Srie case DBG_DEP_ORPHAN: 267*4734Sab196087 str = MSG_FIL_DEP_ORPHAN; 268*4734Sab196087 break; 2693731Srie case DBG_DEP_REINST: 270*4734Sab196087 str = MSG_FIL_DEP_REINST; 271*4734Sab196087 break; 2723731Srie default: 273*4734Sab196087 return; 2743731Srie } 2750Sstevel@tonic-gate 2763731Srie if ((type == DBG_DEP_ADD) && flags) 277*4734Sab196087 group = conv_grpdesc_flags(flags, &grpdesc_flags_buf); 2783731Srie else 2793731Srie group = MSG_ORIG(MSG_STR_EMPTY); 2800Sstevel@tonic-gate 2813731Srie if ((MODE(lmp) & (RTLD_GLOBAL | RTLD_NODELETE)) == 2823731Srie (RTLD_GLOBAL | RTLD_NODELETE)) 2833731Srie mode = MSG_ORIG(MSG_MODE_GLOBNODEL); 2843731Srie else if (MODE(lmp) & RTLD_GLOBAL) 2853731Srie mode = MSG_ORIG(MSG_MODE_GLOB); 2860Sstevel@tonic-gate 2873731Srie else if (MODE(lmp) & RTLD_NODELETE) 2883731Srie mode = MSG_ORIG(MSG_MODE_NODEL); 2893731Srie else 2903731Srie mode = MSG_ORIG(MSG_STR_EMPTY); 2913731Srie 2923731Srie dbg_print(lml, MSG_INTL(str), NAME(lmp), mode, group); 2930Sstevel@tonic-gate } 2940Sstevel@tonic-gate 2950Sstevel@tonic-gate void 2961618Srie Dbg_file_bind_entry(Lm_list *lml, Bnd_desc *bdp) 2970Sstevel@tonic-gate { 298*4734Sab196087 Conv_bnd_type_buf_t bnd_type_buf; 299*4734Sab196087 3001618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 3010Sstevel@tonic-gate return; 3020Sstevel@tonic-gate if (DBG_NOTDETAIL()) 3030Sstevel@tonic-gate return; 3040Sstevel@tonic-gate 3050Sstevel@tonic-gate /* 3060Sstevel@tonic-gate * Print the dependency together with the modes of the binding. 3070Sstevel@tonic-gate */ 3081618Srie Dbg_util_nl(lml, DBG_NL_STD); 3091618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BND_ADD), NAME(bdp->b_caller)); 3101618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BND_FILE), NAME(bdp->b_depend), 311*4734Sab196087 conv_bnd_type(bdp->b_flags, &bnd_type_buf)); 312280Srie } 313280Srie 314280Srie void 3151618Srie Dbg_file_bindings(Rt_map *lmp, int flag) 316280Srie { 317*4734Sab196087 Conv_bnd_obj_buf_t bnd_obj_buf; 318*4734Sab196087 Conv_bnd_type_buf_t bnd_type_buf; 319280Srie const char *str; 320280Srie Rt_map *tlmp; 3211618Srie Lm_list *lml = LIST(lmp); 322280Srie int next = 0; 323280Srie 3241618Srie if (DBG_NOTCLASS(DBG_C_INIT)) 325280Srie return; 326280Srie if (DBG_NOTDETAIL()) 327280Srie return; 328280Srie 329280Srie if (flag & RT_SORT_REV) 330280Srie str = MSG_ORIG(MSG_SCN_INIT); 331280Srie else 332280Srie str = MSG_ORIG(MSG_SCN_FINI); 333280Srie 3341618Srie Dbg_util_nl(lml, DBG_NL_STD); 3351618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEP_TITLE), str, 336*4734Sab196087 conv_bnd_obj(lml->lm_flags, &bnd_obj_buf)); 337280Srie 338280Srie /* LINTED */ 339280Srie for (tlmp = lmp; tlmp; tlmp = (Rt_map *)NEXT(tlmp)) { 3401618Srie Bnd_desc **bdpp; 341280Srie Aliste off; 342280Srie 343280Srie /* 344280Srie * For .init processing, only collect objects that have been 345280Srie * relocated and haven't already been collected. 346280Srie * For .fini processing, only collect objects that have had 347280Srie * their .init collected, and haven't already been .fini 348280Srie * collected. 349280Srie */ 350280Srie if (flag & RT_SORT_REV) { 351280Srie if ((FLAGS(tlmp) & (FLG_RT_RELOCED | 352280Srie FLG_RT_INITCLCT)) != FLG_RT_RELOCED) 353280Srie continue; 354280Srie 355280Srie } else { 356280Srie if ((flag & RT_SORT_DELETE) && 357280Srie ((FLAGS(tlmp) & FLG_RT_DELETE) == 0)) 358280Srie continue; 359280Srie if (((FLAGS(tlmp) & 360280Srie (FLG_RT_INITCLCT | FLG_RT_FINICLCT)) == 361280Srie FLG_RT_INITCLCT) == 0) 362280Srie continue; 363280Srie } 364280Srie 365280Srie if (next++) 3661618Srie Dbg_util_nl(lml, DBG_NL_STD); 367280Srie 368280Srie if (DEPENDS(tlmp) == 0) 3691618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEP_NONE), NAME(tlmp)); 370280Srie else { 3711618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEP_ENT), NAME(tlmp)); 372280Srie 373280Srie for (ALIST_TRAVERSE(DEPENDS(tlmp), off, bdpp)) { 3741618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BND_FILE), 375280Srie NAME((*bdpp)->b_depend), 376*4734Sab196087 conv_bnd_type((*bdpp)->b_flags, 377*4734Sab196087 &bnd_type_buf)); 378280Srie } 379280Srie } 380280Srie } 3811618Srie Dbg_util_nl(lml, DBG_NL_STD); 3820Sstevel@tonic-gate } 3830Sstevel@tonic-gate 3840Sstevel@tonic-gate void 3851618Srie Dbg_file_dlopen(Rt_map *clmp, const char *name, int mode) 3860Sstevel@tonic-gate { 387*4734Sab196087 Conv_dl_mode_buf_t dl_mode_buf; 388*4734Sab196087 Lm_list *lml = LIST(clmp); 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_DLOPEN), name, NAME(clmp), 395*4734Sab196087 conv_dl_mode(mode, 1, &dl_mode_buf)); 3960Sstevel@tonic-gate } 3970Sstevel@tonic-gate 3980Sstevel@tonic-gate void 3991618Srie Dbg_file_dlclose(Lm_list *lml, const char *name, int flag) 4000Sstevel@tonic-gate { 4010Sstevel@tonic-gate const char *str; 4020Sstevel@tonic-gate 4031618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4040Sstevel@tonic-gate return; 4050Sstevel@tonic-gate 4060Sstevel@tonic-gate if (flag == DBG_DLCLOSE_IGNORE) 4070Sstevel@tonic-gate str = MSG_INTL(MSG_STR_IGNORE); 4080Sstevel@tonic-gate else 4090Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 4100Sstevel@tonic-gate 4111618Srie Dbg_util_nl(lml, DBG_NL_STD); 4121618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DLCLOSE), name, str); 4130Sstevel@tonic-gate } 4140Sstevel@tonic-gate 4150Sstevel@tonic-gate void 4161618Srie Dbg_file_dldump(Rt_map *lmp, const char *path, int flags) 4170Sstevel@tonic-gate { 418*4734Sab196087 Conv_dl_flag_buf_t dl_flag_buf; 419*4734Sab196087 Lm_list *lml = LIST(lmp); 4201618Srie 4211618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4220Sstevel@tonic-gate return; 4230Sstevel@tonic-gate 4241618Srie Dbg_util_nl(lml, DBG_NL_STD); 4251618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DLDUMP), NAME(lmp), path, 426*4734Sab196087 conv_dl_flag(flags, 0, &dl_flag_buf)); 4270Sstevel@tonic-gate } 4280Sstevel@tonic-gate 4290Sstevel@tonic-gate void 4301618Srie Dbg_file_lazyload(Rt_map *clmp, const char *fname, const char *sname) 4310Sstevel@tonic-gate { 4321618Srie Lm_list *lml = LIST(clmp); 4331618Srie 4341618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4350Sstevel@tonic-gate return; 4360Sstevel@tonic-gate 4371618Srie Dbg_util_nl(lml, DBG_NL_STD); 4381618Srie dbg_print(lml, MSG_INTL(MSG_FIL_LAZYLOAD), fname, NAME(clmp), 4391618Srie Dbg_demangle_name(sname)); 4400Sstevel@tonic-gate } 4410Sstevel@tonic-gate 4420Sstevel@tonic-gate void 4431618Srie Dbg_file_preload(Lm_list *lml, const char *name) 4440Sstevel@tonic-gate { 4451618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4460Sstevel@tonic-gate return; 4470Sstevel@tonic-gate 4481618Srie Dbg_util_nl(lml, DBG_NL_STD); 4491618Srie dbg_print(lml, MSG_INTL(MSG_FIL_PRELOAD), name); 4500Sstevel@tonic-gate } 4510Sstevel@tonic-gate 4520Sstevel@tonic-gate void 4531618Srie Dbg_file_needed(Rt_map *lmp, const char *name) 4540Sstevel@tonic-gate { 4551618Srie Lm_list *lml = LIST(lmp); 4561618Srie 4571618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4580Sstevel@tonic-gate return; 4590Sstevel@tonic-gate 4601618Srie Dbg_util_nl(lml, DBG_NL_STD); 4611618Srie dbg_print(lml, MSG_INTL(MSG_FIL_NEEDED), name, NAME(lmp)); 4620Sstevel@tonic-gate } 4630Sstevel@tonic-gate 4640Sstevel@tonic-gate void 4651618Srie Dbg_file_filter(Lm_list *lml, const char *filter, const char *filtee, 4661618Srie int config) 4670Sstevel@tonic-gate { 4681618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4690Sstevel@tonic-gate return; 4700Sstevel@tonic-gate 4711618Srie Dbg_util_nl(lml, DBG_NL_STD); 4720Sstevel@tonic-gate if (config) 4731618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTER_1), filter, filtee); 4740Sstevel@tonic-gate else 4751618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTER_2), filter, filtee); 4760Sstevel@tonic-gate } 4770Sstevel@tonic-gate 4780Sstevel@tonic-gate void 4791618Srie Dbg_file_filtee(Lm_list *lml, const char *filter, const char *filtee, int audit) 4800Sstevel@tonic-gate { 4810Sstevel@tonic-gate if (audit) { 4821618Srie if (DBG_NOTCLASS(DBG_C_AUDITING | DBG_C_FILES)) 4830Sstevel@tonic-gate return; 4840Sstevel@tonic-gate 4851618Srie Dbg_util_nl(lml, DBG_NL_STD); 4861618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTEE_3), filtee); 4870Sstevel@tonic-gate } else { 4881618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 4890Sstevel@tonic-gate return; 4900Sstevel@tonic-gate 4911618Srie Dbg_util_nl(lml, DBG_NL_STD); 4920Sstevel@tonic-gate if (filter) 4931618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTEE_1), filtee, 4941618Srie filter); 4950Sstevel@tonic-gate else 4961618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FILTEE_2), filtee); 4970Sstevel@tonic-gate } 4980Sstevel@tonic-gate } 4990Sstevel@tonic-gate 5000Sstevel@tonic-gate void 5011618Srie Dbg_file_fixname(Lm_list *lml, const char *oname, const char *nname) 5020Sstevel@tonic-gate { 5031618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 5040Sstevel@tonic-gate return; 5050Sstevel@tonic-gate 5061618Srie Dbg_util_nl(lml, DBG_NL_STD); 5071618Srie dbg_print(lml, MSG_INTL(MSG_FIL_FIXNAME), oname, nname); 5080Sstevel@tonic-gate } 5090Sstevel@tonic-gate 5100Sstevel@tonic-gate void 5110Sstevel@tonic-gate Dbg_file_output(Ofl_desc *ofl) 5120Sstevel@tonic-gate { 5130Sstevel@tonic-gate const char *prefix = MSG_ORIG(MSG_PTH_OBJECT); 5140Sstevel@tonic-gate char *oname, *nname, *ofile; 5150Sstevel@tonic-gate int fd; 5160Sstevel@tonic-gate 5171618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 5180Sstevel@tonic-gate return; 5190Sstevel@tonic-gate if (DBG_NOTDETAIL()) 5200Sstevel@tonic-gate return; 5210Sstevel@tonic-gate 5220Sstevel@tonic-gate /* 5230Sstevel@tonic-gate * Obtain the present input object filename for concatenation to the 5240Sstevel@tonic-gate * prefix name. 5250Sstevel@tonic-gate */ 5260Sstevel@tonic-gate oname = (char *)ofl->ofl_name; 5270Sstevel@tonic-gate if ((ofile = strrchr(oname, '/')) == NULL) 5280Sstevel@tonic-gate ofile = oname; 5290Sstevel@tonic-gate else 5300Sstevel@tonic-gate ofile++; 5310Sstevel@tonic-gate 5320Sstevel@tonic-gate /* 5330Sstevel@tonic-gate * Concatenate the prefix with the object filename, open the file and 5340Sstevel@tonic-gate * write out the present Elf memory image. As this is debugging we 5350Sstevel@tonic-gate * ignore all errors. 5360Sstevel@tonic-gate */ 5371618Srie if ((nname = malloc(strlen(prefix) + strlen(ofile) + 1)) != 0) { 5380Sstevel@tonic-gate (void) strcpy(nname, prefix); 5390Sstevel@tonic-gate (void) strcat(nname, ofile); 5400Sstevel@tonic-gate if ((fd = open(nname, O_RDWR | O_CREAT | O_TRUNC, 5410Sstevel@tonic-gate 0666)) != -1) { 5421618Srie (void) write(fd, ofl->ofl_nehdr, ofl->ofl_size); 5431618Srie (void) close(fd); 5440Sstevel@tonic-gate } 5450Sstevel@tonic-gate free(nname); 5460Sstevel@tonic-gate } 5470Sstevel@tonic-gate } 5480Sstevel@tonic-gate 5490Sstevel@tonic-gate void 5501618Srie Dbg_file_config_dis(Lm_list *lml, const char *config, int features) 5510Sstevel@tonic-gate { 552*4734Sab196087 Conv_config_feat_buf_t config_feat_buf; 553*4734Sab196087 const char *str; 5540Sstevel@tonic-gate 5551976Sab196087 switch (features & ~CONF_FEATMSK) { 5561976Sab196087 case DBG_CONF_IGNORE: 5570Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_1); 5581976Sab196087 break; 5591976Sab196087 case DBG_CONF_VERSION: 5600Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_2); 5611976Sab196087 break; 5621976Sab196087 case DBG_CONF_PRCFAIL: 5630Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_3); 5641976Sab196087 break; 5651976Sab196087 case DBG_CONF_CORRUPT: 5660Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_4); 5671976Sab196087 break; 5681976Sab196087 case DBG_CONF_ABIMISMATCH: 5691976Sab196087 str = MSG_INTL(MSG_FIL_CONFIG_ERR_5); 5701976Sab196087 break; 5711976Sab196087 default: 572*4734Sab196087 str = conv_config_feat(features, &config_feat_buf); 5731976Sab196087 break; 5741976Sab196087 } 5750Sstevel@tonic-gate 5761618Srie Dbg_util_nl(lml, DBG_NL_FRC); 5771618Srie dbg_print(lml, MSG_INTL(MSG_FIL_CONFIG_ERR), config, str); 5781618Srie Dbg_util_nl(lml, DBG_NL_FRC); 5790Sstevel@tonic-gate } 5800Sstevel@tonic-gate 5810Sstevel@tonic-gate void 5821618Srie Dbg_file_config_obj(Lm_list *lml, const char *dir, const char *file, 5831618Srie const char *config) 5840Sstevel@tonic-gate { 5850Sstevel@tonic-gate char *name, _name[PATH_MAX]; 5860Sstevel@tonic-gate 5871618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 5880Sstevel@tonic-gate return; 5890Sstevel@tonic-gate 5900Sstevel@tonic-gate if (file) { 5910Sstevel@tonic-gate (void) snprintf(_name, PATH_MAX, MSG_ORIG(MSG_FMT_PATH), 5920Sstevel@tonic-gate dir, file); 5930Sstevel@tonic-gate name = _name; 5940Sstevel@tonic-gate } else 5950Sstevel@tonic-gate name = (char *)dir; 5960Sstevel@tonic-gate 5971618Srie dbg_print(lml, MSG_INTL(MSG_FIL_CONFIG), name, config); 5981618Srie } 5991618Srie 6001618Srie void 6011618Srie Dbg_file_del_rescan(Lm_list *lml) 6021618Srie { 6031618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6041618Srie return; 6051618Srie 6061618Srie Dbg_util_nl(lml, DBG_NL_STD); 6071618Srie dbg_print(lml, MSG_INTL(MSG_FIL_DEL_RESCAN)); 6081618Srie } 6091618Srie 6101618Srie void 6111618Srie Dbg_file_mode_promote(Rt_map *lmp, int mode) 6121618Srie { 613*4734Sab196087 Conv_dl_mode_buf_t dl_mode_buf; 614*4734Sab196087 Lm_list *lml = LIST(lmp); 6151618Srie 6161618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6171618Srie return; 6181618Srie 6191618Srie Dbg_util_nl(lml, DBG_NL_STD); 6201618Srie dbg_print(lml, MSG_INTL(MSG_FIL_PROMOTE), NAME(lmp), 621*4734Sab196087 conv_dl_mode(mode, 0, &dl_mode_buf)); 6221618Srie Dbg_util_nl(lml, DBG_NL_STD); 6230Sstevel@tonic-gate } 6240Sstevel@tonic-gate 6251618Srie void 6261618Srie Dbg_file_cntl(Lm_list *lml, Aliste flmco, Aliste tlmco) 6271618Srie { 6281618Srie Lm_cntl *lmc; 6291618Srie Aliste off; 6301618Srie 6311618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6321618Srie return; 6331618Srie if (DBG_NOTDETAIL()) 6341618Srie return; 6351618Srie 6361618Srie Dbg_util_nl(lml, DBG_NL_STD); 6371618Srie dbg_print(lml, MSG_INTL(MSG_CNTL_TITLE), EC_XWORD(flmco), 6381618Srie EC_XWORD(tlmco)); 6391618Srie 6401618Srie for (ALIST_TRAVERSE(lml->lm_lists, off, lmc)) { 6411618Srie Rt_map *lmp; 6421618Srie 6431618Srie /* LINTED */ 6441618Srie for (lmp = lmc->lc_head; lmp; lmp = (Rt_map *)NEXT(lmp)) 6451618Srie dbg_print(lml, MSG_ORIG(MSG_CNTL_ENTRY), EC_XWORD(off), 6461618Srie NAME(lmp)); 6471618Srie } 6481618Srie Dbg_util_nl(lml, DBG_NL_STD); 6491618Srie } 6501618Srie 6511618Srie void 6521618Srie Dbg_file_ar_rescan(Lm_list *lml) 6531618Srie { 6541618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6551618Srie return; 6560Sstevel@tonic-gate 6571618Srie Dbg_util_nl(lml, DBG_NL_STD); 6581618Srie dbg_print(lml, MSG_INTL(MSG_FIL_AR_RESCAN)); 6591618Srie Dbg_util_nl(lml, DBG_NL_STD); 6601618Srie } 6611618Srie 6621618Srie void 6631618Srie Dbg_file_ar(Lm_list *lml, const char *name, int again) 6641618Srie { 6651618Srie const char *str; 6661618Srie 6671618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6681618Srie return; 6691618Srie 6701618Srie if (again) 6711618Srie str = MSG_INTL(MSG_STR_AGAIN); 6721618Srie else 6731618Srie str = MSG_ORIG(MSG_STR_EMPTY); 6741618Srie 6751618Srie Dbg_util_nl(lml, DBG_NL_STD); 6761618Srie dbg_print(lml, MSG_INTL(MSG_FIL_ARCHIVE), name, str); 6771618Srie } 6781618Srie 6791618Srie void 6801618Srie Dbg_file_generic(Lm_list *lml, Ifl_desc *ifl) 6811618Srie { 682*4734Sab196087 Conv_inv_buf_t inv_buf; 683*4734Sab196087 6841618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 6851618Srie return; 6861618Srie 6871618Srie Dbg_util_nl(lml, DBG_NL_STD); 6881618Srie dbg_print(lml, MSG_INTL(MSG_FIL_BASIC), ifl->ifl_name, 689*4734Sab196087 conv_ehdr_type(ifl->ifl_ehdr->e_type, 0, &inv_buf)); 6901618Srie } 6911618Srie 6921618Srie static const Msg 6930Sstevel@tonic-gate reject[] = { 6940Sstevel@tonic-gate MSG_STR_EMPTY, 6950Sstevel@tonic-gate MSG_REJ_MACH, /* MSG_INTL(MSG_REJ_MACH) */ 6960Sstevel@tonic-gate MSG_REJ_CLASS, /* MSG_INTL(MSG_REJ_CLASS) */ 6970Sstevel@tonic-gate MSG_REJ_DATA, /* MSG_INTL(MSG_REJ_DATA) */ 6980Sstevel@tonic-gate MSG_REJ_TYPE, /* MSG_INTL(MSG_REJ_TYPE) */ 6990Sstevel@tonic-gate MSG_REJ_BADFLAG, /* MSG_INTL(MSG_REJ_BADFLAG) */ 7000Sstevel@tonic-gate MSG_REJ_MISFLAG, /* MSG_INTL(MSG_REJ_MISFLAG) */ 7010Sstevel@tonic-gate MSG_REJ_VERSION, /* MSG_INTL(MSG_REJ_VERSION) */ 7020Sstevel@tonic-gate MSG_REJ_HAL, /* MSG_INTL(MSG_REJ_HAL) */ 7030Sstevel@tonic-gate MSG_REJ_US3, /* MSG_INTL(MSG_REJ_US3) */ 7040Sstevel@tonic-gate MSG_REJ_STR, /* MSG_INTL(MSG_REJ_STR) */ 7050Sstevel@tonic-gate MSG_REJ_UNKFILE, /* MSG_INTL(MSG_REJ_UNKFILE) */ 7060Sstevel@tonic-gate MSG_REJ_HWCAP_1, /* MSG_INTL(MSG_REJ_HWCAP_1) */ 7070Sstevel@tonic-gate }; 7080Sstevel@tonic-gate 7090Sstevel@tonic-gate void 7101618Srie Dbg_file_rejected(Lm_list *lml, Rej_desc *rej) 7110Sstevel@tonic-gate { 712*4734Sab196087 Conv_reject_desc_buf_t rej_buf; 713*4734Sab196087 7141618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 7150Sstevel@tonic-gate return; 7160Sstevel@tonic-gate 7171618Srie Dbg_util_nl(lml, DBG_NL_STD); 7181618Srie dbg_print(lml, MSG_INTL(reject[rej->rej_type]), rej->rej_name ? 719*4734Sab196087 rej->rej_name : MSG_INTL(MSG_STR_UNKNOWN), 720*4734Sab196087 conv_reject_desc(rej, &rej_buf)); 7211618Srie Dbg_util_nl(lml, DBG_NL_STD); 7220Sstevel@tonic-gate } 7230Sstevel@tonic-gate 7240Sstevel@tonic-gate void 7251618Srie Dbg_file_reuse(Lm_list *lml, const char *nname, const char *oname) 7260Sstevel@tonic-gate { 7271618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 7280Sstevel@tonic-gate return; 7290Sstevel@tonic-gate 7301618Srie dbg_print(lml, MSG_INTL(MSG_FIL_REUSE), nname, oname); 7310Sstevel@tonic-gate } 7320Sstevel@tonic-gate 7330Sstevel@tonic-gate void 7341618Srie Dbg_file_skip(Lm_list *lml, const char *oname, const char *nname) 7350Sstevel@tonic-gate { 7361618Srie if (DBG_NOTCLASS(DBG_C_FILES)) 7370Sstevel@tonic-gate return; 7380Sstevel@tonic-gate 7391618Srie if (oname && strcmp(nname, oname)) 7401618Srie dbg_print(lml, MSG_INTL(MSG_FIL_SKIP_1), nname, oname); 7411618Srie else 7421618Srie dbg_print(lml, MSG_INTL(MSG_FIL_SKIP_2), nname); 7430Sstevel@tonic-gate } 7442978Srie 7452978Srie void 7462978Srie Dbg_file_modified(Lm_list *lml, const char *obj, const char *oname, 7472978Srie const char *nname, int ofd, int nfd, Elf *oelf, Elf *nelf) 7482978Srie { 7492978Srie const char *str; 7502978Srie 7512978Srie if (DBG_NOTCLASS(DBG_C_FILES | DBG_C_SUPPORT)) 7522978Srie return; 7532978Srie if (DBG_NOTDETAIL()) 7542978Srie return; 7552978Srie 7562978Srie Dbg_util_nl(lml, DBG_NL_STD); 7572978Srie dbg_print(lml, MSG_INTL(MSG_FIL_MODIFIED), oname, obj); 7582978Srie 7592978Srie if (nname != oname) 7602978Srie dbg_print(lml, MSG_INTL(MSG_FIL_NAMECHANGE), nname); 7612978Srie if (nfd != ofd) { 7622978Srie if (nfd == -1) 7632978Srie str = MSG_INTL(MSG_FIL_IGNORE); 7642978Srie else 7652978Srie str = MSG_ORIG(MSG_STR_EMPTY); 7662978Srie dbg_print(lml, MSG_INTL(MSG_FIL_FDCHANGE), ofd, nfd, str); 7672978Srie } 7682978Srie if (nelf != oelf) { 7692978Srie if (nelf == 0) 7702978Srie str = MSG_INTL(MSG_FIL_IGNORE); 7712978Srie else 7722978Srie str = MSG_ORIG(MSG_STR_EMPTY); 7732978Srie dbg_print(lml, MSG_INTL(MSG_FIL_ELFCHANGE), EC_NATPTR(oelf), 7742978Srie EC_NATPTR(nelf), str); 7752978Srie } 7762978Srie Dbg_util_nl(lml, DBG_NL_STD); 7772978Srie } 7783731Srie 7793731Srie void 7803731Srie Dbg_file_cleanup(Lm_list *lml, const char *name, Aliste lmco) 7813731Srie { 7823731Srie if (DBG_NOTCLASS(DBG_C_FILES)) 7833731Srie return; 7843731Srie 7853731Srie Dbg_util_nl(lml, DBG_NL_STD); 7863731Srie dbg_print(lml, MSG_INTL(MSG_FIL_CLEANUP), name, EC_XWORD(lmco)); 7873731Srie } 788