17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 55aefb655Srie * Common Development and Distribution License (the "License"). 65aefb655Srie * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21c174926fSrie 227c478bd9Sstevel@tonic-gate /* 23*57ef7aa9SRod Evans * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24c174926fSrie * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #include "_debug.h" 287c478bd9Sstevel@tonic-gate #include "msg.h" 297c478bd9Sstevel@tonic-gate #include "libld.h" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate void 327c478bd9Sstevel@tonic-gate Dbg_statistics_ld(Ofl_desc *ofl) 337c478bd9Sstevel@tonic-gate { 345aefb655Srie Lm_list *lml = ofl->ofl_lml; 355aefb655Srie 365aefb655Srie if (DBG_NOTCLASS(DBG_C_STATS)) 377c478bd9Sstevel@tonic-gate return; 387c478bd9Sstevel@tonic-gate 395aefb655Srie Dbg_util_nl(lml, DBG_NL_STD); 405aefb655Srie dbg_print(lml, MSG_INTL(MSG_STATS_GENERAL)); 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate if (ofl->ofl_objscnt || ofl->ofl_soscnt || ofl->ofl_arscnt) { 435aefb655Srie dbg_print(lml, MSG_INTL(MSG_STATS_FILES), 447c478bd9Sstevel@tonic-gate EC_XWORD(ofl->ofl_objscnt), EC_XWORD(ofl->ofl_soscnt), 457c478bd9Sstevel@tonic-gate EC_XWORD(ofl->ofl_arscnt)); 467c478bd9Sstevel@tonic-gate } 477c478bd9Sstevel@tonic-gate 48c174926fSrie if (ofl->ofl_locscnt || ofl->ofl_globcnt) { 495aefb655Srie dbg_print(lml, MSG_INTL(MSG_STATS_SYMBOLS_OUT), 50c174926fSrie EC_XWORD(ofl->ofl_globcnt), EC_XWORD(ofl->ofl_locscnt)); 51c174926fSrie } 52c174926fSrie if (ofl->ofl_entercnt || ofl->ofl_scopecnt || ofl->ofl_elimcnt) { 535aefb655Srie dbg_print(lml, MSG_INTL(MSG_STATS_SYMBOLS_IN), 54c174926fSrie EC_XWORD(ofl->ofl_entercnt), EC_XWORD(ofl->ofl_scopecnt), 55c174926fSrie EC_XWORD(ofl->ofl_elimcnt)); 567c478bd9Sstevel@tonic-gate } 577c478bd9Sstevel@tonic-gate 58c174926fSrie if (ofl->ofl_outrelscnt) { 595aefb655Srie dbg_print(lml, MSG_INTL(MSG_STATS_RELOCS_OUT), 60c174926fSrie EC_XWORD(ofl->ofl_outrelscnt)); 61c174926fSrie } 62c174926fSrie if (ofl->ofl_entrelscnt || ofl->ofl_actrelscnt) { 635aefb655Srie dbg_print(lml, MSG_INTL(MSG_STATS_RELOCS_IN), 64c174926fSrie EC_XWORD(ofl->ofl_entrelscnt), 657c478bd9Sstevel@tonic-gate EC_XWORD(ofl->ofl_actrelscnt)); 667c478bd9Sstevel@tonic-gate } 677c478bd9Sstevel@tonic-gate } 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate void 707c478bd9Sstevel@tonic-gate Dbg_statistics_ar(Ofl_desc *ofl) 717c478bd9Sstevel@tonic-gate { 72*57ef7aa9SRod Evans Aliste idx; 737c478bd9Sstevel@tonic-gate Ar_desc *adp; 747c478bd9Sstevel@tonic-gate Elf_Arsym *arsym; 757c478bd9Sstevel@tonic-gate Ar_aux *aux; 765aefb655Srie Lm_list *lml = ofl->ofl_lml; 777c478bd9Sstevel@tonic-gate 785aefb655Srie if (DBG_NOTCLASS(DBG_C_STATS | DBG_C_UNUSED)) 797c478bd9Sstevel@tonic-gate return; 807c478bd9Sstevel@tonic-gate 815aefb655Srie Dbg_util_nl(lml, DBG_NL_STD); 82*57ef7aa9SRod Evans for (APLIST_TRAVERSE(ofl->ofl_ars, idx, adp)) { 837c478bd9Sstevel@tonic-gate size_t poffset = 0; 847c478bd9Sstevel@tonic-gate uint_t count = 0, used = 0; 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate if ((adp->ad_flags & FLG_ARD_EXTRACT) == 0) { 875aefb655Srie Dbg_unused_file(lml, adp->ad_name, 0, 0); 887c478bd9Sstevel@tonic-gate continue; 897c478bd9Sstevel@tonic-gate } 907c478bd9Sstevel@tonic-gate 915aefb655Srie if (DBG_NOTCLASS(DBG_C_STATS)) 927c478bd9Sstevel@tonic-gate continue; 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate arsym = adp->ad_start; 957c478bd9Sstevel@tonic-gate aux = adp->ad_aux; 967c478bd9Sstevel@tonic-gate while (arsym->as_off) { 977c478bd9Sstevel@tonic-gate /* 987c478bd9Sstevel@tonic-gate * Assume that symbols from the same member file are 997c478bd9Sstevel@tonic-gate * adjacent within the archive symbol table. 1007c478bd9Sstevel@tonic-gate */ 1017c478bd9Sstevel@tonic-gate if (poffset != arsym->as_off) { 1027c478bd9Sstevel@tonic-gate count++; 1037c478bd9Sstevel@tonic-gate poffset = arsym->as_off; 1047c478bd9Sstevel@tonic-gate if (aux->au_mem == FLG_ARMEM_PROC) 1057c478bd9Sstevel@tonic-gate used++; 1067c478bd9Sstevel@tonic-gate } 1077c478bd9Sstevel@tonic-gate aux++, arsym++; 1087c478bd9Sstevel@tonic-gate } 1097c478bd9Sstevel@tonic-gate if ((count == 0) || (used == 0)) 1107c478bd9Sstevel@tonic-gate continue; 1117c478bd9Sstevel@tonic-gate #ifndef UDIV_NOT_SUPPORTED 1125aefb655Srie dbg_print(lml, MSG_INTL(MSG_STATS_AR), adp->ad_name, count, 1135aefb655Srie used, ((used * 100) / count)); 1147c478bd9Sstevel@tonic-gate #endif 1157c478bd9Sstevel@tonic-gate } 1165aefb655Srie Dbg_util_nl(lml, DBG_NL_STD); 1177c478bd9Sstevel@tonic-gate } 118