Print this page
10138 smatch fixes for usr/src/cmd/sgs


   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 (c) 1988 AT&T
  24  *        All Rights Reserved
  25  *
  26  * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
  27  */
  28 




  29 #include        <stdio.h>
  30 #include        <string.h>
  31 #include        "msg.h"
  32 #include        "_libld.h"
  33 
  34 
  35 /*
  36  * Print a virtual address map of input and output sections together with
  37  * multiple symbol definitions (if they exist).
  38  */
  39 static Boolean  symbol_title = TRUE;
  40 
  41 static void
  42 sym_muldef_title()
  43 {
  44         (void) printf(MSG_INTL(MSG_ENT_MUL_FMT_TIL_0),
  45             MSG_INTL(MSG_ENT_MUL_TIL_0));
  46         (void) printf(MSG_INTL(MSG_ENT_MUL_FMT_TIL_1),
  47             MSG_INTL(MSG_ENT_MUL_ITM_SYM),
  48             MSG_INTL(MSG_ENT_MUL_ITM_DEF_0),


 139          */
 140         for (sav = avl_first(&ofl->ofl_symavl); sav;
 141             sav = AVL_NEXT(&ofl->ofl_symavl, sav)) {
 142                 Sym_desc        *sdp = sav->sav_sdp;
 143                 const char      *name = sdp->sd_name, *ducp, *adcp;
 144                 APlist          *dfiles;
 145                 Aliste          idx;
 146 
 147                 if (((dfiles = sdp->sd_aux->sa_dfiles) == NULL) ||
 148                     (aplist_nitems(dfiles) == 1))
 149                         continue;
 150 
 151                 /*
 152                  * Files that define a symbol are saved on the `sa_dfiles' list.
 153                  * Ignore symbols that aren't needed, and any special symbols
 154                  * that the link editor may produce (symbols of type ABS and
 155                  * COMMON are not recorded in the first place, however functions
 156                  * like _init() and _fini() commonly have multiple occurrences).
 157                  */
 158                 if ((sdp->sd_ref == REF_DYN_SEEN) ||
 159                     (sdp->sd_aux && sdp->sd_aux->sa_symspec) ||
 160                     (strcmp(MSG_ORIG(MSG_SYM_FINI_U), name) == 0) ||
 161                     (strcmp(MSG_ORIG(MSG_SYM_INIT_U), name) == 0) ||
 162                     (strcmp(MSG_ORIG(MSG_SYM_LIBVER_U), name) == 0))
 163                         continue;
 164 
 165                 if (symbol_title)
 166                         sym_muldef_title();
 167 
 168                 ducp = sdp->sd_file->ifl_name;
 169                 (void) printf(MSG_INTL(MSG_ENT_MUL_ENTRY_1), demangle(name),
 170                     ducp);
 171                 for (APLIST_TRAVERSE(dfiles, idx, adcp)) {
 172                         /*
 173                          * Ignore the referenced symbol.
 174                          */
 175                         if (strcmp(adcp, ducp) != 0)
 176                                 (void) printf(MSG_INTL(MSG_ENT_MUL_ENTRY_2),
 177                                     adcp);
 178                 }
 179         }




   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 (c) 1988 AT&T
  24  *        All Rights Reserved
  25  *
  26  * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
  27  */
  28 
  29 /*
  30  * Copyright (c) 2018, Joyent, Inc.
  31  */
  32 
  33 #include        <stdio.h>
  34 #include        <string.h>
  35 #include        "msg.h"
  36 #include        "_libld.h"
  37 
  38 
  39 /*
  40  * Print a virtual address map of input and output sections together with
  41  * multiple symbol definitions (if they exist).
  42  */
  43 static Boolean  symbol_title = TRUE;
  44 
  45 static void
  46 sym_muldef_title()
  47 {
  48         (void) printf(MSG_INTL(MSG_ENT_MUL_FMT_TIL_0),
  49             MSG_INTL(MSG_ENT_MUL_TIL_0));
  50         (void) printf(MSG_INTL(MSG_ENT_MUL_FMT_TIL_1),
  51             MSG_INTL(MSG_ENT_MUL_ITM_SYM),
  52             MSG_INTL(MSG_ENT_MUL_ITM_DEF_0),


 143          */
 144         for (sav = avl_first(&ofl->ofl_symavl); sav;
 145             sav = AVL_NEXT(&ofl->ofl_symavl, sav)) {
 146                 Sym_desc        *sdp = sav->sav_sdp;
 147                 const char      *name = sdp->sd_name, *ducp, *adcp;
 148                 APlist          *dfiles;
 149                 Aliste          idx;
 150 
 151                 if (((dfiles = sdp->sd_aux->sa_dfiles) == NULL) ||
 152                     (aplist_nitems(dfiles) == 1))
 153                         continue;
 154 
 155                 /*
 156                  * Files that define a symbol are saved on the `sa_dfiles' list.
 157                  * Ignore symbols that aren't needed, and any special symbols
 158                  * that the link editor may produce (symbols of type ABS and
 159                  * COMMON are not recorded in the first place, however functions
 160                  * like _init() and _fini() commonly have multiple occurrences).
 161                  */
 162                 if ((sdp->sd_ref == REF_DYN_SEEN) ||
 163                     (sdp->sd_aux->sa_symspec) ||
 164                     (strcmp(MSG_ORIG(MSG_SYM_FINI_U), name) == 0) ||
 165                     (strcmp(MSG_ORIG(MSG_SYM_INIT_U), name) == 0) ||
 166                     (strcmp(MSG_ORIG(MSG_SYM_LIBVER_U), name) == 0))
 167                         continue;
 168 
 169                 if (symbol_title)
 170                         sym_muldef_title();
 171 
 172                 ducp = sdp->sd_file->ifl_name;
 173                 (void) printf(MSG_INTL(MSG_ENT_MUL_ENTRY_1), demangle(name),
 174                     ducp);
 175                 for (APLIST_TRAVERSE(dfiles, idx, adcp)) {
 176                         /*
 177                          * Ignore the referenced symbol.
 178                          */
 179                         if (strcmp(adcp, ducp) != 0)
 180                                 (void) printf(MSG_INTL(MSG_ENT_MUL_ENTRY_2),
 181                                     adcp);
 182                 }
 183         }