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 */ 215aefb655Srie 227c478bd9Sstevel@tonic-gate /* 2357ef7aa9SRod Evans * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 26e23c41c9SAli Bahrami #include <stdio.h> 277c478bd9Sstevel@tonic-gate #include "msg.h" 287c478bd9Sstevel@tonic-gate #include "_debug.h" 297c478bd9Sstevel@tonic-gate #include "libld.h" 30a194faf8Srie #include "_string_table.h" 317c478bd9Sstevel@tonic-gate 32e23c41c9SAli Bahrami /* 33e23c41c9SAli Bahrami * Format an input section descriptor name for output, in the format 34e23c41c9SAli Bahrami * [ndx]name 35e23c41c9SAli Bahrami * If possible, a user supplied fixed size buffer is used. Failing that, 36e23c41c9SAli Bahrami * dynamic memory is allocated, which must be freed by the caller. 37e23c41c9SAli Bahrami * 38e23c41c9SAli Bahrami * entry: 39e23c41c9SAli Bahrami * [dbg_fmt_isec_name2]: name, scnndx - Name and section index 40e23c41c9SAli Bahrami * [dbg_fmt_isec_name]: isp - Input section descriptor giving name 41e23c41c9SAli Bahrami * and index. 42e23c41c9SAli Bahrami * 43e23c41c9SAli Bahrami * buf - Caller supplied buffer 44e23c41c9SAli Bahrami * alloc_mem - Address of pointer to be set to address of allocated 45e23c41c9SAli Bahrami * memory, or NULL if no memory is allocated. 46e23c41c9SAli Bahrami * 47e23c41c9SAli Bahrami * exit: 48e23c41c9SAli Bahrami * A pointer to the formatted string is returned. If the supplied buffer 49e23c41c9SAli Bahrami * was sufficient, *alloc_mem is set to NULL. If memory was allocated, 50e23c41c9SAli Bahrami * *alloc_mem references it. The caller must free this memory after use. 51e23c41c9SAli Bahrami */ 52e23c41c9SAli Bahrami const char * 53e23c41c9SAli Bahrami dbg_fmt_isec_name2(const char *name, Word scnndx, dbg_isec_name_buf_t buf, 54e23c41c9SAli Bahrami char **alloc_mem) 55e23c41c9SAli Bahrami { 56e23c41c9SAli Bahrami int cnt; 57e23c41c9SAli Bahrami 58e23c41c9SAli Bahrami /* 59e23c41c9SAli Bahrami * If the section index is 0, it's not a real section. 60e23c41c9SAli Bahrami * Just use the name as is. 61e23c41c9SAli Bahrami */ 62e23c41c9SAli Bahrami if (scnndx == 0) { 63e23c41c9SAli Bahrami *alloc_mem = NULL; 64e23c41c9SAli Bahrami return (name); 65e23c41c9SAli Bahrami } 66e23c41c9SAli Bahrami 67e23c41c9SAli Bahrami /* Format into the fixed buffer */ 68e23c41c9SAli Bahrami cnt = snprintf(buf, sizeof (dbg_isec_name_buf_t), 69e23c41c9SAli Bahrami MSG_ORIG(MSG_FMT_ISEC_NAME), EC_WORD(scnndx), name); 70e23c41c9SAli Bahrami 71e23c41c9SAli Bahrami /* 72e23c41c9SAli Bahrami * If the name was too long, try to allocate a dynamic buffer. 73e23c41c9SAli Bahrami * Failing that, fall through and use the clipped one already 74e23c41c9SAli Bahrami * formatted into buf, as that's better than nothing. 75e23c41c9SAli Bahrami */ 76e23c41c9SAli Bahrami if ((cnt >= sizeof (dbg_isec_name_buf_t)) && 77e23c41c9SAli Bahrami ((*alloc_mem = malloc(cnt + 1)) != NULL)) { 78e23c41c9SAli Bahrami (void) snprintf(*alloc_mem, cnt + 1, 79e23c41c9SAli Bahrami MSG_ORIG(MSG_FMT_ISEC_NAME), EC_WORD(scnndx), name); 80e23c41c9SAli Bahrami return (*alloc_mem); 81e23c41c9SAli Bahrami } 82e23c41c9SAli Bahrami 83e23c41c9SAli Bahrami /* Return the caller supplied buffer */ 84e23c41c9SAli Bahrami *alloc_mem = NULL; 85e23c41c9SAli Bahrami return (buf); 86e23c41c9SAli Bahrami } 87e23c41c9SAli Bahrami const char * 88e23c41c9SAli Bahrami dbg_fmt_isec_name(Is_desc *isp, dbg_isec_name_buf_t buf, char **alloc_mem) 89e23c41c9SAli Bahrami { 90e23c41c9SAli Bahrami return (dbg_fmt_isec_name2(isp->is_name, isp->is_scnndx, buf, 91e23c41c9SAli Bahrami alloc_mem)); 92e23c41c9SAli Bahrami } 93e23c41c9SAli Bahrami 947c478bd9Sstevel@tonic-gate void 955aefb655Srie Dbg_sec_strtab(Lm_list *lml, Os_desc *osp, Str_tbl *stp) 967c478bd9Sstevel@tonic-gate { 97a194faf8Srie uint_t cnt; 987c478bd9Sstevel@tonic-gate 995aefb655Srie if (DBG_NOTCLASS(DBG_C_STRTAB)) 1007c478bd9Sstevel@tonic-gate return; 1017c478bd9Sstevel@tonic-gate 1027c478bd9Sstevel@tonic-gate if (!osp) 1037c478bd9Sstevel@tonic-gate return; 1047c478bd9Sstevel@tonic-gate 1057010c12aSrie Dbg_util_nl(lml, DBG_NL_STD); 1067c478bd9Sstevel@tonic-gate if (stp->st_flags & FLG_STTAB_COMPRESS) 1075aefb655Srie dbg_print(lml, MSG_INTL(MSG_SEC_STRTAB_COMP), osp->os_name, 108cce0e03bSab196087 EC_XWORD(stp->st_fullstrsize), EC_XWORD(stp->st_strsize)); 1097c478bd9Sstevel@tonic-gate else 1105aefb655Srie dbg_print(lml, MSG_INTL(MSG_SEC_STRTAB_STND), osp->os_name, 111cce0e03bSab196087 EC_XWORD(stp->st_fullstrsize)); 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate if ((DBG_NOTDETAIL()) || 1147c478bd9Sstevel@tonic-gate ((stp->st_flags & FLG_STTAB_COMPRESS) == 0)) 1157c478bd9Sstevel@tonic-gate return; 1167c478bd9Sstevel@tonic-gate 1175aefb655Srie dbg_print(lml, MSG_ORIG(MSG_STR_EMPTY)); 1185aefb655Srie dbg_print(lml, MSG_INTL(MSG_SEC_STRTAB_HD), osp->os_name, 1197c478bd9Sstevel@tonic-gate stp->st_hbckcnt); 1205aefb655Srie 121a194faf8Srie for (cnt = 0; cnt < stp->st_hbckcnt; cnt++) { 122a194faf8Srie Str_hash *strhash = stp->st_hashbcks[cnt]; 1235aefb655Srie 124e23c41c9SAli Bahrami if (strhash == NULL) 125a194faf8Srie continue; 1265aefb655Srie 127a194faf8Srie dbg_print(lml, MSG_INTL(MSG_SEC_STRTAB_BCKT), cnt); 128a194faf8Srie 129a194faf8Srie while (strhash) { 130cce0e03bSab196087 size_t stroff = strhash->hi_mstr->sm_strlen - 131a194faf8Srie strhash->hi_strlen; 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate if (stroff == 0) { 1345aefb655Srie dbg_print(lml, MSG_INTL(MSG_SEC_STRTAB_MSTR), 135cce0e03bSab196087 EC_XWORD(strhash->hi_refcnt), 136a194faf8Srie strhash->hi_mstr->sm_str); 1377c478bd9Sstevel@tonic-gate } else { 1385aefb655Srie dbg_print(lml, MSG_INTL(MSG_SEC_STRTAB_SUFSTR), 139cce0e03bSab196087 EC_XWORD(strhash->hi_refcnt), 140a194faf8Srie &strhash->hi_mstr->sm_str[stroff], 141a194faf8Srie strhash->hi_mstr->sm_str); 1427c478bd9Sstevel@tonic-gate } 1437c478bd9Sstevel@tonic-gate 144a194faf8Srie strhash = strhash->hi_next; 145a194faf8Srie } 1467c478bd9Sstevel@tonic-gate } 1477c478bd9Sstevel@tonic-gate } 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate void 150cce0e03bSab196087 Dbg_sec_genstr_compress(Lm_list *lml, const char *os_name, 151cce0e03bSab196087 Xword raw_size, Xword merge_size) 152cce0e03bSab196087 { 153cce0e03bSab196087 if (DBG_NOTCLASS(DBG_C_SECTIONS)) 154cce0e03bSab196087 return; 155cce0e03bSab196087 156cce0e03bSab196087 dbg_print(lml, MSG_INTL(MSG_SEC_GENSTR_COMP), os_name, 157cce0e03bSab196087 EC_XWORD(raw_size), EC_XWORD(merge_size)); 158cce0e03bSab196087 } 159cce0e03bSab196087 160cce0e03bSab196087 void 161cce0e03bSab196087 Dbg_sec_unsup_strmerge(Lm_list *lml, Is_desc *isp) 162cce0e03bSab196087 { 163e23c41c9SAli Bahrami dbg_isec_name_buf_t buf; 164e23c41c9SAli Bahrami char *alloc_mem; 165cce0e03bSab196087 const char *str; 166cce0e03bSab196087 167cce0e03bSab196087 if (DBG_NOTCLASS(DBG_C_SECTIONS)) 168cce0e03bSab196087 return; 169cce0e03bSab196087 170cce0e03bSab196087 /* 171cce0e03bSab196087 * We can only merge string table sections with single byte 172cce0e03bSab196087 * (char) characters. For any other (wide) character types, 173cce0e03bSab196087 * issue a message so the user will understand why these 174cce0e03bSab196087 * sections are not being picked up. 175cce0e03bSab196087 */ 176cce0e03bSab196087 if ((isp->is_shdr->sh_entsize > 1) || 177cce0e03bSab196087 (isp->is_shdr->sh_addralign > 1)) { 178cce0e03bSab196087 str = (isp->is_file != NULL) ? isp->is_file->ifl_name : 179cce0e03bSab196087 MSG_INTL(MSG_STR_NULL); 180cce0e03bSab196087 dbg_print(lml, MSG_INTL(MSG_SEC_STRMERGE_UNSUP), 181e23c41c9SAli Bahrami dbg_fmt_isec_name(isp, buf, &alloc_mem), str, 182e23c41c9SAli Bahrami EC_XWORD(isp->is_shdr->sh_addralign), 183cce0e03bSab196087 EC_XWORD(isp->is_shdr->sh_entsize)); 184e23c41c9SAli Bahrami if (alloc_mem != NULL) 185e23c41c9SAli Bahrami free(alloc_mem); 186cce0e03bSab196087 } 187cce0e03bSab196087 } 188cce0e03bSab196087 189cce0e03bSab196087 void 19057ef7aa9SRod Evans Dbg_sec_backing(Lm_list *lml) 19157ef7aa9SRod Evans { 19257ef7aa9SRod Evans if (DBG_NOTCLASS(DBG_C_SECTIONS)) 19357ef7aa9SRod Evans return; 19457ef7aa9SRod Evans 19557ef7aa9SRod Evans Dbg_util_nl(lml, DBG_NL_STD); 19657ef7aa9SRod Evans dbg_print(lml, MSG_INTL(MSG_SEC_BACKING)); 19757ef7aa9SRod Evans } 19857ef7aa9SRod Evans 19957ef7aa9SRod Evans void 2005aefb655Srie Dbg_sec_in(Lm_list *lml, Is_desc *isp) 2017c478bd9Sstevel@tonic-gate { 2025aefb655Srie if (DBG_NOTCLASS(DBG_C_SECTIONS)) 2037c478bd9Sstevel@tonic-gate return; 2047c478bd9Sstevel@tonic-gate 205cce0e03bSab196087 if (isp->is_flags & FLG_IS_GNSTRMRG) { 206cce0e03bSab196087 /* 207cce0e03bSab196087 * This section was generated because we have 1 or 208cce0e03bSab196087 * more SHF_MERGE|SHF_STRINGS input sections that we 209cce0e03bSab196087 * wish to merge. This new section will ultimately 210cce0e03bSab196087 * end up replacing those sections once it has been filled 211cce0e03bSab196087 * with their strings (merged and compressed) and relocations 212cce0e03bSab196087 * have been redirected. 213cce0e03bSab196087 */ 214cce0e03bSab196087 dbg_print(lml, MSG_INTL(MSG_SEC_INPUT_GENSTR), isp->is_name); 215e23c41c9SAli Bahrami } else if (isp->is_file == NULL) { 216e23c41c9SAli Bahrami /* Generated input section */ 217e23c41c9SAli Bahrami dbg_print(lml, MSG_INTL(MSG_SEC_INPUT_GEN), isp->is_name); 218cce0e03bSab196087 } else { 219cce0e03bSab196087 /* Standard input section */ 220e23c41c9SAli Bahrami dbg_isec_name_buf_t buf; 221e23c41c9SAli Bahrami char *alloc_mem; 222e23c41c9SAli Bahrami 223e23c41c9SAli Bahrami dbg_print(lml, MSG_INTL(MSG_SEC_INPUT), 224e23c41c9SAli Bahrami dbg_fmt_isec_name(isp, buf, &alloc_mem), 225e23c41c9SAli Bahrami isp->is_file->ifl_name); 226e23c41c9SAli Bahrami if (alloc_mem != NULL) 227e23c41c9SAli Bahrami free(alloc_mem); 2287c478bd9Sstevel@tonic-gate } 229cce0e03bSab196087 } 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate void 2325aefb655Srie Dbg_sec_added(Lm_list *lml, Os_desc *osp, Sg_desc *sgp) 2337c478bd9Sstevel@tonic-gate { 2347c478bd9Sstevel@tonic-gate const char *str; 2357c478bd9Sstevel@tonic-gate 2365aefb655Srie if (DBG_NOTCLASS(DBG_C_SECTIONS)) 2377c478bd9Sstevel@tonic-gate return; 2387c478bd9Sstevel@tonic-gate 2397c478bd9Sstevel@tonic-gate if (sgp->sg_name && *sgp->sg_name) 2407c478bd9Sstevel@tonic-gate str = sgp->sg_name; 2417c478bd9Sstevel@tonic-gate else 2427c478bd9Sstevel@tonic-gate str = MSG_INTL(MSG_STR_NULL); 2437c478bd9Sstevel@tonic-gate 2445aefb655Srie dbg_print(lml, MSG_INTL(MSG_SEC_ADDED), osp->os_name, str); 2457c478bd9Sstevel@tonic-gate } 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate void 2485aefb655Srie Dbg_sec_created(Lm_list *lml, Os_desc *osp, Sg_desc *sgp) 2497c478bd9Sstevel@tonic-gate { 2507c478bd9Sstevel@tonic-gate const char *str; 2517c478bd9Sstevel@tonic-gate 2525aefb655Srie if (DBG_NOTCLASS(DBG_C_SECTIONS)) 2537c478bd9Sstevel@tonic-gate return; 2547c478bd9Sstevel@tonic-gate 2557c478bd9Sstevel@tonic-gate if (sgp->sg_name && *sgp->sg_name) 2567c478bd9Sstevel@tonic-gate str = sgp->sg_name; 2577c478bd9Sstevel@tonic-gate else 2587c478bd9Sstevel@tonic-gate str = MSG_INTL(MSG_STR_NULL); 2597c478bd9Sstevel@tonic-gate 2605aefb655Srie dbg_print(lml, MSG_INTL(MSG_SEC_CREATED), osp->os_name, str); 2617c478bd9Sstevel@tonic-gate } 2627c478bd9Sstevel@tonic-gate 2637c478bd9Sstevel@tonic-gate void 2645aefb655Srie Dbg_sec_discarded(Lm_list *lml, Is_desc *isp, Is_desc *disp) 2657c478bd9Sstevel@tonic-gate { 266a194faf8Srie if (DBG_NOTCLASS(DBG_C_SECTIONS | DBG_C_UNUSED)) 2677c478bd9Sstevel@tonic-gate return; 2687c478bd9Sstevel@tonic-gate 269cce0e03bSab196087 if ((isp->is_flags & FLG_IS_INSTRMRG) && 270cce0e03bSab196087 (disp->is_flags & FLG_IS_GNSTRMRG)) { 271cce0e03bSab196087 /* 272cce0e03bSab196087 * This SHF_MERGE|SHF_STRINGS input section is being 273cce0e03bSab196087 * discarded in favor of the generated merged string section. 274cce0e03bSab196087 */ 275e23c41c9SAli Bahrami dbg_isec_name_buf_t buf; 276e23c41c9SAli Bahrami char *alloc_mem; 277e23c41c9SAli Bahrami 278cce0e03bSab196087 dbg_print(lml, MSG_INTL(MSG_SEC_STRMERGE_DISCARDED), 279e23c41c9SAli Bahrami dbg_fmt_isec_name(isp, buf, &alloc_mem), 280e23c41c9SAli Bahrami isp->is_file->ifl_name); 281e23c41c9SAli Bahrami if (alloc_mem != NULL) 282e23c41c9SAli Bahrami free(alloc_mem); 283cce0e03bSab196087 } else { 284cce0e03bSab196087 /* Generic section discard */ 285e23c41c9SAli Bahrami dbg_isec_name_buf_t buf1, buf2; 286e23c41c9SAli Bahrami char *alloc_mem1, *alloc_mem2; 287e23c41c9SAli Bahrami 288e23c41c9SAli Bahrami dbg_print(lml, MSG_INTL(MSG_SEC_DISCARDED), 289e23c41c9SAli Bahrami dbg_fmt_isec_name(isp, buf1, &alloc_mem1), 290e23c41c9SAli Bahrami isp->is_file->ifl_name, 291e23c41c9SAli Bahrami dbg_fmt_isec_name(disp, buf2, &alloc_mem2), 2927c478bd9Sstevel@tonic-gate disp->is_file->ifl_name); 293e23c41c9SAli Bahrami if (alloc_mem1 != NULL) 294e23c41c9SAli Bahrami free(alloc_mem1); 295e23c41c9SAli Bahrami if (alloc_mem2 != NULL) 296e23c41c9SAli Bahrami free(alloc_mem2); 2977c478bd9Sstevel@tonic-gate } 298cce0e03bSab196087 } 2997c478bd9Sstevel@tonic-gate 3007c478bd9Sstevel@tonic-gate void 3015aefb655Srie Dbg_sec_group(Lm_list *lml, Is_desc *isp, Group_desc *gdp) 3027c478bd9Sstevel@tonic-gate { 303e23c41c9SAli Bahrami dbg_isec_name_buf_t buf; 304e23c41c9SAli Bahrami char *alloc_mem; 305e23c41c9SAli Bahrami const char *comdat, *isp_str; 3067c478bd9Sstevel@tonic-gate 3075aefb655Srie if (DBG_NOTCLASS(DBG_C_SECTIONS)) 3087c478bd9Sstevel@tonic-gate return; 309cc7efc4fSrie 3100e233487SRod Evans if (gdp->gd_data[0] & GRP_COMDAT) 3110e233487SRod Evans comdat = MSG_ORIG(MSG_STR_COMDAT); 312cc7efc4fSrie else 3130e233487SRod Evans comdat = MSG_ORIG(MSG_STR_EMPTY); 314cc7efc4fSrie 315e23c41c9SAli Bahrami isp_str = dbg_fmt_isec_name(isp, buf, &alloc_mem); 316e23c41c9SAli Bahrami 3170e233487SRod Evans if (isp->is_shdr->sh_type == SHT_GROUP) { 318e23c41c9SAli Bahrami dbg_print(lml, MSG_INTL(MSG_SEC_GRP_DEFINE), isp_str, 3190e233487SRod Evans isp->is_file->ifl_name, comdat, gdp->gd_name); 3200e233487SRod Evans } else { 321e23c41c9SAli Bahrami dbg_print(lml, MSG_INTL(MSG_SEC_GRP_MEMBER), isp_str, 3220e233487SRod Evans isp->is_file->ifl_name, comdat, gdp->gd_name); 3230e233487SRod Evans } 3240e233487SRod Evans 3250e233487SRod Evans if (gdp->gd_oisc) { 326e23c41c9SAli Bahrami dbg_print(lml, MSG_INTL(MSG_SEC_GRP_DISCARDED), isp_str, 3270e233487SRod Evans isp->is_file->ifl_name, gdp->gd_name, 3280e233487SRod Evans gdp->gd_oisc->is_file->ifl_name); 3290e233487SRod Evans } 330e23c41c9SAli Bahrami 331e23c41c9SAli Bahrami if (alloc_mem != NULL) 332e23c41c9SAli Bahrami free(alloc_mem); 3337c478bd9Sstevel@tonic-gate } 3347c478bd9Sstevel@tonic-gate 3357c478bd9Sstevel@tonic-gate void 3367c478bd9Sstevel@tonic-gate Dbg_sec_order_list(Ofl_desc *ofl, int flag) 3377c478bd9Sstevel@tonic-gate { 3387c478bd9Sstevel@tonic-gate Os_desc *osp; 3397c478bd9Sstevel@tonic-gate Is_desc *isp1; 34057ef7aa9SRod Evans Aliste idx1; 3415aefb655Srie Lm_list *lml = ofl->ofl_lml; 3427c478bd9Sstevel@tonic-gate const char *str; 3437c478bd9Sstevel@tonic-gate 3445aefb655Srie if (DBG_NOTCLASS(DBG_C_SECTIONS)) 3457c478bd9Sstevel@tonic-gate return; 3467c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 3477c478bd9Sstevel@tonic-gate return; 3487c478bd9Sstevel@tonic-gate 3497010c12aSrie Dbg_util_nl(lml, DBG_NL_STD); 3507010c12aSrie 3517c478bd9Sstevel@tonic-gate /* 3527c478bd9Sstevel@tonic-gate * If the flag == 0, then the routine is called before sorting. 3537c478bd9Sstevel@tonic-gate */ 3547c478bd9Sstevel@tonic-gate if (flag == 0) 3557c478bd9Sstevel@tonic-gate str = MSG_INTL(MSG_ORD_SORT_BEFORE); 3567c478bd9Sstevel@tonic-gate else 3577c478bd9Sstevel@tonic-gate str = MSG_INTL(MSG_ORD_SORT_AFTER); 3587c478bd9Sstevel@tonic-gate 35957ef7aa9SRod Evans for (APLIST_TRAVERSE(ofl->ofl_ordered, idx1, osp)) { 3601dd9d86fSAli Bahrami int os_isdescs_idx; 36157ef7aa9SRod Evans Aliste idx2; 3627c478bd9Sstevel@tonic-gate 363e23c41c9SAli Bahrami Dbg_util_nl(lml, DBG_NL_STD); 3645aefb655Srie dbg_print(lml, str, osp->os_name); 3655aefb655Srie dbg_print(lml, MSG_INTL(MSG_ORD_HDR_1), 3661dd9d86fSAli Bahrami EC_WORD(aplist_nitems(osp->os_isdescs[OS_ISD_BEFORE])), 3671dd9d86fSAli Bahrami EC_WORD(aplist_nitems(osp->os_isdescs[OS_ISD_ORDERED])), 3681dd9d86fSAli Bahrami EC_WORD(aplist_nitems(osp->os_isdescs[OS_ISD_DEFAULT])), 3691dd9d86fSAli Bahrami EC_WORD(aplist_nitems(osp->os_isdescs[OS_ISD_AFTER]))); 3707c478bd9Sstevel@tonic-gate 3711dd9d86fSAli Bahrami OS_ISDESCS_TRAVERSE(os_isdescs_idx, osp, idx2, isp1) { 372e23c41c9SAli Bahrami dbg_isec_name_buf_t buf; 373e23c41c9SAli Bahrami char *alloc_mem; 374e23c41c9SAli Bahrami const char *isp1_str; 3757c478bd9Sstevel@tonic-gate Word link; 3767c478bd9Sstevel@tonic-gate Ifl_desc *ifl = isp1->is_file; 3777c478bd9Sstevel@tonic-gate Is_desc *isp2; 3787010c12aSrie const char *msg; 3797c478bd9Sstevel@tonic-gate 380e23c41c9SAli Bahrami /* 381604635faSRod Evans * An output segment that requires ordering might have 382604635faSRod Evans * as little as two sorted input sections. For example, 383604635faSRod Evans * the crt's can provide a SHN_BEGIN and SHN_AFTER, and 384604635faSRod Evans * only these two sections must be processed. Thus, if 385604635faSRod Evans * a input section is unordered, move on. Diagnosing 386604635faSRod Evans * any unsorted section can produce way too much noise. 387e23c41c9SAli Bahrami */ 388604635faSRod Evans if ((isp1->is_flags & FLG_IS_ORDERED) == 0) 3897c478bd9Sstevel@tonic-gate continue; 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate if (isp1->is_shdr->sh_flags & SHF_ORDERED) { 3927c478bd9Sstevel@tonic-gate link = isp1->is_shdr->sh_info; 3937010c12aSrie msg = MSG_ORIG(MSG_SH_INFO); 394e23c41c9SAli Bahrami } else { /* SHF_LINK_ORDER */ 3957c478bd9Sstevel@tonic-gate link = isp1->is_shdr->sh_link; 3967010c12aSrie msg = MSG_ORIG(MSG_SH_LINK); 3977c478bd9Sstevel@tonic-gate } 3987c478bd9Sstevel@tonic-gate 399e23c41c9SAli Bahrami isp1_str = dbg_fmt_isec_name(isp1, buf, &alloc_mem); 400e23c41c9SAli Bahrami 4017c478bd9Sstevel@tonic-gate if (link == SHN_BEFORE) { 402e23c41c9SAli Bahrami dbg_print(lml, MSG_INTL(MSG_ORD_TITLE_1), msg, 403e23c41c9SAli Bahrami isp1_str, isp1->is_file->ifl_name); 404e23c41c9SAli Bahrami } else if (link == SHN_AFTER) { 405e23c41c9SAli Bahrami dbg_print(lml, MSG_INTL(MSG_ORD_TITLE_2), msg, 406e23c41c9SAli Bahrami isp1_str, isp1->is_file->ifl_name); 407e23c41c9SAli Bahrami } else { 4087c478bd9Sstevel@tonic-gate isp2 = ifl->ifl_isdesc[link]; 4097010c12aSrie dbg_print(lml, MSG_INTL(MSG_ORD_TITLE_3), 410e23c41c9SAli Bahrami EC_WORD(isp2->is_keyident), isp1_str, 411e23c41c9SAli Bahrami ifl->ifl_name, msg, isp2->is_name); 412e23c41c9SAli Bahrami } 413e23c41c9SAli Bahrami if (alloc_mem != NULL) 414e23c41c9SAli Bahrami free(alloc_mem); 4157c478bd9Sstevel@tonic-gate } 4167c478bd9Sstevel@tonic-gate } 4177010c12aSrie Dbg_util_nl(lml, DBG_NL_STD); 4187c478bd9Sstevel@tonic-gate } 4197c478bd9Sstevel@tonic-gate 420a194faf8Srie /* 421a194faf8Srie * Error message string table. 422a194faf8Srie */ 423a194faf8Srie static const Msg order_errors[] = { 424a194faf8Srie MSG_ORD_ERR_INFORANGE, /* MSG_INTL(MSG_ORD_ERR_INFORANGE) */ 425a194faf8Srie MSG_ORD_ERR_ORDER, /* MSG_INTL(MSG_ORD_ERR_ORDER) */ 426a194faf8Srie MSG_ORD_ERR_LINKRANGE, /* MSG_INTL(MSG_ORD_ERR_LINKRANGE) */ 427a194faf8Srie MSG_ORD_ERR_FLAGS, /* MSG_INTL(MSG_ORD_ERR_FLAGS) */ 428a194faf8Srie MSG_ORD_ERR_CYCLIC, /* MSG_INTL(MSG_ORD_ERR_CYCLIC) */ 429a194faf8Srie MSG_ORD_ERR_LINKINV /* MSG_INTL(MSG_ORD_ERR_LINKINV) */ 430a194faf8Srie }; 431a194faf8Srie 4327c478bd9Sstevel@tonic-gate void 4335aefb655Srie Dbg_sec_order_error(Lm_list *lml, Ifl_desc *ifl, Word ndx, int error) 4347c478bd9Sstevel@tonic-gate { 435e23c41c9SAli Bahrami dbg_isec_name_buf_t buf; 436e23c41c9SAli Bahrami char *alloc_mem; 437e23c41c9SAli Bahrami 4385aefb655Srie if (DBG_NOTCLASS(DBG_C_SECTIONS)) 4397c478bd9Sstevel@tonic-gate return; 4407c478bd9Sstevel@tonic-gate if (DBG_NOTDETAIL()) 4417c478bd9Sstevel@tonic-gate return; 4427c478bd9Sstevel@tonic-gate 4437c478bd9Sstevel@tonic-gate if (error == 0) 4447c478bd9Sstevel@tonic-gate return; 4457c478bd9Sstevel@tonic-gate 4465aefb655Srie dbg_print(lml, MSG_INTL(MSG_ORD_ERR_TITLE), 447e23c41c9SAli Bahrami dbg_fmt_isec_name(ifl->ifl_isdesc[ndx], buf, &alloc_mem), 448e23c41c9SAli Bahrami ifl->ifl_name); 449e23c41c9SAli Bahrami if (alloc_mem != NULL) 450e23c41c9SAli Bahrami free(alloc_mem); 4517c478bd9Sstevel@tonic-gate 4527c478bd9Sstevel@tonic-gate if (error) 4535aefb655Srie dbg_print(lml, MSG_INTL(order_errors[error - 1])); 4547c478bd9Sstevel@tonic-gate } 4550e233487SRod Evans 4560e233487SRod Evans void 457e23c41c9SAli Bahrami Dbg_sec_redirected(Lm_list *lml, Is_desc *isp, const char *nname) 4580e233487SRod Evans { 459e23c41c9SAli Bahrami dbg_isec_name_buf_t buf; 460e23c41c9SAli Bahrami char *alloc_mem; 461e23c41c9SAli Bahrami 4620e233487SRod Evans if (DBG_NOTCLASS(DBG_C_SECTIONS)) 4630e233487SRod Evans return; 4640e233487SRod Evans 465e23c41c9SAli Bahrami dbg_print(lml, MSG_INTL(MSG_SEC_REDIRECTED), 466e23c41c9SAli Bahrami dbg_fmt_isec_name(isp, buf, &alloc_mem), nname); 467e23c41c9SAli Bahrami if (alloc_mem != NULL) 468e23c41c9SAli Bahrami free(alloc_mem); 4690e233487SRod Evans } 4700e233487SRod Evans 4710e233487SRod Evans void 472*e64d0ff9SAli Bahrami Dbg_sec_gnu_comdat(Lm_list *lml, Is_desc *isp, Boolean comdat, Boolean relax) 4730e233487SRod Evans { 474e23c41c9SAli Bahrami dbg_isec_name_buf_t buf; 475e23c41c9SAli Bahrami char *alloc_mem; 4760e233487SRod Evans const char *fmt; 4770e233487SRod Evans 4780e233487SRod Evans if (DBG_NOTCLASS(DBG_C_SECTIONS)) 4790e233487SRod Evans return; 4800e233487SRod Evans 4810e233487SRod Evans if (comdat && relax) 4820e233487SRod Evans fmt = MSG_INTL(MSG_SEC_GNU_COMDAT_1); 4830e233487SRod Evans else if (comdat) 4840e233487SRod Evans fmt = MSG_INTL(MSG_SEC_GNU_COMDAT_2); 4850e233487SRod Evans else 4860e233487SRod Evans fmt = MSG_INTL(MSG_SEC_GNU_COMDAT_3); 4870e233487SRod Evans 488e23c41c9SAli Bahrami dbg_print(lml, fmt, dbg_fmt_isec_name(isp, buf, &alloc_mem)); 489e23c41c9SAli Bahrami if (alloc_mem != NULL) 490e23c41c9SAli Bahrami free(alloc_mem); 4910e233487SRod Evans } 492