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 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 22*685Srie 230Sstevel@tonic-gate /* 240Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 250Sstevel@tonic-gate * Use is subject to license terms. 260Sstevel@tonic-gate */ 270Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 280Sstevel@tonic-gate 290Sstevel@tonic-gate #include "_synonyms.h" 300Sstevel@tonic-gate 316Srie #include <sys/auxv.h> 320Sstevel@tonic-gate #include <string.h> 330Sstevel@tonic-gate #include <unistd.h> 340Sstevel@tonic-gate #include <fcntl.h> 350Sstevel@tonic-gate #include <limits.h> 360Sstevel@tonic-gate #include <stdio.h> 370Sstevel@tonic-gate #include "msg.h" 380Sstevel@tonic-gate #include "_debug.h" 390Sstevel@tonic-gate #include "libld.h" 40280Srie #include "rtld.h" 410Sstevel@tonic-gate 420Sstevel@tonic-gate 430Sstevel@tonic-gate void 440Sstevel@tonic-gate Dbg_file_generic(Ifl_desc *ifl) 450Sstevel@tonic-gate { 460Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 470Sstevel@tonic-gate return; 480Sstevel@tonic-gate 490Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 500Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_BASIC), ifl->ifl_name, 510Sstevel@tonic-gate conv_etype_str(ifl->ifl_ehdr->e_type)); 520Sstevel@tonic-gate } 530Sstevel@tonic-gate 540Sstevel@tonic-gate void 550Sstevel@tonic-gate Dbg_file_skip(const char *nname, const char *oname) 560Sstevel@tonic-gate { 570Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 580Sstevel@tonic-gate return; 590Sstevel@tonic-gate 600Sstevel@tonic-gate if (oname && strcmp(nname, oname)) 610Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_SKIP_1), nname, oname); 620Sstevel@tonic-gate else 630Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_SKIP_2), nname); 640Sstevel@tonic-gate } 650Sstevel@tonic-gate 660Sstevel@tonic-gate void 670Sstevel@tonic-gate Dbg_file_reuse(const char *nname, const char *oname) 680Sstevel@tonic-gate { 690Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 700Sstevel@tonic-gate return; 710Sstevel@tonic-gate 720Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_REUSE), nname, oname); 730Sstevel@tonic-gate } 740Sstevel@tonic-gate 750Sstevel@tonic-gate void 760Sstevel@tonic-gate Dbg_file_archive(const char *name, int again) 770Sstevel@tonic-gate { 780Sstevel@tonic-gate const char *str; 790Sstevel@tonic-gate 800Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 810Sstevel@tonic-gate return; 820Sstevel@tonic-gate 830Sstevel@tonic-gate if (again) 840Sstevel@tonic-gate str = MSG_INTL(MSG_STR_AGAIN); 850Sstevel@tonic-gate else 860Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 870Sstevel@tonic-gate 880Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 890Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_ARCHIVE), name, str); 900Sstevel@tonic-gate } 910Sstevel@tonic-gate 920Sstevel@tonic-gate void 930Sstevel@tonic-gate Dbg_file_analyze(Rt_map * lmp) 940Sstevel@tonic-gate { 950Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 960Sstevel@tonic-gate return; 970Sstevel@tonic-gate 980Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 990Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_ANALYZE), NAME(lmp), 1000Sstevel@tonic-gate conv_dlmode_str(MODE(lmp), 1)); 1010Sstevel@tonic-gate } 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate void 1040Sstevel@tonic-gate Dbg_file_aout(const char *name, ulong_t dynamic, ulong_t base, ulong_t size) 1050Sstevel@tonic-gate { 1060Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1070Sstevel@tonic-gate return; 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_AOUT), name); 1100Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DATA_1), EC_XWORD(dynamic), 1110Sstevel@tonic-gate EC_ADDR(base), EC_XWORD(size)); 1120Sstevel@tonic-gate } 1130Sstevel@tonic-gate 1140Sstevel@tonic-gate void 1150Sstevel@tonic-gate Dbg_file_elf(const char *name, ulong_t dynamic, ulong_t base, 1160Sstevel@tonic-gate ulong_t size, ulong_t entry, Lmid_t lmid, Aliste lmco) 1170Sstevel@tonic-gate { 1180Sstevel@tonic-gate const char *str; 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1210Sstevel@tonic-gate return; 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate if (base == 0) 1240Sstevel@tonic-gate str = MSG_INTL(MSG_STR_TEMPORARY); 1250Sstevel@tonic-gate else 1260Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_ELF), name, str); 1290Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DATA_1), EC_XWORD(dynamic), 1300Sstevel@tonic-gate EC_ADDR(base), EC_XWORD(size)); 1310Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DATA_2), EC_XWORD(entry), 1320Sstevel@tonic-gate EC_XWORD(lmid), EC_XWORD(lmco)); 1330Sstevel@tonic-gate } 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate void 1366Srie Dbg_file_ldso(const char *name, ulong_t dynamic, ulong_t base, char **envp, 1376Srie auxv_t *auxv) 1380Sstevel@tonic-gate { 1390Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1400Sstevel@tonic-gate return; 1410Sstevel@tonic-gate 1420Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 1430Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_LDSO), name); 1440Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DATA_3), EC_XWORD(dynamic), 1450Sstevel@tonic-gate EC_ADDR(base)); 1460Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DATA_4), EC_ADDR(envp), EC_ADDR(auxv)); 1470Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 1480Sstevel@tonic-gate } 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate void 1510Sstevel@tonic-gate Dbg_file_prot(const char *name, int prot) 1520Sstevel@tonic-gate { 1530Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1540Sstevel@tonic-gate return; 1550Sstevel@tonic-gate 1560Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 1570Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_PROT), name, (prot ? '+' : '-')); 1580Sstevel@tonic-gate } 1590Sstevel@tonic-gate 1600Sstevel@tonic-gate void 1610Sstevel@tonic-gate Dbg_file_delete(const char *name) 1620Sstevel@tonic-gate { 1630Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1640Sstevel@tonic-gate return; 1650Sstevel@tonic-gate 1660Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 1670Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DELETE), name); 1680Sstevel@tonic-gate } 1690Sstevel@tonic-gate 1700Sstevel@tonic-gate static int hdl_title = 0; 1710Sstevel@tonic-gate static Msg hdl_str = 0; 1720Sstevel@tonic-gate 1730Sstevel@tonic-gate void 1740Sstevel@tonic-gate Dbg_file_hdl_title(int type) 1750Sstevel@tonic-gate { 1760Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1770Sstevel@tonic-gate return; 1780Sstevel@tonic-gate if (DBG_NOTDETAIL()) 1790Sstevel@tonic-gate return; 1800Sstevel@tonic-gate 1810Sstevel@tonic-gate hdl_title = 1; 1820Sstevel@tonic-gate 1830Sstevel@tonic-gate /* 1840Sstevel@tonic-gate * Establish a binding title for later use in Dbg_file_bind_entry. 1850Sstevel@tonic-gate */ 1860Sstevel@tonic-gate if (type == DBG_DEP_CREATE) 1870Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_CREATE; /* MSG_INTL(MSG_FIL_HDL_CREATE) */ 1880Sstevel@tonic-gate else if (type == DBG_DEP_ADD) 1890Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_ADD; /* MSG_INTL(MSG_FIL_HDL_ADD) */ 1900Sstevel@tonic-gate else if (type == DBG_DEP_DELETE) 1910Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_DELETE; /* MSG_INTL(MSG_FIL_HDL_DELETE) */ 1920Sstevel@tonic-gate else if (type == DBG_DEP_ORPHAN) 1930Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_ORPHAN; /* MSG_INTL(MSG_FIL_HDL_ORPHAN) */ 1940Sstevel@tonic-gate else if (type == DBG_DEP_REINST) 1950Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_REINST; /* MSG_INTL(MSG_FIL_HDL_REINST) */ 1960Sstevel@tonic-gate else 1970Sstevel@tonic-gate hdl_str = 0; 1980Sstevel@tonic-gate } 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate void 2010Sstevel@tonic-gate Dbg_file_hdl_collect(Grp_hdl * ghp, const char *name) 2020Sstevel@tonic-gate { 2030Sstevel@tonic-gate const char *str; 2040Sstevel@tonic-gate 2050Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 2060Sstevel@tonic-gate return; 2070Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2080Sstevel@tonic-gate return; 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate if (ghp->gh_owner) 2110Sstevel@tonic-gate str = NAME(ghp->gh_owner); 2120Sstevel@tonic-gate else 2130Sstevel@tonic-gate str = MSG_INTL(MSG_STR_ORPHAN); 2140Sstevel@tonic-gate 2150Sstevel@tonic-gate if (hdl_title) { 2160Sstevel@tonic-gate hdl_title = 0; 2170Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 2180Sstevel@tonic-gate } 2190Sstevel@tonic-gate if (name) 2200Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_HDL_RETAIN), str, name); 2210Sstevel@tonic-gate else 2220Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_HDL_COLLECT), str, 2230Sstevel@tonic-gate conv_grphdrflags_str(ghp->gh_flags)); 2240Sstevel@tonic-gate } 2250Sstevel@tonic-gate 2260Sstevel@tonic-gate void 2270Sstevel@tonic-gate Dbg_file_hdl_action(Grp_hdl * ghp, Rt_map * lmp, int type) 2280Sstevel@tonic-gate { 2290Sstevel@tonic-gate Msg str; 2300Sstevel@tonic-gate 2310Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 2320Sstevel@tonic-gate return; 2330Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2340Sstevel@tonic-gate return; 2350Sstevel@tonic-gate 2360Sstevel@tonic-gate if (hdl_title) { 2370Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 2380Sstevel@tonic-gate if (hdl_str) { 2390Sstevel@tonic-gate const char *name; 2400Sstevel@tonic-gate 2410Sstevel@tonic-gate /* 2420Sstevel@tonic-gate * Protect ourselves in case this handle has no 2430Sstevel@tonic-gate * originating owner. 2440Sstevel@tonic-gate */ 2450Sstevel@tonic-gate if (ghp->gh_owner) 2460Sstevel@tonic-gate name = NAME(ghp->gh_owner); 2470Sstevel@tonic-gate else 2480Sstevel@tonic-gate name = MSG_INTL(MSG_STR_UNKNOWN); 2490Sstevel@tonic-gate 2500Sstevel@tonic-gate dbg_print(MSG_INTL(hdl_str), name); 2510Sstevel@tonic-gate } 2520Sstevel@tonic-gate hdl_title = 0; 2530Sstevel@tonic-gate } 2540Sstevel@tonic-gate 2550Sstevel@tonic-gate if (type == DBG_DEP_ADD) 2560Sstevel@tonic-gate str = MSG_FIL_DEP_ADD; /* MSG_INTL(MSG_FIL_DEP_ADD) */ 2570Sstevel@tonic-gate else if (type == DBG_DEP_DELETE) 2580Sstevel@tonic-gate str = MSG_FIL_DEP_DELETE; /* MSG_INTL(MSG_FIL_DEP_DELETE) */ 2590Sstevel@tonic-gate else if (type == DBG_DEP_REMOVE) 2600Sstevel@tonic-gate str = MSG_FIL_DEP_REMOVE; /* MSG_INTL(MSG_FIL_DEP_REMOVE) */ 2610Sstevel@tonic-gate else if (type == DBG_DEP_REMAIN) 2620Sstevel@tonic-gate str = MSG_FIL_DEP_REMAIN; /* MSG_INTL(MSG_FIL_DEP_REMAIN) */ 2630Sstevel@tonic-gate else 2640Sstevel@tonic-gate str = 0; 2650Sstevel@tonic-gate 2660Sstevel@tonic-gate if (str) { 2670Sstevel@tonic-gate const char *mode; 2680Sstevel@tonic-gate 2690Sstevel@tonic-gate if ((MODE(lmp) & (RTLD_GLOBAL | RTLD_NODELETE)) == 2700Sstevel@tonic-gate (RTLD_GLOBAL | RTLD_NODELETE)) 2710Sstevel@tonic-gate mode = MSG_ORIG(MSG_MODE_GLOBNODEL); 2720Sstevel@tonic-gate else if (MODE(lmp) & RTLD_GLOBAL) 2730Sstevel@tonic-gate mode = MSG_ORIG(MSG_MODE_GLOB); 2740Sstevel@tonic-gate 2750Sstevel@tonic-gate else if (MODE(lmp) & RTLD_NODELETE) 2760Sstevel@tonic-gate mode = MSG_ORIG(MSG_MODE_NODEL); 2770Sstevel@tonic-gate else 2780Sstevel@tonic-gate mode = MSG_ORIG(MSG_STR_EMPTY); 2790Sstevel@tonic-gate 2800Sstevel@tonic-gate dbg_print(MSG_INTL(str), NAME(lmp), mode); 2810Sstevel@tonic-gate } 2820Sstevel@tonic-gate } 2830Sstevel@tonic-gate 2840Sstevel@tonic-gate void 2850Sstevel@tonic-gate Dbg_file_bind_entry(Bnd_desc *bdp) 2860Sstevel@tonic-gate { 2870Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 2880Sstevel@tonic-gate return; 2890Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2900Sstevel@tonic-gate return; 2910Sstevel@tonic-gate 2920Sstevel@tonic-gate /* 2930Sstevel@tonic-gate * Print the dependency together with the modes of the binding. 2940Sstevel@tonic-gate */ 2950Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 296280Srie dbg_print(MSG_INTL(MSG_FIL_BND_ADD), NAME(bdp->b_caller)); 297280Srie dbg_print(MSG_INTL(MSG_FIL_BND_FILE), NAME(bdp->b_depend), 298280Srie conv_bindent_str(bdp->b_flags)); 299280Srie } 300280Srie 301280Srie void 302280Srie Dbg_file_bindings(Rt_map *lmp, int flag, Word lmflags) 303280Srie { 304280Srie const char *str; 305280Srie Rt_map *tlmp; 306280Srie int next = 0; 307280Srie 308280Srie if (DBG_NOTCLASS(DBG_INIT)) 309280Srie return; 310280Srie if (DBG_NOTDETAIL()) 311280Srie return; 312280Srie 313280Srie if (flag & RT_SORT_REV) 314280Srie str = MSG_ORIG(MSG_SCN_INIT); 315280Srie else 316280Srie str = MSG_ORIG(MSG_SCN_FINI); 317280Srie 318280Srie dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 319280Srie dbg_print(MSG_INTL(MSG_FIL_DEP_TITLE), str, conv_binding_str(lmflags)); 320280Srie 321280Srie /* LINTED */ 322280Srie for (tlmp = lmp; tlmp; tlmp = (Rt_map *)NEXT(tlmp)) { 323280Srie Bnd_desc ** bdpp; 324280Srie Aliste off; 325280Srie 326280Srie /* 327280Srie * For .init processing, only collect objects that have been 328280Srie * relocated and haven't already been collected. 329280Srie * For .fini processing, only collect objects that have had 330280Srie * their .init collected, and haven't already been .fini 331280Srie * collected. 332280Srie */ 333280Srie if (flag & RT_SORT_REV) { 334280Srie if ((FLAGS(tlmp) & (FLG_RT_RELOCED | 335280Srie FLG_RT_INITCLCT)) != FLG_RT_RELOCED) 336280Srie continue; 337280Srie 338280Srie } else { 339280Srie if ((flag & RT_SORT_DELETE) && 340280Srie ((FLAGS(tlmp) & FLG_RT_DELETE) == 0)) 341280Srie continue; 342280Srie if (((FLAGS(tlmp) & 343280Srie (FLG_RT_INITCLCT | FLG_RT_FINICLCT)) == 344280Srie FLG_RT_INITCLCT) == 0) 345280Srie continue; 346280Srie } 347280Srie 348280Srie if (next++) 349280Srie dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 350280Srie 351280Srie if (DEPENDS(tlmp) == 0) 352280Srie dbg_print(MSG_INTL(MSG_FIL_DEP_NONE), NAME(tlmp)); 353280Srie else { 354280Srie dbg_print(MSG_INTL(MSG_FIL_DEP_ENT), NAME(tlmp)); 355280Srie 356280Srie for (ALIST_TRAVERSE(DEPENDS(tlmp), off, bdpp)) { 357280Srie dbg_print(MSG_INTL(MSG_FIL_BND_FILE), 358280Srie NAME((*bdpp)->b_depend), 359280Srie conv_bindent_str((*bdpp)->b_flags)); 360280Srie } 361280Srie } 362280Srie } 363280Srie dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 3640Sstevel@tonic-gate } 3650Sstevel@tonic-gate 3660Sstevel@tonic-gate void 3670Sstevel@tonic-gate Dbg_file_dlopen(const char *name, const char *from, int mode) 3680Sstevel@tonic-gate { 3690Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 3700Sstevel@tonic-gate return; 3710Sstevel@tonic-gate 3720Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 3730Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DLOPEN), name, from, 3740Sstevel@tonic-gate conv_dlmode_str(mode, 1)); 3750Sstevel@tonic-gate } 3760Sstevel@tonic-gate 3770Sstevel@tonic-gate void 3780Sstevel@tonic-gate Dbg_file_dlclose(const char *name, int flag) 3790Sstevel@tonic-gate { 3800Sstevel@tonic-gate const char *str; 3810Sstevel@tonic-gate 3820Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 3830Sstevel@tonic-gate return; 3840Sstevel@tonic-gate 3850Sstevel@tonic-gate if (flag == DBG_DLCLOSE_IGNORE) 3860Sstevel@tonic-gate str = MSG_INTL(MSG_STR_IGNORE); 3870Sstevel@tonic-gate else 3880Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 3890Sstevel@tonic-gate 3900Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 3910Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DLCLOSE), name, str); 3920Sstevel@tonic-gate } 3930Sstevel@tonic-gate 3940Sstevel@tonic-gate void 3950Sstevel@tonic-gate Dbg_file_dldump(const char *ipath, const char *opath, int flags) 3960Sstevel@tonic-gate { 3970Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 3980Sstevel@tonic-gate return; 3990Sstevel@tonic-gate 4000Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4010Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DLDUMP), ipath, opath, 4020Sstevel@tonic-gate conv_dlflag_str(flags, 0)); 4030Sstevel@tonic-gate } 4040Sstevel@tonic-gate 4050Sstevel@tonic-gate void 4060Sstevel@tonic-gate Dbg_file_lazyload(const char *file, const char *from, const char *symname) 4070Sstevel@tonic-gate { 4080Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4090Sstevel@tonic-gate return; 4100Sstevel@tonic-gate 4110Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4120Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_LAZYLOAD), file, from, 4130Sstevel@tonic-gate _Dbg_sym_dem(symname)); 4140Sstevel@tonic-gate } 4150Sstevel@tonic-gate 4160Sstevel@tonic-gate void 4170Sstevel@tonic-gate Dbg_file_nl() 4180Sstevel@tonic-gate { 4190Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4200Sstevel@tonic-gate return; 4210Sstevel@tonic-gate if (DBG_NOTDETAIL()) 4220Sstevel@tonic-gate return; 4230Sstevel@tonic-gate 4240Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4250Sstevel@tonic-gate } 4260Sstevel@tonic-gate 4270Sstevel@tonic-gate void 4280Sstevel@tonic-gate Dbg_file_preload(const char *name) 4290Sstevel@tonic-gate { 4300Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4310Sstevel@tonic-gate return; 4320Sstevel@tonic-gate 4330Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_PRELOAD), name); 4340Sstevel@tonic-gate } 4350Sstevel@tonic-gate 4360Sstevel@tonic-gate void 4370Sstevel@tonic-gate Dbg_file_needed(const char *name, const char *parent) 4380Sstevel@tonic-gate { 4390Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4400Sstevel@tonic-gate return; 4410Sstevel@tonic-gate 4420Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4430Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_NEEDED), name, parent); 4440Sstevel@tonic-gate } 4450Sstevel@tonic-gate 4460Sstevel@tonic-gate void 4470Sstevel@tonic-gate Dbg_file_filter(const char *filter, const char *filtee, int config) 4480Sstevel@tonic-gate { 4490Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4500Sstevel@tonic-gate return; 4510Sstevel@tonic-gate 4520Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4530Sstevel@tonic-gate if (config) 4540Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FILTER_1), filter, filtee); 4550Sstevel@tonic-gate else 4560Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FILTER_2), filter, filtee); 4570Sstevel@tonic-gate } 4580Sstevel@tonic-gate 4590Sstevel@tonic-gate void 4600Sstevel@tonic-gate Dbg_file_filtee(const char *filter, const char *filtee, int audit) 4610Sstevel@tonic-gate { 4620Sstevel@tonic-gate if (audit) { 4630Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_AUDITING | DBG_FILES)) 4640Sstevel@tonic-gate return; 4650Sstevel@tonic-gate 4660Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4670Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FILTEE_3), filtee); 4680Sstevel@tonic-gate } else { 4690Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4700Sstevel@tonic-gate return; 4710Sstevel@tonic-gate 4720Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4730Sstevel@tonic-gate if (filter) 4740Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FILTEE_1), filtee, filter); 4750Sstevel@tonic-gate else 4760Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FILTEE_2), filtee); 4770Sstevel@tonic-gate } 4780Sstevel@tonic-gate } 4790Sstevel@tonic-gate 4800Sstevel@tonic-gate void 4810Sstevel@tonic-gate Dbg_file_fixname(const char *oname, const char *nname) 4820Sstevel@tonic-gate { 4830Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4840Sstevel@tonic-gate return; 4850Sstevel@tonic-gate 4860Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4870Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FIXNAME), oname, nname); 4880Sstevel@tonic-gate } 4890Sstevel@tonic-gate 4900Sstevel@tonic-gate void 4910Sstevel@tonic-gate Dbg_file_output(Ofl_desc *ofl) 4920Sstevel@tonic-gate { 4930Sstevel@tonic-gate const char *prefix = MSG_ORIG(MSG_PTH_OBJECT); 4940Sstevel@tonic-gate char *oname, *nname, *ofile; 4950Sstevel@tonic-gate int fd; 4960Sstevel@tonic-gate 4970Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4980Sstevel@tonic-gate return; 4990Sstevel@tonic-gate if (DBG_NOTDETAIL()) 5000Sstevel@tonic-gate return; 5010Sstevel@tonic-gate 5020Sstevel@tonic-gate /* 5030Sstevel@tonic-gate * Obtain the present input object filename for concatenation to the 5040Sstevel@tonic-gate * prefix name. 5050Sstevel@tonic-gate */ 5060Sstevel@tonic-gate oname = (char *)ofl->ofl_name; 5070Sstevel@tonic-gate if ((ofile = strrchr(oname, '/')) == NULL) 5080Sstevel@tonic-gate ofile = oname; 5090Sstevel@tonic-gate else 5100Sstevel@tonic-gate ofile++; 5110Sstevel@tonic-gate 5120Sstevel@tonic-gate /* 5130Sstevel@tonic-gate * Concatenate the prefix with the object filename, open the file and 5140Sstevel@tonic-gate * write out the present Elf memory image. As this is debugging we 5150Sstevel@tonic-gate * ignore all errors. 5160Sstevel@tonic-gate */ 5170Sstevel@tonic-gate if ((nname = (char *)malloc(strlen(prefix) + strlen(ofile) + 1)) != 0) { 5180Sstevel@tonic-gate (void) strcpy(nname, prefix); 5190Sstevel@tonic-gate (void) strcat(nname, ofile); 5200Sstevel@tonic-gate if ((fd = open(nname, O_RDWR | O_CREAT | O_TRUNC, 5210Sstevel@tonic-gate 0666)) != -1) { 5220Sstevel@tonic-gate (void) write(fd, ofl->ofl_ehdr, ofl->ofl_size); 5230Sstevel@tonic-gate close(fd); 5240Sstevel@tonic-gate } 5250Sstevel@tonic-gate free(nname); 5260Sstevel@tonic-gate } 5270Sstevel@tonic-gate } 5280Sstevel@tonic-gate 5290Sstevel@tonic-gate void 5300Sstevel@tonic-gate Dbg_file_config_dis(const char *config, int features) 5310Sstevel@tonic-gate { 5320Sstevel@tonic-gate const char *str; 5330Sstevel@tonic-gate int error = features & ~CONF_FEATMSK; 5340Sstevel@tonic-gate 5350Sstevel@tonic-gate if (error == DBG_CONF_IGNORE) 5360Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_1); 5370Sstevel@tonic-gate else if (error == DBG_CONF_VERSION) 5380Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_2); 5390Sstevel@tonic-gate else if (error == DBG_CONF_PRCFAIL) 5400Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_3); 5410Sstevel@tonic-gate else if (error == DBG_CONF_CORRUPT) 5420Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_4); 5430Sstevel@tonic-gate else 5440Sstevel@tonic-gate str = conv_config_str(features); 5450Sstevel@tonic-gate 5460Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5470Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_CONFIG_ERR), config, str); 5480Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5490Sstevel@tonic-gate } 5500Sstevel@tonic-gate 5510Sstevel@tonic-gate void 5520Sstevel@tonic-gate Dbg_file_config_obj(const char *dir, const char *file, const char *config) 5530Sstevel@tonic-gate { 5540Sstevel@tonic-gate char *name, _name[PATH_MAX]; 5550Sstevel@tonic-gate 5560Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 5570Sstevel@tonic-gate return; 5580Sstevel@tonic-gate 5590Sstevel@tonic-gate if (file) { 5600Sstevel@tonic-gate (void) snprintf(_name, PATH_MAX, MSG_ORIG(MSG_FMT_PATH), 5610Sstevel@tonic-gate dir, file); 5620Sstevel@tonic-gate name = _name; 5630Sstevel@tonic-gate } else 5640Sstevel@tonic-gate name = (char *)dir; 5650Sstevel@tonic-gate 5660Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_CONFIG), name, config); 5670Sstevel@tonic-gate } 5680Sstevel@tonic-gate 5690Sstevel@tonic-gate #if !defined(_ELF64) 5700Sstevel@tonic-gate 5710Sstevel@tonic-gate const Msg 5720Sstevel@tonic-gate reject[] = { 5730Sstevel@tonic-gate MSG_STR_EMPTY, 5740Sstevel@tonic-gate MSG_REJ_MACH, /* MSG_INTL(MSG_REJ_MACH) */ 5750Sstevel@tonic-gate MSG_REJ_CLASS, /* MSG_INTL(MSG_REJ_CLASS) */ 5760Sstevel@tonic-gate MSG_REJ_DATA, /* MSG_INTL(MSG_REJ_DATA) */ 5770Sstevel@tonic-gate MSG_REJ_TYPE, /* MSG_INTL(MSG_REJ_TYPE) */ 5780Sstevel@tonic-gate MSG_REJ_BADFLAG, /* MSG_INTL(MSG_REJ_BADFLAG) */ 5790Sstevel@tonic-gate MSG_REJ_MISFLAG, /* MSG_INTL(MSG_REJ_MISFLAG) */ 5800Sstevel@tonic-gate MSG_REJ_VERSION, /* MSG_INTL(MSG_REJ_VERSION) */ 5810Sstevel@tonic-gate MSG_REJ_HAL, /* MSG_INTL(MSG_REJ_HAL) */ 5820Sstevel@tonic-gate MSG_REJ_US3, /* MSG_INTL(MSG_REJ_US3) */ 5830Sstevel@tonic-gate MSG_REJ_STR, /* MSG_INTL(MSG_REJ_STR) */ 5840Sstevel@tonic-gate MSG_REJ_UNKFILE, /* MSG_INTL(MSG_REJ_UNKFILE) */ 5850Sstevel@tonic-gate MSG_REJ_HWCAP_1, /* MSG_INTL(MSG_REJ_HWCAP_1) */ 5860Sstevel@tonic-gate }; 5870Sstevel@tonic-gate 5880Sstevel@tonic-gate void 5890Sstevel@tonic-gate Dbg_file_rejected(Rej_desc *rej) 5900Sstevel@tonic-gate { 5910Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 5920Sstevel@tonic-gate return; 5930Sstevel@tonic-gate 5940Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5950Sstevel@tonic-gate dbg_print(MSG_INTL(reject[rej->rej_type]), rej->rej_name ? 5960Sstevel@tonic-gate rej->rej_name : MSG_INTL(MSG_STR_UNKNOWN), conv_reject_str(rej)); 5970Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5980Sstevel@tonic-gate } 5990Sstevel@tonic-gate 6000Sstevel@tonic-gate void 6010Sstevel@tonic-gate Dbg_file_del_rescan(void) 6020Sstevel@tonic-gate { 6030Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 6040Sstevel@tonic-gate return; 6050Sstevel@tonic-gate 6060Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6070Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DEL_RESCAN)); 6080Sstevel@tonic-gate } 6090Sstevel@tonic-gate 6100Sstevel@tonic-gate void 6110Sstevel@tonic-gate Dbg_file_ar_rescan(void) 6120Sstevel@tonic-gate { 6130Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 6140Sstevel@tonic-gate return; 6150Sstevel@tonic-gate 6160Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6170Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_AR_RESCAN)); 6180Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6190Sstevel@tonic-gate } 6200Sstevel@tonic-gate 6210Sstevel@tonic-gate void 6220Sstevel@tonic-gate Dbg_file_mode_promote(const char *file, int mode) 6230Sstevel@tonic-gate { 6240Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 6250Sstevel@tonic-gate return; 6260Sstevel@tonic-gate 6270Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6280Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_PROMOTE), file, conv_dlmode_str(mode, 0)); 6290Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6300Sstevel@tonic-gate } 6310Sstevel@tonic-gate 6320Sstevel@tonic-gate void 6330Sstevel@tonic-gate Dbg_file_cntl(Lm_list *lml, Aliste flmco, Aliste tlmco) 6340Sstevel@tonic-gate { 6350Sstevel@tonic-gate Lm_cntl *lmc; 6360Sstevel@tonic-gate Aliste off; 6370Sstevel@tonic-gate 6380Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 6390Sstevel@tonic-gate return; 6400Sstevel@tonic-gate if (DBG_NOTDETAIL()) 6410Sstevel@tonic-gate return; 6420Sstevel@tonic-gate 6430Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6440Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_CNTL_TITLE), EC_XWORD(flmco), EC_XWORD(tlmco)); 6450Sstevel@tonic-gate 6460Sstevel@tonic-gate for (ALIST_TRAVERSE(lml->lm_lists, off, lmc)) { 6470Sstevel@tonic-gate Rt_map *lmp; 6480Sstevel@tonic-gate 649*685Srie if (lmc->lc_head == 0) { 650*685Srie dbg_print(MSG_ORIG(MSG_CNTL_ENTRY), EC_XWORD(off), 651*685Srie MSG_ORIG(MSG_STR_EMPTY)); 652*685Srie continue; 653*685Srie } 6540Sstevel@tonic-gate for (lmp = lmc->lc_head; lmp; lmp = (Rt_map *)NEXT(lmp)) 6550Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_CNTL_ENTRY), EC_XWORD(off), 6560Sstevel@tonic-gate NAME(lmp)); 6570Sstevel@tonic-gate } 6580Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6590Sstevel@tonic-gate } 6600Sstevel@tonic-gate #endif 661