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 */ 220Sstevel@tonic-gate /* 230Sstevel@tonic-gate * Copyright 2005 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 280Sstevel@tonic-gate #include "_synonyms.h" 290Sstevel@tonic-gate 306Srie #include <sys/auxv.h> 310Sstevel@tonic-gate #include <string.h> 320Sstevel@tonic-gate #include <unistd.h> 330Sstevel@tonic-gate #include <fcntl.h> 340Sstevel@tonic-gate #include <limits.h> 350Sstevel@tonic-gate #include <stdio.h> 360Sstevel@tonic-gate #include "msg.h" 370Sstevel@tonic-gate #include "_debug.h" 380Sstevel@tonic-gate #include "libld.h" 39*280Srie #include "rtld.h" 400Sstevel@tonic-gate 410Sstevel@tonic-gate 420Sstevel@tonic-gate void 430Sstevel@tonic-gate Dbg_file_generic(Ifl_desc *ifl) 440Sstevel@tonic-gate { 450Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 460Sstevel@tonic-gate return; 470Sstevel@tonic-gate 480Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 490Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_BASIC), ifl->ifl_name, 500Sstevel@tonic-gate conv_etype_str(ifl->ifl_ehdr->e_type)); 510Sstevel@tonic-gate } 520Sstevel@tonic-gate 530Sstevel@tonic-gate void 540Sstevel@tonic-gate Dbg_file_skip(const char *nname, const char *oname) 550Sstevel@tonic-gate { 560Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 570Sstevel@tonic-gate return; 580Sstevel@tonic-gate 590Sstevel@tonic-gate if (oname && strcmp(nname, oname)) 600Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_SKIP_1), nname, oname); 610Sstevel@tonic-gate else 620Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_SKIP_2), nname); 630Sstevel@tonic-gate } 640Sstevel@tonic-gate 650Sstevel@tonic-gate void 660Sstevel@tonic-gate Dbg_file_reuse(const char *nname, const char *oname) 670Sstevel@tonic-gate { 680Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 690Sstevel@tonic-gate return; 700Sstevel@tonic-gate 710Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_REUSE), nname, oname); 720Sstevel@tonic-gate } 730Sstevel@tonic-gate 740Sstevel@tonic-gate void 750Sstevel@tonic-gate Dbg_file_archive(const char *name, int again) 760Sstevel@tonic-gate { 770Sstevel@tonic-gate const char *str; 780Sstevel@tonic-gate 790Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 800Sstevel@tonic-gate return; 810Sstevel@tonic-gate 820Sstevel@tonic-gate if (again) 830Sstevel@tonic-gate str = MSG_INTL(MSG_STR_AGAIN); 840Sstevel@tonic-gate else 850Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 860Sstevel@tonic-gate 870Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 880Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_ARCHIVE), name, str); 890Sstevel@tonic-gate } 900Sstevel@tonic-gate 910Sstevel@tonic-gate void 920Sstevel@tonic-gate Dbg_file_analyze(Rt_map * lmp) 930Sstevel@tonic-gate { 940Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 950Sstevel@tonic-gate return; 960Sstevel@tonic-gate 970Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 980Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_ANALYZE), NAME(lmp), 990Sstevel@tonic-gate conv_dlmode_str(MODE(lmp), 1)); 1000Sstevel@tonic-gate } 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate void 1030Sstevel@tonic-gate Dbg_file_aout(const char *name, ulong_t dynamic, ulong_t base, ulong_t size) 1040Sstevel@tonic-gate { 1050Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1060Sstevel@tonic-gate return; 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_AOUT), name); 1090Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DATA_1), EC_XWORD(dynamic), 1100Sstevel@tonic-gate EC_ADDR(base), EC_XWORD(size)); 1110Sstevel@tonic-gate } 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate void 1140Sstevel@tonic-gate Dbg_file_elf(const char *name, ulong_t dynamic, ulong_t base, 1150Sstevel@tonic-gate ulong_t size, ulong_t entry, Lmid_t lmid, Aliste lmco) 1160Sstevel@tonic-gate { 1170Sstevel@tonic-gate const char *str; 1180Sstevel@tonic-gate 1190Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1200Sstevel@tonic-gate return; 1210Sstevel@tonic-gate 1220Sstevel@tonic-gate if (base == 0) 1230Sstevel@tonic-gate str = MSG_INTL(MSG_STR_TEMPORARY); 1240Sstevel@tonic-gate else 1250Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 1260Sstevel@tonic-gate 1270Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_ELF), name, str); 1280Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DATA_1), EC_XWORD(dynamic), 1290Sstevel@tonic-gate EC_ADDR(base), EC_XWORD(size)); 1300Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DATA_2), EC_XWORD(entry), 1310Sstevel@tonic-gate EC_XWORD(lmid), EC_XWORD(lmco)); 1320Sstevel@tonic-gate } 1330Sstevel@tonic-gate 1340Sstevel@tonic-gate void 1356Srie Dbg_file_ldso(const char *name, ulong_t dynamic, ulong_t base, char **envp, 1366Srie auxv_t *auxv) 1370Sstevel@tonic-gate { 1380Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1390Sstevel@tonic-gate return; 1400Sstevel@tonic-gate 1410Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 1420Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_LDSO), name); 1430Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DATA_3), EC_XWORD(dynamic), 1440Sstevel@tonic-gate EC_ADDR(base)); 1450Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DATA_4), EC_ADDR(envp), EC_ADDR(auxv)); 1460Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 1470Sstevel@tonic-gate } 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate void 1500Sstevel@tonic-gate Dbg_file_prot(const char *name, int prot) 1510Sstevel@tonic-gate { 1520Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1530Sstevel@tonic-gate return; 1540Sstevel@tonic-gate 1550Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 1560Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_PROT), name, (prot ? '+' : '-')); 1570Sstevel@tonic-gate } 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate void 1600Sstevel@tonic-gate Dbg_file_delete(const char *name) 1610Sstevel@tonic-gate { 1620Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1630Sstevel@tonic-gate return; 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 1660Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DELETE), name); 1670Sstevel@tonic-gate } 1680Sstevel@tonic-gate 1690Sstevel@tonic-gate static int hdl_title = 0; 1700Sstevel@tonic-gate static Msg hdl_str = 0; 1710Sstevel@tonic-gate 1720Sstevel@tonic-gate void 1730Sstevel@tonic-gate Dbg_file_hdl_title(int type) 1740Sstevel@tonic-gate { 1750Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1760Sstevel@tonic-gate return; 1770Sstevel@tonic-gate if (DBG_NOTDETAIL()) 1780Sstevel@tonic-gate return; 1790Sstevel@tonic-gate 1800Sstevel@tonic-gate hdl_title = 1; 1810Sstevel@tonic-gate 1820Sstevel@tonic-gate /* 1830Sstevel@tonic-gate * Establish a binding title for later use in Dbg_file_bind_entry. 1840Sstevel@tonic-gate */ 1850Sstevel@tonic-gate if (type == DBG_DEP_CREATE) 1860Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_CREATE; /* MSG_INTL(MSG_FIL_HDL_CREATE) */ 1870Sstevel@tonic-gate else if (type == DBG_DEP_ADD) 1880Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_ADD; /* MSG_INTL(MSG_FIL_HDL_ADD) */ 1890Sstevel@tonic-gate else if (type == DBG_DEP_DELETE) 1900Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_DELETE; /* MSG_INTL(MSG_FIL_HDL_DELETE) */ 1910Sstevel@tonic-gate else if (type == DBG_DEP_ORPHAN) 1920Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_ORPHAN; /* MSG_INTL(MSG_FIL_HDL_ORPHAN) */ 1930Sstevel@tonic-gate else if (type == DBG_DEP_REINST) 1940Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_REINST; /* MSG_INTL(MSG_FIL_HDL_REINST) */ 1950Sstevel@tonic-gate else 1960Sstevel@tonic-gate hdl_str = 0; 1970Sstevel@tonic-gate } 1980Sstevel@tonic-gate 1990Sstevel@tonic-gate void 2000Sstevel@tonic-gate Dbg_file_hdl_collect(Grp_hdl * ghp, const char *name) 2010Sstevel@tonic-gate { 2020Sstevel@tonic-gate const char *str; 2030Sstevel@tonic-gate 2040Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 2050Sstevel@tonic-gate return; 2060Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2070Sstevel@tonic-gate return; 2080Sstevel@tonic-gate 2090Sstevel@tonic-gate if (ghp->gh_owner) 2100Sstevel@tonic-gate str = NAME(ghp->gh_owner); 2110Sstevel@tonic-gate else 2120Sstevel@tonic-gate str = MSG_INTL(MSG_STR_ORPHAN); 2130Sstevel@tonic-gate 2140Sstevel@tonic-gate if (hdl_title) { 2150Sstevel@tonic-gate hdl_title = 0; 2160Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 2170Sstevel@tonic-gate } 2180Sstevel@tonic-gate if (name) 2190Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_HDL_RETAIN), str, name); 2200Sstevel@tonic-gate else 2210Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_HDL_COLLECT), str, 2220Sstevel@tonic-gate conv_grphdrflags_str(ghp->gh_flags)); 2230Sstevel@tonic-gate } 2240Sstevel@tonic-gate 2250Sstevel@tonic-gate void 2260Sstevel@tonic-gate Dbg_file_hdl_action(Grp_hdl * ghp, Rt_map * lmp, int type) 2270Sstevel@tonic-gate { 2280Sstevel@tonic-gate Msg str; 2290Sstevel@tonic-gate 2300Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 2310Sstevel@tonic-gate return; 2320Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2330Sstevel@tonic-gate return; 2340Sstevel@tonic-gate 2350Sstevel@tonic-gate if (hdl_title) { 2360Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 2370Sstevel@tonic-gate if (hdl_str) { 2380Sstevel@tonic-gate const char *name; 2390Sstevel@tonic-gate 2400Sstevel@tonic-gate /* 2410Sstevel@tonic-gate * Protect ourselves in case this handle has no 2420Sstevel@tonic-gate * originating owner. 2430Sstevel@tonic-gate */ 2440Sstevel@tonic-gate if (ghp->gh_owner) 2450Sstevel@tonic-gate name = NAME(ghp->gh_owner); 2460Sstevel@tonic-gate else 2470Sstevel@tonic-gate name = MSG_INTL(MSG_STR_UNKNOWN); 2480Sstevel@tonic-gate 2490Sstevel@tonic-gate dbg_print(MSG_INTL(hdl_str), name); 2500Sstevel@tonic-gate } 2510Sstevel@tonic-gate hdl_title = 0; 2520Sstevel@tonic-gate } 2530Sstevel@tonic-gate 2540Sstevel@tonic-gate if (type == DBG_DEP_ADD) 2550Sstevel@tonic-gate str = MSG_FIL_DEP_ADD; /* MSG_INTL(MSG_FIL_DEP_ADD) */ 2560Sstevel@tonic-gate else if (type == DBG_DEP_DELETE) 2570Sstevel@tonic-gate str = MSG_FIL_DEP_DELETE; /* MSG_INTL(MSG_FIL_DEP_DELETE) */ 2580Sstevel@tonic-gate else if (type == DBG_DEP_REMOVE) 2590Sstevel@tonic-gate str = MSG_FIL_DEP_REMOVE; /* MSG_INTL(MSG_FIL_DEP_REMOVE) */ 2600Sstevel@tonic-gate else if (type == DBG_DEP_REMAIN) 2610Sstevel@tonic-gate str = MSG_FIL_DEP_REMAIN; /* MSG_INTL(MSG_FIL_DEP_REMAIN) */ 2620Sstevel@tonic-gate else 2630Sstevel@tonic-gate str = 0; 2640Sstevel@tonic-gate 2650Sstevel@tonic-gate if (str) { 2660Sstevel@tonic-gate const char *mode; 2670Sstevel@tonic-gate 2680Sstevel@tonic-gate if ((MODE(lmp) & (RTLD_GLOBAL | RTLD_NODELETE)) == 2690Sstevel@tonic-gate (RTLD_GLOBAL | RTLD_NODELETE)) 2700Sstevel@tonic-gate mode = MSG_ORIG(MSG_MODE_GLOBNODEL); 2710Sstevel@tonic-gate else if (MODE(lmp) & RTLD_GLOBAL) 2720Sstevel@tonic-gate mode = MSG_ORIG(MSG_MODE_GLOB); 2730Sstevel@tonic-gate 2740Sstevel@tonic-gate else if (MODE(lmp) & RTLD_NODELETE) 2750Sstevel@tonic-gate mode = MSG_ORIG(MSG_MODE_NODEL); 2760Sstevel@tonic-gate else 2770Sstevel@tonic-gate mode = MSG_ORIG(MSG_STR_EMPTY); 2780Sstevel@tonic-gate 2790Sstevel@tonic-gate dbg_print(MSG_INTL(str), NAME(lmp), mode); 2800Sstevel@tonic-gate } 2810Sstevel@tonic-gate } 2820Sstevel@tonic-gate 2830Sstevel@tonic-gate void 2840Sstevel@tonic-gate Dbg_file_bind_entry(Bnd_desc *bdp) 2850Sstevel@tonic-gate { 2860Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 2870Sstevel@tonic-gate return; 2880Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2890Sstevel@tonic-gate return; 2900Sstevel@tonic-gate 2910Sstevel@tonic-gate /* 2920Sstevel@tonic-gate * Print the dependency together with the modes of the binding. 2930Sstevel@tonic-gate */ 2940Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 295*280Srie dbg_print(MSG_INTL(MSG_FIL_BND_ADD), NAME(bdp->b_caller)); 296*280Srie dbg_print(MSG_INTL(MSG_FIL_BND_FILE), NAME(bdp->b_depend), 297*280Srie conv_bindent_str(bdp->b_flags)); 298*280Srie } 299*280Srie 300*280Srie void 301*280Srie Dbg_file_bindings(Rt_map *lmp, int flag, Word lmflags) 302*280Srie { 303*280Srie const char *str; 304*280Srie Rt_map *tlmp; 305*280Srie int next = 0; 306*280Srie 307*280Srie if (DBG_NOTCLASS(DBG_INIT)) 308*280Srie return; 309*280Srie if (DBG_NOTDETAIL()) 310*280Srie return; 311*280Srie 312*280Srie if (flag & RT_SORT_REV) 313*280Srie str = MSG_ORIG(MSG_SCN_INIT); 314*280Srie else 315*280Srie str = MSG_ORIG(MSG_SCN_FINI); 316*280Srie 317*280Srie dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 318*280Srie dbg_print(MSG_INTL(MSG_FIL_DEP_TITLE), str, conv_binding_str(lmflags)); 319*280Srie 320*280Srie /* LINTED */ 321*280Srie for (tlmp = lmp; tlmp; tlmp = (Rt_map *)NEXT(tlmp)) { 322*280Srie Bnd_desc ** bdpp; 323*280Srie Aliste off; 324*280Srie 325*280Srie /* 326*280Srie * For .init processing, only collect objects that have been 327*280Srie * relocated and haven't already been collected. 328*280Srie * For .fini processing, only collect objects that have had 329*280Srie * their .init collected, and haven't already been .fini 330*280Srie * collected. 331*280Srie */ 332*280Srie if (flag & RT_SORT_REV) { 333*280Srie if ((FLAGS(tlmp) & (FLG_RT_RELOCED | 334*280Srie FLG_RT_INITCLCT)) != FLG_RT_RELOCED) 335*280Srie continue; 336*280Srie 337*280Srie } else { 338*280Srie if ((flag & RT_SORT_DELETE) && 339*280Srie ((FLAGS(tlmp) & FLG_RT_DELETE) == 0)) 340*280Srie continue; 341*280Srie if (((FLAGS(tlmp) & 342*280Srie (FLG_RT_INITCLCT | FLG_RT_FINICLCT)) == 343*280Srie FLG_RT_INITCLCT) == 0) 344*280Srie continue; 345*280Srie } 346*280Srie 347*280Srie if (next++) 348*280Srie dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 349*280Srie 350*280Srie if (DEPENDS(tlmp) == 0) 351*280Srie dbg_print(MSG_INTL(MSG_FIL_DEP_NONE), NAME(tlmp)); 352*280Srie else { 353*280Srie dbg_print(MSG_INTL(MSG_FIL_DEP_ENT), NAME(tlmp)); 354*280Srie 355*280Srie for (ALIST_TRAVERSE(DEPENDS(tlmp), off, bdpp)) { 356*280Srie dbg_print(MSG_INTL(MSG_FIL_BND_FILE), 357*280Srie NAME((*bdpp)->b_depend), 358*280Srie conv_bindent_str((*bdpp)->b_flags)); 359*280Srie } 360*280Srie } 361*280Srie } 362*280Srie dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 3630Sstevel@tonic-gate } 3640Sstevel@tonic-gate 3650Sstevel@tonic-gate void 3660Sstevel@tonic-gate Dbg_file_dlopen(const char *name, const char *from, int mode) 3670Sstevel@tonic-gate { 3680Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 3690Sstevel@tonic-gate return; 3700Sstevel@tonic-gate 3710Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 3720Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DLOPEN), name, from, 3730Sstevel@tonic-gate conv_dlmode_str(mode, 1)); 3740Sstevel@tonic-gate } 3750Sstevel@tonic-gate 3760Sstevel@tonic-gate void 3770Sstevel@tonic-gate Dbg_file_dlclose(const char *name, int flag) 3780Sstevel@tonic-gate { 3790Sstevel@tonic-gate const char *str; 3800Sstevel@tonic-gate 3810Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 3820Sstevel@tonic-gate return; 3830Sstevel@tonic-gate 3840Sstevel@tonic-gate if (flag == DBG_DLCLOSE_IGNORE) 3850Sstevel@tonic-gate str = MSG_INTL(MSG_STR_IGNORE); 3860Sstevel@tonic-gate else 3870Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 3880Sstevel@tonic-gate 3890Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 3900Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DLCLOSE), name, str); 3910Sstevel@tonic-gate } 3920Sstevel@tonic-gate 3930Sstevel@tonic-gate void 3940Sstevel@tonic-gate Dbg_file_dldump(const char *ipath, const char *opath, int flags) 3950Sstevel@tonic-gate { 3960Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 3970Sstevel@tonic-gate return; 3980Sstevel@tonic-gate 3990Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4000Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DLDUMP), ipath, opath, 4010Sstevel@tonic-gate conv_dlflag_str(flags, 0)); 4020Sstevel@tonic-gate } 4030Sstevel@tonic-gate 4040Sstevel@tonic-gate void 4050Sstevel@tonic-gate Dbg_file_lazyload(const char *file, const char *from, const char *symname) 4060Sstevel@tonic-gate { 4070Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4080Sstevel@tonic-gate return; 4090Sstevel@tonic-gate 4100Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4110Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_LAZYLOAD), file, from, 4120Sstevel@tonic-gate _Dbg_sym_dem(symname)); 4130Sstevel@tonic-gate } 4140Sstevel@tonic-gate 4150Sstevel@tonic-gate void 4160Sstevel@tonic-gate Dbg_file_nl() 4170Sstevel@tonic-gate { 4180Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4190Sstevel@tonic-gate return; 4200Sstevel@tonic-gate if (DBG_NOTDETAIL()) 4210Sstevel@tonic-gate return; 4220Sstevel@tonic-gate 4230Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4240Sstevel@tonic-gate } 4250Sstevel@tonic-gate 4260Sstevel@tonic-gate void 4270Sstevel@tonic-gate Dbg_file_preload(const char *name) 4280Sstevel@tonic-gate { 4290Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4300Sstevel@tonic-gate return; 4310Sstevel@tonic-gate 4320Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_PRELOAD), name); 4330Sstevel@tonic-gate } 4340Sstevel@tonic-gate 4350Sstevel@tonic-gate void 4360Sstevel@tonic-gate Dbg_file_needed(const char *name, const char *parent) 4370Sstevel@tonic-gate { 4380Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4390Sstevel@tonic-gate return; 4400Sstevel@tonic-gate 4410Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4420Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_NEEDED), name, parent); 4430Sstevel@tonic-gate } 4440Sstevel@tonic-gate 4450Sstevel@tonic-gate void 4460Sstevel@tonic-gate Dbg_file_filter(const char *filter, const char *filtee, int config) 4470Sstevel@tonic-gate { 4480Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4490Sstevel@tonic-gate return; 4500Sstevel@tonic-gate 4510Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4520Sstevel@tonic-gate if (config) 4530Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FILTER_1), filter, filtee); 4540Sstevel@tonic-gate else 4550Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FILTER_2), filter, filtee); 4560Sstevel@tonic-gate } 4570Sstevel@tonic-gate 4580Sstevel@tonic-gate void 4590Sstevel@tonic-gate Dbg_file_filtee(const char *filter, const char *filtee, int audit) 4600Sstevel@tonic-gate { 4610Sstevel@tonic-gate if (audit) { 4620Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_AUDITING | DBG_FILES)) 4630Sstevel@tonic-gate return; 4640Sstevel@tonic-gate 4650Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4660Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FILTEE_3), filtee); 4670Sstevel@tonic-gate } else { 4680Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4690Sstevel@tonic-gate return; 4700Sstevel@tonic-gate 4710Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4720Sstevel@tonic-gate if (filter) 4730Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FILTEE_1), filtee, filter); 4740Sstevel@tonic-gate else 4750Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FILTEE_2), filtee); 4760Sstevel@tonic-gate } 4770Sstevel@tonic-gate } 4780Sstevel@tonic-gate 4790Sstevel@tonic-gate void 4800Sstevel@tonic-gate Dbg_file_fixname(const char *oname, const char *nname) 4810Sstevel@tonic-gate { 4820Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4830Sstevel@tonic-gate return; 4840Sstevel@tonic-gate 4850Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4860Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FIXNAME), oname, nname); 4870Sstevel@tonic-gate } 4880Sstevel@tonic-gate 4890Sstevel@tonic-gate void 4900Sstevel@tonic-gate Dbg_file_output(Ofl_desc *ofl) 4910Sstevel@tonic-gate { 4920Sstevel@tonic-gate const char *prefix = MSG_ORIG(MSG_PTH_OBJECT); 4930Sstevel@tonic-gate char *oname, *nname, *ofile; 4940Sstevel@tonic-gate int fd; 4950Sstevel@tonic-gate 4960Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4970Sstevel@tonic-gate return; 4980Sstevel@tonic-gate if (DBG_NOTDETAIL()) 4990Sstevel@tonic-gate return; 5000Sstevel@tonic-gate 5010Sstevel@tonic-gate /* 5020Sstevel@tonic-gate * Obtain the present input object filename for concatenation to the 5030Sstevel@tonic-gate * prefix name. 5040Sstevel@tonic-gate */ 5050Sstevel@tonic-gate oname = (char *)ofl->ofl_name; 5060Sstevel@tonic-gate if ((ofile = strrchr(oname, '/')) == NULL) 5070Sstevel@tonic-gate ofile = oname; 5080Sstevel@tonic-gate else 5090Sstevel@tonic-gate ofile++; 5100Sstevel@tonic-gate 5110Sstevel@tonic-gate /* 5120Sstevel@tonic-gate * Concatenate the prefix with the object filename, open the file and 5130Sstevel@tonic-gate * write out the present Elf memory image. As this is debugging we 5140Sstevel@tonic-gate * ignore all errors. 5150Sstevel@tonic-gate */ 5160Sstevel@tonic-gate if ((nname = (char *)malloc(strlen(prefix) + strlen(ofile) + 1)) != 0) { 5170Sstevel@tonic-gate (void) strcpy(nname, prefix); 5180Sstevel@tonic-gate (void) strcat(nname, ofile); 5190Sstevel@tonic-gate if ((fd = open(nname, O_RDWR | O_CREAT | O_TRUNC, 5200Sstevel@tonic-gate 0666)) != -1) { 5210Sstevel@tonic-gate (void) write(fd, ofl->ofl_ehdr, ofl->ofl_size); 5220Sstevel@tonic-gate close(fd); 5230Sstevel@tonic-gate } 5240Sstevel@tonic-gate free(nname); 5250Sstevel@tonic-gate } 5260Sstevel@tonic-gate } 5270Sstevel@tonic-gate 5280Sstevel@tonic-gate void 5290Sstevel@tonic-gate Dbg_file_config_dis(const char *config, int features) 5300Sstevel@tonic-gate { 5310Sstevel@tonic-gate const char *str; 5320Sstevel@tonic-gate int error = features & ~CONF_FEATMSK; 5330Sstevel@tonic-gate 5340Sstevel@tonic-gate if (error == DBG_CONF_IGNORE) 5350Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_1); 5360Sstevel@tonic-gate else if (error == DBG_CONF_VERSION) 5370Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_2); 5380Sstevel@tonic-gate else if (error == DBG_CONF_PRCFAIL) 5390Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_3); 5400Sstevel@tonic-gate else if (error == DBG_CONF_CORRUPT) 5410Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_4); 5420Sstevel@tonic-gate else 5430Sstevel@tonic-gate str = conv_config_str(features); 5440Sstevel@tonic-gate 5450Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5460Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_CONFIG_ERR), config, str); 5470Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5480Sstevel@tonic-gate } 5490Sstevel@tonic-gate 5500Sstevel@tonic-gate void 5510Sstevel@tonic-gate Dbg_file_config_obj(const char *dir, const char *file, const char *config) 5520Sstevel@tonic-gate { 5530Sstevel@tonic-gate char *name, _name[PATH_MAX]; 5540Sstevel@tonic-gate 5550Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_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 5650Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_CONFIG), name, config); 5660Sstevel@tonic-gate } 5670Sstevel@tonic-gate 5680Sstevel@tonic-gate #if !defined(_ELF64) 5690Sstevel@tonic-gate 5700Sstevel@tonic-gate const Msg 5710Sstevel@tonic-gate reject[] = { 5720Sstevel@tonic-gate MSG_STR_EMPTY, 5730Sstevel@tonic-gate MSG_REJ_MACH, /* MSG_INTL(MSG_REJ_MACH) */ 5740Sstevel@tonic-gate MSG_REJ_CLASS, /* MSG_INTL(MSG_REJ_CLASS) */ 5750Sstevel@tonic-gate MSG_REJ_DATA, /* MSG_INTL(MSG_REJ_DATA) */ 5760Sstevel@tonic-gate MSG_REJ_TYPE, /* MSG_INTL(MSG_REJ_TYPE) */ 5770Sstevel@tonic-gate MSG_REJ_BADFLAG, /* MSG_INTL(MSG_REJ_BADFLAG) */ 5780Sstevel@tonic-gate MSG_REJ_MISFLAG, /* MSG_INTL(MSG_REJ_MISFLAG) */ 5790Sstevel@tonic-gate MSG_REJ_VERSION, /* MSG_INTL(MSG_REJ_VERSION) */ 5800Sstevel@tonic-gate MSG_REJ_HAL, /* MSG_INTL(MSG_REJ_HAL) */ 5810Sstevel@tonic-gate MSG_REJ_US3, /* MSG_INTL(MSG_REJ_US3) */ 5820Sstevel@tonic-gate MSG_REJ_STR, /* MSG_INTL(MSG_REJ_STR) */ 5830Sstevel@tonic-gate MSG_REJ_UNKFILE, /* MSG_INTL(MSG_REJ_UNKFILE) */ 5840Sstevel@tonic-gate MSG_REJ_HWCAP_1, /* MSG_INTL(MSG_REJ_HWCAP_1) */ 5850Sstevel@tonic-gate }; 5860Sstevel@tonic-gate 5870Sstevel@tonic-gate void 5880Sstevel@tonic-gate Dbg_file_rejected(Rej_desc *rej) 5890Sstevel@tonic-gate { 5900Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 5910Sstevel@tonic-gate return; 5920Sstevel@tonic-gate 5930Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5940Sstevel@tonic-gate dbg_print(MSG_INTL(reject[rej->rej_type]), rej->rej_name ? 5950Sstevel@tonic-gate rej->rej_name : MSG_INTL(MSG_STR_UNKNOWN), conv_reject_str(rej)); 5960Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5970Sstevel@tonic-gate } 5980Sstevel@tonic-gate 5990Sstevel@tonic-gate void 6000Sstevel@tonic-gate Dbg_file_del_rescan(void) 6010Sstevel@tonic-gate { 6020Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 6030Sstevel@tonic-gate return; 6040Sstevel@tonic-gate 6050Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6060Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DEL_RESCAN)); 6070Sstevel@tonic-gate } 6080Sstevel@tonic-gate 6090Sstevel@tonic-gate void 6100Sstevel@tonic-gate Dbg_file_ar_rescan(void) 6110Sstevel@tonic-gate { 6120Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 6130Sstevel@tonic-gate return; 6140Sstevel@tonic-gate 6150Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6160Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_AR_RESCAN)); 6170Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6180Sstevel@tonic-gate } 6190Sstevel@tonic-gate 6200Sstevel@tonic-gate void 6210Sstevel@tonic-gate Dbg_file_mode_promote(const char *file, int mode) 6220Sstevel@tonic-gate { 6230Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 6240Sstevel@tonic-gate return; 6250Sstevel@tonic-gate 6260Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6270Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_PROMOTE), file, conv_dlmode_str(mode, 0)); 6280Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6290Sstevel@tonic-gate } 6300Sstevel@tonic-gate 6310Sstevel@tonic-gate void 6320Sstevel@tonic-gate Dbg_file_cntl(Lm_list *lml, Aliste flmco, Aliste tlmco) 6330Sstevel@tonic-gate { 6340Sstevel@tonic-gate Lm_cntl *lmc; 6350Sstevel@tonic-gate Aliste off; 6360Sstevel@tonic-gate 6370Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 6380Sstevel@tonic-gate return; 6390Sstevel@tonic-gate if (DBG_NOTDETAIL()) 6400Sstevel@tonic-gate return; 6410Sstevel@tonic-gate 6420Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6430Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_CNTL_TITLE), EC_XWORD(flmco), EC_XWORD(tlmco)); 6440Sstevel@tonic-gate 6450Sstevel@tonic-gate for (ALIST_TRAVERSE(lml->lm_lists, off, lmc)) { 6460Sstevel@tonic-gate Rt_map *lmp; 6470Sstevel@tonic-gate 6480Sstevel@tonic-gate for (lmp = lmc->lc_head; lmp; lmp = (Rt_map *)NEXT(lmp)) 6490Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_CNTL_ENTRY), EC_XWORD(off), 6500Sstevel@tonic-gate NAME(lmp)); 6510Sstevel@tonic-gate } 6520Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6530Sstevel@tonic-gate } 6540Sstevel@tonic-gate #endif 655