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 30*6Srie #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" 390Sstevel@tonic-gate 400Sstevel@tonic-gate 410Sstevel@tonic-gate void 420Sstevel@tonic-gate Dbg_file_generic(Ifl_desc *ifl) 430Sstevel@tonic-gate { 440Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 450Sstevel@tonic-gate return; 460Sstevel@tonic-gate 470Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 480Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_BASIC), ifl->ifl_name, 490Sstevel@tonic-gate conv_etype_str(ifl->ifl_ehdr->e_type)); 500Sstevel@tonic-gate } 510Sstevel@tonic-gate 520Sstevel@tonic-gate void 530Sstevel@tonic-gate Dbg_file_skip(const char *nname, const char *oname) 540Sstevel@tonic-gate { 550Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 560Sstevel@tonic-gate return; 570Sstevel@tonic-gate 580Sstevel@tonic-gate if (oname && strcmp(nname, oname)) 590Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_SKIP_1), nname, oname); 600Sstevel@tonic-gate else 610Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_SKIP_2), nname); 620Sstevel@tonic-gate } 630Sstevel@tonic-gate 640Sstevel@tonic-gate void 650Sstevel@tonic-gate Dbg_file_reuse(const char *nname, const char *oname) 660Sstevel@tonic-gate { 670Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 680Sstevel@tonic-gate return; 690Sstevel@tonic-gate 700Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_REUSE), nname, oname); 710Sstevel@tonic-gate } 720Sstevel@tonic-gate 730Sstevel@tonic-gate void 740Sstevel@tonic-gate Dbg_file_archive(const char *name, int again) 750Sstevel@tonic-gate { 760Sstevel@tonic-gate const char *str; 770Sstevel@tonic-gate 780Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 790Sstevel@tonic-gate return; 800Sstevel@tonic-gate 810Sstevel@tonic-gate if (again) 820Sstevel@tonic-gate str = MSG_INTL(MSG_STR_AGAIN); 830Sstevel@tonic-gate else 840Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 850Sstevel@tonic-gate 860Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 870Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_ARCHIVE), name, str); 880Sstevel@tonic-gate } 890Sstevel@tonic-gate 900Sstevel@tonic-gate void 910Sstevel@tonic-gate Dbg_file_analyze(Rt_map * lmp) 920Sstevel@tonic-gate { 930Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 940Sstevel@tonic-gate return; 950Sstevel@tonic-gate 960Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 970Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_ANALYZE), NAME(lmp), 980Sstevel@tonic-gate conv_dlmode_str(MODE(lmp), 1)); 990Sstevel@tonic-gate } 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate void 1020Sstevel@tonic-gate Dbg_file_aout(const char *name, ulong_t dynamic, ulong_t base, ulong_t size) 1030Sstevel@tonic-gate { 1040Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1050Sstevel@tonic-gate return; 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_AOUT), name); 1080Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DATA_1), EC_XWORD(dynamic), 1090Sstevel@tonic-gate EC_ADDR(base), EC_XWORD(size)); 1100Sstevel@tonic-gate } 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate void 1130Sstevel@tonic-gate Dbg_file_elf(const char *name, ulong_t dynamic, ulong_t base, 1140Sstevel@tonic-gate ulong_t size, ulong_t entry, Lmid_t lmid, Aliste lmco) 1150Sstevel@tonic-gate { 1160Sstevel@tonic-gate const char *str; 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1190Sstevel@tonic-gate return; 1200Sstevel@tonic-gate 1210Sstevel@tonic-gate if (base == 0) 1220Sstevel@tonic-gate str = MSG_INTL(MSG_STR_TEMPORARY); 1230Sstevel@tonic-gate else 1240Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 1250Sstevel@tonic-gate 1260Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_ELF), name, str); 1270Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DATA_1), EC_XWORD(dynamic), 1280Sstevel@tonic-gate EC_ADDR(base), EC_XWORD(size)); 1290Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DATA_2), EC_XWORD(entry), 1300Sstevel@tonic-gate EC_XWORD(lmid), EC_XWORD(lmco)); 1310Sstevel@tonic-gate } 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate void 134*6Srie Dbg_file_ldso(const char *name, ulong_t dynamic, ulong_t base, char **envp, 135*6Srie auxv_t *auxv) 1360Sstevel@tonic-gate { 1370Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1380Sstevel@tonic-gate return; 1390Sstevel@tonic-gate 1400Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 1410Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_LDSO), name); 1420Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DATA_3), EC_XWORD(dynamic), 1430Sstevel@tonic-gate EC_ADDR(base)); 1440Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DATA_4), EC_ADDR(envp), EC_ADDR(auxv)); 1450Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 1460Sstevel@tonic-gate } 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate void 1490Sstevel@tonic-gate Dbg_file_prot(const char *name, int prot) 1500Sstevel@tonic-gate { 1510Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1520Sstevel@tonic-gate return; 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 1550Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_PROT), name, (prot ? '+' : '-')); 1560Sstevel@tonic-gate } 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate void 1590Sstevel@tonic-gate Dbg_file_delete(const char *name) 1600Sstevel@tonic-gate { 1610Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1620Sstevel@tonic-gate return; 1630Sstevel@tonic-gate 1640Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 1650Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DELETE), name); 1660Sstevel@tonic-gate } 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate static int hdl_title = 0; 1690Sstevel@tonic-gate static Msg hdl_str = 0; 1700Sstevel@tonic-gate 1710Sstevel@tonic-gate void 1720Sstevel@tonic-gate Dbg_file_hdl_title(int type) 1730Sstevel@tonic-gate { 1740Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 1750Sstevel@tonic-gate return; 1760Sstevel@tonic-gate if (DBG_NOTDETAIL()) 1770Sstevel@tonic-gate return; 1780Sstevel@tonic-gate 1790Sstevel@tonic-gate hdl_title = 1; 1800Sstevel@tonic-gate 1810Sstevel@tonic-gate /* 1820Sstevel@tonic-gate * Establish a binding title for later use in Dbg_file_bind_entry. 1830Sstevel@tonic-gate */ 1840Sstevel@tonic-gate if (type == DBG_DEP_CREATE) 1850Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_CREATE; /* MSG_INTL(MSG_FIL_HDL_CREATE) */ 1860Sstevel@tonic-gate else if (type == DBG_DEP_ADD) 1870Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_ADD; /* MSG_INTL(MSG_FIL_HDL_ADD) */ 1880Sstevel@tonic-gate else if (type == DBG_DEP_DELETE) 1890Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_DELETE; /* MSG_INTL(MSG_FIL_HDL_DELETE) */ 1900Sstevel@tonic-gate else if (type == DBG_DEP_ORPHAN) 1910Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_ORPHAN; /* MSG_INTL(MSG_FIL_HDL_ORPHAN) */ 1920Sstevel@tonic-gate else if (type == DBG_DEP_REINST) 1930Sstevel@tonic-gate hdl_str = MSG_FIL_HDL_REINST; /* MSG_INTL(MSG_FIL_HDL_REINST) */ 1940Sstevel@tonic-gate else 1950Sstevel@tonic-gate hdl_str = 0; 1960Sstevel@tonic-gate } 1970Sstevel@tonic-gate 1980Sstevel@tonic-gate void 1990Sstevel@tonic-gate Dbg_file_hdl_collect(Grp_hdl * ghp, const char *name) 2000Sstevel@tonic-gate { 2010Sstevel@tonic-gate const char *str; 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 2040Sstevel@tonic-gate return; 2050Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2060Sstevel@tonic-gate return; 2070Sstevel@tonic-gate 2080Sstevel@tonic-gate if (ghp->gh_owner) 2090Sstevel@tonic-gate str = NAME(ghp->gh_owner); 2100Sstevel@tonic-gate else 2110Sstevel@tonic-gate str = MSG_INTL(MSG_STR_ORPHAN); 2120Sstevel@tonic-gate 2130Sstevel@tonic-gate if (hdl_title) { 2140Sstevel@tonic-gate hdl_title = 0; 2150Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 2160Sstevel@tonic-gate } 2170Sstevel@tonic-gate if (name) 2180Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_HDL_RETAIN), str, name); 2190Sstevel@tonic-gate else 2200Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_HDL_COLLECT), str, 2210Sstevel@tonic-gate conv_grphdrflags_str(ghp->gh_flags)); 2220Sstevel@tonic-gate } 2230Sstevel@tonic-gate 2240Sstevel@tonic-gate void 2250Sstevel@tonic-gate Dbg_file_hdl_action(Grp_hdl * ghp, Rt_map * lmp, int type) 2260Sstevel@tonic-gate { 2270Sstevel@tonic-gate Msg str; 2280Sstevel@tonic-gate 2290Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 2300Sstevel@tonic-gate return; 2310Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2320Sstevel@tonic-gate return; 2330Sstevel@tonic-gate 2340Sstevel@tonic-gate if (hdl_title) { 2350Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 2360Sstevel@tonic-gate if (hdl_str) { 2370Sstevel@tonic-gate const char *name; 2380Sstevel@tonic-gate 2390Sstevel@tonic-gate /* 2400Sstevel@tonic-gate * Protect ourselves in case this handle has no 2410Sstevel@tonic-gate * originating owner. 2420Sstevel@tonic-gate */ 2430Sstevel@tonic-gate if (ghp->gh_owner) 2440Sstevel@tonic-gate name = NAME(ghp->gh_owner); 2450Sstevel@tonic-gate else 2460Sstevel@tonic-gate name = MSG_INTL(MSG_STR_UNKNOWN); 2470Sstevel@tonic-gate 2480Sstevel@tonic-gate dbg_print(MSG_INTL(hdl_str), name); 2490Sstevel@tonic-gate } 2500Sstevel@tonic-gate hdl_title = 0; 2510Sstevel@tonic-gate } 2520Sstevel@tonic-gate 2530Sstevel@tonic-gate if (type == DBG_DEP_ADD) 2540Sstevel@tonic-gate str = MSG_FIL_DEP_ADD; /* MSG_INTL(MSG_FIL_DEP_ADD) */ 2550Sstevel@tonic-gate else if (type == DBG_DEP_DELETE) 2560Sstevel@tonic-gate str = MSG_FIL_DEP_DELETE; /* MSG_INTL(MSG_FIL_DEP_DELETE) */ 2570Sstevel@tonic-gate else if (type == DBG_DEP_REMOVE) 2580Sstevel@tonic-gate str = MSG_FIL_DEP_REMOVE; /* MSG_INTL(MSG_FIL_DEP_REMOVE) */ 2590Sstevel@tonic-gate else if (type == DBG_DEP_REMAIN) 2600Sstevel@tonic-gate str = MSG_FIL_DEP_REMAIN; /* MSG_INTL(MSG_FIL_DEP_REMAIN) */ 2610Sstevel@tonic-gate else 2620Sstevel@tonic-gate str = 0; 2630Sstevel@tonic-gate 2640Sstevel@tonic-gate if (str) { 2650Sstevel@tonic-gate const char *mode; 2660Sstevel@tonic-gate 2670Sstevel@tonic-gate if ((MODE(lmp) & (RTLD_GLOBAL | RTLD_NODELETE)) == 2680Sstevel@tonic-gate (RTLD_GLOBAL | RTLD_NODELETE)) 2690Sstevel@tonic-gate mode = MSG_ORIG(MSG_MODE_GLOBNODEL); 2700Sstevel@tonic-gate else if (MODE(lmp) & RTLD_GLOBAL) 2710Sstevel@tonic-gate mode = MSG_ORIG(MSG_MODE_GLOB); 2720Sstevel@tonic-gate 2730Sstevel@tonic-gate else if (MODE(lmp) & RTLD_NODELETE) 2740Sstevel@tonic-gate mode = MSG_ORIG(MSG_MODE_NODEL); 2750Sstevel@tonic-gate else 2760Sstevel@tonic-gate mode = MSG_ORIG(MSG_STR_EMPTY); 2770Sstevel@tonic-gate 2780Sstevel@tonic-gate dbg_print(MSG_INTL(str), NAME(lmp), mode); 2790Sstevel@tonic-gate } 2800Sstevel@tonic-gate } 2810Sstevel@tonic-gate 2820Sstevel@tonic-gate #define BINDSZ MSG_STR_OSQBRKT_SIZE + \ 2830Sstevel@tonic-gate MSG_BND_NEEDED_SIZE + \ 2840Sstevel@tonic-gate MSG_BND_REFER_SIZE + \ 2850Sstevel@tonic-gate MSG_STR_CSQBRKT_SIZE 2860Sstevel@tonic-gate 2870Sstevel@tonic-gate void 2880Sstevel@tonic-gate Dbg_file_bind_entry(Bnd_desc *bdp) 2890Sstevel@tonic-gate { 2900Sstevel@tonic-gate char string[BINDSZ]; 2910Sstevel@tonic-gate Rt_map *clmp, *dlmp; 2920Sstevel@tonic-gate uint_t flags; 2930Sstevel@tonic-gate 2940Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 2950Sstevel@tonic-gate return; 2960Sstevel@tonic-gate if (DBG_NOTDETAIL()) 2970Sstevel@tonic-gate return; 2980Sstevel@tonic-gate 2990Sstevel@tonic-gate clmp = bdp->b_caller; 3000Sstevel@tonic-gate dlmp = bdp->b_depend; 3010Sstevel@tonic-gate flags = bdp->b_flags; 3020Sstevel@tonic-gate 3030Sstevel@tonic-gate /* 3040Sstevel@tonic-gate * Evaluate the binding descriptors flags. 3050Sstevel@tonic-gate */ 3060Sstevel@tonic-gate if (flags) { 3070Sstevel@tonic-gate (void) strcpy(string, MSG_ORIG(MSG_STR_OSQBRKT)); 3080Sstevel@tonic-gate if (flags & BND_NEEDED) 3090Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_BND_NEEDED)); 3100Sstevel@tonic-gate if (flags & BND_REFER) 3110Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_BND_REFER)); 3120Sstevel@tonic-gate (void) strcat(string, MSG_ORIG(MSG_STR_CSQBRKT)); 3130Sstevel@tonic-gate } else 3140Sstevel@tonic-gate (void) strcpy(string, MSG_ORIG(MSG_STR_EMPTY)); 3150Sstevel@tonic-gate 3160Sstevel@tonic-gate /* 3170Sstevel@tonic-gate * Print the dependency together with the modes of the binding. 3180Sstevel@tonic-gate */ 3190Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 3200Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_BND_ADD), NAME(clmp)); 3210Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_BND_FILE), NAME(dlmp), string); 3220Sstevel@tonic-gate } 3230Sstevel@tonic-gate 3240Sstevel@tonic-gate void 3250Sstevel@tonic-gate Dbg_file_dlopen(const char *name, const char *from, int mode) 3260Sstevel@tonic-gate { 3270Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 3280Sstevel@tonic-gate return; 3290Sstevel@tonic-gate 3300Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 3310Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DLOPEN), name, from, 3320Sstevel@tonic-gate conv_dlmode_str(mode, 1)); 3330Sstevel@tonic-gate } 3340Sstevel@tonic-gate 3350Sstevel@tonic-gate void 3360Sstevel@tonic-gate Dbg_file_dlclose(const char *name, int flag) 3370Sstevel@tonic-gate { 3380Sstevel@tonic-gate const char *str; 3390Sstevel@tonic-gate 3400Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 3410Sstevel@tonic-gate return; 3420Sstevel@tonic-gate 3430Sstevel@tonic-gate if (flag == DBG_DLCLOSE_IGNORE) 3440Sstevel@tonic-gate str = MSG_INTL(MSG_STR_IGNORE); 3450Sstevel@tonic-gate else 3460Sstevel@tonic-gate str = MSG_ORIG(MSG_STR_EMPTY); 3470Sstevel@tonic-gate 3480Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 3490Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DLCLOSE), name, str); 3500Sstevel@tonic-gate } 3510Sstevel@tonic-gate 3520Sstevel@tonic-gate void 3530Sstevel@tonic-gate Dbg_file_dldump(const char *ipath, const char *opath, int flags) 3540Sstevel@tonic-gate { 3550Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 3560Sstevel@tonic-gate return; 3570Sstevel@tonic-gate 3580Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 3590Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DLDUMP), ipath, opath, 3600Sstevel@tonic-gate conv_dlflag_str(flags, 0)); 3610Sstevel@tonic-gate } 3620Sstevel@tonic-gate 3630Sstevel@tonic-gate void 3640Sstevel@tonic-gate Dbg_file_lazyload(const char *file, const char *from, const char *symname) 3650Sstevel@tonic-gate { 3660Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 3670Sstevel@tonic-gate return; 3680Sstevel@tonic-gate 3690Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 3700Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_LAZYLOAD), file, from, 3710Sstevel@tonic-gate _Dbg_sym_dem(symname)); 3720Sstevel@tonic-gate } 3730Sstevel@tonic-gate 3740Sstevel@tonic-gate void 3750Sstevel@tonic-gate Dbg_file_nl() 3760Sstevel@tonic-gate { 3770Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 3780Sstevel@tonic-gate return; 3790Sstevel@tonic-gate if (DBG_NOTDETAIL()) 3800Sstevel@tonic-gate return; 3810Sstevel@tonic-gate 3820Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 3830Sstevel@tonic-gate } 3840Sstevel@tonic-gate 3850Sstevel@tonic-gate void 3860Sstevel@tonic-gate Dbg_file_preload(const char *name) 3870Sstevel@tonic-gate { 3880Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 3890Sstevel@tonic-gate return; 3900Sstevel@tonic-gate 3910Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_PRELOAD), name); 3920Sstevel@tonic-gate } 3930Sstevel@tonic-gate 3940Sstevel@tonic-gate void 3950Sstevel@tonic-gate Dbg_file_needed(const char *name, const char *parent) 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_NEEDED), name, parent); 4020Sstevel@tonic-gate } 4030Sstevel@tonic-gate 4040Sstevel@tonic-gate void 4050Sstevel@tonic-gate Dbg_file_filter(const char *filter, const char *filtee, int config) 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 if (config) 4120Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FILTER_1), filter, filtee); 4130Sstevel@tonic-gate else 4140Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FILTER_2), filter, filtee); 4150Sstevel@tonic-gate } 4160Sstevel@tonic-gate 4170Sstevel@tonic-gate void 4180Sstevel@tonic-gate Dbg_file_filtee(const char *filter, const char *filtee, int audit) 4190Sstevel@tonic-gate { 4200Sstevel@tonic-gate if (audit) { 4210Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_AUDITING | DBG_FILES)) 4220Sstevel@tonic-gate return; 4230Sstevel@tonic-gate 4240Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4250Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FILTEE_3), filtee); 4260Sstevel@tonic-gate } else { 4270Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4280Sstevel@tonic-gate return; 4290Sstevel@tonic-gate 4300Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4310Sstevel@tonic-gate if (filter) 4320Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FILTEE_1), filtee, filter); 4330Sstevel@tonic-gate else 4340Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FILTEE_2), filtee); 4350Sstevel@tonic-gate } 4360Sstevel@tonic-gate } 4370Sstevel@tonic-gate 4380Sstevel@tonic-gate void 4390Sstevel@tonic-gate Dbg_file_fixname(const char *oname, const char *nname) 4400Sstevel@tonic-gate { 4410Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4420Sstevel@tonic-gate return; 4430Sstevel@tonic-gate 4440Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 4450Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_FIXNAME), oname, nname); 4460Sstevel@tonic-gate } 4470Sstevel@tonic-gate 4480Sstevel@tonic-gate void 4490Sstevel@tonic-gate Dbg_file_output(Ofl_desc *ofl) 4500Sstevel@tonic-gate { 4510Sstevel@tonic-gate const char *prefix = MSG_ORIG(MSG_PTH_OBJECT); 4520Sstevel@tonic-gate char *oname, *nname, *ofile; 4530Sstevel@tonic-gate int fd; 4540Sstevel@tonic-gate 4550Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 4560Sstevel@tonic-gate return; 4570Sstevel@tonic-gate if (DBG_NOTDETAIL()) 4580Sstevel@tonic-gate return; 4590Sstevel@tonic-gate 4600Sstevel@tonic-gate /* 4610Sstevel@tonic-gate * Obtain the present input object filename for concatenation to the 4620Sstevel@tonic-gate * prefix name. 4630Sstevel@tonic-gate */ 4640Sstevel@tonic-gate oname = (char *)ofl->ofl_name; 4650Sstevel@tonic-gate if ((ofile = strrchr(oname, '/')) == NULL) 4660Sstevel@tonic-gate ofile = oname; 4670Sstevel@tonic-gate else 4680Sstevel@tonic-gate ofile++; 4690Sstevel@tonic-gate 4700Sstevel@tonic-gate /* 4710Sstevel@tonic-gate * Concatenate the prefix with the object filename, open the file and 4720Sstevel@tonic-gate * write out the present Elf memory image. As this is debugging we 4730Sstevel@tonic-gate * ignore all errors. 4740Sstevel@tonic-gate */ 4750Sstevel@tonic-gate if ((nname = (char *)malloc(strlen(prefix) + strlen(ofile) + 1)) != 0) { 4760Sstevel@tonic-gate (void) strcpy(nname, prefix); 4770Sstevel@tonic-gate (void) strcat(nname, ofile); 4780Sstevel@tonic-gate if ((fd = open(nname, O_RDWR | O_CREAT | O_TRUNC, 4790Sstevel@tonic-gate 0666)) != -1) { 4800Sstevel@tonic-gate (void) write(fd, ofl->ofl_ehdr, ofl->ofl_size); 4810Sstevel@tonic-gate close(fd); 4820Sstevel@tonic-gate } 4830Sstevel@tonic-gate free(nname); 4840Sstevel@tonic-gate } 4850Sstevel@tonic-gate } 4860Sstevel@tonic-gate 4870Sstevel@tonic-gate void 4880Sstevel@tonic-gate Dbg_file_config_dis(const char *config, int features) 4890Sstevel@tonic-gate { 4900Sstevel@tonic-gate const char *str; 4910Sstevel@tonic-gate int error = features & ~CONF_FEATMSK; 4920Sstevel@tonic-gate 4930Sstevel@tonic-gate if (error == DBG_CONF_IGNORE) 4940Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_1); 4950Sstevel@tonic-gate else if (error == DBG_CONF_VERSION) 4960Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_2); 4970Sstevel@tonic-gate else if (error == DBG_CONF_PRCFAIL) 4980Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_3); 4990Sstevel@tonic-gate else if (error == DBG_CONF_CORRUPT) 5000Sstevel@tonic-gate str = MSG_INTL(MSG_FIL_CONFIG_ERR_4); 5010Sstevel@tonic-gate else 5020Sstevel@tonic-gate str = conv_config_str(features); 5030Sstevel@tonic-gate 5040Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5050Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_CONFIG_ERR), config, str); 5060Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5070Sstevel@tonic-gate } 5080Sstevel@tonic-gate 5090Sstevel@tonic-gate void 5100Sstevel@tonic-gate Dbg_file_config_obj(const char *dir, const char *file, const char *config) 5110Sstevel@tonic-gate { 5120Sstevel@tonic-gate char *name, _name[PATH_MAX]; 5130Sstevel@tonic-gate 5140Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 5150Sstevel@tonic-gate return; 5160Sstevel@tonic-gate 5170Sstevel@tonic-gate if (file) { 5180Sstevel@tonic-gate (void) snprintf(_name, PATH_MAX, MSG_ORIG(MSG_FMT_PATH), 5190Sstevel@tonic-gate dir, file); 5200Sstevel@tonic-gate name = _name; 5210Sstevel@tonic-gate } else 5220Sstevel@tonic-gate name = (char *)dir; 5230Sstevel@tonic-gate 5240Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_CONFIG), name, config); 5250Sstevel@tonic-gate } 5260Sstevel@tonic-gate 5270Sstevel@tonic-gate #if !defined(_ELF64) 5280Sstevel@tonic-gate 5290Sstevel@tonic-gate const Msg 5300Sstevel@tonic-gate reject[] = { 5310Sstevel@tonic-gate MSG_STR_EMPTY, 5320Sstevel@tonic-gate MSG_REJ_MACH, /* MSG_INTL(MSG_REJ_MACH) */ 5330Sstevel@tonic-gate MSG_REJ_CLASS, /* MSG_INTL(MSG_REJ_CLASS) */ 5340Sstevel@tonic-gate MSG_REJ_DATA, /* MSG_INTL(MSG_REJ_DATA) */ 5350Sstevel@tonic-gate MSG_REJ_TYPE, /* MSG_INTL(MSG_REJ_TYPE) */ 5360Sstevel@tonic-gate MSG_REJ_BADFLAG, /* MSG_INTL(MSG_REJ_BADFLAG) */ 5370Sstevel@tonic-gate MSG_REJ_MISFLAG, /* MSG_INTL(MSG_REJ_MISFLAG) */ 5380Sstevel@tonic-gate MSG_REJ_VERSION, /* MSG_INTL(MSG_REJ_VERSION) */ 5390Sstevel@tonic-gate MSG_REJ_HAL, /* MSG_INTL(MSG_REJ_HAL) */ 5400Sstevel@tonic-gate MSG_REJ_US3, /* MSG_INTL(MSG_REJ_US3) */ 5410Sstevel@tonic-gate MSG_REJ_STR, /* MSG_INTL(MSG_REJ_STR) */ 5420Sstevel@tonic-gate MSG_REJ_UNKFILE, /* MSG_INTL(MSG_REJ_UNKFILE) */ 5430Sstevel@tonic-gate MSG_REJ_HWCAP_1, /* MSG_INTL(MSG_REJ_HWCAP_1) */ 5440Sstevel@tonic-gate }; 5450Sstevel@tonic-gate 5460Sstevel@tonic-gate void 5470Sstevel@tonic-gate Dbg_file_rejected(Rej_desc *rej) 5480Sstevel@tonic-gate { 5490Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 5500Sstevel@tonic-gate return; 5510Sstevel@tonic-gate 5520Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5530Sstevel@tonic-gate dbg_print(MSG_INTL(reject[rej->rej_type]), rej->rej_name ? 5540Sstevel@tonic-gate rej->rej_name : MSG_INTL(MSG_STR_UNKNOWN), conv_reject_str(rej)); 5550Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5560Sstevel@tonic-gate } 5570Sstevel@tonic-gate 5580Sstevel@tonic-gate void 5590Sstevel@tonic-gate Dbg_file_del_rescan(void) 5600Sstevel@tonic-gate { 5610Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 5620Sstevel@tonic-gate return; 5630Sstevel@tonic-gate 5640Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5650Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_DEL_RESCAN)); 5660Sstevel@tonic-gate } 5670Sstevel@tonic-gate 5680Sstevel@tonic-gate void 5690Sstevel@tonic-gate Dbg_file_ar_rescan(void) 5700Sstevel@tonic-gate { 5710Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 5720Sstevel@tonic-gate return; 5730Sstevel@tonic-gate 5740Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5750Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_AR_RESCAN)); 5760Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5770Sstevel@tonic-gate } 5780Sstevel@tonic-gate 5790Sstevel@tonic-gate void 5800Sstevel@tonic-gate Dbg_file_mode_promote(const char *file, int mode) 5810Sstevel@tonic-gate { 5820Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 5830Sstevel@tonic-gate return; 5840Sstevel@tonic-gate 5850Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5860Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_FIL_PROMOTE), file, conv_dlmode_str(mode, 0)); 5870Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 5880Sstevel@tonic-gate } 5890Sstevel@tonic-gate 5900Sstevel@tonic-gate void 5910Sstevel@tonic-gate Dbg_file_cntl(Lm_list *lml, Aliste flmco, Aliste tlmco) 5920Sstevel@tonic-gate { 5930Sstevel@tonic-gate Lm_cntl *lmc; 5940Sstevel@tonic-gate Aliste off; 5950Sstevel@tonic-gate 5960Sstevel@tonic-gate if (DBG_NOTCLASS(DBG_FILES)) 5970Sstevel@tonic-gate return; 5980Sstevel@tonic-gate if (DBG_NOTDETAIL()) 5990Sstevel@tonic-gate return; 6000Sstevel@tonic-gate 6010Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6020Sstevel@tonic-gate dbg_print(MSG_INTL(MSG_CNTL_TITLE), EC_XWORD(flmco), EC_XWORD(tlmco)); 6030Sstevel@tonic-gate 6040Sstevel@tonic-gate for (ALIST_TRAVERSE(lml->lm_lists, off, lmc)) { 6050Sstevel@tonic-gate Rt_map *lmp; 6060Sstevel@tonic-gate 6070Sstevel@tonic-gate for (lmp = lmc->lc_head; lmp; lmp = (Rt_map *)NEXT(lmp)) 6080Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_CNTL_ENTRY), EC_XWORD(off), 6090Sstevel@tonic-gate NAME(lmp)); 6100Sstevel@tonic-gate } 6110Sstevel@tonic-gate dbg_print(MSG_ORIG(MSG_STR_EMPTY)); 6120Sstevel@tonic-gate } 6130Sstevel@tonic-gate #endif 614