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 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 #pragma ident "%Z%%M% %I% %E% SMI" 27 28 #include "msg.h" 29 #include "_debug.h" 30 #include "libld.h" 31 32 /* 33 * Error message string table. 34 */ 35 static const Msg order_errors[] = { 36 MSG_ORD_ERR_INFORANGE, /* MSG_INTL(MSG_ORD_ERR_INFORANGE) */ 37 MSG_ORD_ERR_ORDER, /* MSG_INTL(MSG_ORD_ERR_ORDER) */ 38 MSG_ORD_ERR_LINKRANGE, /* MSG_INTL(MSG_ORD_ERR_LINKRANGE) */ 39 MSG_ORD_ERR_FLAGS, /* MSG_INTL(MSG_ORD_ERR_FLAGS) */ 40 MSG_ORD_ERR_CYCLIC, /* MSG_INTL(MSG_ORD_ERR_CYCLIC) */ 41 MSG_ORD_ERR_LINKINV /* MSG_INTL(MSG_ORD_ERR_LINKINV) */ 42 }; 43 44 void 45 Dbg_sec_strtab(Lm_list *lml, Os_desc *osp, Str_tbl *stp) 46 { 47 uint_t i; 48 49 if (DBG_NOTCLASS(DBG_C_STRTAB)) 50 return; 51 52 if (!osp) 53 return; 54 55 dbg_print(lml, MSG_ORIG(MSG_STR_EMPTY)); 56 if (stp->st_flags & FLG_STTAB_COMPRESS) 57 dbg_print(lml, MSG_INTL(MSG_SEC_STRTAB_COMP), osp->os_name, 58 stp->st_fullstringsize, stp->st_stringsize); 59 else 60 dbg_print(lml, MSG_INTL(MSG_SEC_STRTAB_STND), osp->os_name, 61 stp->st_fullstringsize); 62 63 if ((DBG_NOTDETAIL()) || 64 ((stp->st_flags & FLG_STTAB_COMPRESS) == 0)) 65 return; 66 67 dbg_print(lml, MSG_ORIG(MSG_STR_EMPTY)); 68 dbg_print(lml, MSG_INTL(MSG_SEC_STRTAB_HD), osp->os_name, 69 stp->st_hbckcnt); 70 71 for (i = 0; i < stp->st_hbckcnt; i++) { 72 Str_hash *sthash; 73 74 dbg_print(lml, MSG_INTL(MSG_SEC_STRTAB_BCKT), i); 75 76 for (sthash = stp->st_hashbcks[i]; sthash; 77 sthash = sthash->hi_next) { 78 uint_t stroff = sthash->hi_mstr->sm_stlen - 79 sthash->hi_stlen; 80 81 if (stroff == 0) { 82 dbg_print(lml, MSG_INTL(MSG_SEC_STRTAB_MSTR), 83 sthash->hi_refcnt, sthash->hi_mstr->sm_str); 84 } else { 85 dbg_print(lml, MSG_INTL(MSG_SEC_STRTAB_SUFSTR), 86 sthash->hi_refcnt, 87 &sthash->hi_mstr->sm_str[stroff], 88 sthash->hi_mstr->sm_str); 89 } 90 } 91 92 } 93 } 94 95 void 96 Dbg_sec_in(Lm_list *lml, Is_desc *isp) 97 { 98 const char *str; 99 100 if (DBG_NOTCLASS(DBG_C_SECTIONS)) 101 return; 102 103 if (isp->is_file != NULL) 104 str = isp->is_file->ifl_name; 105 else 106 str = MSG_INTL(MSG_STR_NULL); 107 108 dbg_print(lml, MSG_INTL(MSG_SEC_INPUT), isp->is_name, str); 109 } 110 111 void 112 Dbg_sec_added(Lm_list *lml, Os_desc *osp, Sg_desc *sgp) 113 { 114 const char *str; 115 116 if (DBG_NOTCLASS(DBG_C_SECTIONS)) 117 return; 118 119 if (sgp->sg_name && *sgp->sg_name) 120 str = sgp->sg_name; 121 else 122 str = MSG_INTL(MSG_STR_NULL); 123 124 dbg_print(lml, MSG_INTL(MSG_SEC_ADDED), osp->os_name, str); 125 } 126 127 void 128 Dbg_sec_created(Lm_list *lml, Os_desc *osp, Sg_desc *sgp) 129 { 130 const char *str; 131 132 if (DBG_NOTCLASS(DBG_C_SECTIONS)) 133 return; 134 135 if (sgp->sg_name && *sgp->sg_name) 136 str = sgp->sg_name; 137 else 138 str = MSG_INTL(MSG_STR_NULL); 139 140 dbg_print(lml, MSG_INTL(MSG_SEC_CREATED), osp->os_name, str); 141 } 142 143 void 144 Dbg_sec_discarded(Lm_list *lml, Is_desc *isp, Is_desc *disp) 145 { 146 if (DBG_NOTCLASS(DBG_C_SECTIONS)) 147 return; 148 149 dbg_print(lml, MSG_INTL(MSG_SEC_DISCARDED), isp->is_basename, 150 isp->is_file->ifl_name, disp->is_basename, 151 disp->is_file->ifl_name); 152 } 153 154 void 155 Dbg_sec_group(Lm_list *lml, Is_desc *isp, Group_desc *gdp) 156 { 157 const char *fmt; 158 159 if (DBG_NOTCLASS(DBG_C_SECTIONS)) 160 return; 161 162 if (gdp->gd_flags & GRP_FLG_DISCARD) 163 fmt = MSG_INTL(MSG_SEC_GRP_DISCARDED); 164 else 165 fmt = MSG_INTL(MSG_SEC_GRP_INPUT); 166 167 dbg_print(lml, fmt, isp->is_name, isp->is_file->ifl_name, 168 gdp->gd_gsectname, gdp->gd_symname); 169 } 170 171 void 172 Dbg_sec_order_list(Ofl_desc *ofl, int flag) 173 { 174 Os_desc *osp; 175 Is_desc *isp1; 176 Listnode *lnp1, *lnp2; 177 Lm_list *lml = ofl->ofl_lml; 178 const char *str; 179 180 if (DBG_NOTCLASS(DBG_C_SECTIONS)) 181 return; 182 if (DBG_NOTDETAIL()) 183 return; 184 185 /* 186 * If the flag == 0, then the routine is called before sorting. 187 */ 188 if (flag == 0) 189 str = MSG_INTL(MSG_ORD_SORT_BEFORE); 190 else 191 str = MSG_INTL(MSG_ORD_SORT_AFTER); 192 193 for (LIST_TRAVERSE(&ofl->ofl_ordered, lnp1, osp)) { 194 Sort_desc *sort = osp->os_sort; 195 196 dbg_print(lml, str, osp->os_name); 197 dbg_print(lml, MSG_INTL(MSG_ORD_HDR_1), 198 EC_WORD(sort->st_beforecnt), EC_WORD(sort->st_aftercnt), 199 EC_WORD(sort->st_ordercnt)); 200 201 for (LIST_TRAVERSE(&osp->os_isdescs, lnp2, isp1)) { 202 Word link; 203 Ifl_desc *ifl = isp1->is_file; 204 Is_desc *isp2; 205 static const char *msg; 206 207 if ((isp1->is_flags & FLG_IS_ORDERED) == 0) { 208 dbg_print(lml, MSG_INTL(MSG_ORD_TITLE_0), 209 isp1->is_name, isp1->is_file->ifl_name); 210 continue; 211 } 212 213 if (isp1->is_shdr->sh_flags & SHF_ORDERED) { 214 link = isp1->is_shdr->sh_info; 215 msg = MSG_INTL(MSG_ORD_TITLE_3); 216 } else { 217 /* SHF_LINK_ORDER */ 218 link = isp1->is_shdr->sh_link; 219 msg = MSG_INTL(MSG_ORD_TITLE_4); 220 } 221 222 if (link == SHN_BEFORE) { 223 dbg_print(lml, MSG_INTL(MSG_ORD_TITLE_1), 224 isp1->is_name, isp1->is_file->ifl_name); 225 continue; 226 } 227 228 if (link == SHN_AFTER) { 229 dbg_print(lml, MSG_INTL(MSG_ORD_TITLE_2), 230 isp1->is_name, isp1->is_file->ifl_name); 231 continue; 232 } 233 234 isp2 = ifl->ifl_isdesc[link]; 235 dbg_print(lml, msg, isp1->is_name, ifl->ifl_name, 236 isp2->is_name, isp2->is_key); 237 } 238 } 239 } 240 241 void 242 Dbg_sec_order_error(Lm_list *lml, Ifl_desc *ifl, Word ndx, int error) 243 { 244 if (DBG_NOTCLASS(DBG_C_SECTIONS)) 245 return; 246 if (DBG_NOTDETAIL()) 247 return; 248 249 if (error == 0) 250 return; 251 252 dbg_print(lml, MSG_INTL(MSG_ORD_ERR_TITLE), 253 ifl->ifl_isdesc[ndx]->is_name, ifl->ifl_name); 254 255 if (error) 256 dbg_print(lml, MSG_INTL(order_errors[error - 1])); 257 } 258