Print this page
10138 smatch fixes for usr/src/cmd/sgs
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/sgs/libld/common/ldentry.c
+++ new/usr/src/cmd/sgs/libld/common/ldentry.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 1988 AT&T
24 24 * All Rights Reserved
25 25 *
26 26 * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
27 27 */
28 28
29 +/*
30 + * Copyright (c) 2018, Joyent, Inc.
31 + */
32 +
29 33 #include <stdio.h>
30 34 #include <string.h>
31 35 #include "msg.h"
32 36 #include "_libld.h"
33 37
34 38
35 39 /*
36 40 * Print a virtual address map of input and output sections together with
37 41 * multiple symbol definitions (if they exist).
38 42 */
39 43 static Boolean symbol_title = TRUE;
40 44
41 45 static void
42 46 sym_muldef_title()
43 47 {
44 48 (void) printf(MSG_INTL(MSG_ENT_MUL_FMT_TIL_0),
45 49 MSG_INTL(MSG_ENT_MUL_TIL_0));
46 50 (void) printf(MSG_INTL(MSG_ENT_MUL_FMT_TIL_1),
47 51 MSG_INTL(MSG_ENT_MUL_ITM_SYM),
48 52 MSG_INTL(MSG_ENT_MUL_ITM_DEF_0),
49 53 MSG_INTL(MSG_ENT_MUL_ITM_DEF_1));
50 54 symbol_title = FALSE;
51 55 }
52 56
53 57 void
54 58 ld_map_out(Ofl_desc *ofl)
55 59 {
56 60 Sg_desc *sgp;
57 61 Is_desc *isp;
58 62 Sym_avlnode *sav;
59 63 Aliste idx1;
60 64
61 65 (void) printf(MSG_INTL(MSG_ENT_MAP_FMT_TIL_1),
62 66 MSG_INTL(MSG_ENT_MAP_TITLE_1));
63 67 if (ofl->ofl_flags & FLG_OF_RELOBJ)
64 68 (void) printf(MSG_INTL(MSG_ENT_MAP_FMT_TIL_2),
65 69 MSG_INTL(MSG_ENT_ITM_OUTPUT),
66 70 MSG_INTL(MSG_ENT_ITM_INPUT),
67 71 MSG_INTL(MSG_ENT_ITM_NEW),
68 72 MSG_INTL(MSG_ENT_ITM_SECTION),
69 73 MSG_INTL(MSG_ENT_ITM_SECTION),
70 74 MSG_INTL(MSG_ENT_ITM_DISPMNT),
71 75 MSG_INTL(MSG_ENT_ITM_SIZE));
72 76 else
73 77 (void) printf(MSG_INTL(MSG_ENT_MAP_FMT_TIL_3),
74 78 MSG_INTL(MSG_ENT_ITM_OUTPUT),
75 79 MSG_INTL(MSG_ENT_ITM_INPUT),
76 80 MSG_INTL(MSG_ENT_ITM_VIRTUAL),
77 81 MSG_INTL(MSG_ENT_ITM_SECTION),
78 82 MSG_INTL(MSG_ENT_ITM_SECTION),
79 83 MSG_INTL(MSG_ENT_ITM_ADDRESS),
80 84 MSG_INTL(MSG_ENT_ITM_SIZE));
81 85
82 86 for (APLIST_TRAVERSE(ofl->ofl_segs, idx1, sgp)) {
83 87 Os_desc *osp;
84 88 Aliste idx2;
85 89
86 90 if (sgp->sg_phdr.p_type != PT_LOAD)
87 91 continue;
88 92
89 93 for (APLIST_TRAVERSE(sgp->sg_osdescs, idx2, osp)) {
90 94 int os_isdescs_idx;
91 95 Aliste idx3;
92 96
93 97 (void) printf(MSG_INTL(MSG_ENT_MAP_ENTRY_1),
94 98 osp->os_name, EC_ADDR(osp->os_shdr->sh_addr),
95 99 EC_XWORD(osp->os_shdr->sh_size));
96 100
97 101 OS_ISDESCS_TRAVERSE(os_isdescs_idx, osp, idx3, isp) {
98 102 Addr addr;
99 103
100 104 /*
101 105 * Although there seems little point in printing
102 106 * discarded (empty) sections, especially as
103 107 * diagnostics under -Dsegments,details are more
104 108 * informative, continue printing them. There
105 109 * are user scripts, fragile to say the least,
106 110 * that grep(1) through load-map output to
107 111 * discover object requirements. These scripts
108 112 * don't grep for all input sections types (ie.
109 113 * .picdata), and have become dependent on null
110 114 * sections (ie. .text) existing in the
111 115 * load-map output.
112 116 */
113 117 if (isp->is_flags & FLG_IS_DISCARD) {
114 118 addr = 0;
115 119 } else {
116 120 addr = (Addr)
117 121 _elf_getxoff(isp->is_indata);
118 122 if (!(ofl->ofl_flags & FLG_OF_RELOBJ))
119 123 addr += isp->is_osdesc->
120 124 os_shdr->sh_addr;
121 125 }
122 126
123 127 (void) printf(MSG_INTL(MSG_ENT_MAP_ENTRY_2),
124 128 isp->is_name, EC_ADDR(addr),
125 129 EC_XWORD(isp->is_shdr->sh_size),
126 130 ((isp->is_file != NULL) ?
127 131 (char *)(isp->is_file->ifl_name) :
128 132 MSG_INTL(MSG_STR_NULL)));
129 133 }
130 134 }
131 135 }
132 136
133 137 if (ofl->ofl_flags & FLG_OF_RELOBJ)
134 138 return;
135 139
136 140 /*
137 141 * Check for any multiply referenced symbols (ie. symbols that have
138 142 * been overridden from a shared library).
139 143 */
140 144 for (sav = avl_first(&ofl->ofl_symavl); sav;
141 145 sav = AVL_NEXT(&ofl->ofl_symavl, sav)) {
142 146 Sym_desc *sdp = sav->sav_sdp;
143 147 const char *name = sdp->sd_name, *ducp, *adcp;
144 148 APlist *dfiles;
145 149 Aliste idx;
146 150
147 151 if (((dfiles = sdp->sd_aux->sa_dfiles) == NULL) ||
148 152 (aplist_nitems(dfiles) == 1))
↓ open down ↓ |
110 lines elided |
↑ open up ↑ |
149 153 continue;
150 154
151 155 /*
152 156 * Files that define a symbol are saved on the `sa_dfiles' list.
153 157 * Ignore symbols that aren't needed, and any special symbols
154 158 * that the link editor may produce (symbols of type ABS and
155 159 * COMMON are not recorded in the first place, however functions
156 160 * like _init() and _fini() commonly have multiple occurrences).
157 161 */
158 162 if ((sdp->sd_ref == REF_DYN_SEEN) ||
159 - (sdp->sd_aux && sdp->sd_aux->sa_symspec) ||
163 + (sdp->sd_aux->sa_symspec) ||
160 164 (strcmp(MSG_ORIG(MSG_SYM_FINI_U), name) == 0) ||
161 165 (strcmp(MSG_ORIG(MSG_SYM_INIT_U), name) == 0) ||
162 166 (strcmp(MSG_ORIG(MSG_SYM_LIBVER_U), name) == 0))
163 167 continue;
164 168
165 169 if (symbol_title)
166 170 sym_muldef_title();
167 171
168 172 ducp = sdp->sd_file->ifl_name;
169 173 (void) printf(MSG_INTL(MSG_ENT_MUL_ENTRY_1), demangle(name),
170 174 ducp);
171 175 for (APLIST_TRAVERSE(dfiles, idx, adcp)) {
172 176 /*
173 177 * Ignore the referenced symbol.
174 178 */
175 179 if (strcmp(adcp, ducp) != 0)
176 180 (void) printf(MSG_INTL(MSG_ENT_MUL_ENTRY_2),
177 181 adcp);
178 182 }
179 183 }
180 184 }
181 185
182 186 /*
183 187 * Traverse the entrance criteria list searching for those sections that haven't
184 188 * been met and print error message. (only in the case of reordering)
185 189 */
186 190 void
187 191 ld_ent_check(Ofl_desc * ofl)
188 192 {
189 193 Ent_desc *enp;
190 194 Aliste ndx;
191 195
192 196 /*
193 197 * Try to give as much information to the user about the specific
194 198 * line in the mapfile. If the line contains a file name then
195 199 * output the filename too. Hence we have two warning lines -
196 200 * one for criterias where a filename is used and the other
197 201 * for those without a filename.
198 202 */
199 203 for (APLIST_TRAVERSE(ofl->ofl_ents, ndx, enp)) {
200 204 /*
201 205 * No warning if any of the following hold:
202 206 * - The segment has no entrance criteria requiring
203 207 * input section sorting (FLG_SG_IS_ORDER not set).
204 208 * - The entrance criteria was used to place a section.
205 209 * - The specific entrance criteria does not require sorting
206 210 */
207 211 if (((enp->ec_segment->sg_flags & FLG_SG_IS_ORDER) == 0) ||
208 212 (enp->ec_flags & FLG_EC_USED) || (enp->ec_ordndx == 0))
209 213 continue;
210 214
211 215
212 216 if (alist_nitems(enp->ec_files) > 0) {
213 217 ld_eprintf(ofl, ERR_WARNING, MSG_INTL(MSG_ENT_NOSEC_1),
214 218 enp->ec_segment->sg_name, enp->ec_is_name);
215 219 } else {
216 220 ld_eprintf(ofl, ERR_WARNING, MSG_INTL(MSG_ENT_NOSEC_2),
217 221 enp->ec_segment->sg_name, enp->ec_is_name);
218 222 }
219 223 }
220 224 }
↓ open down ↓ |
51 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX