1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #include "_debug.h" 28 #include "msg.h" 29 #include "libld.h" 30 31 void 32 Dbg_statistics_ld(Ofl_desc *ofl) 33 { 34 Lm_list *lml = ofl->ofl_lml; 35 36 if (DBG_NOTCLASS(DBG_C_STATS)) 37 return; 38 39 Dbg_util_nl(lml, DBG_NL_STD); 40 dbg_print(lml, MSG_INTL(MSG_STATS_GENERAL)); 41 42 if (ofl->ofl_objscnt || ofl->ofl_soscnt || ofl->ofl_arscnt) { 43 dbg_print(lml, MSG_INTL(MSG_STATS_FILES), 44 EC_XWORD(ofl->ofl_objscnt), EC_XWORD(ofl->ofl_soscnt), 45 EC_XWORD(ofl->ofl_arscnt)); 46 } 47 48 if (ofl->ofl_locscnt || ofl->ofl_globcnt) { 49 dbg_print(lml, MSG_INTL(MSG_STATS_SYMBOLS_OUT), 50 EC_XWORD(ofl->ofl_globcnt), EC_XWORD(ofl->ofl_locscnt)); 51 } 52 if (ofl->ofl_entercnt || ofl->ofl_scopecnt || ofl->ofl_elimcnt) { 53 dbg_print(lml, MSG_INTL(MSG_STATS_SYMBOLS_IN), 54 EC_XWORD(ofl->ofl_entercnt), EC_XWORD(ofl->ofl_scopecnt), 55 EC_XWORD(ofl->ofl_elimcnt)); 56 } 57 58 if (ofl->ofl_outrelscnt) { 59 dbg_print(lml, MSG_INTL(MSG_STATS_RELOCS_OUT), 60 EC_XWORD(ofl->ofl_outrelscnt)); 61 } 62 if (ofl->ofl_entrelscnt || ofl->ofl_actrelscnt) { 63 dbg_print(lml, MSG_INTL(MSG_STATS_RELOCS_IN), 64 EC_XWORD(ofl->ofl_entrelscnt), 65 EC_XWORD(ofl->ofl_actrelscnt)); 66 } 67 } 68 69 void 70 Dbg_statistics_ar(Ofl_desc *ofl) 71 { 72 Aliste idx; 73 Ar_desc *adp; 74 Elf_Arsym *arsym; 75 Ar_aux *aux; 76 Lm_list *lml = ofl->ofl_lml; 77 78 if (DBG_NOTCLASS(DBG_C_STATS | DBG_C_UNUSED)) 79 return; 80 81 Dbg_util_nl(lml, DBG_NL_STD); 82 for (APLIST_TRAVERSE(ofl->ofl_ars, idx, adp)) { 83 size_t poffset = 0; 84 uint_t count = 0, used = 0; 85 86 if ((adp->ad_flags & FLG_ARD_EXTRACT) == 0) { 87 Dbg_unused_file(lml, adp->ad_name, 0, 0); 88 continue; 89 } 90 91 if (DBG_NOTCLASS(DBG_C_STATS)) 92 continue; 93 94 arsym = adp->ad_start; 95 aux = adp->ad_aux; 96 while (arsym->as_off) { 97 /* 98 * Assume that symbols from the same member file are 99 * adjacent within the archive symbol table. 100 */ 101 if (poffset != arsym->as_off) { 102 count++; 103 poffset = arsym->as_off; 104 if (aux->au_mem == FLG_ARMEM_PROC) 105 used++; 106 } 107 aux++, arsym++; 108 } 109 if ((count == 0) || (used == 0)) 110 continue; 111 #ifndef UDIV_NOT_SUPPORTED 112 dbg_print(lml, MSG_INTL(MSG_STATS_AR), adp->ad_name, count, 113 used, ((used * 100) / count)); 114 #endif 115 } 116 Dbg_util_nl(lml, DBG_NL_STD); 117 } 118