author | Rod Evans <Rod.Evans@Sun.COM> |
Wed, 19 May 2010 22:33:49 -0700 | |
changeset 12449 | a87750d92895 |
parent 12254 | ff5bb54e2a40 |
child 13086 | 787bf65954d0 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
5 |
* Common Development and Distribution License (the "License"). |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
6 |
* You may not use this file except in compliance with the License. |
0 | 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 |
*/ |
|
1109
1a3bd84f03cd
6362044 ld(1) inconsistencies with LD_DEBUG=-Dunused and -zignore
rie
parents:
574
diff
changeset
|
21 |
|
0 | 22 |
/* |
23 |
* Copyright (c) 1988 AT&T |
|
24 |
* All Rights Reserved |
|
25 |
* |
|
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
26 |
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 27 |
*/ |
28 |
||
29 |
/* |
|
30 |
* Processing of relocatable objects and shared objects. |
|
31 |
*/ |
|
6206 | 32 |
|
33 |
#define ELF_TARGET_AMD64 |
|
34 |
#define ELF_TARGET_SPARC |
|
35 |
||
0 | 36 |
#include <stdio.h> |
37 |
#include <string.h> |
|
38 |
#include <fcntl.h> |
|
39 |
#include <unistd.h> |
|
40 |
#include <link.h> |
|
41 |
#include <limits.h> |
|
42 |
#include <sys/stat.h> |
|
43 |
#include <sys/systeminfo.h> |
|
44 |
#include <debug.h> |
|
45 |
#include <msg.h> |
|
46 |
#include <_libld.h> |
|
47 |
||
48 |
/* |
|
49 |
* Decide if we can link against this input file. |
|
50 |
*/ |
|
51 |
static int |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
52 |
ifl_verify(Ehdr *ehdr, Ofl_desc *ofl, Rej_desc *rej) |
0 | 53 |
{ |
54 |
/* |
|
55 |
* Check the validity of the elf header information for compatibility |
|
56 |
* with this machine and our own internal elf library. |
|
57 |
*/ |
|
6206 | 58 |
if ((ehdr->e_machine != ld_targ.t_m.m_mach) && |
59 |
((ehdr->e_machine != ld_targ.t_m.m_machplus) && |
|
60 |
((ehdr->e_flags & ld_targ.t_m.m_flagsplus) == 0))) { |
|
0 | 61 |
rej->rej_type = SGS_REJ_MACH; |
62 |
rej->rej_info = (uint_t)ehdr->e_machine; |
|
63 |
return (0); |
|
64 |
} |
|
6206 | 65 |
if (ehdr->e_ident[EI_DATA] != ld_targ.t_m.m_data) { |
0 | 66 |
rej->rej_type = SGS_REJ_DATA; |
67 |
rej->rej_info = (uint_t)ehdr->e_ident[EI_DATA]; |
|
68 |
return (0); |
|
69 |
} |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
70 |
if (ehdr->e_version > ofl->ofl_dehdr->e_version) { |
0 | 71 |
rej->rej_type = SGS_REJ_VERSION; |
72 |
rej->rej_info = (uint_t)ehdr->e_version; |
|
73 |
return (0); |
|
74 |
} |
|
75 |
return (1); |
|
76 |
} |
|
77 |
||
78 |
/* |
|
79 |
* Check sanity of file header and allocate an infile descriptor |
|
80 |
* for the file being processed. |
|
81 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
82 |
static Ifl_desc * |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
83 |
ifl_setup(const char *name, Ehdr *ehdr, Elf *elf, Word flags, Ofl_desc *ofl, |
0 | 84 |
Rej_desc *rej) |
85 |
{ |
|
86 |
Ifl_desc *ifl; |
|
87 |
Rej_desc _rej = { 0 }; |
|
88 |
||
89 |
if (ifl_verify(ehdr, ofl, &_rej) == 0) { |
|
90 |
_rej.rej_name = name; |
|
6206 | 91 |
DBG_CALL(Dbg_file_rejected(ofl->ofl_lml, &_rej, |
92 |
ld_targ.t_m.m_mach)); |
|
0 | 93 |
if (rej->rej_type == 0) { |
94 |
*rej = _rej; |
|
95 |
rej->rej_name = strdup(_rej.rej_name); |
|
96 |
} |
|
97 |
return (0); |
|
98 |
} |
|
99 |
||
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
100 |
if ((ifl = libld_calloc(1, sizeof (Ifl_desc))) == NULL) |
0 | 101 |
return ((Ifl_desc *)S_ERROR); |
102 |
ifl->ifl_name = name; |
|
103 |
ifl->ifl_ehdr = ehdr; |
|
104 |
ifl->ifl_elf = elf; |
|
105 |
ifl->ifl_flags = flags; |
|
106 |
||
107 |
/* |
|
108 |
* Is this file using 'extended Section Indexes'. If so, use the |
|
109 |
* e_shnum & e_shstrndx which can be found at: |
|
110 |
* |
|
111 |
* e_shnum == Shdr[0].sh_size |
|
112 |
* e_shstrndx == Shdr[0].sh_link |
|
113 |
*/ |
|
114 |
if ((ehdr->e_shnum == 0) && (ehdr->e_shoff != 0)) { |
|
115 |
Elf_Scn *scn; |
|
116 |
Shdr *shdr0; |
|
117 |
||
118 |
if ((scn = elf_getscn(elf, 0)) == NULL) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
119 |
eprintf(ofl->ofl_lml, ERR_ELF, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
120 |
MSG_INTL(MSG_ELF_GETSCN), name); |
0 | 121 |
ofl->ofl_flags |= FLG_OF_FATAL; |
122 |
return ((Ifl_desc *)S_ERROR); |
|
123 |
} |
|
124 |
if ((shdr0 = elf_getshdr(scn)) == NULL) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
125 |
eprintf(ofl->ofl_lml, ERR_ELF, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
126 |
MSG_INTL(MSG_ELF_GETSHDR), name); |
0 | 127 |
ofl->ofl_flags |= FLG_OF_FATAL; |
128 |
return ((Ifl_desc *)S_ERROR); |
|
129 |
} |
|
130 |
ifl->ifl_shnum = (Word)shdr0->sh_size; |
|
131 |
if (ehdr->e_shstrndx == SHN_XINDEX) |
|
132 |
ifl->ifl_shstrndx = shdr0->sh_link; |
|
133 |
else |
|
134 |
ifl->ifl_shstrndx = ehdr->e_shstrndx; |
|
135 |
} else { |
|
136 |
ifl->ifl_shnum = ehdr->e_shnum; |
|
137 |
ifl->ifl_shstrndx = ehdr->e_shstrndx; |
|
138 |
} |
|
139 |
||
140 |
if ((ifl->ifl_isdesc = libld_calloc(ifl->ifl_shnum, |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
141 |
sizeof (Is_desc *))) == NULL) |
0 | 142 |
return ((Ifl_desc *)S_ERROR); |
143 |
||
144 |
/* |
|
145 |
* Record this new input file on the shared object or relocatable |
|
146 |
* object input file list. |
|
147 |
*/ |
|
148 |
if (ifl->ifl_ehdr->e_type == ET_DYN) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
149 |
if (aplist_append(&ofl->ofl_sos, ifl, AL_CNT_OFL_LIBS) == NULL) |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
150 |
return ((Ifl_desc *)S_ERROR); |
0 | 151 |
} else { |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
152 |
if (aplist_append(&ofl->ofl_objs, ifl, AL_CNT_OFL_OBJS) == NULL) |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
153 |
return ((Ifl_desc *)S_ERROR); |
0 | 154 |
} |
155 |
||
156 |
return (ifl); |
|
157 |
} |
|
158 |
||
159 |
/* |
|
160 |
* Process a generic section. The appropriate section information is added |
|
161 |
* to the files input descriptor list. |
|
162 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
163 |
static uintptr_t |
0 | 164 |
process_section(const char *name, Ifl_desc *ifl, Shdr *shdr, Elf_Scn *scn, |
165 |
Word ndx, int ident, Ofl_desc *ofl) |
|
166 |
{ |
|
167 |
Is_desc *isp; |
|
168 |
||
169 |
/* |
|
170 |
* Create a new input section descriptor. If this is a NOBITS |
|
171 |
* section elf_getdata() will still create a data buffer (the buffer |
|
172 |
* will be null and the size will reflect the actual memory size). |
|
173 |
*/ |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
174 |
if ((isp = libld_calloc(sizeof (Is_desc), 1)) == NULL) |
0 | 175 |
return (S_ERROR); |
176 |
isp->is_shdr = shdr; |
|
177 |
isp->is_file = ifl; |
|
178 |
isp->is_name = name; |
|
179 |
isp->is_scnndx = ndx; |
|
574 | 180 |
isp->is_flags = FLG_IS_EXTERNAL; |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
181 |
isp->is_keyident = ident; |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
182 |
|
0 | 183 |
if ((isp->is_indata = elf_getdata(scn, NULL)) == NULL) { |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
184 |
eprintf(ofl->ofl_lml, ERR_ELF, MSG_INTL(MSG_ELF_GETDATA), |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
185 |
ifl->ifl_name); |
0 | 186 |
ofl->ofl_flags |= FLG_OF_FATAL; |
187 |
return (0); |
|
188 |
} |
|
189 |
||
190 |
if ((shdr->sh_flags & SHF_EXCLUDE) && |
|
191 |
((ofl->ofl_flags & FLG_OF_RELOBJ) == 0)) { |
|
192 |
isp->is_flags |= FLG_IS_DISCARD; |
|
193 |
} |
|
194 |
||
195 |
/* |
|
196 |
* Add the new input section to the files input section list and |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
197 |
* flag whether the section needs placing in an output section. This |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
198 |
* placement is deferred until all input section processing has been |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
199 |
* completed, as SHT_GROUP sections can provide information that will |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
200 |
* affect how other sections within the file should be placed. |
0 | 201 |
*/ |
202 |
ifl->ifl_isdesc[ndx] = isp; |
|
203 |
||
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
204 |
if (ident) { |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
205 |
if (shdr->sh_flags & ALL_SHF_ORDER) { |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
206 |
isp->is_flags |= FLG_IS_ORDERED; |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
207 |
ifl->ifl_flags |= FLG_IF_ORDERED; |
2647 | 208 |
} |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
209 |
isp->is_flags |= FLG_IS_PLACE; |
0 | 210 |
} |
211 |
return (1); |
|
212 |
} |
|
213 |
||
214 |
/* |
|
215 |
* Determine the software capabilities of the object being built from the |
|
216 |
* capabilities of the input relocatable objects. One software capability |
|
217 |
* is presently recognized, and represented with the following (sys/elf.h): |
|
218 |
* |
|
219 |
* SF1_SUNW_FPKNWN use/non-use of frame pointer is known, and |
|
220 |
* SF1_SUNW_FPUSED the frame pointer is in use. |
|
221 |
* |
|
222 |
* The resolution of the present fame pointer state, and the capabilities |
|
223 |
* provided by a new input relocatable object are: |
|
224 |
* |
|
225 |
* new input relocatable object |
|
226 |
* |
|
227 |
* present | SF1_SUNW_FPKNWN | SF1_SUNW_FPKNWN | <unknown> |
|
228 |
* state | SF1_SUNW_FPUSED | | |
|
229 |
* --------------------------------------------------------------------------- |
|
230 |
* SF1_SUNW_FPKNWN | SF1_SUNW_FPKNWN | SF1_SUNW_FPKNWN | SF1_SUNW_FPKNWN |
|
231 |
* SF1_SUNW_FPUSED | SF1_SUNW_FPUSED | | SF1_SUNW_FPUSED |
|
232 |
* --------------------------------------------------------------------------- |
|
233 |
* SF1_SUNW_FPKNWN | SF1_SUNW_FPKNWN | SF1_SUNW_FPKNWN | SF1_SUNW_FPKNWN |
|
234 |
* | | | |
|
235 |
* --------------------------------------------------------------------------- |
|
236 |
* <unknown> | SF1_SUNW_FPKNWN | SF1_SUNW_FPKNWN | <unknown> |
|
237 |
* | SF1_SUNW_FPUSED | | |
|
238 |
*/ |
|
239 |
static void |
|
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
240 |
sf1_cap(Ofl_desc *ofl, Xword val, Ifl_desc *ifl, Is_desc *cisp) |
0 | 241 |
{ |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
242 |
#define FP_FLAGS (SF1_SUNW_FPKNWN | SF1_SUNW_FPUSED) |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
243 |
|
0 | 244 |
Xword badval; |
245 |
||
246 |
/* |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
247 |
* If a mapfile has established definitions to override any object |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
248 |
* capabilities, ignore any new object capabilities. |
0 | 249 |
*/ |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
250 |
if (ofl->ofl_flags1 & FLG_OF1_OVSFCAP1) { |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
251 |
DBG_CALL(Dbg_cap_val_entry(ofl->ofl_lml, DBG_STATE_IGNORED, |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
252 |
CA_SUNW_SF_1, val, ld_targ.t_m.m_mach)); |
0 | 253 |
return; |
254 |
} |
|
255 |
||
7833
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
256 |
#if !defined(_ELF64) |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
257 |
if (ifl && (ifl->ifl_ehdr->e_type == ET_REL)) { |
7833
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
258 |
/* |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
259 |
* The SF1_SUNW_ADDR32 is only meaningful when building a 64-bit |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
260 |
* object. Warn the user, and remove the setting, if we're |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
261 |
* building a 32-bit object. |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
262 |
*/ |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
263 |
if (val & SF1_SUNW_ADDR32) { |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
264 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
265 |
MSG_INTL(MSG_FIL_INADDR32SF1), ifl->ifl_name, |
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
266 |
EC_WORD(cisp->is_scnndx), cisp->is_name); |
7833
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
267 |
val &= ~SF1_SUNW_ADDR32; |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
268 |
} |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
269 |
} |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
270 |
#endif |
0 | 271 |
/* |
272 |
* If this object doesn't specify any capabilities, ignore it, and |
|
273 |
* leave the state as is. |
|
274 |
*/ |
|
275 |
if (val == 0) |
|
276 |
return; |
|
277 |
||
278 |
/* |
|
279 |
* Make sure we only accept known software capabilities. Note, that |
|
280 |
* an F1_SUNW_FPUSED by itself is viewed as bad practice. |
|
281 |
*/ |
|
282 |
if ((badval = (val & ~SF1_SUNW_MASK)) != 0) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
283 |
eprintf(ofl->ofl_lml, ERR_WARNING, MSG_INTL(MSG_FIL_BADSF1), |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
284 |
ifl->ifl_name, EC_WORD(cisp->is_scnndx), cisp->is_name, |
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
285 |
EC_XWORD(badval)); |
0 | 286 |
val &= SF1_SUNW_MASK; |
287 |
} |
|
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
288 |
if ((val & FP_FLAGS) == SF1_SUNW_FPUSED) { |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
289 |
eprintf(ofl->ofl_lml, ERR_WARNING, MSG_INTL(MSG_FIL_BADSF1), |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
290 |
ifl->ifl_name, EC_WORD(cisp->is_scnndx), cisp->is_name, |
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
291 |
EC_XWORD(val)); |
0 | 292 |
return; |
293 |
} |
|
294 |
||
7833
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
295 |
/* |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
296 |
* If the input file is not a relocatable object, then we're only here |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
297 |
* to warn the user of any questionable capabilities. |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
298 |
*/ |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
299 |
if (ifl->ifl_ehdr->e_type != ET_REL) { |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
300 |
#if defined(_ELF64) |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
301 |
/* |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
302 |
* If we're building a 64-bit executable, and we come across a |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
303 |
* dependency that requires a restricted address space, then |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
304 |
* that dependencies requirement can only be satisfied if the |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
305 |
* executable triggers the restricted address space. This is a |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
306 |
* warning rather than a fatal error, as the possibility exists |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
307 |
* that an appropriate dependency will be provided at runtime. |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
308 |
* The runtime linker will refuse to use this dependency. |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
309 |
*/ |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
310 |
if ((val & SF1_SUNW_ADDR32) && (ofl->ofl_flags & FLG_OF_EXEC) && |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
311 |
((ofl->ofl_ocapset.oc_sf_1.cm_val & |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
312 |
SF1_SUNW_ADDR32) == 0)) { |
7833
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
313 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
314 |
MSG_INTL(MSG_FIL_EXADDR32SF1), ifl->ifl_name, |
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
315 |
EC_WORD(cisp->is_scnndx), cisp->is_name); |
7833
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
316 |
} |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
317 |
#endif |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
318 |
return; |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
319 |
} |
60e027e61b69
6754965 introduce the SF1_SUNW_ADDR32 bit in software capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
7463
diff
changeset
|
320 |
|
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
321 |
if (DBG_ENABLED) { |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
322 |
Dbg_cap_val_entry(ofl->ofl_lml, DBG_STATE_CURRENT, CA_SUNW_SF_1, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
323 |
ofl->ofl_ocapset.oc_sf_1.cm_val, ld_targ.t_m.m_mach); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
324 |
Dbg_cap_val_entry(ofl->ofl_lml, DBG_STATE_NEW, CA_SUNW_SF_1, |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
325 |
val, ld_targ.t_m.m_mach); |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
326 |
} |
0 | 327 |
|
328 |
/* |
|
329 |
* Determine the resolution of the present frame pointer and the |
|
330 |
* new input relocatable objects frame pointer. |
|
331 |
*/ |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
332 |
if ((ofl->ofl_ocapset.oc_sf_1.cm_val & FP_FLAGS) == FP_FLAGS) { |
0 | 333 |
/* |
334 |
* If the new relocatable object isn't using a frame pointer, |
|
335 |
* reduce the present state to unused. |
|
336 |
*/ |
|
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
337 |
if ((val & FP_FLAGS) != FP_FLAGS) |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
338 |
ofl->ofl_ocapset.oc_sf_1.cm_val &= ~SF1_SUNW_FPUSED; |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
339 |
|
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
340 |
/* |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
341 |
* Having processed the frame pointer bits, remove them from |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
342 |
* the value so they don't get OR'd in below. |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
343 |
*/ |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
344 |
val &= ~FP_FLAGS; |
0 | 345 |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
346 |
} else if ((ofl->ofl_ocapset.oc_sf_1.cm_val & SF1_SUNW_FPKNWN) == 0) { |
0 | 347 |
/* |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
348 |
* If the present frame pointer state is unknown, mask it out |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
349 |
* and allow the values from the new relocatable object |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
350 |
* to overwrite them. |
0 | 351 |
*/ |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
352 |
ofl->ofl_ocapset.oc_sf_1.cm_val &= ~FP_FLAGS; |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
353 |
} else { |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
354 |
/* Do not take the frame pointer flags from the object */ |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
355 |
val &= ~FP_FLAGS; |
0 | 356 |
} |
357 |
||
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
358 |
ofl->ofl_ocapset.oc_sf_1.cm_val |= val; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
359 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
360 |
DBG_CALL(Dbg_cap_val_entry(ofl->ofl_lml, DBG_STATE_RESOLVED, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
361 |
CA_SUNW_SF_1, ofl->ofl_ocapset.oc_sf_1.cm_val, ld_targ.t_m.m_mach)); |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
362 |
|
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
363 |
#undef FP_FLAGS |
0 | 364 |
} |
365 |
||
366 |
/* |
|
367 |
* Determine the hardware capabilities of the object being built from the |
|
368 |
* capabilities of the input relocatable objects. There's really little to |
|
369 |
* do here, other than to offer diagnostics, hardware capabilities are simply |
|
370 |
* additive. |
|
371 |
*/ |
|
372 |
static void |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
373 |
hw_cap(Ofl_desc *ofl, Xword tag, Xword val) |
0 | 374 |
{ |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
375 |
elfcap_mask_t *hwcap; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
376 |
ofl_flag_t flags1; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
377 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
378 |
if (tag == CA_SUNW_HW_1) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
379 |
hwcap = &ofl->ofl_ocapset.oc_hw_1.cm_val; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
380 |
flags1 = FLG_OF1_OVHWCAP1; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
381 |
} else { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
382 |
hwcap = &ofl->ofl_ocapset.oc_hw_2.cm_val; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
383 |
flags1 = FLG_OF1_OVHWCAP2; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
384 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
385 |
|
0 | 386 |
/* |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
387 |
* If a mapfile has established definitions to override any object |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
388 |
* capabilities, ignore any new object capabilities. |
0 | 389 |
*/ |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
390 |
if (ofl->ofl_flags1 & flags1) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
391 |
DBG_CALL(Dbg_cap_val_entry(ofl->ofl_lml, DBG_STATE_IGNORED, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
392 |
tag, val, ld_targ.t_m.m_mach)); |
0 | 393 |
return; |
394 |
} |
|
395 |
||
396 |
/* |
|
397 |
* If this object doesn't specify any capabilities, ignore it, and |
|
398 |
* leave the state as is. |
|
399 |
*/ |
|
400 |
if (val == 0) |
|
401 |
return; |
|
402 |
||
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
403 |
if (DBG_ENABLED) { |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
404 |
Dbg_cap_val_entry(ofl->ofl_lml, DBG_STATE_CURRENT, CA_SUNW_HW_1, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
405 |
ofl->ofl_ocapset.oc_hw_1.cm_val, ld_targ.t_m.m_mach); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
406 |
Dbg_cap_val_entry(ofl->ofl_lml, DBG_STATE_NEW, CA_SUNW_HW_1, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
407 |
val, ld_targ.t_m.m_mach); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
408 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
409 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
410 |
*hwcap |= val; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
411 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
412 |
DBG_CALL(Dbg_cap_val_entry(ofl->ofl_lml, DBG_STATE_RESOLVED, tag, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
413 |
*hwcap, ld_targ.t_m.m_mach)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
414 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
415 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
416 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
417 |
* Promote a machine capability or platform capability to the output file. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
418 |
* Multiple instances of these names can be defined. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
419 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
420 |
static void |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
421 |
str_cap(Ofl_desc *ofl, char *pstr, ofl_flag_t flags, Xword tag, Caplist *list) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
422 |
{ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
423 |
Capstr *capstr; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
424 |
Aliste idx; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
425 |
Boolean found = FALSE; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
426 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
427 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
428 |
* If a mapfile has established definitions to override this capability, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
429 |
* ignore any new capability. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
430 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
431 |
if (ofl->ofl_flags1 & flags) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
432 |
DBG_CALL(Dbg_cap_ptr_entry(ofl->ofl_lml, DBG_STATE_IGNORED, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
433 |
tag, pstr)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
434 |
return; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
435 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
436 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
437 |
for (ALIST_TRAVERSE(list->cl_val, idx, capstr)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
438 |
DBG_CALL(Dbg_cap_ptr_entry(ofl->ofl_lml, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
439 |
DBG_STATE_CURRENT, tag, capstr->cs_str)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
440 |
if (strcmp(capstr->cs_str, pstr) == 0) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
441 |
found = TRUE; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
442 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
443 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
444 |
DBG_CALL(Dbg_cap_ptr_entry(ofl->ofl_lml, DBG_STATE_NEW, tag, pstr)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
445 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
446 |
if (found == FALSE) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
447 |
if ((capstr = alist_append(&list->cl_val, NULL, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
448 |
sizeof (Capstr), AL_CNT_CAP_NAMES)) == NULL) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
449 |
ofl->ofl_flags |= FLG_OF_FATAL; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
450 |
return; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
451 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
452 |
capstr->cs_str = pstr; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
453 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
454 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
455 |
if (DBG_ENABLED) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
456 |
for (ALIST_TRAVERSE(list->cl_val, idx, capstr)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
457 |
DBG_CALL(Dbg_cap_ptr_entry(ofl->ofl_lml, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
458 |
DBG_STATE_RESOLVED, tag, capstr->cs_str)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
459 |
} |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
460 |
} |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
461 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
462 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
463 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
464 |
* Promote a capability identifier to the output file. A capability group can |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
465 |
* only have one identifier, and thus only the first identifier seen from any |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
466 |
* input relocatable objects is retained. An explicit user defined identifier, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
467 |
* rather than an an identifier fabricated by ld(1) with -z symbcap processing, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
468 |
* takes precedence. Note, a user may have defined an identifier via a mapfile, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
469 |
* in which case the mapfile identifier is retained. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
470 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
471 |
static void |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
472 |
id_cap(Ofl_desc *ofl, char *pstr, oc_flag_t flags) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
473 |
{ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
474 |
Objcapset *ocapset = &ofl->ofl_ocapset; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
475 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
476 |
if (ocapset->oc_id.cs_str) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
477 |
DBG_CALL(Dbg_cap_ptr_entry(ofl->ofl_lml, DBG_STATE_CURRENT, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
478 |
CA_SUNW_ID, ocapset->oc_id.cs_str)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
479 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
480 |
if ((ocapset->oc_flags & FLG_OCS_USRDEFID) || |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
481 |
((flags & FLG_OCS_USRDEFID) == 0)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
482 |
DBG_CALL(Dbg_cap_ptr_entry(ofl->ofl_lml, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
483 |
DBG_STATE_IGNORED, CA_SUNW_ID, pstr)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
484 |
return; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
485 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
486 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
487 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
488 |
DBG_CALL(Dbg_cap_ptr_entry(ofl->ofl_lml, DBG_STATE_NEW, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
489 |
CA_SUNW_ID, pstr)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
490 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
491 |
ocapset->oc_id.cs_str = pstr; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
492 |
ocapset->oc_flags |= flags; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
493 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
494 |
DBG_CALL(Dbg_cap_ptr_entry(ofl->ofl_lml, DBG_STATE_RESOLVED, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
495 |
CA_SUNW_ID, pstr)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
496 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
497 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
498 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
499 |
* Promote a capabilities group to the object capabilities. This catches a |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
500 |
* corner case. An object capabilities file can be converted to symbol |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
501 |
* capabilities with -z symbolcap. However, if the user has indicated that all |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
502 |
* the symbols should be demoted, we'd be left with a symbol capabilities file, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
503 |
* with no associated symbols. Catch this case by promoting the symbol |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
504 |
* capabilities back to object capabilities. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
505 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
506 |
void |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
507 |
ld_cap_move_symtoobj(Ofl_desc *ofl) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
508 |
{ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
509 |
Cap_group *cgp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
510 |
Aliste idx1; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
511 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
512 |
for (APLIST_TRAVERSE(ofl->ofl_capgroups, idx1, cgp)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
513 |
Objcapset *scapset = &cgp->cg_set; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
514 |
Capstr *capstr; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
515 |
Aliste idx2; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
516 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
517 |
if (scapset->oc_id.cs_str) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
518 |
if (scapset->oc_flags & FLG_OCS_USRDEFID) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
519 |
id_cap(ofl, scapset->oc_id.cs_str, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
520 |
scapset->oc_flags); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
521 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
522 |
if (scapset->oc_plat.cl_val) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
523 |
for (ALIST_TRAVERSE(scapset->oc_plat.cl_val, idx2, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
524 |
capstr)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
525 |
str_cap(ofl, capstr->cs_str, FLG_OF1_OVPLATCAP, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
526 |
CA_SUNW_PLAT, &ofl->ofl_ocapset.oc_plat); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
527 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
528 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
529 |
if (scapset->oc_mach.cl_val) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
530 |
for (ALIST_TRAVERSE(scapset->oc_mach.cl_val, idx2, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
531 |
capstr)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
532 |
str_cap(ofl, capstr->cs_str, FLG_OF1_OVMACHCAP, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
533 |
CA_SUNW_MACH, &ofl->ofl_ocapset.oc_mach); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
534 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
535 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
536 |
if (scapset->oc_hw_2.cm_val) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
537 |
hw_cap(ofl, CA_SUNW_HW_2, scapset->oc_hw_2.cm_val); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
538 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
539 |
if (scapset->oc_hw_1.cm_val) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
540 |
hw_cap(ofl, CA_SUNW_HW_1, scapset->oc_hw_1.cm_val); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
541 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
542 |
if (scapset->oc_sf_1.cm_val) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
543 |
sf1_cap(ofl, scapset->oc_sf_1.cm_val, NULL, NULL); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
544 |
} |
0 | 545 |
} |
546 |
||
547 |
/* |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
548 |
* Determine whether a capabilities group already exists that describes this |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
549 |
* new capabilities group. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
550 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
551 |
* Note, a capability group identifier, CA_SUNW_ID, isn't used as part of the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
552 |
* comparison. This attribute simply assigns a diagnostic name to the group, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
553 |
* and in the case of multiple identifiers, the first will be taken. |
0 | 554 |
*/ |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
555 |
static Cap_group * |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
556 |
get_cap_group(Objcapset *ocapset, Word cnum, Ofl_desc *ofl, Is_desc *isp) |
0 | 557 |
{ |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
558 |
Aliste idx; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
559 |
Cap_group *cgp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
560 |
Word ccnum = cnum; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
561 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
562 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
563 |
* If the new capabilities contains a CA_SUNW_ID, drop the count of the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
564 |
* number of comparable items. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
565 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
566 |
if (ocapset->oc_id.cs_str) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
567 |
ccnum--; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
568 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
569 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
570 |
* Traverse the existing symbols capabilities groups. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
571 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
572 |
for (APLIST_TRAVERSE(ofl->ofl_capgroups, idx, cgp)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
573 |
Word onum = cgp->cg_num; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
574 |
Alist *calp, *oalp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
575 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
576 |
if (cgp->cg_set.oc_id.cs_str) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
577 |
onum--; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
578 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
579 |
if (onum != ccnum) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
580 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
581 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
582 |
if (cgp->cg_set.oc_hw_1.cm_val != ocapset->oc_hw_1.cm_val) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
583 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
584 |
if (cgp->cg_set.oc_sf_1.cm_val != ocapset->oc_sf_1.cm_val) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
585 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
586 |
if (cgp->cg_set.oc_hw_2.cm_val != ocapset->oc_hw_2.cm_val) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
587 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
588 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
589 |
calp = cgp->cg_set.oc_plat.cl_val; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
590 |
oalp = ocapset->oc_plat.cl_val; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
591 |
if ((calp == NULL) && oalp) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
592 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
593 |
if (calp && ((oalp == NULL) || cap_names_match(calp, oalp))) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
594 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
595 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
596 |
calp = cgp->cg_set.oc_mach.cl_val; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
597 |
oalp = ocapset->oc_mach.cl_val; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
598 |
if ((calp == NULL) && oalp) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
599 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
600 |
if (calp && ((oalp == NULL) || cap_names_match(calp, oalp))) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
601 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
602 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
603 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
604 |
* If a matching group is found, then this new group has |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
605 |
* already been supplied by a previous file, and hence the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
606 |
* existing group can be used. Record this new input section, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
607 |
* from which we can also derive the input file name, on the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
608 |
* existing groups input sections. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
609 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
610 |
if (aplist_append(&(cgp->cg_secs), isp, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
611 |
AL_CNT_CAP_SECS) == NULL) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
612 |
return (NULL); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
613 |
return (cgp); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
614 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
615 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
616 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
617 |
* If a capabilities group is not found, create a new one. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
618 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
619 |
if (((cgp = libld_calloc(sizeof (Cap_group), 1)) == NULL) || |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
620 |
(aplist_append(&(ofl->ofl_capgroups), cgp, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
621 |
AL_CNT_CAP_DESCS) == NULL)) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
622 |
return (NULL); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
623 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
624 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
625 |
* If we're converting object capabilities to symbol capabilities and |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
626 |
* no CA_SUNW_ID is defined, fabricate one. This identifier is appended |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
627 |
* to all symbol names that are converted into capabilities symbols, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
628 |
* see ld_sym_process(). |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
629 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
630 |
if ((isp->is_file->ifl_flags & FLG_IF_OTOSCAP) && |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
631 |
(ocapset->oc_id.cs_str == NULL)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
632 |
size_t len; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
633 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
634 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
635 |
* Create an identifier using the group number together with a |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
636 |
* default template. We allocate a buffer large enough for any |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
637 |
* possible number of items (way more than we need). |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
638 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
639 |
len = MSG_STR_CAPGROUPID_SIZE + CONV_INV_BUFSIZE; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
640 |
if ((ocapset->oc_id.cs_str = libld_malloc(len)) == NULL) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
641 |
return (NULL); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
642 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
643 |
(void) snprintf(ocapset->oc_id.cs_str, len, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
644 |
MSG_ORIG(MSG_STR_CAPGROUPID), |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
645 |
aplist_nitems(ofl->ofl_capgroups)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
646 |
cnum++; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
647 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
648 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
649 |
cgp->cg_set = *ocapset; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
650 |
cgp->cg_num = cnum; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
651 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
652 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
653 |
* Null the callers alist's as they've effectively been transferred |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
654 |
* to this new Cap_group. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
655 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
656 |
ocapset->oc_plat.cl_val = ocapset->oc_mach.cl_val = NULL; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
657 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
658 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
659 |
* Keep track of which input section, and hence input file, established |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
660 |
* this group. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
661 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
662 |
if (aplist_append(&(cgp->cg_secs), isp, AL_CNT_CAP_SECS) == NULL) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
663 |
return (NULL); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
664 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
665 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
666 |
* Keep track of the number of symbol capabilities entries that will be |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
667 |
* required in the output file. Each group requires a terminating |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
668 |
* CA_SUNW_NULL. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
669 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
670 |
ofl->ofl_capsymcnt += (cnum + 1); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
671 |
return (cgp); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
672 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
673 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
674 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
675 |
* Capture symbol capability family information. This data structure is focal |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
676 |
* in maintaining all symbol capability relationships, and provides for the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
677 |
* eventual creation of a capabilities information section, and possibly a |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
678 |
* capabilities chain section. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
679 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
680 |
* Capabilities families are lead by a CAPINFO_SUNW_GLOB symbol. This symbol |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
681 |
* provides the visible global symbol that is referenced by all external |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
682 |
* callers. This symbol may have aliases. For example, a weak/global symbol |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
683 |
* pair, such as memcpy()/_memcpy() may lead the same capabilities family. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
684 |
* Each family contains one or more local symbol members. These members provide |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
685 |
* the capabilities specific functions, and are associated to a capabilities |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
686 |
* group. For example, the capability members memcpy%sun4u and memcpy%sun4v |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
687 |
* might be associated with the memcpy() capability family. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
688 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
689 |
* This routine is called when a relocatable object that provides object |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
690 |
* capabilities is transformed into a symbol capabilities object, using the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
691 |
* -z symbolcap option. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
692 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
693 |
* This routine is also called to collect the SUNW_capinfo section information |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
694 |
* of a relocatable object that contains symbol capability definitions. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
695 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
696 |
uintptr_t |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
697 |
ld_cap_add_family(Ofl_desc *ofl, Sym_desc *lsdp, Sym_desc *csdp, Cap_group *cgp, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
698 |
APlist **csyms) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
699 |
{ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
700 |
Cap_avlnode qcav, *cav; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
701 |
avl_tree_t *avlt; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
702 |
avl_index_t where = 0; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
703 |
Cap_sym *mcsp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
704 |
Aliste idx; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
705 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
706 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
707 |
* Make sure the capability families have an initialized AVL tree. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
708 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
709 |
if ((avlt = ofl->ofl_capfamilies) == NULL) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
710 |
if ((avlt = libld_calloc(sizeof (avl_tree_t), 1)) == NULL) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
711 |
return (S_ERROR); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
712 |
avl_create(avlt, &ld_sym_avl_comp, sizeof (Cap_avlnode), |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
713 |
SGSOFFSETOF(Cap_avlnode, cn_symavlnode.sav_node)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
714 |
ofl->ofl_capfamilies = avlt; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
715 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
716 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
717 |
* When creating a dynamic object, capability family members |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
718 |
* are maintained in a .SUNW_capchain, the first entry of |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
719 |
* which is the version number of the chain. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
720 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
721 |
ofl->ofl_capchaincnt = 1; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
722 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
723 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
724 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
725 |
* Determine whether a family already exists, and if not, create one |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
726 |
* using the lead family symbol. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
727 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
728 |
qcav.cn_symavlnode.sav_hash = (Word)elf_hash(lsdp->sd_name); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
729 |
qcav.cn_symavlnode.sav_name = lsdp->sd_name; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
730 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
731 |
if ((cav = avl_find(avlt, &qcav, &where)) == NULL) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
732 |
if ((cav = libld_calloc(sizeof (Cap_avlnode), 1)) == NULL) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
733 |
return (S_ERROR); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
734 |
cav->cn_symavlnode.sav_hash = qcav.cn_symavlnode.sav_hash; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
735 |
cav->cn_symavlnode.sav_name = qcav.cn_symavlnode.sav_name; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
736 |
cav->cn_symavlnode.sav_sdp = lsdp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
737 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
738 |
avl_insert(avlt, cav, where); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
739 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
740 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
741 |
* When creating a dynamic object, capability family members |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
742 |
* are maintained in a .SUNW_capchain, each family starts with |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
743 |
* this lead symbol, and is terminated with a 0 element. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
744 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
745 |
ofl->ofl_capchaincnt += 2; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
746 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
747 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
748 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
749 |
* If no group information is provided then this request is to add a |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
750 |
* lead capability symbol, or lead symbol alias. If this is the lead |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
751 |
* symbol there's nothing more to do. Otherwise save the alias. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
752 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
753 |
if (cgp == NULL) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
754 |
if ((lsdp != csdp) && (aplist_append(&cav->cn_aliases, csdp, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
755 |
AL_CNT_CAP_ALIASES) == NULL)) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
756 |
return (S_ERROR); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
757 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
758 |
return (0); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
759 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
760 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
761 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
762 |
* Determine whether a member of the same group as this new member is |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
763 |
* already defined within this family. If so, we have a multiply |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
764 |
* defined symbol. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
765 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
766 |
for (APLIST_TRAVERSE(cav->cn_members, idx, mcsp)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
767 |
Sym_desc *msdp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
768 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
769 |
if (cgp != mcsp->cs_group) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
770 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
771 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
772 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
773 |
* Diagnose that a multiple symbol definition exists. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
774 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
775 |
msdp = mcsp->cs_sdp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
776 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
777 |
eprintf(ofl->ofl_lml, ERR_FATAL, MSG_INTL(MSG_CAP_MULDEF), |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
778 |
demangle(lsdp->sd_name)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
779 |
eprintf(ofl->ofl_lml, ERR_NONE, MSG_INTL(MSG_CAP_MULDEFSYMS), |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
780 |
msdp->sd_file->ifl_name, msdp->sd_name, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
781 |
csdp->sd_file->ifl_name, csdp->sd_name); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
782 |
ofl->ofl_flags |= FLG_OF_FATAL; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
783 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
784 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
785 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
786 |
* Add this capabilities symbol member to the family. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
787 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
788 |
if (((mcsp = libld_malloc(sizeof (Cap_sym))) == NULL) || |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
789 |
(aplist_append(&cav->cn_members, mcsp, AL_CNT_CAP_MEMS) == NULL)) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
790 |
return (S_ERROR); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
791 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
792 |
mcsp->cs_sdp = csdp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
793 |
mcsp->cs_group = cgp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
794 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
795 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
796 |
* When creating a dynamic object, capability family members are |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
797 |
* maintained in a .SUNW_capchain. Account for this family member. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
798 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
799 |
ofl->ofl_capchaincnt++; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
800 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
801 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
802 |
* If this input file is undergoing object capabilities to symbol |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
803 |
* capabilities conversion, then this member is a new local symbol |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
804 |
* that has been generated from an original global symbol. Keep track |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
805 |
* of this symbol so that the output file symbol table can be populated |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
806 |
* with these new symbol entries. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
807 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
808 |
if (csyms && (aplist_append(csyms, mcsp, AL_CNT_CAP_SYMS) == NULL)) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
809 |
return (S_ERROR); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
810 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
811 |
return (0); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
812 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
813 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
814 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
815 |
* Process a SHT_SUNW_cap capabilities section. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
816 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
817 |
static uintptr_t |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
818 |
process_cap(Ofl_desc *ofl, Ifl_desc *ifl, Is_desc *cisp) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
819 |
{ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
820 |
Objcapset ocapset = { 0 }; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
821 |
Cap_desc *cdp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
822 |
Cap *data, *cdata; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
823 |
char *strs; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
824 |
Word ndx, cnum; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
825 |
int objcapndx, descapndx, symcapndx; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
826 |
int nulls, capstrs = 0; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
827 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
828 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
829 |
* Determine the capabilities data and size. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
830 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
831 |
cdata = (Cap *)cisp->is_indata->d_buf; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
832 |
cnum = (Word)(cisp->is_shdr->sh_size / cisp->is_shdr->sh_entsize); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
833 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
834 |
if ((cdata == NULL) || (cnum == 0)) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
835 |
return (0); |
0 | 836 |
|
8501
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
7983
diff
changeset
|
837 |
DBG_CALL(Dbg_cap_sec_title(ofl->ofl_lml, ifl->ifl_name)); |
0 | 838 |
|
3617
4b744d361365
6521504 ld: hardware capabilities processing from relocatables objects needs hardening.
rie
parents:
2978
diff
changeset
|
839 |
/* |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
840 |
* Traverse the section to determine what capabilities groups are |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
841 |
* available. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
842 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
843 |
* A capabilities section can contain one or more, CA_SUNW_NULL |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
844 |
* terminated groups. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
845 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
846 |
* - The first group defines the object capabilities. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
847 |
* - Additional groups define symbol capabilities. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
848 |
* - Since the initial group is always reserved for object |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
849 |
* capabilities, any object with symbol capabilities must also |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
850 |
* have an object capabilities group. If the object has no object |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
851 |
* capabilities, an empty object group is defined, consisting of a |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
852 |
* CA_SUNW_NULL element in index [0]. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
853 |
* - If any capabilities require references to a named string, then |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
854 |
* the section header sh_info points to the associated string |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
855 |
* table. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
856 |
* - If an object contains symbol capability groups, then the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
857 |
* section header sh_link points to the associated capinfo table. |
3617
4b744d361365
6521504 ld: hardware capabilities processing from relocatables objects needs hardening.
rie
parents:
2978
diff
changeset
|
858 |
*/ |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
859 |
objcapndx = 0; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
860 |
descapndx = symcapndx = -1; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
861 |
nulls = 0; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
862 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
863 |
for (ndx = 0, data = cdata; ndx < cnum; ndx++, data++) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
864 |
switch (data->c_tag) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
865 |
case CA_SUNW_NULL: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
866 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
867 |
* If this is the first CA_SUNW_NULL entry, and no |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
868 |
* capabilities group has been found, then this object |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
869 |
* does not define any object capabilities. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
870 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
871 |
if (nulls++ == 0) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
872 |
if (ndx == 0) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
873 |
objcapndx = -1; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
874 |
} else if ((symcapndx == -1) && (descapndx != -1)) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
875 |
symcapndx = descapndx; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
876 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
877 |
break; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
878 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
879 |
case CA_SUNW_PLAT: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
880 |
case CA_SUNW_MACH: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
881 |
case CA_SUNW_ID: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
882 |
capstrs++; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
883 |
/* FALLTHROUGH */ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
884 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
885 |
case CA_SUNW_HW_1: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
886 |
case CA_SUNW_SF_1: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
887 |
case CA_SUNW_HW_2: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
888 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
889 |
* If this is the start of a new group, save it. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
890 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
891 |
if (descapndx == -1) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
892 |
descapndx = ndx; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
893 |
break; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
894 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
895 |
default: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
896 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
897 |
MSG_INTL(MSG_FIL_UNKCAP), ifl->ifl_name, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
898 |
EC_WORD(cisp->is_scnndx), cisp->is_name, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
899 |
data->c_tag); |
0 | 900 |
} |
901 |
} |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
902 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
903 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
904 |
* If a string capabilities entry has been found, the capabilities |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
905 |
* section must reference the associated string table. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
906 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
907 |
if (capstrs) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
908 |
Word info = cisp->is_shdr->sh_info; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
909 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
910 |
if ((info == 0) || (info > ifl->ifl_shnum)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
911 |
eprintf(ofl->ofl_lml, ERR_FATAL, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
912 |
MSG_INTL(MSG_FIL_INVSHINFO), ifl->ifl_name, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
913 |
EC_WORD(cisp->is_scnndx), cisp->is_name, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
914 |
EC_XWORD(info)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
915 |
ofl->ofl_flags |= FLG_OF_FATAL; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
916 |
return (S_ERROR); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
917 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
918 |
strs = (char *)ifl->ifl_isdesc[info]->is_indata->d_buf; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
919 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
920 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
921 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
922 |
* The processing of capabilities groups is as follows: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
923 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
924 |
* - if a relocatable object provides only object capabilities, and |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
925 |
* the -z symbolcap option is in effect, then the object |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
926 |
* capabilities are transformed into symbol capabilities and the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
927 |
* symbol capabilities are carried over to the output file. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
928 |
* - in all other cases, any capabilities present in an input |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
929 |
* relocatable object are carried from the input object to the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
930 |
* output without any transformation or conversion. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
931 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
932 |
* Capture any object capabilities that are to be carried over to the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
933 |
* output file. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
934 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
935 |
if ((objcapndx == 0) && |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
936 |
((symcapndx != -1) || ((ofl->ofl_flags & FLG_OF_OTOSCAP) == 0))) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
937 |
for (ndx = 0, data = cdata; ndx < cnum; ndx++, data++) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
938 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
939 |
* Object capabilities end at the first null. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
940 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
941 |
if (data->c_tag == CA_SUNW_NULL) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
942 |
break; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
943 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
944 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
945 |
* Only the object software capabilities that are |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
946 |
* defined in a relocatable object become part of the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
947 |
* object software capabilities in the output file. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
948 |
* However, check the validity of any object software |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
949 |
* capabilities of any dependencies. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
950 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
951 |
if (data->c_tag == CA_SUNW_SF_1) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
952 |
sf1_cap(ofl, data->c_un.c_val, ifl, cisp); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
953 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
954 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
955 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
956 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
957 |
* The remaining capability types must come from a |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
958 |
* relocatable object in order to contribute to the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
959 |
* output. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
960 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
961 |
if (ifl->ifl_ehdr->e_type != ET_REL) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
962 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
963 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
964 |
switch (data->c_tag) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
965 |
case CA_SUNW_HW_1: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
966 |
case CA_SUNW_HW_2: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
967 |
hw_cap(ofl, data->c_tag, data->c_un.c_val); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
968 |
break; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
969 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
970 |
case CA_SUNW_PLAT: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
971 |
str_cap(ofl, strs + data->c_un.c_ptr, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
972 |
FLG_OF1_OVPLATCAP, CA_SUNW_PLAT, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
973 |
&ofl->ofl_ocapset.oc_plat); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
974 |
break; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
975 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
976 |
case CA_SUNW_MACH: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
977 |
str_cap(ofl, strs + data->c_un.c_ptr, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
978 |
FLG_OF1_OVMACHCAP, CA_SUNW_MACH, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
979 |
&ofl->ofl_ocapset.oc_mach); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
980 |
break; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
981 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
982 |
case CA_SUNW_ID: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
983 |
id_cap(ofl, strs + data->c_un.c_ptr, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
984 |
FLG_OCS_USRDEFID); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
985 |
break; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
986 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
987 |
default: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
988 |
assert(0); /* Unknown capability type */ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
989 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
990 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
991 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
992 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
993 |
* If there are no symbol capabilities, or this objects |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
994 |
* capabilities aren't being transformed into a symbol |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
995 |
* capabilities, then we're done. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
996 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
997 |
if ((symcapndx == -1) && |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
998 |
((ofl->ofl_flags & FLG_OF_OTOSCAP) == 0)) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
999 |
return (1); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1000 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1001 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1002 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1003 |
* If these capabilities don't originate from a relocatable object |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1004 |
* there's no further processing required. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1005 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1006 |
if (ifl->ifl_ehdr->e_type != ET_REL) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1007 |
return (1); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1008 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1009 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1010 |
* If this object only defines an object capabilities group, and the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1011 |
* -z symbolcap option is in effect, then all global function symbols |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1012 |
* and initialized global data symbols are renamed and assigned to the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1013 |
* transformed symbol capabilities group. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1014 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1015 |
if ((objcapndx == 0) && |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1016 |
(symcapndx == -1) && (ofl->ofl_flags & FLG_OF_OTOSCAP)) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1017 |
ifl->ifl_flags |= FLG_IF_OTOSCAP; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1018 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1019 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1020 |
* Allocate a capabilities descriptor to collect the capabilities data |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1021 |
* for this input file. Allocate a mirror of the raw capabilities data |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1022 |
* that points to the individual symbol capabilities groups. An APlist |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1023 |
* is used, although it will be sparsely populated, as the list provides |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1024 |
* a convenient mechanism for traversal later. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1025 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1026 |
if (((cdp = libld_calloc(sizeof (Cap_desc), 1)) == NULL) || |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1027 |
(aplist_append(&(cdp->ca_groups), NULL, cnum) == NULL)) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1028 |
return (S_ERROR); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1029 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1030 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1031 |
* Clear the allocated APlist data array, and assign the number of |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1032 |
* items as the total number of array items. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1033 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1034 |
(void) memset(&cdp->ca_groups->apl_data[0], 0, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1035 |
(cnum * sizeof (void *))); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1036 |
cdp->ca_groups->apl_nitems = cnum; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1037 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1038 |
ifl->ifl_caps = cdp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1039 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1040 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1041 |
* Traverse the capabilities data, unpacking the data into a |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1042 |
* capabilities set. Process each capabilities set as a unique group. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1043 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1044 |
descapndx = -1; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1045 |
nulls = 0; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1046 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1047 |
for (ndx = 0, data = cdata; ndx < cnum; ndx++, data++) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1048 |
Capstr *capstr; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1049 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1050 |
switch (data->c_tag) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1051 |
case CA_SUNW_NULL: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1052 |
nulls++; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1053 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1054 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1055 |
* Process the capabilities group that this null entry |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1056 |
* terminates. The capabilities group that is returned |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1057 |
* will either point to this file's data, or to a |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1058 |
* matching capabilities group that has already been |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1059 |
* processed. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1060 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1061 |
* Note, if this object defines object capabilities, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1062 |
* the first group descriptor points to these object |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1063 |
* capabilities. It is only necessary to save this |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1064 |
* descriptor when object capabilities are being |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1065 |
* transformed into symbol capabilities (-z symbolcap). |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1066 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1067 |
if (descapndx != -1) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1068 |
if ((nulls > 1) || |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1069 |
(ifl->ifl_flags & FLG_IF_OTOSCAP)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1070 |
APlist *alp = cdp->ca_groups; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1071 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1072 |
if ((alp->apl_data[descapndx] = |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1073 |
get_cap_group(&ocapset, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1074 |
(ndx - descapndx), ofl, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1075 |
cisp)) == NULL) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1076 |
return (S_ERROR); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1077 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1078 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1079 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1080 |
* Clean up the capabilities data in preparation |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1081 |
* for processing additional groups. If the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1082 |
* collected capabilities strings were used to |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1083 |
* establish a new output group, they will have |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1084 |
* been saved in get_cap_group(). If these |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1085 |
* descriptors still exist, then an existing |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1086 |
* descriptor has been used to associate with |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1087 |
* this file, and these string descriptors can |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1088 |
* be freed. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1089 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1090 |
ocapset.oc_hw_1.cm_val = |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1091 |
ocapset.oc_sf_1.cm_val = |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1092 |
ocapset.oc_hw_2.cm_val = 0; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1093 |
if (ocapset.oc_plat.cl_val) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1094 |
free((void *)ocapset.oc_plat.cl_val); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1095 |
ocapset.oc_plat.cl_val = NULL; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1096 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1097 |
if (ocapset.oc_mach.cl_val) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1098 |
free((void *)ocapset.oc_mach.cl_val); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1099 |
ocapset.oc_mach.cl_val = NULL; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1100 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1101 |
descapndx = -1; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1102 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1103 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1104 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1105 |
case CA_SUNW_HW_1: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1106 |
ocapset.oc_hw_1.cm_val = data->c_un.c_val; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1107 |
DBG_CALL(Dbg_cap_val_entry(ofl->ofl_lml, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1108 |
DBG_STATE_ORIGINAL, CA_SUNW_HW_1, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1109 |
ocapset.oc_hw_1.cm_val, ld_targ.t_m.m_mach)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1110 |
break; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1111 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1112 |
case CA_SUNW_SF_1: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1113 |
ocapset.oc_sf_1.cm_val = data->c_un.c_val; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1114 |
DBG_CALL(Dbg_cap_val_entry(ofl->ofl_lml, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1115 |
DBG_STATE_ORIGINAL, CA_SUNW_SF_1, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1116 |
ocapset.oc_sf_1.cm_val, ld_targ.t_m.m_mach)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1117 |
break; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1118 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1119 |
case CA_SUNW_HW_2: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1120 |
ocapset.oc_hw_2.cm_val = data->c_un.c_val; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1121 |
DBG_CALL(Dbg_cap_val_entry(ofl->ofl_lml, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1122 |
DBG_STATE_ORIGINAL, CA_SUNW_HW_2, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1123 |
ocapset.oc_hw_2.cm_val, ld_targ.t_m.m_mach)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1124 |
break; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1125 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1126 |
case CA_SUNW_PLAT: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1127 |
if ((capstr = alist_append(&ocapset.oc_plat.cl_val, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1128 |
NULL, sizeof (Capstr), AL_CNT_CAP_NAMES)) == NULL) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1129 |
return (S_ERROR); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1130 |
capstr->cs_str = strs + data->c_un.c_ptr; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1131 |
DBG_CALL(Dbg_cap_ptr_entry(ofl->ofl_lml, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1132 |
DBG_STATE_ORIGINAL, CA_SUNW_PLAT, capstr->cs_str)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1133 |
break; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1134 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1135 |
case CA_SUNW_MACH: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1136 |
if ((capstr = alist_append(&ocapset.oc_mach.cl_val, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1137 |
NULL, sizeof (Capstr), AL_CNT_CAP_NAMES)) == NULL) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1138 |
return (S_ERROR); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1139 |
capstr->cs_str = strs + data->c_un.c_ptr; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1140 |
DBG_CALL(Dbg_cap_ptr_entry(ofl->ofl_lml, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1141 |
DBG_STATE_ORIGINAL, CA_SUNW_MACH, capstr->cs_str)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1142 |
break; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1143 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1144 |
case CA_SUNW_ID: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1145 |
ocapset.oc_id.cs_str = strs + data->c_un.c_ptr; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1146 |
DBG_CALL(Dbg_cap_ptr_entry(ofl->ofl_lml, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1147 |
DBG_STATE_ORIGINAL, CA_SUNW_ID, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1148 |
ocapset.oc_id.cs_str)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1149 |
break; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1150 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1151 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1152 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1153 |
* Save the start of this new group. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1154 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1155 |
if (descapndx == -1) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1156 |
descapndx = ndx; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1157 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1158 |
return (1); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1159 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1160 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1161 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1162 |
* Capture any symbol capabilities symbols. An object file that contains symbol |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1163 |
* capabilities has an associated .SUNW_capinfo section. This section |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1164 |
* identifies which symbols are associated to which capabilities, together with |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1165 |
* their associated lead symbol. Each of these symbol pairs are recorded for |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1166 |
* processing later. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1167 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1168 |
static uintptr_t |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1169 |
process_capinfo(Ofl_desc *ofl, Ifl_desc *ifl, Is_desc *isp) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1170 |
{ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1171 |
Cap_desc *cdp = ifl->ifl_caps; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1172 |
Capinfo *capinfo = isp->is_indata->d_buf; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1173 |
Shdr *shdr = isp->is_shdr; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1174 |
Word cndx, capinfonum; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1175 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1176 |
capinfonum = (Word)(shdr->sh_size / shdr->sh_entsize); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1177 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1178 |
if ((cdp == NULL) || (capinfo == NULL) || (capinfonum == 0)) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1179 |
return (0); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1180 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1181 |
for (cndx = 1, capinfo++; cndx < capinfonum; cndx++, capinfo++) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1182 |
Sym_desc *sdp, *lsdp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1183 |
Word lndx; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1184 |
uchar_t gndx; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1185 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1186 |
if ((gndx = (uchar_t)ELF_C_GROUP(*capinfo)) == 0) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1187 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1188 |
lndx = (Word)ELF_C_SYM(*capinfo); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1189 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1190 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1191 |
* Catch any anomalies. A capabilities symbol should be valid, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1192 |
* and the capabilities lead symbol should also be global. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1193 |
* Note, ld(1) -z symbolcap would create local capabilities |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1194 |
* symbols, but we don't enforce this so as to give the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1195 |
* compilation environment a little more freedom. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1196 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1197 |
if ((sdp = ifl->ifl_oldndx[cndx]) == NULL) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1198 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1199 |
MSG_INTL(MSG_CAPINFO_INVALSYM), ifl->ifl_name, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1200 |
EC_WORD(isp->is_scnndx), isp->is_name, cndx, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1201 |
MSG_INTL(MSG_STR_UNKNOWN)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1202 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1203 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1204 |
if ((lndx == 0) || (lndx >= ifl->ifl_symscnt) || |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1205 |
((lsdp = ifl->ifl_oldndx[lndx]) == NULL) || |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1206 |
(ELF_ST_BIND(lsdp->sd_sym->st_info) != STB_GLOBAL)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1207 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1208 |
MSG_INTL(MSG_CAPINFO_INVALLEAD), ifl->ifl_name, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1209 |
EC_WORD(isp->is_scnndx), isp->is_name, cndx, lsdp ? |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1210 |
demangle(lsdp->sd_name) : MSG_INTL(MSG_STR_UNKNOWN), |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1211 |
lndx); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1212 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1213 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1214 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1215 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1216 |
* Indicate that this is a capabilities symbol. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1217 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1218 |
sdp->sd_flags |= FLG_SY_CAP; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1219 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1220 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1221 |
* Save any global capability symbols. Global capability |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1222 |
* symbols are identified with a CAPINFO_SUNW_GLOB group id. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1223 |
* The lead symbol for this global capability symbol is either |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1224 |
* the symbol itself, or an alias. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1225 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1226 |
if (gndx == CAPINFO_SUNW_GLOB) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1227 |
if (ld_cap_add_family(ofl, lsdp, sdp, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1228 |
NULL, NULL) == S_ERROR) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1229 |
return (S_ERROR); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1230 |
continue; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1231 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1232 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1233 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1234 |
* Track the number of non-global capabilities symbols, as these |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1235 |
* are used to size any symbol tables. If we're generating a |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1236 |
* dynamic object, this symbol will be added to the dynamic |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1237 |
* symbol table, therefore ensure there is space in the dynamic |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1238 |
* string table. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1239 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1240 |
ofl->ofl_caploclcnt++; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1241 |
if (((ofl->ofl_flags & FLG_OF_RELOBJ) == 0) && |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1242 |
(st_insert(ofl->ofl_dynstrtab, sdp->sd_name) == -1)) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1243 |
return (S_ERROR); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1244 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1245 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1246 |
* As we're tracking this local symbol as a capabilities symbol, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1247 |
* reduce the local symbol count to compensate. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1248 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1249 |
ofl->ofl_locscnt--; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1250 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1251 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1252 |
* Determine whether the associated lead symbol indicates |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1253 |
* NODYNSORT. If so, remove this local entry from the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1254 |
* SUNW_dynsort section too. NODYNSORT tagging can only be |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1255 |
* obtained from a mapfile symbol definition, and thus any |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1256 |
* global definition that has this tagging has already been |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1257 |
* instantiated and this instance resolved to it. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1258 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1259 |
if (lsdp->sd_flags & FLG_SY_NODYNSORT) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1260 |
Sym *lsym = lsdp->sd_sym; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1261 |
uchar_t ltype = ELF_ST_TYPE(lsym->st_info); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1262 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1263 |
DYNSORT_COUNT(lsdp, lsym, ltype, --); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1264 |
lsdp->sd_flags |= FLG_SY_NODYNSORT; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1265 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1266 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1267 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1268 |
* Track this family member, together with its associated group. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1269 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1270 |
if (ld_cap_add_family(ofl, lsdp, sdp, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1271 |
cdp->ca_groups->apl_data[gndx], NULL) == S_ERROR) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1272 |
return (S_ERROR); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1273 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1274 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1275 |
return (0); |
0 | 1276 |
} |
1277 |
||
1278 |
/* |
|
1279 |
* Simply process the section so that we have pointers to the data for use |
|
1280 |
* in later routines, however don't add the section to the output section |
|
1281 |
* list as we will be creating our own replacement sections later (ie. |
|
1282 |
* symtab and relocation). |
|
1283 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1284 |
static uintptr_t |
0 | 1285 |
/* ARGSUSED5 */ |
1286 |
process_input(const char *name, Ifl_desc *ifl, Shdr *shdr, Elf_Scn *scn, |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1287 |
Word ndx, int ident, Ofl_desc *ofl) |
0 | 1288 |
{ |
6206 | 1289 |
return (process_section(name, ifl, shdr, scn, ndx, |
1290 |
ld_targ.t_id.id_null, ofl)); |
|
0 | 1291 |
} |
1292 |
||
1293 |
/* |
|
1294 |
* Keep a running count of relocation entries from input relocatable objects for |
|
1295 |
* sizing relocation buckets later. If we're building an executable, save any |
|
1296 |
* relocations from shared objects to determine if any copy relocation symbol |
|
1297 |
* has a displacement relocation against it. |
|
1298 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1299 |
static uintptr_t |
0 | 1300 |
/* ARGSUSED5 */ |
1301 |
process_reloc(const char *name, Ifl_desc *ifl, Shdr *shdr, Elf_Scn *scn, |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1302 |
Word ndx, int ident, Ofl_desc *ofl) |
0 | 1303 |
{ |
1304 |
if (process_section(name, ifl, |
|
6206 | 1305 |
shdr, scn, ndx, ld_targ.t_id.id_null, ofl) == S_ERROR) |
0 | 1306 |
return (S_ERROR); |
1307 |
||
1308 |
if (ifl->ifl_ehdr->e_type == ET_REL) { |
|
1309 |
if (shdr->sh_entsize && (shdr->sh_entsize <= shdr->sh_size)) |
|
1310 |
/* LINTED */ |
|
1311 |
ofl->ofl_relocincnt += |
|
1312 |
(Word)(shdr->sh_size / shdr->sh_entsize); |
|
1313 |
} else if (ofl->ofl_flags & FLG_OF_EXEC) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1314 |
if (aplist_append(&ifl->ifl_relsect, ifl->ifl_isdesc[ndx], |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1315 |
AL_CNT_IFL_RELSECS) == NULL) |
0 | 1316 |
return (S_ERROR); |
1317 |
} |
|
1318 |
return (1); |
|
1319 |
} |
|
1320 |
||
1321 |
/* |
|
1322 |
* Process a string table section. A valid section contains an initial and |
|
1323 |
* final null byte. |
|
1324 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1325 |
static uintptr_t |
0 | 1326 |
process_strtab(const char *name, Ifl_desc *ifl, Shdr *shdr, Elf_Scn *scn, |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1327 |
Word ndx, int ident, Ofl_desc *ofl) |
0 | 1328 |
{ |
1329 |
char *data; |
|
1330 |
size_t size; |
|
1331 |
Is_desc *isp; |
|
1332 |
uintptr_t error; |
|
1333 |
||
1334 |
/* |
|
1335 |
* Never include .stab.excl sections in any output file. |
|
1336 |
* If the -s flag has been specified strip any .stab sections. |
|
1337 |
*/ |
|
1338 |
if (((ofl->ofl_flags & FLG_OF_STRIP) && ident && |
|
1339 |
(strncmp(name, MSG_ORIG(MSG_SCN_STAB), MSG_SCN_STAB_SIZE) == 0)) || |
|
1340 |
(strcmp(name, MSG_ORIG(MSG_SCN_STABEXCL)) == 0) && ident) |
|
1341 |
return (1); |
|
1342 |
||
1343 |
/* |
|
1344 |
* If we got here to process a .shstrtab or .dynstr table, `ident' will |
|
1345 |
* be null. Otherwise make sure we don't have a .strtab section as this |
|
1346 |
* should not be added to the output section list either. |
|
1347 |
*/ |
|
6206 | 1348 |
if ((ident != ld_targ.t_id.id_null) && |
0 | 1349 |
(strcmp(name, MSG_ORIG(MSG_SCN_STRTAB)) == 0)) |
6206 | 1350 |
ident = ld_targ.t_id.id_null; |
0 | 1351 |
|
1352 |
error = process_section(name, ifl, shdr, scn, ndx, ident, ofl); |
|
1353 |
if ((error == 0) || (error == S_ERROR)) |
|
1354 |
return (error); |
|
1355 |
||
1356 |
/* |
|
1357 |
* String tables should start and end with a NULL byte. Note, it has |
|
1358 |
* been known for the assembler to create empty string tables, so check |
|
1359 |
* the size before attempting to verify the data itself. |
|
1360 |
*/ |
|
1361 |
isp = ifl->ifl_isdesc[ndx]; |
|
1362 |
size = isp->is_indata->d_size; |
|
1363 |
if (size) { |
|
1364 |
data = isp->is_indata->d_buf; |
|
1365 |
if (data[0] != '\0' || data[size - 1] != '\0') |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1366 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
1367 |
MSG_INTL(MSG_FIL_MALSTR), ifl->ifl_name, |
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
1368 |
EC_WORD(isp->is_scnndx), name); |
0 | 1369 |
} else |
1370 |
isp->is_indata->d_buf = (void *)MSG_ORIG(MSG_STR_EMPTY); |
|
1371 |
||
1372 |
ifl->ifl_flags |= FLG_IF_HSTRTAB; |
|
1373 |
return (1); |
|
1374 |
} |
|
1375 |
||
1376 |
/* |
|
1377 |
* Invalid sections produce a warning and are skipped. |
|
1378 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1379 |
static uintptr_t |
0 | 1380 |
/* ARGSUSED3 */ |
1381 |
invalid_section(const char *name, Ifl_desc *ifl, Shdr *shdr, Elf_Scn *scn, |
|
1382 |
Word ndx, int ident, Ofl_desc *ofl) |
|
1383 |
{ |
|
4734
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
1384 |
Conv_inv_buf_t inv_buf; |
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
1385 |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1386 |
eprintf(ofl->ofl_lml, ERR_WARNING, MSG_INTL(MSG_FIL_INVALSEC), |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
1387 |
ifl->ifl_name, EC_WORD(ndx), name, |
9273
9a0603d78ad3
6821619 Solaris linkers need systematic approach to ELF OSABI
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9131
diff
changeset
|
1388 |
conv_sec_type(ifl->ifl_ehdr->e_ident[EI_OSABI], |
9a0603d78ad3
6821619 Solaris linkers need systematic approach to ELF OSABI
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9131
diff
changeset
|
1389 |
ifl->ifl_ehdr->e_machine, shdr->sh_type, 0, &inv_buf)); |
0 | 1390 |
return (1); |
1391 |
} |
|
1392 |
||
1393 |
/* |
|
10454
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1394 |
* Compare an input section name to a given string, taking the ELF '%' |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1395 |
* section naming convention into account. If an input section name |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1396 |
* contains a '%' character, the '%' and all following characters are |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1397 |
* ignored in the comparison. |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1398 |
* |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1399 |
* entry: |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1400 |
* is_name - Name of input section |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1401 |
* match_name - Name to compare to |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1402 |
* match_len - strlen(match_name) |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1403 |
* |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1404 |
* exit: |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1405 |
* Returns True (1) if the names match, and False (0) otherwise. |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1406 |
*/ |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1407 |
inline static int |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1408 |
is_name_cmp(const char *is_name, const char *match_name, size_t match_len) |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1409 |
{ |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1410 |
/* |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1411 |
* If the start of is_name is not a match for name, |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1412 |
* the match fails. |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1413 |
*/ |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1414 |
if (strncmp(is_name, match_name, match_len) != 0) |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1415 |
return (0); |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1416 |
|
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1417 |
/* |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1418 |
* The prefix matched. The next character must be either '%', or |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1419 |
* NULL, in order for a match to be true. |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1420 |
*/ |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1421 |
is_name += match_len; |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1422 |
return ((*is_name == '\0') || (*is_name == '%')); |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1423 |
} |
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1424 |
|
f68cccac9492
6878605 ld should accept '%' syntax when matching input SHT_PROGBITS sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9878
diff
changeset
|
1425 |
/* |
11993
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1426 |
* Helper routine for process_progbits() to process allocable sections. |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1427 |
* |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1428 |
* entry: |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1429 |
* name, ifl, shdr, ndx, ident, ofl - As passed to process_progbits(). |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1430 |
* is_stab_index - TRUE if section is .index. |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1431 |
* is_flags - Additional flags to be added to the input section. |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1432 |
* |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1433 |
* exit: |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1434 |
* The allocable section has been processed. *ident and *is_flags |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1435 |
* are updated as necessary to reflect the changes. Returns TRUE |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1436 |
* for success, FALSE for failure. |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1437 |
*/ |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1438 |
inline static Boolean |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1439 |
process_progbits_alloc(const char *name, Ifl_desc *ifl, Shdr *shdr, |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1440 |
Word ndx, int *ident, Ofl_desc *ofl, Boolean is_stab_index, |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1441 |
Word *is_flags) |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1442 |
{ |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1443 |
Boolean done = FALSE; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1444 |
|
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1445 |
if (name[0] == '.') { |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1446 |
Conv_inv_buf_t inv_buf1, inv_buf2; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1447 |
|
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1448 |
switch (name[1]) { |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1449 |
case 'e': |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1450 |
if (!is_name_cmp(name, MSG_ORIG(MSG_SCN_EHFRAME), |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1451 |
MSG_SCN_EHFRAME_SIZE)) |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1452 |
break; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1453 |
|
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1454 |
*ident = ld_targ.t_id.id_unwind; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1455 |
*is_flags |= FLG_IS_EHFRAME; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1456 |
done = TRUE; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1457 |
|
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1458 |
/* |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1459 |
* Only accept a progbits .eh_frame on a platform |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1460 |
* for which this is the expected type. |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1461 |
*/ |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1462 |
if (ld_targ.t_m.m_sht_unwind == SHT_PROGBITS) |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1463 |
break; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1464 |
eprintf(ofl->ofl_lml, ERR_FATAL, |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1465 |
MSG_INTL(MSG_FIL_EXEHFRMTYP), ifl->ifl_name, |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1466 |
EC_WORD(ndx), name, |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1467 |
conv_sec_type(ifl->ifl_ehdr->e_ident[EI_OSABI], |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1468 |
ifl->ifl_ehdr->e_machine, shdr->sh_type, |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1469 |
CONV_FMT_ALT_CF, &inv_buf1), |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1470 |
conv_sec_type(ifl->ifl_ehdr->e_ident[EI_OSABI], |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1471 |
ifl->ifl_ehdr->e_machine, ld_targ.t_m.m_sht_unwind, |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1472 |
CONV_FMT_ALT_CF, &inv_buf2)); |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1473 |
ofl->ofl_flags |= FLG_OF_FATAL; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1474 |
return (FALSE); |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1475 |
case 'g': |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1476 |
if (is_name_cmp(name, MSG_ORIG(MSG_SCN_GOT), |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1477 |
MSG_SCN_GOT_SIZE)) { |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1478 |
*ident = ld_targ.t_id.id_null; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1479 |
done = TRUE; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1480 |
break; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1481 |
} |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1482 |
if ((ld_targ.t_m.m_sht_unwind == SHT_PROGBITS) && |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1483 |
is_name_cmp(name, MSG_ORIG(MSG_SCN_GCC_X_TBL), |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1484 |
MSG_SCN_GCC_X_TBL_SIZE)) { |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1485 |
*ident = ld_targ.t_id.id_unwind; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1486 |
done = TRUE; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1487 |
break; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1488 |
} |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1489 |
break; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1490 |
case 'p': |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1491 |
if (is_name_cmp(name, MSG_ORIG(MSG_SCN_PLT), |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1492 |
MSG_SCN_PLT_SIZE)) { |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1493 |
*ident = ld_targ.t_id.id_null; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1494 |
done = TRUE; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1495 |
} |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1496 |
break; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1497 |
} |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1498 |
} |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1499 |
if (!done) { |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1500 |
if (is_stab_index) { |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1501 |
/* |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1502 |
* This is a work-around for x86 compilers that have |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1503 |
* set SHF_ALLOC for the .stab.index section. |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1504 |
* |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1505 |
* Because of this, make sure that the .stab.index |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1506 |
* does not end up as the last section in the text |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1507 |
* segment. Older linkers can produce segmentation |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1508 |
* violations when they strip (ld -s) against a |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1509 |
* shared object whose last section in the text |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1510 |
* segment is a .stab. |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1511 |
*/ |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1512 |
*ident = ld_targ.t_id.id_interp; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1513 |
} else { |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1514 |
*ident = ld_targ.t_id.id_data; |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1515 |
} |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1516 |
} |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1517 |
|
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1518 |
return (TRUE); |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1519 |
} |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1520 |
|
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1521 |
/* |
0 | 1522 |
* Process a progbits section. |
1523 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1524 |
static uintptr_t |
0 | 1525 |
process_progbits(const char *name, Ifl_desc *ifl, Shdr *shdr, Elf_Scn *scn, |
1526 |
Word ndx, int ident, Ofl_desc *ofl) |
|
1527 |
{ |
|
11993
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1528 |
Boolean is_stab_index = FALSE; |
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1529 |
Word is_flags = 0; |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1530 |
uintptr_t r; |
0 | 1531 |
|
1532 |
/* |
|
1533 |
* Never include .stab.excl sections in any output file. |
|
1534 |
* If the -s flag has been specified strip any .stab sections. |
|
1535 |
*/ |
|
1536 |
if (ident && (strncmp(name, MSG_ORIG(MSG_SCN_STAB), |
|
1537 |
MSG_SCN_STAB_SIZE) == 0)) { |
|
1538 |
if ((ofl->ofl_flags & FLG_OF_STRIP) || |
|
1539 |
(strcmp((name + MSG_SCN_STAB_SIZE), |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
1540 |
MSG_ORIG(MSG_SCN_EXCL)) == 0)) |
0 | 1541 |
return (1); |
1542 |
||
1543 |
if (strcmp((name + MSG_SCN_STAB_SIZE), |
|
1544 |
MSG_ORIG(MSG_SCN_INDEX)) == 0) |
|
11993
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1545 |
is_stab_index = TRUE; |
0 | 1546 |
} |
1547 |
||
1548 |
if ((ofl->ofl_flags & FLG_OF_STRIP) && ident) { |
|
1549 |
if ((strncmp(name, MSG_ORIG(MSG_SCN_DEBUG), |
|
1550 |
MSG_SCN_DEBUG_SIZE) == 0) || |
|
1551 |
(strcmp(name, MSG_ORIG(MSG_SCN_LINE)) == 0)) |
|
1552 |
return (1); |
|
1553 |
} |
|
1554 |
||
1555 |
/* |
|
1556 |
* Update the ident to reflect the type of section we've got. |
|
1557 |
* |
|
1558 |
* If there is any .plt or .got section to generate we'll be creating |
|
1559 |
* our own version, so don't allow any input sections of these types to |
|
1560 |
* be added to the output section list (why a relocatable object would |
|
1561 |
* have a .plt or .got is a mystery, but stranger things have occurred). |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1562 |
* |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1563 |
* If there are any unwind sections, and this is a platform that uses |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1564 |
* SHT_PROGBITS for unwind sections, then set their ident to reflect |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1565 |
* that. |
0 | 1566 |
*/ |
1567 |
if (ident) { |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1568 |
if (shdr->sh_flags & SHF_TLS) { |
6206 | 1569 |
ident = ld_targ.t_id.id_tls; |
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1570 |
} else if ((shdr->sh_flags & ~ALL_SHF_IGNORE) == |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1571 |
(SHF_ALLOC | SHF_EXECINSTR)) { |
6206 | 1572 |
ident = ld_targ.t_id.id_text; |
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1573 |
} else if (shdr->sh_flags & SHF_ALLOC) { |
11993
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1574 |
if (process_progbits_alloc(name, ifl, shdr, ndx, |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1575 |
&ident, ofl, is_stab_index, &is_flags) == FALSE) |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1576 |
return (S_ERROR); |
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1577 |
} else { |
6206 | 1578 |
ident = ld_targ.t_id.id_note; |
11993
a39d3ec14d8f
6931044 ld should not allow SHT_PROGBITS .eh_frame sections on amd64
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
1579 |
} |
0 | 1580 |
} |
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1581 |
|
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1582 |
r = process_section(name, ifl, shdr, scn, ndx, ident, ofl); |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1583 |
|
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1584 |
/* |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1585 |
* On success, process_section() creates an input section descriptor. |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1586 |
* Now that it exists, we can add any pending input section flags. |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1587 |
*/ |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1588 |
if ((is_flags != 0) && (r == 1)) |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1589 |
ifl->ifl_isdesc[ndx]->is_flags |= is_flags; |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1590 |
|
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
1591 |
return (r); |
0 | 1592 |
} |
1593 |
||
1594 |
/* |
|
1595 |
* Handles the SHT_SUNW_{DEBUG,DEBUGSTR) sections. |
|
1596 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1597 |
static uintptr_t |
0 | 1598 |
process_debug(const char *name, Ifl_desc *ifl, Shdr *shdr, Elf_Scn *scn, |
1599 |
Word ndx, int ident, Ofl_desc *ofl) |
|
1600 |
{ |
|
1601 |
/* |
|
1602 |
* Debug information is discarded when the 'ld -s' flag is invoked. |
|
1603 |
*/ |
|
1604 |
if (ofl->ofl_flags & FLG_OF_STRIP) { |
|
1605 |
return (1); |
|
1606 |
} |
|
1607 |
return (process_progbits(name, ifl, shdr, scn, ndx, ident, ofl)); |
|
1608 |
} |
|
1609 |
||
1610 |
/* |
|
1611 |
* Process a nobits section. |
|
1612 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1613 |
static uintptr_t |
0 | 1614 |
process_nobits(const char *name, Ifl_desc *ifl, Shdr *shdr, Elf_Scn *scn, |
1615 |
Word ndx, int ident, Ofl_desc *ofl) |
|
1616 |
{ |
|
1617 |
if (ident) { |
|
1618 |
if (shdr->sh_flags & SHF_TLS) |
|
6206 | 1619 |
ident = ld_targ.t_id.id_tlsbss; |
1620 |
#if defined(_ELF64) |
|
1621 |
else if ((shdr->sh_flags & SHF_AMD64_LARGE) && |
|
1622 |
(ld_targ.t_m.m_mach == EM_AMD64)) |
|
1623 |
ident = ld_targ.t_id.id_lbss; |
|
574 | 1624 |
#endif |
0 | 1625 |
else |
6206 | 1626 |
ident = ld_targ.t_id.id_bss; |
0 | 1627 |
} |
1628 |
return (process_section(name, ifl, shdr, scn, ndx, ident, ofl)); |
|
1629 |
} |
|
1630 |
||
1631 |
/* |
|
1632 |
* Process a SHT_*_ARRAY section. |
|
1633 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1634 |
static uintptr_t |
0 | 1635 |
process_array(const char *name, Ifl_desc *ifl, Shdr *shdr, Elf_Scn *scn, |
1636 |
Word ndx, int ident, Ofl_desc *ofl) |
|
1637 |
{ |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1638 |
uintptr_t error; |
0 | 1639 |
|
1640 |
if (ident) |
|
6206 | 1641 |
ident = ld_targ.t_id.id_array; |
0 | 1642 |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1643 |
error = process_section(name, ifl, shdr, scn, ndx, ident, ofl); |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1644 |
if ((error == 0) || (error == S_ERROR)) |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1645 |
return (error); |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1646 |
|
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1647 |
return (1); |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1648 |
} |
0 | 1649 |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1650 |
static uintptr_t |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1651 |
/* ARGSUSED1 */ |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1652 |
array_process(Is_desc *isc, Ifl_desc *ifl, Ofl_desc *ofl) |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1653 |
{ |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1654 |
Os_desc *osp; |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1655 |
Shdr *shdr; |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1656 |
|
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1657 |
if ((isc == NULL) || ((osp = isc->is_osdesc) == NULL)) |
0 | 1658 |
return (0); |
1659 |
||
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1660 |
shdr = isc->is_shdr; |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1661 |
|
0 | 1662 |
if ((shdr->sh_type == SHT_FINI_ARRAY) && |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1663 |
(ofl->ofl_osfiniarray == NULL)) |
0 | 1664 |
ofl->ofl_osfiniarray = osp; |
1665 |
else if ((shdr->sh_type == SHT_INIT_ARRAY) && |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1666 |
(ofl->ofl_osinitarray == NULL)) |
0 | 1667 |
ofl->ofl_osinitarray = osp; |
1668 |
else if ((shdr->sh_type == SHT_PREINIT_ARRAY) && |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
1669 |
(ofl->ofl_ospreinitarray == NULL)) |
0 | 1670 |
ofl->ofl_ospreinitarray = osp; |
1671 |
||
1672 |
return (1); |
|
1673 |
} |
|
1674 |
||
1675 |
/* |
|
1676 |
* Process a SHT_SYMTAB_SHNDX section. |
|
1677 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1678 |
static uintptr_t |
0 | 1679 |
process_sym_shndx(const char *name, Ifl_desc *ifl, Shdr *shdr, Elf_Scn *scn, |
1680 |
Word ndx, int ident, Ofl_desc *ofl) |
|
1681 |
{ |
|
1682 |
if (process_input(name, ifl, shdr, scn, ndx, ident, ofl) == S_ERROR) |
|
1683 |
return (S_ERROR); |
|
1684 |
||
1685 |
/* |
|
1686 |
* Have we already seen the related SYMTAB - if so verify it now. |
|
1687 |
*/ |
|
1688 |
if (shdr->sh_link < ndx) { |
|
1689 |
Is_desc *isp = ifl->ifl_isdesc[shdr->sh_link]; |
|
1690 |
||
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
1691 |
if ((isp == NULL) || ((isp->is_shdr->sh_type != SHT_SYMTAB) && |
0 | 1692 |
(isp->is_shdr->sh_type != SHT_DYNSYM))) { |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1693 |
eprintf(ofl->ofl_lml, ERR_FATAL, |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
1694 |
MSG_INTL(MSG_FIL_INVSHLINK), ifl->ifl_name, |
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
1695 |
EC_WORD(ndx), name, EC_XWORD(shdr->sh_link)); |
0 | 1696 |
return (S_ERROR); |
1697 |
} |
|
1698 |
isp->is_symshndx = ifl->ifl_isdesc[ndx]; |
|
1699 |
} |
|
1700 |
return (1); |
|
1701 |
} |
|
1702 |
||
1703 |
/* |
|
1704 |
* Final processing for SHT_SYMTAB_SHNDX section. |
|
1705 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1706 |
static uintptr_t |
0 | 1707 |
/* ARGSUSED2 */ |
1708 |
sym_shndx_process(Is_desc *isc, Ifl_desc *ifl, Ofl_desc *ofl) |
|
1709 |
{ |
|
1710 |
if (isc->is_shdr->sh_link > isc->is_scnndx) { |
|
1711 |
Is_desc *isp = ifl->ifl_isdesc[isc->is_shdr->sh_link]; |
|
1712 |
||
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
1713 |
if ((isp == NULL) || ((isp->is_shdr->sh_type != SHT_SYMTAB) && |
0 | 1714 |
(isp->is_shdr->sh_type != SHT_DYNSYM))) { |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1715 |
eprintf(ofl->ofl_lml, ERR_FATAL, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1716 |
MSG_INTL(MSG_FIL_INVSHLINK), isc->is_file->ifl_name, |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
1717 |
EC_WORD(isc->is_scnndx), isc->is_name, |
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
1718 |
EC_XWORD(isc->is_shdr->sh_link)); |
0 | 1719 |
return (S_ERROR); |
1720 |
} |
|
1721 |
isp->is_symshndx = isc; |
|
1722 |
} |
|
1723 |
return (1); |
|
1724 |
} |
|
1725 |
||
1726 |
/* |
|
1727 |
* Process .dynamic section from a relocatable object. |
|
1728 |
* |
|
1729 |
* Note: That the .dynamic section is only considered interesting when |
|
1730 |
* dlopen()ing a relocatable object (thus FLG_OF1_RELDYN can only get |
|
1731 |
* set when libld is called from ld.so.1). |
|
1732 |
*/ |
|
1733 |
/*ARGSUSED*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1734 |
static uintptr_t |
0 | 1735 |
process_rel_dynamic(const char *name, Ifl_desc *ifl, Shdr *shdr, Elf_Scn *scn, |
1736 |
Word ndx, int ident, Ofl_desc *ofl) |
|
1737 |
{ |
|
1738 |
Dyn *dyn; |
|
1739 |
Elf_Scn *strscn; |
|
1740 |
Elf_Data *dp; |
|
1741 |
char *str; |
|
1742 |
||
1743 |
/* |
|
1744 |
* Process .dynamic sections from relocatable objects ? |
|
1745 |
*/ |
|
1746 |
if ((ofl->ofl_flags1 & FLG_OF1_RELDYN) == 0) |
|
1747 |
return (1); |
|
1748 |
||
1749 |
/* |
|
1750 |
* Find the string section associated with the .dynamic section. |
|
1751 |
*/ |
|
1752 |
if ((strscn = elf_getscn(ifl->ifl_elf, shdr->sh_link)) == NULL) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1753 |
eprintf(ofl->ofl_lml, ERR_ELF, MSG_INTL(MSG_ELF_GETSCN), |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
1754 |
ifl->ifl_name); |
0 | 1755 |
ofl->ofl_flags |= FLG_OF_FATAL; |
1756 |
return (0); |
|
1757 |
} |
|
1758 |
dp = elf_getdata(strscn, NULL); |
|
1759 |
str = (char *)dp->d_buf; |
|
1760 |
||
1761 |
/* |
|
1762 |
* And get the .dynamic data |
|
1763 |
*/ |
|
1764 |
dp = elf_getdata(scn, NULL); |
|
1765 |
||
1766 |
for (dyn = (Dyn *)dp->d_buf; dyn->d_tag != DT_NULL; dyn++) { |
|
1109
1a3bd84f03cd
6362044 ld(1) inconsistencies with LD_DEBUG=-Dunused and -zignore
rie
parents:
574
diff
changeset
|
1767 |
Ifl_desc *difl; |
0 | 1768 |
|
1769 |
switch (dyn->d_tag) { |
|
1770 |
case DT_NEEDED: |
|
1771 |
case DT_USED: |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1772 |
if (((difl = libld_calloc(1, |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1773 |
sizeof (Ifl_desc))) == NULL) || |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1774 |
(aplist_append(&ofl->ofl_sos, difl, |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1775 |
AL_CNT_OFL_LIBS) == NULL)) |
0 | 1776 |
return (S_ERROR); |
1109
1a3bd84f03cd
6362044 ld(1) inconsistencies with LD_DEBUG=-Dunused and -zignore
rie
parents:
574
diff
changeset
|
1777 |
|
1a3bd84f03cd
6362044 ld(1) inconsistencies with LD_DEBUG=-Dunused and -zignore
rie
parents:
574
diff
changeset
|
1778 |
difl->ifl_name = MSG_ORIG(MSG_STR_DYNAMIC); |
1a3bd84f03cd
6362044 ld(1) inconsistencies with LD_DEBUG=-Dunused and -zignore
rie
parents:
574
diff
changeset
|
1779 |
difl->ifl_soname = str + (size_t)dyn->d_un.d_val; |
1a3bd84f03cd
6362044 ld(1) inconsistencies with LD_DEBUG=-Dunused and -zignore
rie
parents:
574
diff
changeset
|
1780 |
difl->ifl_flags = FLG_IF_NEEDSTR; |
0 | 1781 |
break; |
1782 |
case DT_RPATH: |
|
1783 |
case DT_RUNPATH: |
|
1784 |
if ((ofl->ofl_rpath = add_string(ofl->ofl_rpath, |
|
1785 |
(str + (size_t)dyn->d_un.d_val))) == |
|
1786 |
(const char *)S_ERROR) |
|
1787 |
return (S_ERROR); |
|
1788 |
break; |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
1789 |
case DT_VERSYM: |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
1790 |
/* |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
1791 |
* The Solaris ld does not put DT_VERSYM in the |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
1792 |
* dynamic section. If the object has DT_VERSYM, |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
1793 |
* then it must have been produced by the GNU ld, |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
1794 |
* and is using the GNU style of versioning. |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
1795 |
*/ |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
1796 |
ifl->ifl_flags |= FLG_IF_GNUVER; |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
1797 |
break; |
0 | 1798 |
} |
1799 |
} |
|
1800 |
return (1); |
|
1801 |
} |
|
1802 |
||
1803 |
/* |
|
1804 |
* Expand implicit references. Dependencies can be specified in terms of the |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1805 |
* $ORIGIN, $MACHINE, $PLATFORM, $OSREL and $OSNAME tokens, either from their |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1806 |
* needed name, or via a runpath. In addition runpaths may also specify the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1807 |
* $ISALIST token. |
0 | 1808 |
* |
1109
1a3bd84f03cd
6362044 ld(1) inconsistencies with LD_DEBUG=-Dunused and -zignore
rie
parents:
574
diff
changeset
|
1809 |
* Probably the most common reference to explicit dependencies (via -L) will be |
0 | 1810 |
* sufficient to find any associated implicit dependencies, but just in case we |
1811 |
* expand any occurrence of these known tokens here. |
|
1812 |
* |
|
1813 |
* Note, if any errors occur we simply return the original name. |
|
1814 |
* |
|
1815 |
* This code is remarkably similar to expand() in rtld/common/paths.c. |
|
1816 |
*/ |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1817 |
static char *machine = NULL; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1818 |
static size_t machine_sz = 0; |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
1819 |
static char *platform = NULL; |
0 | 1820 |
static size_t platform_sz = 0; |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
1821 |
static Isa_desc *isa = NULL; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
1822 |
static Uts_desc *uts = NULL; |
0 | 1823 |
|
1824 |
static char * |
|
1825 |
expand(const char *parent, const char *name, char **next) |
|
1826 |
{ |
|
1827 |
char _name[PATH_MAX], *nptr, *_next; |
|
1828 |
const char *optr; |
|
1829 |
size_t nrem = PATH_MAX - 1; |
|
1830 |
int expanded = 0, _expanded, isaflag = 0; |
|
1831 |
||
1832 |
optr = name; |
|
1833 |
nptr = _name; |
|
1834 |
||
1835 |
while (*optr) { |
|
1836 |
if (nrem == 0) |
|
1837 |
return ((char *)name); |
|
1838 |
||
1839 |
if (*optr != '$') { |
|
1840 |
*nptr++ = *optr++, nrem--; |
|
1841 |
continue; |
|
1842 |
} |
|
1843 |
||
1844 |
_expanded = 0; |
|
1845 |
||
1846 |
if (strncmp(optr, MSG_ORIG(MSG_STR_ORIGIN), |
|
1847 |
MSG_STR_ORIGIN_SIZE) == 0) { |
|
1848 |
char *eptr; |
|
1849 |
||
1850 |
/* |
|
1851 |
* For $ORIGIN, expansion is really just a concatenation |
|
1852 |
* of the parents directory name. For example, an |
|
1109
1a3bd84f03cd
6362044 ld(1) inconsistencies with LD_DEBUG=-Dunused and -zignore
rie
parents:
574
diff
changeset
|
1853 |
* explicit dependency foo/bar/lib1.so with a dependency |
0 | 1854 |
* on $ORIGIN/lib2.so would be expanded to |
1855 |
* foo/bar/lib2.so. |
|
1856 |
*/ |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
1857 |
if ((eptr = strrchr(parent, '/')) == NULL) { |
0 | 1858 |
*nptr++ = '.'; |
1859 |
nrem--; |
|
1860 |
} else { |
|
1861 |
size_t len = eptr - parent; |
|
1862 |
||
1863 |
if (len >= nrem) |
|
1864 |
return ((char *)name); |
|
1865 |
||
1866 |
(void) strncpy(nptr, parent, len); |
|
1867 |
nptr = nptr + len; |
|
1868 |
nrem -= len; |
|
1869 |
} |
|
1870 |
optr += MSG_STR_ORIGIN_SIZE; |
|
1871 |
expanded = _expanded = 1; |
|
1872 |
||
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1873 |
} else if (strncmp(optr, MSG_ORIG(MSG_STR_MACHINE), |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1874 |
MSG_STR_MACHINE_SIZE) == 0) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1875 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1876 |
* Establish the machine from sysconf - like uname -i. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1877 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1878 |
if ((machine == NULL) && (machine_sz == 0)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1879 |
char info[SYS_NMLN]; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1880 |
long size; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1881 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1882 |
size = sysinfo(SI_MACHINE, info, SYS_NMLN); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1883 |
if ((size != -1) && |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1884 |
(machine = libld_malloc((size_t)size))) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1885 |
(void) strcpy(machine, info); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1886 |
machine_sz = (size_t)size - 1; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1887 |
} else |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1888 |
machine_sz = 1; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1889 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1890 |
if (machine) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1891 |
if (machine_sz >= nrem) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1892 |
return ((char *)name); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1893 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1894 |
(void) strncpy(nptr, machine, machine_sz); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1895 |
nptr = nptr + machine_sz; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1896 |
nrem -= machine_sz; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1897 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1898 |
optr += MSG_STR_MACHINE_SIZE; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1899 |
expanded = _expanded = 1; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1900 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1901 |
|
0 | 1902 |
} else if (strncmp(optr, MSG_ORIG(MSG_STR_PLATFORM), |
1903 |
MSG_STR_PLATFORM_SIZE) == 0) { |
|
1904 |
/* |
|
1905 |
* Establish the platform from sysconf - like uname -i. |
|
1906 |
*/ |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
1907 |
if ((platform == NULL) && (platform_sz == 0)) { |
0 | 1908 |
char info[SYS_NMLN]; |
1909 |
long size; |
|
1910 |
||
1911 |
size = sysinfo(SI_PLATFORM, info, SYS_NMLN); |
|
1912 |
if ((size != -1) && |
|
1913 |
(platform = libld_malloc((size_t)size))) { |
|
1914 |
(void) strcpy(platform, info); |
|
1915 |
platform_sz = (size_t)size - 1; |
|
1916 |
} else |
|
1917 |
platform_sz = 1; |
|
1918 |
} |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
1919 |
if (platform) { |
0 | 1920 |
if (platform_sz >= nrem) |
1921 |
return ((char *)name); |
|
1922 |
||
1923 |
(void) strncpy(nptr, platform, platform_sz); |
|
1924 |
nptr = nptr + platform_sz; |
|
1925 |
nrem -= platform_sz; |
|
1926 |
||
1927 |
optr += MSG_STR_PLATFORM_SIZE; |
|
1928 |
expanded = _expanded = 1; |
|
1929 |
} |
|
1930 |
||
1931 |
} else if (strncmp(optr, MSG_ORIG(MSG_STR_OSNAME), |
|
1932 |
MSG_STR_OSNAME_SIZE) == 0) { |
|
1933 |
/* |
|
1934 |
* Establish the os name - like uname -s. |
|
1935 |
*/ |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
1936 |
if (uts == NULL) |
0 | 1937 |
uts = conv_uts(); |
1938 |
||
1939 |
if (uts && uts->uts_osnamesz) { |
|
1940 |
if (uts->uts_osnamesz >= nrem) |
|
1941 |
return ((char *)name); |
|
1942 |
||
1943 |
(void) strncpy(nptr, uts->uts_osname, |
|
1944 |
uts->uts_osnamesz); |
|
1945 |
nptr = nptr + uts->uts_osnamesz; |
|
1946 |
nrem -= uts->uts_osnamesz; |
|
1947 |
||
1948 |
optr += MSG_STR_OSNAME_SIZE; |
|
1949 |
expanded = _expanded = 1; |
|
1950 |
} |
|
1951 |
||
1952 |
} else if (strncmp(optr, MSG_ORIG(MSG_STR_OSREL), |
|
1953 |
MSG_STR_OSREL_SIZE) == 0) { |
|
1954 |
/* |
|
1955 |
* Establish the os release - like uname -r. |
|
1956 |
*/ |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
1957 |
if (uts == NULL) |
0 | 1958 |
uts = conv_uts(); |
1959 |
||
1960 |
if (uts && uts->uts_osrelsz) { |
|
1961 |
if (uts->uts_osrelsz >= nrem) |
|
1962 |
return ((char *)name); |
|
1963 |
||
1964 |
(void) strncpy(nptr, uts->uts_osrel, |
|
1965 |
uts->uts_osrelsz); |
|
1966 |
nptr = nptr + uts->uts_osrelsz; |
|
1967 |
nrem -= uts->uts_osrelsz; |
|
1968 |
||
1969 |
optr += MSG_STR_OSREL_SIZE; |
|
1970 |
expanded = _expanded = 1; |
|
1971 |
} |
|
1972 |
||
1973 |
} else if ((strncmp(optr, MSG_ORIG(MSG_STR_ISALIST), |
|
1974 |
MSG_STR_ISALIST_SIZE) == 0) && next && (isaflag++ == 0)) { |
|
1975 |
/* |
|
1976 |
* Establish instruction sets from sysconf. Note that |
|
1977 |
* this is only meaningful from runpaths. |
|
1978 |
*/ |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
1979 |
if (isa == NULL) |
0 | 1980 |
isa = conv_isalist(); |
1981 |
||
1982 |
if (isa && isa->isa_listsz && |
|
1983 |
(nrem > isa->isa_opt->isa_namesz)) { |
|
1984 |
size_t mlen, tlen, hlen = optr - name; |
|
1985 |
size_t no; |
|
1986 |
char *lptr; |
|
1987 |
Isa_opt *opt = isa->isa_opt; |
|
1988 |
||
1989 |
(void) strncpy(nptr, opt->isa_name, |
|
1990 |
opt->isa_namesz); |
|
1991 |
nptr = nptr + opt->isa_namesz; |
|
1992 |
nrem -= opt->isa_namesz; |
|
1993 |
||
1994 |
optr += MSG_STR_ISALIST_SIZE; |
|
1995 |
expanded = _expanded = 1; |
|
1996 |
||
1997 |
tlen = strlen(optr); |
|
1998 |
||
1999 |
/* |
|
2000 |
* As ISALIST expands to a number of elements, |
|
2001 |
* establish a new list to return to the caller. |
|
2002 |
* This will contain the present path being |
|
2003 |
* processed redefined for each isalist option, |
|
2004 |
* plus the original remaining list entries. |
|
2005 |
*/ |
|
2006 |
mlen = ((hlen + tlen) * (isa->isa_optno - 1)) + |
|
2007 |
isa->isa_listsz - opt->isa_namesz; |
|
2008 |
if (*next) |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2009 |
mlen += strlen(*next); |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
2010 |
if ((_next = lptr = libld_malloc(mlen)) == NULL) |
0 | 2011 |
return (0); |
2012 |
||
2013 |
for (no = 1, opt++; no < isa->isa_optno; |
|
2014 |
no++, opt++) { |
|
2015 |
(void) strncpy(lptr, name, hlen); |
|
2016 |
lptr = lptr + hlen; |
|
2017 |
(void) strncpy(lptr, opt->isa_name, |
|
2018 |
opt->isa_namesz); |
|
2019 |
lptr = lptr + opt->isa_namesz; |
|
2020 |
(void) strncpy(lptr, optr, tlen); |
|
2021 |
lptr = lptr + tlen; |
|
2022 |
*lptr++ = ':'; |
|
2023 |
} |
|
2024 |
if (*next) |
|
2025 |
(void) strcpy(lptr, *next); |
|
2026 |
else |
|
2027 |
*--lptr = '\0'; |
|
2028 |
} |
|
2029 |
} |
|
2030 |
||
2031 |
/* |
|
2032 |
* If no expansion occurred skip the $ and continue. |
|
2033 |
*/ |
|
2034 |
if (_expanded == 0) |
|
2035 |
*nptr++ = *optr++, nrem--; |
|
2036 |
} |
|
2037 |
||
2038 |
/* |
|
2039 |
* If any ISALIST processing has occurred not only do we return the |
|
2040 |
* expanded node we're presently working on, but we must also update the |
|
2041 |
* remaining list so that it is effectively prepended with this node |
|
2042 |
* expanded to all remaining isalist options. Note that we can only |
|
2043 |
* handle one ISALIST per node. For more than one ISALIST to be |
|
2044 |
* processed we'd need a better algorithm than above to replace the |
|
2045 |
* newly generated list. Whether we want to encourage the number of |
|
2046 |
* pathname permutations this would provide is another question. So, for |
|
2047 |
* now if more than one ISALIST is encountered we return the original |
|
2048 |
* node untouched. |
|
2049 |
*/ |
|
2050 |
if (isaflag) { |
|
2051 |
if (isaflag == 1) |
|
2052 |
*next = _next; |
|
2053 |
else |
|
2054 |
return ((char *)name); |
|
2055 |
} |
|
2056 |
||
2057 |
*nptr = '\0'; |
|
2058 |
||
2059 |
if (expanded) { |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
2060 |
if ((nptr = libld_malloc(strlen(_name) + 1)) == NULL) |
0 | 2061 |
return ((char *)name); |
2062 |
(void) strcpy(nptr, _name); |
|
2063 |
return (nptr); |
|
2064 |
} |
|
2065 |
return ((char *)name); |
|
2066 |
} |
|
2067 |
||
2068 |
/* |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2069 |
* The Solaris ld does not put DT_VERSYM in the dynamic section, but the |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2070 |
* GNU ld does, and it is used by the runtime linker to implement their |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2071 |
* versioning scheme. Use this fact to determine if the sharable object |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2072 |
* was produced by the GNU ld rather than the Solaris one, and to set |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2073 |
* FLG_IF_GNUVER if so. This needs to be done before the symbols are |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2074 |
* processed, since the answer determines whether we interpret the |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2075 |
* symbols versions according to Solaris or GNU rules. |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2076 |
*/ |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2077 |
/*ARGSUSED*/ |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2078 |
static uintptr_t |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2079 |
process_dynamic_isgnu(const char *name, Ifl_desc *ifl, Shdr *shdr, |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2080 |
Elf_Scn *scn, Word ndx, int ident, Ofl_desc *ofl) |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2081 |
{ |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2082 |
Dyn *dyn; |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2083 |
Elf_Data *dp; |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2084 |
uintptr_t error; |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2085 |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2086 |
error = process_section(name, ifl, shdr, scn, ndx, ident, ofl); |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2087 |
if ((error == 0) || (error == S_ERROR)) |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2088 |
return (error); |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2089 |
|
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2090 |
/* Get the .dynamic data */ |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2091 |
dp = elf_getdata(scn, NULL); |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2092 |
|
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2093 |
for (dyn = (Dyn *)dp->d_buf; dyn->d_tag != DT_NULL; dyn++) { |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2094 |
if (dyn->d_tag == DT_VERSYM) { |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2095 |
ifl->ifl_flags |= FLG_IF_GNUVER; |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2096 |
break; |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2097 |
} |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2098 |
} |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2099 |
return (1); |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2100 |
} |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2101 |
|
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2102 |
/* |
0 | 2103 |
* Process a dynamic section. If we are processing an explicit shared object |
2104 |
* then we need to determine if it has a recorded SONAME, if so, this name will |
|
2105 |
* be recorded in the output file being generated as the NEEDED entry rather |
|
2106 |
* than the shared objects filename itself. |
|
2107 |
* If the mode of the link-edit indicates that no undefined symbols should |
|
2108 |
* remain, then we also need to build up a list of any additional shared object |
|
2109 |
* dependencies this object may have. In this case save any NEEDED entries |
|
2110 |
* together with any associated run-path specifications. This information is |
|
2111 |
* recorded on the `ofl_soneed' list and will be analyzed after all explicit |
|
2112 |
* file processing has been completed (refer finish_libs()). |
|
2113 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2114 |
static uintptr_t |
0 | 2115 |
process_dynamic(Is_desc *isc, Ifl_desc *ifl, Ofl_desc *ofl) |
2116 |
{ |
|
2117 |
Dyn *data, *dyn; |
|
2118 |
char *str, *rpath = NULL; |
|
2119 |
const char *soname, *needed; |
|
2120 |
||
2121 |
data = (Dyn *)isc->is_indata->d_buf; |
|
2122 |
str = (char *)ifl->ifl_isdesc[isc->is_shdr->sh_link]->is_indata->d_buf; |
|
2123 |
||
2124 |
/* |
|
2125 |
* First loop through the dynamic section looking for a run path. |
|
2126 |
*/ |
|
2127 |
if (ofl->ofl_flags & (FLG_OF_NOUNDEF | FLG_OF_SYMBOLIC)) { |
|
2128 |
for (dyn = data; dyn->d_tag != DT_NULL; dyn++) { |
|
2129 |
if ((dyn->d_tag != DT_RPATH) && |
|
2130 |
(dyn->d_tag != DT_RUNPATH)) |
|
2131 |
continue; |
|
2132 |
if ((rpath = str + (size_t)dyn->d_un.d_val) == NULL) |
|
2133 |
continue; |
|
2134 |
break; |
|
2135 |
} |
|
2136 |
} |
|
2137 |
||
2138 |
/* |
|
2139 |
* Now look for any needed dependencies (which may use the rpath) |
|
2140 |
* or a new SONAME. |
|
2141 |
*/ |
|
2142 |
for (dyn = data; dyn->d_tag != DT_NULL; dyn++) { |
|
2143 |
if (dyn->d_tag == DT_SONAME) { |
|
2144 |
if ((soname = str + (size_t)dyn->d_un.d_val) == NULL) |
|
2145 |
continue; |
|
2146 |
||
2147 |
/* |
|
2148 |
* Update the input file structure with this new name. |
|
2149 |
*/ |
|
2150 |
ifl->ifl_soname = soname; |
|
2151 |
||
2152 |
} else if ((dyn->d_tag == DT_NEEDED) || |
|
2153 |
(dyn->d_tag == DT_USED)) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2154 |
Sdf_desc *sdf; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2155 |
|
0 | 2156 |
if (!(ofl->ofl_flags & |
2157 |
(FLG_OF_NOUNDEF | FLG_OF_SYMBOLIC))) |
|
2158 |
continue; |
|
2159 |
if ((needed = str + (size_t)dyn->d_un.d_val) == NULL) |
|
2160 |
continue; |
|
2161 |
||
2162 |
/* |
|
2163 |
* Determine if this needed entry is already recorded on |
|
2164 |
* the shared object needed list, if not create a new |
|
2165 |
* definition for later processing (see finish_libs()). |
|
2166 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2167 |
needed = expand(ifl->ifl_name, needed, NULL); |
0 | 2168 |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2169 |
if ((sdf = sdf_find(needed, ofl->ofl_soneed)) == NULL) { |
0 | 2170 |
if ((sdf = sdf_add(needed, |
2171 |
&ofl->ofl_soneed)) == (Sdf_desc *)S_ERROR) |
|
2172 |
return (S_ERROR); |
|
2173 |
sdf->sdf_rfile = ifl->ifl_name; |
|
2174 |
} |
|
2175 |
||
2176 |
/* |
|
2177 |
* Record the runpath (Note that we take the first |
|
2178 |
* runpath which is exactly what ld.so.1 would do during |
|
2179 |
* its dependency processing). |
|
2180 |
*/ |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
2181 |
if (rpath && (sdf->sdf_rpath == NULL)) |
0 | 2182 |
sdf->sdf_rpath = rpath; |
2183 |
||
2184 |
} else if (dyn->d_tag == DT_FLAGS_1) { |
|
2185 |
if (dyn->d_un.d_val & (DF_1_INITFIRST | DF_1_INTERPOSE)) |
|
2186 |
ifl->ifl_flags &= ~FLG_IF_LAZYLD; |
|
2187 |
if (dyn->d_un.d_val & DF_1_DISPRELPND) |
|
2188 |
ifl->ifl_flags |= FLG_IF_DISPPEND; |
|
2189 |
if (dyn->d_un.d_val & DF_1_DISPRELDNE) |
|
2190 |
ifl->ifl_flags |= FLG_IF_DISPDONE; |
|
2191 |
if (dyn->d_un.d_val & DF_1_NODIRECT) |
|
2192 |
ifl->ifl_flags |= FLG_IF_NODIRECT; |
|
2193 |
||
2194 |
} else if ((dyn->d_tag == DT_AUDIT) && |
|
2195 |
(ifl->ifl_flags & FLG_IF_NEEDED)) { |
|
2196 |
/* |
|
2197 |
* Record audit string as DT_DEPAUDIT. |
|
2198 |
*/ |
|
2199 |
if ((ofl->ofl_depaudit = add_string(ofl->ofl_depaudit, |
|
2200 |
(str + (size_t)dyn->d_un.d_val))) == |
|
2201 |
(const char *)S_ERROR) |
|
2202 |
return (S_ERROR); |
|
2203 |
||
2204 |
} else if (dyn->d_tag == DT_SUNW_RTLDINF) { |
|
2205 |
/* |
|
12449
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
2206 |
* If this dependency has the DT_SUNW_RTLDINF .dynamic |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
2207 |
* entry, then ensure no specialized dependency |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
2208 |
* processing is in effect. This tag identifies libc, |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
2209 |
* which provides critical startup information (TLS |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
2210 |
* routines, threads initialization, etc.) that must |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
2211 |
* be exercised as part of process initialization. |
0 | 2212 |
*/ |
12449
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
2213 |
ifl->ifl_flags &= ~MSK_IF_POSFLAG1; |
0 | 2214 |
} |
2215 |
} |
|
2216 |
||
2217 |
/* |
|
2218 |
* Perform some SONAME sanity checks. |
|
2219 |
*/ |
|
2220 |
if (ifl->ifl_flags & FLG_IF_NEEDED) { |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2221 |
Ifl_desc *sifl; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2222 |
Aliste idx; |
0 | 2223 |
|
2224 |
/* |
|
2225 |
* Determine if anyone else will cause the same SONAME to be |
|
2226 |
* used (this is either caused by two different files having the |
|
2227 |
* same SONAME, or by one file SONAME actually matching another |
|
2228 |
* file basename (if no SONAME is specified within a shared |
|
2229 |
* library its basename will be used)). Probably rare, but some |
|
2230 |
* idiot will do it. |
|
2231 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2232 |
for (APLIST_TRAVERSE(ofl->ofl_sos, idx, sifl)) { |
0 | 2233 |
if ((strcmp(ifl->ifl_soname, sifl->ifl_soname) == 0) && |
2234 |
(ifl != sifl)) { |
|
2235 |
const char *hint, *iflb, *siflb; |
|
2236 |
||
2237 |
/* |
|
2238 |
* Determine the basename of each file. Perhaps |
|
2239 |
* there are multiple copies of the same file |
|
2240 |
* being brought in using different -L search |
|
2241 |
* paths, and if so give an extra hint in the |
|
2242 |
* error message. |
|
2243 |
*/ |
|
2244 |
iflb = strrchr(ifl->ifl_name, '/'); |
|
2245 |
if (iflb == NULL) |
|
2246 |
iflb = ifl->ifl_name; |
|
2247 |
else |
|
2248 |
iflb++; |
|
2249 |
||
2250 |
siflb = strrchr(sifl->ifl_name, '/'); |
|
2251 |
if (siflb == NULL) |
|
2252 |
siflb = sifl->ifl_name; |
|
2253 |
else |
|
2254 |
siflb++; |
|
2255 |
||
2256 |
if (strcmp(iflb, siflb) == 0) |
|
2257 |
hint = MSG_INTL(MSG_REC_CNFLTHINT); |
|
2258 |
else |
|
2259 |
hint = MSG_ORIG(MSG_STR_EMPTY); |
|
2260 |
||
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2261 |
eprintf(ofl->ofl_lml, ERR_FATAL, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2262 |
MSG_INTL(MSG_REC_OBJCNFLT), sifl->ifl_name, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2263 |
ifl->ifl_name, sifl->ifl_soname, hint); |
0 | 2264 |
ofl->ofl_flags |= FLG_OF_FATAL; |
2265 |
return (0); |
|
2266 |
} |
|
2267 |
} |
|
2268 |
||
2269 |
/* |
|
2270 |
* If the SONAME is the same as the name the user wishes to |
|
2271 |
* record when building a dynamic library (refer -h option), |
|
2272 |
* we also have a name clash. |
|
2273 |
*/ |
|
2274 |
if (ofl->ofl_soname && |
|
2275 |
(strcmp(ofl->ofl_soname, ifl->ifl_soname) == 0)) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2276 |
eprintf(ofl->ofl_lml, ERR_FATAL, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2277 |
MSG_INTL(MSG_REC_OPTCNFLT), ifl->ifl_name, |
7983
4c593ea9ad3a
6748160 problem with -zrescan
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7833
diff
changeset
|
2278 |
MSG_INTL(MSG_MARG_SONAME), ifl->ifl_soname); |
0 | 2279 |
ofl->ofl_flags |= FLG_OF_FATAL; |
2280 |
return (0); |
|
2281 |
} |
|
2282 |
} |
|
2283 |
return (1); |
|
2284 |
} |
|
2285 |
||
2286 |
/* |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2287 |
* Process a progbits section from a relocatable object (ET_REL). |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2288 |
* This is used on non-amd64 objects to recognize .eh_frame sections. |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2289 |
*/ |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2290 |
/*ARGSUSED1*/ |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2291 |
static uintptr_t |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2292 |
process_progbits_final(Is_desc *isc, Ifl_desc *ifl, Ofl_desc *ofl) |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2293 |
{ |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2294 |
if (isc->is_osdesc && (isc->is_flags & FLG_IS_EHFRAME) && |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2295 |
(ld_unwind_register(isc->is_osdesc, ofl) == S_ERROR)) |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2296 |
return (S_ERROR); |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2297 |
|
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2298 |
return (1); |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2299 |
} |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2300 |
|
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2301 |
/* |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2302 |
* Process a group section. |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2303 |
*/ |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2304 |
static uintptr_t |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2305 |
process_group(const char *name, Ifl_desc *ifl, Shdr *shdr, Elf_Scn *scn, |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2306 |
Word ndx, int ident, Ofl_desc *ofl) |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2307 |
{ |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2308 |
uintptr_t error; |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2309 |
|
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2310 |
error = process_section(name, ifl, shdr, scn, ndx, ident, ofl); |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2311 |
if ((error == 0) || (error == S_ERROR)) |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2312 |
return (error); |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2313 |
|
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2314 |
/* |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2315 |
* Indicate that this input file has groups to process. Groups are |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2316 |
* processed after all input sections have been processed. |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2317 |
*/ |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2318 |
ifl->ifl_flags |= FLG_IS_GROUPS; |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2319 |
|
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2320 |
return (1); |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2321 |
} |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2322 |
|
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2323 |
/* |
0 | 2324 |
* Process a relocation entry. At this point all input sections from this |
2325 |
* input file have been assigned an input section descriptor which is saved |
|
2326 |
* in the `ifl_isdesc' array. |
|
2327 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2328 |
static uintptr_t |
0 | 2329 |
rel_process(Is_desc *isc, Ifl_desc *ifl, Ofl_desc *ofl) |
2330 |
{ |
|
2331 |
Word rndx; |
|
2332 |
Is_desc *risc; |
|
2333 |
Os_desc *osp; |
|
2334 |
Shdr *shdr = isc->is_shdr; |
|
4734
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
2335 |
Conv_inv_buf_t inv_buf; |
0 | 2336 |
|
2337 |
/* |
|
2338 |
* Make sure this is a valid relocation we can handle. |
|
2339 |
*/ |
|
6206 | 2340 |
if (shdr->sh_type != ld_targ.t_m.m_rel_sht_type) { |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2341 |
eprintf(ofl->ofl_lml, ERR_FATAL, MSG_INTL(MSG_FIL_INVALSEC), |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
2342 |
ifl->ifl_name, EC_WORD(isc->is_scnndx), isc->is_name, |
9273
9a0603d78ad3
6821619 Solaris linkers need systematic approach to ELF OSABI
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9131
diff
changeset
|
2343 |
conv_sec_type(ifl->ifl_ehdr->e_ident[EI_OSABI], |
9a0603d78ad3
6821619 Solaris linkers need systematic approach to ELF OSABI
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9131
diff
changeset
|
2344 |
ifl->ifl_ehdr->e_machine, shdr->sh_type, 0, &inv_buf)); |
0 | 2345 |
ofl->ofl_flags |= FLG_OF_FATAL; |
2346 |
return (0); |
|
2347 |
} |
|
2348 |
||
2349 |
/* |
|
2350 |
* From the relocation section header information determine which |
|
2351 |
* section needs the actual relocation. Determine which output section |
|
2352 |
* this input section has been assigned to and add to its relocation |
|
2353 |
* list. Note that the relocation section may be null if it is not |
|
2354 |
* required (ie. .debug, .stabs, etc). |
|
2355 |
*/ |
|
2356 |
rndx = shdr->sh_info; |
|
2357 |
if (rndx >= ifl->ifl_shnum) { |
|
2358 |
/* |
|
2359 |
* Broken input file. |
|
2360 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2361 |
eprintf(ofl->ofl_lml, ERR_FATAL, MSG_INTL(MSG_FIL_INVSHINFO), |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
2362 |
ifl->ifl_name, EC_WORD(isc->is_scnndx), isc->is_name, |
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
2363 |
EC_XWORD(rndx)); |
0 | 2364 |
ofl->ofl_flags |= FLG_OF_FATAL; |
2365 |
return (0); |
|
2366 |
} |
|
2367 |
if (rndx == 0) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2368 |
if (aplist_append(&ofl->ofl_extrarels, isc, |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2369 |
AL_CNT_OFL_RELS) == NULL) |
0 | 2370 |
return (S_ERROR); |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2371 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2372 |
} else if ((risc = ifl->ifl_isdesc[rndx]) != NULL) { |
0 | 2373 |
/* |
2374 |
* Discard relocations if they are against a section |
|
2375 |
* which has been discarded. |
|
2376 |
*/ |
|
2377 |
if (risc->is_flags & FLG_IS_DISCARD) |
|
2378 |
return (1); |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2379 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2380 |
if ((osp = risc->is_osdesc) == NULL) { |
0 | 2381 |
if (risc->is_shdr->sh_type == SHT_SUNW_move) { |
2382 |
/* |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2383 |
* This section is processed later in |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2384 |
* process_movereloc(). |
0 | 2385 |
*/ |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2386 |
if (aplist_append(&ofl->ofl_ismoverel, |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2387 |
isc, AL_CNT_OFL_MOVE) == NULL) |
0 | 2388 |
return (S_ERROR); |
2389 |
return (1); |
|
2390 |
} |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2391 |
eprintf(ofl->ofl_lml, ERR_FATAL, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2392 |
MSG_INTL(MSG_FIL_INVRELOC1), ifl->ifl_name, |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
2393 |
EC_WORD(isc->is_scnndx), isc->is_name, |
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
2394 |
EC_WORD(risc->is_scnndx), risc->is_name); |
0 | 2395 |
return (0); |
2396 |
} |
|
8608
9719dcedb8a3
6792836 ld is slow when processing GNU linkonce sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8598
diff
changeset
|
2397 |
if (aplist_append(&osp->os_relisdescs, isc, |
9719dcedb8a3
6792836 ld is slow when processing GNU linkonce sections
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8598
diff
changeset
|
2398 |
AL_CNT_OS_RELISDESCS) == NULL) |
0 | 2399 |
return (S_ERROR); |
2400 |
} |
|
2401 |
return (1); |
|
2402 |
} |
|
2403 |
||
2404 |
/* |
|
2405 |
* SHF_EXCLUDE flags is set for this section. |
|
2406 |
*/ |
|
2407 |
static uintptr_t |
|
2408 |
process_exclude(const char *name, Ifl_desc *ifl, Shdr *shdr, Elf_Scn *scn, |
|
2409 |
Word ndx, Ofl_desc *ofl) |
|
2410 |
{ |
|
2411 |
/* |
|
2412 |
* Sections SHT_SYMTAB and SHT_DYNDYM, even if SHF_EXCLUDE is on, might |
|
2413 |
* be needed for ld processing. These sections need to be in the |
|
2414 |
* internal table. Later it will be determined whether they can be |
|
2415 |
* eliminated or not. |
|
2416 |
*/ |
|
2417 |
if (shdr->sh_type == SHT_SYMTAB || shdr->sh_type == SHT_DYNSYM) |
|
2418 |
return (0); |
|
2419 |
||
2420 |
/* |
|
2421 |
* Other checks |
|
2422 |
*/ |
|
2423 |
if (shdr->sh_flags & SHF_ALLOC) { |
|
2424 |
/* |
|
2425 |
* A conflict, issue an warning message, and ignore the section. |
|
2426 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2427 |
eprintf(ofl->ofl_lml, ERR_WARNING, MSG_INTL(MSG_FIL_EXCLUDE), |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
2428 |
ifl->ifl_name, EC_WORD(ndx), name); |
0 | 2429 |
return (0); |
2430 |
} |
|
2431 |
||
2432 |
/* |
|
2433 |
* This sections is not going to the output file. |
|
2434 |
*/ |
|
2435 |
return (process_section(name, ifl, shdr, scn, ndx, 0, ofl)); |
|
2436 |
} |
|
2437 |
||
2438 |
/* |
|
2439 |
* Section processing state table. `Initial' describes the required initial |
|
2440 |
* procedure to be called (if any), `Final' describes the final processing |
|
2441 |
* procedure (ie. things that can only be done when all required sections |
|
2442 |
* have been collected). |
|
2443 |
*/ |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2444 |
typedef uintptr_t (* initial_func_t)(const char *, Ifl_desc *, Shdr *, |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2445 |
Elf_Scn *, Word, int, Ofl_desc *); |
0 | 2446 |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2447 |
static initial_func_t Initial[SHT_NUM][2] = { |
0 | 2448 |
/* ET_REL ET_DYN */ |
2449 |
||
2450 |
/* SHT_NULL */ invalid_section, invalid_section, |
|
2451 |
/* SHT_PROGBITS */ process_progbits, process_progbits, |
|
2452 |
/* SHT_SYMTAB */ process_input, process_input, |
|
2453 |
/* SHT_STRTAB */ process_strtab, process_strtab, |
|
2454 |
/* SHT_RELA */ process_reloc, process_reloc, |
|
2455 |
/* SHT_HASH */ invalid_section, NULL, |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
2456 |
/* SHT_DYNAMIC */ process_rel_dynamic, process_dynamic_isgnu, |
0 | 2457 |
/* SHT_NOTE */ process_section, NULL, |
2458 |
/* SHT_NOBITS */ process_nobits, process_nobits, |
|
2459 |
/* SHT_REL */ process_reloc, process_reloc, |
|
2460 |
/* SHT_SHLIB */ process_section, invalid_section, |
|
2461 |
/* SHT_DYNSYM */ invalid_section, process_input, |
|
2462 |
/* SHT_UNKNOWN12 */ process_progbits, process_progbits, |
|
2463 |
/* SHT_UNKNOWN13 */ process_progbits, process_progbits, |
|
2464 |
/* SHT_INIT_ARRAY */ process_array, NULL, |
|
2465 |
/* SHT_FINI_ARRAY */ process_array, NULL, |
|
2466 |
/* SHT_PREINIT_ARRAY */ process_array, NULL, |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2467 |
/* SHT_GROUP */ process_group, invalid_section, |
0 | 2468 |
/* SHT_SYMTAB_SHNDX */ process_sym_shndx, NULL |
2469 |
}; |
|
2470 |
||
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2471 |
typedef uintptr_t (* final_func_t)(Is_desc *, Ifl_desc *, Ofl_desc *); |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2472 |
|
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2473 |
static final_func_t Final[SHT_NUM][2] = { |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2474 |
/* ET_REL ET_DYN */ |
0 | 2475 |
|
2476 |
/* SHT_NULL */ NULL, NULL, |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2477 |
/* SHT_PROGBITS */ process_progbits_final, NULL, |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2478 |
/* SHT_SYMTAB */ ld_sym_process, ld_sym_process, |
0 | 2479 |
/* SHT_STRTAB */ NULL, NULL, |
2480 |
/* SHT_RELA */ rel_process, NULL, |
|
2481 |
/* SHT_HASH */ NULL, NULL, |
|
2482 |
/* SHT_DYNAMIC */ NULL, process_dynamic, |
|
2483 |
/* SHT_NOTE */ NULL, NULL, |
|
2484 |
/* SHT_NOBITS */ NULL, NULL, |
|
2485 |
/* SHT_REL */ rel_process, NULL, |
|
2486 |
/* SHT_SHLIB */ NULL, NULL, |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2487 |
/* SHT_DYNSYM */ NULL, ld_sym_process, |
0 | 2488 |
/* SHT_UNKNOWN12 */ NULL, NULL, |
2489 |
/* SHT_UNKNOWN13 */ NULL, NULL, |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2490 |
/* SHT_INIT_ARRAY */ array_process, NULL, |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2491 |
/* SHT_FINI_ARRAY */ array_process, NULL, |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2492 |
/* SHT_PREINIT_ARRAY */ array_process, NULL, |
0 | 2493 |
/* SHT_GROUP */ NULL, NULL, |
2494 |
/* SHT_SYMTAB_SHNDX */ sym_shndx_process, NULL |
|
2495 |
}; |
|
2496 |
||
2497 |
#define MAXNDXSIZE 10 |
|
2498 |
||
2499 |
/* |
|
2500 |
* Process an elf file. Each section is compared against the section state |
|
2501 |
* table to determine whether it should be processed (saved), ignored, or |
|
2502 |
* is invalid for the type of input file being processed. |
|
2503 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2504 |
static uintptr_t |
0 | 2505 |
process_elf(Ifl_desc *ifl, Elf *elf, Ofl_desc *ofl) |
2506 |
{ |
|
2507 |
Elf_Scn *scn; |
|
2508 |
Shdr *shdr; |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2509 |
Word ndx, sndx, ordndx = 0, ordcnt = 0; |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
2510 |
char *str, *name; |
0 | 2511 |
Word row, column; |
2512 |
int ident; |
|
2513 |
uintptr_t error; |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2514 |
Is_desc *vdfisp, *vndisp, *vsyisp, *sifisp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2515 |
Is_desc *capinfoisp, *capisp; |
0 | 2516 |
Sdf_desc *sdf; |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
2517 |
Place_path_info path_info_buf, *path_info; |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
2518 |
|
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
2519 |
/* |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
2520 |
* Path information buffer used by ld_place_section() and related |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
2521 |
* routines. This information is used to evaluate entrance criteria |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
2522 |
* with non-empty file matching lists (ec_files). |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
2523 |
*/ |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
2524 |
path_info = ld_place_path_info_init(ofl, ifl, &path_info_buf); |
0 | 2525 |
|
2526 |
/* |
|
2527 |
* First process the .shstrtab section so that later sections can |
|
2528 |
* reference their name. |
|
2529 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2530 |
ld_sup_file(ofl, ifl->ifl_name, elf_kind(elf), ifl->ifl_flags, elf); |
0 | 2531 |
|
2532 |
sndx = ifl->ifl_shstrndx; |
|
2533 |
if ((scn = elf_getscn(elf, (size_t)sndx)) == NULL) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2534 |
eprintf(ofl->ofl_lml, ERR_ELF, MSG_INTL(MSG_ELF_GETSCN), |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2535 |
ifl->ifl_name); |
0 | 2536 |
ofl->ofl_flags |= FLG_OF_FATAL; |
2537 |
return (0); |
|
2538 |
} |
|
2539 |
if ((shdr = elf_getshdr(scn)) == NULL) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2540 |
eprintf(ofl->ofl_lml, ERR_ELF, MSG_INTL(MSG_ELF_GETSHDR), |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2541 |
ifl->ifl_name); |
0 | 2542 |
ofl->ofl_flags |= FLG_OF_FATAL; |
2543 |
return (0); |
|
2544 |
} |
|
2545 |
if ((name = elf_strptr(elf, (size_t)sndx, (size_t)shdr->sh_name)) == |
|
2546 |
NULL) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2547 |
eprintf(ofl->ofl_lml, ERR_ELF, MSG_INTL(MSG_ELF_STRPTR), |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2548 |
ifl->ifl_name); |
0 | 2549 |
ofl->ofl_flags |= FLG_OF_FATAL; |
2550 |
return (0); |
|
2551 |
} |
|
2552 |
||
2647 | 2553 |
if (ld_sup_input_section(ofl, ifl, name, &shdr, sndx, scn, |
2554 |
elf) == S_ERROR) |
|
0 | 2555 |
return (S_ERROR); |
2556 |
||
2557 |
/* |
|
2558 |
* Reset the name since the shdr->sh_name could have been changed as |
|
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
2559 |
* part of ld_sup_input_section(). |
0 | 2560 |
*/ |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
2561 |
if ((name = elf_strptr(elf, (size_t)sndx, (size_t)shdr->sh_name)) == |
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
2562 |
NULL) { |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2563 |
eprintf(ofl->ofl_lml, ERR_ELF, MSG_INTL(MSG_ELF_STRPTR), |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2564 |
ifl->ifl_name); |
0 | 2565 |
ofl->ofl_flags |= FLG_OF_FATAL; |
2566 |
return (0); |
|
2567 |
} |
|
2568 |
||
2569 |
error = process_strtab(name, ifl, shdr, scn, sndx, FALSE, ofl); |
|
2570 |
if ((error == 0) || (error == S_ERROR)) |
|
2571 |
return (error); |
|
2572 |
str = ifl->ifl_isdesc[sndx]->is_indata->d_buf; |
|
2573 |
||
2574 |
/* |
|
2575 |
* Determine the state table column from the input file type. Note, |
|
2576 |
* shared library sections are not added to the output section list. |
|
2577 |
*/ |
|
2578 |
if (ifl->ifl_ehdr->e_type == ET_DYN) { |
|
2579 |
column = 1; |
|
2580 |
ofl->ofl_soscnt++; |
|
6206 | 2581 |
ident = ld_targ.t_id.id_null; |
0 | 2582 |
} else { |
2583 |
column = 0; |
|
2584 |
ofl->ofl_objscnt++; |
|
6206 | 2585 |
ident = ld_targ.t_id.id_unknown; |
0 | 2586 |
} |
2587 |
||
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2588 |
DBG_CALL(Dbg_file_generic(ofl->ofl_lml, ifl)); |
0 | 2589 |
ndx = 0; |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2590 |
vdfisp = vndisp = vsyisp = sifisp = capinfoisp = capisp = NULL; |
0 | 2591 |
scn = NULL; |
2592 |
while (scn = elf_nextscn(elf, scn)) { |
|
2593 |
ndx++; |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2594 |
|
0 | 2595 |
/* |
2596 |
* As we've already processed the .shstrtab don't do it again. |
|
2597 |
*/ |
|
2598 |
if (ndx == sndx) |
|
2599 |
continue; |
|
2600 |
||
2601 |
if ((shdr = elf_getshdr(scn)) == NULL) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2602 |
eprintf(ofl->ofl_lml, ERR_ELF, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2603 |
MSG_INTL(MSG_ELF_GETSHDR), ifl->ifl_name); |
0 | 2604 |
ofl->ofl_flags |= FLG_OF_FATAL; |
2605 |
return (0); |
|
2606 |
} |
|
2607 |
name = str + (size_t)(shdr->sh_name); |
|
2608 |
||
2647 | 2609 |
if (ld_sup_input_section(ofl, ifl, name, &shdr, ndx, scn, |
2610 |
elf) == S_ERROR) |
|
0 | 2611 |
return (S_ERROR); |
2612 |
||
2613 |
/* |
|
2614 |
* Reset the name since the shdr->sh_name could have been |
|
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
2615 |
* changed as part of ld_sup_input_section(). |
0 | 2616 |
*/ |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
2617 |
name = str + (size_t)(shdr->sh_name); |
0 | 2618 |
|
2619 |
row = shdr->sh_type; |
|
2620 |
||
2621 |
/* |
|
2622 |
* If the section has the SHF_EXCLUDE flag on, and we're not |
|
2623 |
* generating a relocatable object, exclude the section. |
|
2624 |
*/ |
|
2625 |
if (((shdr->sh_flags & SHF_EXCLUDE) != 0) && |
|
2626 |
((ofl->ofl_flags & FLG_OF_RELOBJ) == 0)) { |
|
2627 |
if ((error = process_exclude(name, ifl, shdr, scn, |
|
2628 |
ndx, ofl)) == S_ERROR) |
|
2629 |
return (S_ERROR); |
|
2630 |
if (error == 1) |
|
2631 |
continue; |
|
2632 |
} |
|
2633 |
||
2634 |
/* |
|
2635 |
* If this is a standard section type process it via the |
|
2636 |
* appropriate action routine. |
|
2637 |
*/ |
|
2638 |
if (row < SHT_NUM) { |
|
2639 |
if (Initial[row][column] != NULL) { |
|
2640 |
if (Initial[row][column](name, ifl, shdr, scn, |
|
2641 |
ndx, ident, ofl) == S_ERROR) |
|
2642 |
return (S_ERROR); |
|
2643 |
} |
|
2644 |
} else { |
|
2645 |
/* |
|
2646 |
* If this section is below SHT_LOSUNW then we don't |
|
2647 |
* really know what to do with it, issue a warning |
|
2648 |
* message but do the basic section processing anyway. |
|
2649 |
*/ |
|
4734
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
2650 |
if (row < (Word)SHT_LOSUNW) { |
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
2651 |
Conv_inv_buf_t inv_buf; |
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
2652 |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2653 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2654 |
MSG_INTL(MSG_FIL_INVALSEC), ifl->ifl_name, |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
2655 |
EC_WORD(ndx), name, conv_sec_type( |
9273
9a0603d78ad3
6821619 Solaris linkers need systematic approach to ELF OSABI
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9131
diff
changeset
|
2656 |
ifl->ifl_ehdr->e_ident[EI_OSABI], |
9a0603d78ad3
6821619 Solaris linkers need systematic approach to ELF OSABI
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9131
diff
changeset
|
2657 |
ifl->ifl_ehdr->e_machine, |
4734
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
2658 |
shdr->sh_type, 0, &inv_buf)); |
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
2659 |
} |
0 | 2660 |
|
2661 |
/* |
|
2662 |
* Handle sections greater than SHT_LOSUNW. |
|
2663 |
*/ |
|
2664 |
switch (row) { |
|
2665 |
case SHT_SUNW_dof: |
|
2666 |
if (process_section(name, ifl, shdr, scn, |
|
2667 |
ndx, ident, ofl) == S_ERROR) |
|
2668 |
return (S_ERROR); |
|
2669 |
break; |
|
2670 |
case SHT_SUNW_cap: |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2671 |
if (process_section(name, ifl, shdr, scn, ndx, |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2672 |
ld_targ.t_id.id_null, ofl) == S_ERROR) |
0 | 2673 |
return (S_ERROR); |
2674 |
capisp = ifl->ifl_isdesc[ndx]; |
|
2675 |
break; |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2676 |
case SHT_SUNW_capinfo: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2677 |
if (process_section(name, ifl, shdr, scn, ndx, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2678 |
ld_targ.t_id.id_null, ofl) == S_ERROR) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2679 |
return (S_ERROR); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2680 |
capinfoisp = ifl->ifl_isdesc[ndx]; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2681 |
break; |
0 | 2682 |
case SHT_SUNW_DEBUGSTR: |
2683 |
case SHT_SUNW_DEBUG: |
|
2684 |
if (process_debug(name, ifl, shdr, scn, |
|
2685 |
ndx, ident, ofl) == S_ERROR) |
|
2686 |
return (S_ERROR); |
|
2687 |
break; |
|
2688 |
case SHT_SUNW_move: |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2689 |
if (process_section(name, ifl, shdr, scn, ndx, |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2690 |
ld_targ.t_id.id_null, ofl) == S_ERROR) |
0 | 2691 |
return (S_ERROR); |
2692 |
break; |
|
2693 |
case SHT_SUNW_syminfo: |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2694 |
if (process_section(name, ifl, shdr, scn, ndx, |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2695 |
ld_targ.t_id.id_null, ofl) == S_ERROR) |
0 | 2696 |
return (S_ERROR); |
2697 |
sifisp = ifl->ifl_isdesc[ndx]; |
|
2698 |
break; |
|
2699 |
case SHT_SUNW_ANNOTATE: |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2700 |
if (process_progbits(name, ifl, shdr, scn, |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2701 |
ndx, ident, ofl) == S_ERROR) |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2702 |
return (S_ERROR); |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2703 |
break; |
0 | 2704 |
case SHT_SUNW_COMDAT: |
2705 |
if (process_progbits(name, ifl, shdr, scn, |
|
2706 |
ndx, ident, ofl) == S_ERROR) |
|
2707 |
return (S_ERROR); |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2708 |
ifl->ifl_isdesc[ndx]->is_flags |= FLG_IS_COMDAT; |
0 | 2709 |
break; |
2710 |
case SHT_SUNW_verdef: |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2711 |
if (process_section(name, ifl, shdr, scn, ndx, |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2712 |
ld_targ.t_id.id_null, ofl) == S_ERROR) |
0 | 2713 |
return (S_ERROR); |
2714 |
vdfisp = ifl->ifl_isdesc[ndx]; |
|
2715 |
break; |
|
2716 |
case SHT_SUNW_verneed: |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2717 |
if (process_section(name, ifl, shdr, scn, ndx, |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2718 |
ld_targ.t_id.id_null, ofl) == S_ERROR) |
0 | 2719 |
return (S_ERROR); |
2720 |
vndisp = ifl->ifl_isdesc[ndx]; |
|
2721 |
break; |
|
2722 |
case SHT_SUNW_versym: |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2723 |
if (process_section(name, ifl, shdr, scn, ndx, |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2724 |
ld_targ.t_id.id_null, ofl) == S_ERROR) |
0 | 2725 |
return (S_ERROR); |
2726 |
vsyisp = ifl->ifl_isdesc[ndx]; |
|
2727 |
break; |
|
2728 |
case SHT_SPARC_GOTDATA: |
|
6206 | 2729 |
/* |
2730 |
* SHT_SPARC_GOTDATA (0x70000000) is in the |
|
2731 |
* SHT_LOPROC - SHT_HIPROC range reserved |
|
2732 |
* for processor-specific semantics. It is |
|
2733 |
* only meaningful for sparc targets. |
|
2734 |
*/ |
|
2735 |
if (ld_targ.t_m.m_mach != |
|
2736 |
LD_TARG_BYCLASS(EM_SPARC, EM_SPARCV9)) |
|
2737 |
goto do_default; |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2738 |
if (process_section(name, ifl, shdr, scn, ndx, |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2739 |
ld_targ.t_id.id_gotdata, ofl) == S_ERROR) |
0 | 2740 |
return (S_ERROR); |
2741 |
break; |
|
6206 | 2742 |
#if defined(_ELF64) |
0 | 2743 |
case SHT_AMD64_UNWIND: |
6206 | 2744 |
/* |
2745 |
* SHT_AMD64_UNWIND (0x70000001) is in the |
|
2746 |
* SHT_LOPROC - SHT_HIPROC range reserved |
|
2747 |
* for processor-specific semantics. It is |
|
2748 |
* only meaningful for amd64 targets. |
|
2749 |
*/ |
|
2750 |
if (ld_targ.t_m.m_mach != EM_AMD64) |
|
2751 |
goto do_default; |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2752 |
|
6206 | 2753 |
/* |
2754 |
* Target is x86, so this really is |
|
2755 |
* SHT_AMD64_UNWIND |
|
2756 |
*/ |
|
0 | 2757 |
if (column == 0) { |
2758 |
/* |
|
2759 |
* column == ET_REL |
|
2760 |
*/ |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2761 |
if (process_section(name, ifl, shdr, |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2762 |
scn, ndx, ld_targ.t_id.id_unwind, |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2763 |
ofl) == S_ERROR) |
0 | 2764 |
return (S_ERROR); |
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2765 |
ifl->ifl_isdesc[ndx]->is_flags |= |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2766 |
FLG_IS_EHFRAME; |
0 | 2767 |
} |
2768 |
break; |
|
2769 |
#endif |
|
2770 |
default: |
|
6206 | 2771 |
do_default: |
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2772 |
if (process_section(name, ifl, shdr, scn, ndx, |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2773 |
((ident == ld_targ.t_id.id_null) ? |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2774 |
ident : ld_targ.t_id.id_user), ofl) == |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2775 |
S_ERROR) |
0 | 2776 |
return (S_ERROR); |
2777 |
break; |
|
2778 |
} |
|
2779 |
} |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2780 |
} |
0 | 2781 |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2782 |
/* |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2783 |
* Now that all input sections have been analyzed, and prior to placing |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2784 |
* any input sections to their output sections, process any groups. |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2785 |
* Groups can contribute COMDAT items, which may get discarded as part |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2786 |
* of placement. In addition, COMDAT names may require transformation |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2787 |
* to indicate different output section placement. |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2788 |
*/ |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2789 |
if (ifl->ifl_flags & FLG_IS_GROUPS) { |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2790 |
for (ndx = 1; ndx < ifl->ifl_shnum; ndx++) { |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2791 |
Is_desc *isp; |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2792 |
|
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2793 |
if (((isp = ifl->ifl_isdesc[ndx]) == NULL) || |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2794 |
(isp->is_shdr->sh_type != SHT_GROUP)) |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2795 |
continue; |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2796 |
|
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2797 |
if (ld_group_process(isp, ofl) == S_ERROR) |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2798 |
return (S_ERROR); |
0 | 2799 |
} |
2800 |
} |
|
2801 |
||
2802 |
/* |
|
9615
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2803 |
* Now that all of the input sections have been processed, place |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2804 |
* them in the appropriate output sections. |
0 | 2805 |
*/ |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2806 |
for (ndx = 1; ndx < ifl->ifl_shnum; ndx++) { |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2807 |
Is_desc *isp; |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2808 |
|
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2809 |
if (((isp = ifl->ifl_isdesc[ndx]) == NULL) || |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2810 |
((isp->is_flags & FLG_IS_PLACE) == 0)) |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2811 |
continue; |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2812 |
|
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2813 |
/* |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2814 |
* Place all non-ordered sections within their appropriate |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2815 |
* output section. |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2816 |
*/ |
9615
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2817 |
if ((isp->is_flags & FLG_IS_ORDERED) == 0) { |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
2818 |
if (ld_place_section(ofl, isp, path_info, |
9615
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2819 |
isp->is_keyident, NULL) == (Os_desc *)S_ERROR) |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2820 |
return (S_ERROR); |
9615
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2821 |
continue; |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2822 |
} |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2823 |
|
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2824 |
/* |
9615
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2825 |
* Count the number of ordered sections and retain the first |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2826 |
* ordered section index. This will be used to optimize the |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2827 |
* ordered section loop that immediately follows this one. |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2828 |
*/ |
9615
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2829 |
ordcnt++; |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2830 |
if (ordndx == 0) |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2831 |
ordndx = ndx; |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2832 |
} |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2833 |
|
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2834 |
/* |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2835 |
* Having placed all the non-ordered sections, it is now |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2836 |
* safe to place SHF_ORDERED/SHF_LINK_ORDER sections. |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2837 |
*/ |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2838 |
if (ifl->ifl_flags & FLG_IF_ORDERED) { |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2839 |
for (ndx = ordndx; ndx < ifl->ifl_shnum; ndx++) { |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2840 |
Is_desc *isp; |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2841 |
|
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2842 |
if (((isp = ifl->ifl_isdesc[ndx]) == NULL) || |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2843 |
((isp->is_flags & |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2844 |
(FLG_IS_PLACE | FLG_IS_ORDERED)) != |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2845 |
(FLG_IS_PLACE | FLG_IS_ORDERED))) |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2846 |
continue; |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2847 |
|
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2848 |
/* ld_process_ordered() calls ld_place_section() */ |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
2849 |
if (ld_process_ordered(ofl, ifl, path_info, ndx) == |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
2850 |
S_ERROR) |
9615
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2851 |
return (S_ERROR); |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2852 |
|
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2853 |
/* If we've done them all, stop searching */ |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2854 |
if (--ordcnt == 0) |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2855 |
break; |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2856 |
} |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2857 |
} |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2858 |
|
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2859 |
/* |
9615
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2860 |
* If this is a shared object explicitly specified on the command |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2861 |
* line (as opposed to being a dependency of such an object), |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2862 |
* determine if the user has specified a control definition. This |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2863 |
* descriptor may specify which version definitions can be used |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2864 |
* from this object. It may also update the dependency to USED and |
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9406
diff
changeset
|
2865 |
* supply an alternative SONAME. |
0 | 2866 |
*/ |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
2867 |
sdf = NULL; |
0 | 2868 |
if (column && (ifl->ifl_flags & FLG_IF_NEEDED)) { |
2869 |
const char *base; |
|
2870 |
||
2871 |
/* |
|
2872 |
* Use the basename of the input file (typically this is the |
|
2873 |
* compilation environment name, ie. libfoo.so). |
|
2874 |
*/ |
|
2875 |
if ((base = strrchr(ifl->ifl_name, '/')) == NULL) |
|
2876 |
base = ifl->ifl_name; |
|
2877 |
else |
|
2878 |
base++; |
|
2879 |
||
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2880 |
if ((sdf = sdf_find(base, ofl->ofl_socntl)) != NULL) { |
0 | 2881 |
sdf->sdf_file = ifl; |
2882 |
ifl->ifl_sdfdesc = sdf; |
|
2883 |
} |
|
2884 |
} |
|
2885 |
||
2886 |
/* |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2887 |
* Before symbol processing, process any capabilities. Capabilities |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2888 |
* can reference a string table, which is why this processing is |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2889 |
* carried out after the initial section processing. Capabilities, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2890 |
* together with -z symbolcap, can require the conversion of global |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2891 |
* symbols to local symbols. |
0 | 2892 |
*/ |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2893 |
if (capisp && (process_cap(ofl, ifl, capisp) == S_ERROR)) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2894 |
return (S_ERROR); |
0 | 2895 |
|
2896 |
/* |
|
2897 |
* Process any version dependencies. These will establish shared object |
|
2898 |
* `needed' entries in the same manner as will be generated from the |
|
2899 |
* .dynamic's NEEDED entries. |
|
2900 |
*/ |
|
2901 |
if (vndisp && (ofl->ofl_flags & (FLG_OF_NOUNDEF | FLG_OF_SYMBOLIC))) |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2902 |
if (ld_vers_need_process(vndisp, ifl, ofl) == S_ERROR) |
0 | 2903 |
return (S_ERROR); |
2904 |
||
2905 |
/* |
|
2906 |
* Before processing any symbol resolution or relocations process any |
|
2907 |
* version sections. |
|
2908 |
*/ |
|
2909 |
if (vsyisp) |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2910 |
(void) ld_vers_sym_process(ofl->ofl_lml, vsyisp, ifl); |
0 | 2911 |
|
2912 |
if (ifl->ifl_versym && |
|
2913 |
(vdfisp || (sdf && (sdf->sdf_flags & FLG_SDF_SELECT)))) |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2914 |
if (ld_vers_def_process(vdfisp, ifl, ofl) == S_ERROR) |
0 | 2915 |
return (S_ERROR); |
2916 |
||
2917 |
/* |
|
2918 |
* Having collected the appropriate sections carry out any additional |
|
2919 |
* processing if necessary. |
|
2920 |
*/ |
|
2921 |
for (ndx = 0; ndx < ifl->ifl_shnum; ndx++) { |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2922 |
Is_desc *isp; |
0 | 2923 |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
2924 |
if ((isp = ifl->ifl_isdesc[ndx]) == NULL) |
0 | 2925 |
continue; |
2926 |
row = isp->is_shdr->sh_type; |
|
2927 |
||
2928 |
if ((isp->is_flags & FLG_IS_DISCARD) == 0) |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2929 |
ld_sup_section(ofl, isp->is_name, isp->is_shdr, ndx, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2930 |
isp->is_indata, elf); |
0 | 2931 |
|
2932 |
/* |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2933 |
* If this is a SHT_SUNW_move section from a relocatable file, |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2934 |
* keep track of the section for later processing. |
0 | 2935 |
*/ |
2936 |
if ((row == SHT_SUNW_move) && (column == 0)) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2937 |
if (aplist_append(&(ofl->ofl_ismove), isp, |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2938 |
AL_CNT_OFL_MOVE) == NULL) |
0 | 2939 |
return (S_ERROR); |
2940 |
} |
|
2941 |
||
2942 |
/* |
|
2943 |
* If this is a standard section type process it via the |
|
2944 |
* appropriate action routine. |
|
2945 |
*/ |
|
2946 |
if (row < SHT_NUM) { |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2947 |
if (Final[row][column] != NULL) { |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2948 |
if (Final[row][column](isp, ifl, |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2949 |
ofl) == S_ERROR) |
0 | 2950 |
return (S_ERROR); |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2951 |
} |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2952 |
#if defined(_ELF64) |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2953 |
} else if ((row == SHT_AMD64_UNWIND) && (column == 0)) { |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2954 |
Os_desc *osp = isp->is_osdesc; |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2955 |
|
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2956 |
/* |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2957 |
* SHT_AMD64_UNWIND (0x70000001) is in the SHT_LOPROC - |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2958 |
* SHT_HIPROC range reserved for processor-specific |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2959 |
* semantics, and is only meaningful for amd64 targets. |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2960 |
* |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2961 |
* Only process unwind contents from relocatable |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2962 |
* objects. |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2963 |
*/ |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2964 |
if (osp && (ld_targ.t_m.m_mach == EM_AMD64) && |
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8608
diff
changeset
|
2965 |
(ld_unwind_register(osp, ofl) == S_ERROR)) |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2966 |
return (S_ERROR); |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
2967 |
#endif |
0 | 2968 |
} |
2969 |
} |
|
2970 |
||
2971 |
/* |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2972 |
* Following symbol processing, if this relocatable object input file |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2973 |
* provides symbol capabilities, tag the associated symbols so that |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2974 |
* the symbols can be re-assigned to the new capabilities symbol |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2975 |
* section that will be created for the output file. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2976 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2977 |
if (capinfoisp && (ifl->ifl_ehdr->e_type == ET_REL) && |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2978 |
(process_capinfo(ofl, ifl, capinfoisp) == S_ERROR)) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2979 |
return (S_ERROR); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2980 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2981 |
/* |
0 | 2982 |
* After processing any symbol resolution, and if this dependency |
2983 |
* indicates it contains symbols that can't be directly bound to, |
|
2984 |
* set the symbols appropriately. |
|
2985 |
*/ |
|
2986 |
if (sifisp && ((ifl->ifl_flags & (FLG_IF_NEEDED | FLG_IF_NODIRECT)) == |
|
2987 |
(FLG_IF_NEEDED | FLG_IF_NODIRECT))) |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
2988 |
(void) ld_sym_nodirect(sifisp, ifl, ofl); |
0 | 2989 |
|
2990 |
return (1); |
|
2991 |
} |
|
2992 |
||
2993 |
/* |
|
2994 |
* Process the current input file. There are basically three types of files |
|
2995 |
* that come through here: |
|
2996 |
* |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
2997 |
* - files explicitly defined on the command line (ie. foo.o or bar.so), |
0 | 2998 |
* in this case only the `name' field is valid. |
2999 |
* |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
3000 |
* - libraries determined from the -l command line option (ie. -lbar), |
0 | 3001 |
* in this case the `soname' field contains the basename of the located |
3002 |
* file. |
|
3003 |
* |
|
3004 |
* Any shared object specified via the above two conventions must be recorded |
|
3005 |
* as a needed dependency. |
|
3006 |
* |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
3007 |
* - libraries specified as dependencies of those libraries already obtained |
0 | 3008 |
* via the command line (ie. bar.so has a DT_NEEDED entry of fred.so.1), |
3009 |
* in this case the `soname' field contains either a full pathname (if the |
|
3010 |
* needed entry contained a `/'), or the basename of the located file. |
|
3011 |
* These libraries are processed to verify symbol binding but are not |
|
3012 |
* recorded as dependencies of the output file being generated. |
|
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3013 |
* |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3014 |
* entry: |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3015 |
* name - File name |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3016 |
* soname - SONAME for needed sharable library, as described above |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3017 |
* fd - Open file descriptor |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3018 |
* elf - Open ELF handle |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3019 |
* flags - FLG_IF_ flags applicable to file |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3020 |
* ofl - Output file descriptor |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3021 |
* rej - Rejection descriptor used to record rejection reason |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3022 |
* ifl_ret - NULL, or address of pointer to receive reference to |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3023 |
* resulting input descriptor for file. If ifl_ret is non-NULL, |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3024 |
* the file cannot be an archive or it will be rejected. |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3025 |
* |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3026 |
* exit: |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3027 |
* If a error occurs in examining the file, S_ERROR is returned. |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3028 |
* If the file can be examined, but is not suitable, *rej is updated, |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3029 |
* and 0 is returned. If the file is acceptable, 1 is returned, and if |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3030 |
* ifl_ret is non-NULL, *ifl_ret is set to contain the pointer to the |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3031 |
* resulting input descriptor. |
0 | 3032 |
*/ |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3033 |
uintptr_t |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3034 |
ld_process_ifl(const char *name, const char *soname, int fd, Elf *elf, |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3035 |
Word flags, Ofl_desc *ofl, Rej_desc *rej, Ifl_desc **ifl_ret) |
0 | 3036 |
{ |
3037 |
Ifl_desc *ifl; |
|
3038 |
Ehdr *ehdr; |
|
3039 |
uintptr_t error = 0; |
|
3040 |
struct stat status; |
|
3041 |
Ar_desc *adp; |
|
3042 |
Rej_desc _rej; |
|
3043 |
||
3044 |
/* |
|
3045 |
* If this file was not extracted from an archive obtain its device |
|
3046 |
* information. This will be used to determine if the file has already |
|
3047 |
* been processed (rather than simply comparing filenames, the device |
|
3048 |
* information provides a quicker comparison and detects linked files). |
|
3049 |
*/ |
|
8598
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3050 |
if (fd && ((flags & FLG_IF_EXTRACT) == 0)) |
0 | 3051 |
(void) fstat(fd, &status); |
3052 |
else { |
|
3053 |
status.st_dev = 0; |
|
3054 |
status.st_ino = 0; |
|
3055 |
} |
|
3056 |
||
3057 |
switch (elf_kind(elf)) { |
|
3058 |
case ELF_K_AR: |
|
3059 |
/* |
|
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3060 |
* If the caller has supplied a non-NULL ifl_ret, then |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3061 |
* we cannot process archives, for there will be no |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3062 |
* input file descriptor for us to return. In this case, |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3063 |
* reject the attempt. |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3064 |
*/ |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3065 |
if (ifl_ret != NULL) { |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3066 |
_rej.rej_type = SGS_REJ_ARCHIVE; |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3067 |
_rej.rej_name = name; |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3068 |
DBG_CALL(Dbg_file_rejected(ofl->ofl_lml, &_rej, |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3069 |
ld_targ.t_m.m_mach)); |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3070 |
if (rej->rej_type == 0) { |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3071 |
*rej = _rej; |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3072 |
rej->rej_name = strdup(_rej.rej_name); |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3073 |
} |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3074 |
return (0); |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3075 |
} |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3076 |
|
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3077 |
/* |
0 | 3078 |
* Determine if we've already come across this archive file. |
3079 |
*/ |
|
3080 |
if (!(flags & FLG_IF_EXTRACT)) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3081 |
Aliste idx; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3082 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3083 |
for (APLIST_TRAVERSE(ofl->ofl_ars, idx, adp)) { |
0 | 3084 |
if ((adp->ad_stdev != status.st_dev) || |
3085 |
(adp->ad_stino != status.st_ino)) |
|
3086 |
continue; |
|
3087 |
||
3088 |
/* |
|
3089 |
* We've seen this file before so reuse the |
|
3090 |
* original archive descriptor and discard the |
|
7359
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3091 |
* new elf descriptor. Note that a file |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3092 |
* descriptor is unnecessary, as the file is |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3093 |
* already available in memory. |
0 | 3094 |
*/ |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3095 |
DBG_CALL(Dbg_file_reuse(ofl->ofl_lml, name, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3096 |
adp->ad_name)); |
0 | 3097 |
(void) elf_end(elf); |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3098 |
if (!ld_process_archive(name, -1, adp, ofl)) |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3099 |
return (S_ERROR); |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3100 |
return (1); |
0 | 3101 |
} |
3102 |
} |
|
3103 |
||
3104 |
/* |
|
3105 |
* As we haven't processed this file before establish a new |
|
3106 |
* archive descriptor. |
|
3107 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3108 |
adp = ld_ar_setup(name, elf, ofl); |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
3109 |
if ((adp == NULL) || (adp == (Ar_desc *)S_ERROR)) |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3110 |
return ((uintptr_t)adp); |
0 | 3111 |
adp->ad_stdev = status.st_dev; |
3112 |
adp->ad_stino = status.st_ino; |
|
3113 |
||
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3114 |
ld_sup_file(ofl, name, ELF_K_AR, flags, elf); |
0 | 3115 |
|
7359
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3116 |
/* |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3117 |
* Indicate that the ELF descriptor no longer requires a file |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3118 |
* descriptor by reading the entire file. The file is already |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3119 |
* read via the initial mmap(2) behind elf_begin(3elf), thus |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3120 |
* this operation is effectively a no-op. However, a side- |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3121 |
* effect is that the internal file descriptor, maintained in |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3122 |
* the ELF descriptor, is set to -1. This setting will not |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3123 |
* be compared with any file descriptor that is passed to |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3124 |
* elf_begin(), should this archive, or one of the archive |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3125 |
* members, be processed again from the command line or |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3126 |
* because of a -z rescan. |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3127 |
*/ |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3128 |
if (elf_cntl(elf, ELF_C_FDREAD) == -1) { |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3129 |
eprintf(ofl->ofl_lml, ERR_ELF, MSG_INTL(MSG_ELF_CNTL), |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3130 |
name); |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3131 |
ofl->ofl_flags |= FLG_OF_FATAL; |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3132 |
return (0); |
7359
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3133 |
} |
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3134 |
|
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3135 |
if (!ld_process_archive(name, -1, adp, ofl)) |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3136 |
return (S_ERROR); |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3137 |
return (1); |
0 | 3138 |
|
3139 |
case ELF_K_ELF: |
|
3140 |
/* |
|
3141 |
* Obtain the elf header so that we can determine what type of |
|
3142 |
* elf ELF_K_ELF file this is. |
|
3143 |
*/ |
|
3144 |
if ((ehdr = elf_getehdr(elf)) == NULL) { |
|
3145 |
int _class = gelf_getclass(elf); |
|
3146 |
||
3147 |
/* |
|
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3148 |
* This can fail for a number of reasons. Typically |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3149 |
* the object class is incorrect (ie. user is building |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3150 |
* 64-bit but managed to point at 32-bit libraries). |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3151 |
* Other ELF errors can include a truncated or corrupt |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3152 |
* file. Try to get the best error message possible. |
0 | 3153 |
*/ |
6206 | 3154 |
if (ld_targ.t_m.m_class != _class) { |
0 | 3155 |
_rej.rej_type = SGS_REJ_CLASS; |
3156 |
_rej.rej_info = (uint_t)_class; |
|
3157 |
} else { |
|
3158 |
_rej.rej_type = SGS_REJ_STR; |
|
3159 |
_rej.rej_str = elf_errmsg(-1); |
|
3160 |
} |
|
3161 |
_rej.rej_name = name; |
|
6206 | 3162 |
DBG_CALL(Dbg_file_rejected(ofl->ofl_lml, &_rej, |
3163 |
ld_targ.t_m.m_mach)); |
|
0 | 3164 |
if (rej->rej_type == 0) { |
3165 |
*rej = _rej; |
|
3166 |
rej->rej_name = strdup(_rej.rej_name); |
|
3167 |
} |
|
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3168 |
return (0); |
0 | 3169 |
} |
3170 |
||
3171 |
/* |
|
3172 |
* Determine if we've already come across this file. |
|
3173 |
*/ |
|
3174 |
if (!(flags & FLG_IF_EXTRACT)) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3175 |
APlist *apl; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3176 |
Aliste idx; |
0 | 3177 |
|
3178 |
if (ehdr->e_type == ET_REL) |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3179 |
apl = ofl->ofl_objs; |
0 | 3180 |
else |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3181 |
apl = ofl->ofl_sos; |
0 | 3182 |
|
3183 |
/* |
|
3184 |
* Traverse the appropriate file list and determine if |
|
3185 |
* a dev/inode match is found. |
|
3186 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3187 |
for (APLIST_TRAVERSE(apl, idx, ifl)) { |
0 | 3188 |
/* |
3189 |
* Ifl_desc generated via -Nneed, therefore no |
|
3190 |
* actual file behind it. |
|
3191 |
*/ |
|
3192 |
if (ifl->ifl_flags & FLG_IF_NEEDSTR) |
|
3193 |
continue; |
|
3194 |
||
3195 |
if ((ifl->ifl_stino != status.st_ino) || |
|
3196 |
(ifl->ifl_stdev != status.st_dev)) |
|
3197 |
continue; |
|
3198 |
||
3199 |
/* |
|
3200 |
* Disregard (skip) this image. |
|
3201 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3202 |
DBG_CALL(Dbg_file_skip(ofl->ofl_lml, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3203 |
ifl->ifl_name, name)); |
0 | 3204 |
(void) elf_end(elf); |
3205 |
||
3206 |
/* |
|
3207 |
* If the file was explicitly defined on the |
|
3208 |
* command line (this is always the case for |
|
3209 |
* relocatable objects, and is true for shared |
|
3210 |
* objects when they weren't specified via -l or |
|
3211 |
* were dragged in as an implicit dependency), |
|
3212 |
* then warn the user. |
|
3213 |
*/ |
|
3214 |
if ((flags & FLG_IF_CMDLINE) || |
|
3215 |
(ifl->ifl_flags & FLG_IF_CMDLINE)) { |
|
3216 |
const char *errmsg; |
|
3217 |
||
3218 |
/* |
|
3219 |
* Determine whether this is the same |
|
3220 |
* file name as originally encountered |
|
3221 |
* so as to provide the most |
|
3222 |
* descriptive diagnostic. |
|
3223 |
*/ |
|
4734
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
3224 |
errmsg = |
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
3225 |
(strcmp(name, ifl->ifl_name) == 0) ? |
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
3226 |
MSG_INTL(MSG_FIL_MULINC_1) : |
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
3227 |
MSG_INTL(MSG_FIL_MULINC_2); |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3228 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3229 |
errmsg, name, ifl->ifl_name); |
0 | 3230 |
} |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3231 |
if (ifl_ret) |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3232 |
*ifl_ret = ifl; |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3233 |
return (1); |
0 | 3234 |
} |
3235 |
} |
|
3236 |
||
3237 |
/* |
|
3238 |
* At this point, we know we need the file. Establish an input |
|
3239 |
* file descriptor and continue processing. |
|
3240 |
*/ |
|
3241 |
ifl = ifl_setup(name, ehdr, elf, flags, ofl, rej); |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
3242 |
if ((ifl == NULL) || (ifl == (Ifl_desc *)S_ERROR)) |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3243 |
return ((uintptr_t)ifl); |
0 | 3244 |
ifl->ifl_stdev = status.st_dev; |
3245 |
ifl->ifl_stino = status.st_ino; |
|
3246 |
||
3247 |
/* |
|
3248 |
* If -zignore is in effect, mark this file as a potential |
|
3249 |
* candidate (the files use isn't actually determined until |
|
3250 |
* symbol resolution and relocation processing are completed). |
|
3251 |
*/ |
|
3252 |
if (ofl->ofl_flags1 & FLG_OF1_IGNORE) |
|
3253 |
ifl->ifl_flags |= FLG_IF_IGNORE; |
|
3254 |
||
3255 |
switch (ehdr->e_type) { |
|
3256 |
case ET_REL: |
|
6206 | 3257 |
(*ld_targ.t_mr.mr_mach_eflags)(ehdr, ofl); |
0 | 3258 |
error = process_elf(ifl, elf, ofl); |
3259 |
break; |
|
3260 |
case ET_DYN: |
|
3261 |
if ((ofl->ofl_flags & FLG_OF_STATIC) || |
|
3262 |
!(ofl->ofl_flags & FLG_OF_DYNLIBS)) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3263 |
eprintf(ofl->ofl_lml, ERR_FATAL, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3264 |
MSG_INTL(MSG_FIL_SOINSTAT), name); |
0 | 3265 |
ofl->ofl_flags |= FLG_OF_FATAL; |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3266 |
return (0); |
0 | 3267 |
} |
3268 |
||
3269 |
/* |
|
3270 |
* Record any additional shared object information. |
|
3271 |
* If no soname is specified (eg. this file was |
|
3272 |
* derived from a explicit filename declaration on the |
|
3273 |
* command line, ie. bar.so) use the pathname. |
|
3274 |
* This entry may be overridden if the files dynamic |
|
3275 |
* section specifies an DT_SONAME value. |
|
3276 |
*/ |
|
3277 |
if (soname == NULL) |
|
3278 |
ifl->ifl_soname = ifl->ifl_name; |
|
3279 |
else |
|
3280 |
ifl->ifl_soname = soname; |
|
3281 |
||
3282 |
/* |
|
12449
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
3283 |
* If direct bindings, lazy loading, group permissions, |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
3284 |
* or deferred dependencies need to be established, mark |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
3285 |
* this object. |
0 | 3286 |
*/ |
3287 |
if (ofl->ofl_flags1 & FLG_OF1_ZDIRECT) |
|
3288 |
ifl->ifl_flags |= FLG_IF_DIRECT; |
|
3289 |
if (ofl->ofl_flags1 & FLG_OF1_LAZYLD) |
|
3290 |
ifl->ifl_flags |= FLG_IF_LAZYLD; |
|
3291 |
if (ofl->ofl_flags1 & FLG_OF1_GRPPRM) |
|
3292 |
ifl->ifl_flags |= FLG_IF_GRPPRM; |
|
12449
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
3293 |
if (ofl->ofl_flags1 & FLG_OF1_DEFERRED) |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
3294 |
ifl->ifl_flags |= |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
3295 |
(FLG_IF_LAZYLD | FLG_IF_DEFERRED); |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
3296 |
|
0 | 3297 |
error = process_elf(ifl, elf, ofl); |
3298 |
||
3299 |
/* |
|
12449
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
3300 |
* Determine whether this dependency requires a syminfo. |
0 | 3301 |
*/ |
12449
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12254
diff
changeset
|
3302 |
if (ifl->ifl_flags & MSK_IF_SYMINFO) |
0 | 3303 |
ofl->ofl_flags |= FLG_OF_SYMINFO; |
3304 |
||
3305 |
break; |
|
3306 |
default: |
|
3307 |
(void) elf_errno(); |
|
3308 |
_rej.rej_type = SGS_REJ_UNKFILE; |
|
3309 |
_rej.rej_name = name; |
|
6206 | 3310 |
DBG_CALL(Dbg_file_rejected(ofl->ofl_lml, &_rej, |
3311 |
ld_targ.t_m.m_mach)); |
|
0 | 3312 |
if (rej->rej_type == 0) { |
3313 |
*rej = _rej; |
|
3314 |
rej->rej_name = strdup(_rej.rej_name); |
|
3315 |
} |
|
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3316 |
return (0); |
0 | 3317 |
} |
3318 |
break; |
|
3319 |
default: |
|
3320 |
(void) elf_errno(); |
|
3321 |
_rej.rej_type = SGS_REJ_UNKFILE; |
|
3322 |
_rej.rej_name = name; |
|
6206 | 3323 |
DBG_CALL(Dbg_file_rejected(ofl->ofl_lml, &_rej, |
3324 |
ld_targ.t_m.m_mach)); |
|
0 | 3325 |
if (rej->rej_type == 0) { |
3326 |
*rej = _rej; |
|
3327 |
rej->rej_name = strdup(_rej.rej_name); |
|
3328 |
} |
|
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3329 |
return (0); |
0 | 3330 |
} |
3331 |
if ((error == 0) || (error == S_ERROR)) |
|
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3332 |
return (error); |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3333 |
|
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3334 |
if (ifl_ret) |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3335 |
*ifl_ret = ifl; |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3336 |
return (1); |
0 | 3337 |
} |
3338 |
||
3339 |
/* |
|
3340 |
* Having successfully opened a file, set up the necessary elf structures to |
|
3341 |
* process it further. This small section of processing is slightly different |
|
3342 |
* from the elf initialization required to process a relocatable object from an |
|
2850 | 3343 |
* archive (see libs.c: ld_process_archive()). |
0 | 3344 |
*/ |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3345 |
uintptr_t |
2978
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3346 |
ld_process_open(const char *opath, const char *ofile, int *fd, Ofl_desc *ofl, |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3347 |
Word flags, Rej_desc *rej, Ifl_desc **ifl_ret) |
0 | 3348 |
{ |
2978
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3349 |
Elf *elf; |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3350 |
const char *npath = opath; |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3351 |
const char *nfile = ofile; |
0 | 3352 |
|
2978
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3353 |
if ((elf = elf_begin(*fd, ELF_C_READ, NULL)) == NULL) { |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3354 |
eprintf(ofl->ofl_lml, ERR_ELF, MSG_INTL(MSG_ELF_BEGIN), npath); |
0 | 3355 |
ofl->ofl_flags |= FLG_OF_FATAL; |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3356 |
return (0); |
0 | 3357 |
} |
3358 |
||
2978
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3359 |
/* |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3360 |
* Determine whether the support library wishes to process this open. |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3361 |
* The support library may return: |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3362 |
* . a different ELF descriptor (in which case they should have |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3363 |
* closed the original) |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3364 |
* . a different file descriptor (in which case they should have |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3365 |
* closed the original) |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3366 |
* . a different path and file name (presumably associated with |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3367 |
* a different file descriptor) |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3368 |
* |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3369 |
* A file descriptor of -1, or and ELF descriptor of zero indicates |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3370 |
* the file should be ignored. |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3371 |
*/ |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3372 |
ld_sup_open(ofl, &npath, &nfile, fd, flags, &elf, NULL, 0, |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3373 |
elf_kind(elf)); |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3374 |
|
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3375 |
if ((*fd == -1) || (elf == NULL)) |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3376 |
return (0); |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3377 |
|
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3378 |
return (ld_process_ifl(npath, nfile, *fd, elf, flags, ofl, rej, |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3379 |
ifl_ret)); |
0 | 3380 |
} |
3381 |
||
3382 |
/* |
|
8598
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3383 |
* Having successfully mapped a file, set up the necessary elf structures to |
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3384 |
* process it further. This routine is patterned after ld_process_open() and |
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3385 |
* is only called by ld.so.1(1) to process a relocatable object. |
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3386 |
*/ |
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3387 |
Ifl_desc * |
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3388 |
ld_process_mem(const char *path, const char *file, char *addr, size_t size, |
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3389 |
Ofl_desc *ofl, Rej_desc *rej) |
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3390 |
{ |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3391 |
Elf *elf; |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3392 |
uintptr_t open_ret; |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3393 |
Ifl_desc *ifl; |
8598
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3394 |
|
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3395 |
if ((elf = elf_memory(addr, size)) == NULL) { |
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3396 |
eprintf(ofl->ofl_lml, ERR_ELF, MSG_INTL(MSG_ELF_MEMORY), path); |
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3397 |
ofl->ofl_flags |= FLG_OF_FATAL; |
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3398 |
return (0); |
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3399 |
} |
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3400 |
|
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3401 |
open_ret = ld_process_ifl(path, file, 0, elf, 0, ofl, rej, &ifl); |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3402 |
if (open_ret != 1) |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3403 |
return ((Ifl_desc *) open_ret); |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3404 |
return (ifl); |
8598
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3405 |
} |
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3406 |
|
0867fc633d66
6686372 ld.so.1 should use mmapobj(2)
Rod Evans <Rod.Evans@Sun.COM>
parents:
8501
diff
changeset
|
3407 |
/* |
0 | 3408 |
* Process a required library (i.e. the dependency of a shared object). |
3409 |
* Combine the directory and filename, check the resultant path size, and try |
|
3410 |
* opening the pathname. |
|
3411 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3412 |
static Ifl_desc * |
0 | 3413 |
process_req_lib(Sdf_desc *sdf, const char *dir, const char *file, |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
7359
diff
changeset
|
3414 |
Ofl_desc *ofl, Rej_desc *rej) |
0 | 3415 |
{ |
3416 |
size_t dlen, plen; |
|
3417 |
int fd; |
|
3418 |
char path[PATH_MAX]; |
|
3419 |
const char *_dir = dir; |
|
3420 |
||
3421 |
/* |
|
3422 |
* Determine the sizes of the directory and filename to insure we don't |
|
3423 |
* exceed our buffer. |
|
3424 |
*/ |
|
3425 |
if ((dlen = strlen(dir)) == 0) { |
|
3426 |
_dir = MSG_ORIG(MSG_STR_DOT); |
|
3427 |
dlen = 1; |
|
3428 |
} |
|
3429 |
dlen++; |
|
3430 |
plen = dlen + strlen(file) + 1; |
|
3431 |
if (plen > PATH_MAX) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3432 |
eprintf(ofl->ofl_lml, ERR_FATAL, MSG_INTL(MSG_FIL_PTHTOLONG), |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3433 |
_dir, file); |
0 | 3434 |
ofl->ofl_flags |= FLG_OF_FATAL; |
3435 |
return (0); |
|
3436 |
} |
|
3437 |
||
3438 |
/* |
|
3439 |
* Build the entire pathname and try and open the file. |
|
3440 |
*/ |
|
3441 |
(void) strcpy(path, _dir); |
|
3442 |
(void) strcat(path, MSG_ORIG(MSG_STR_SLASH)); |
|
3443 |
(void) strcat(path, file); |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3444 |
DBG_CALL(Dbg_libs_req(ofl->ofl_lml, sdf->sdf_name, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3445 |
sdf->sdf_rfile, path)); |
0 | 3446 |
|
3447 |
if ((fd = open(path, O_RDONLY)) == -1) |
|
3448 |
return (0); |
|
3449 |
else { |
|
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3450 |
uintptr_t open_ret; |
0 | 3451 |
Ifl_desc *ifl; |
3452 |
char *_path; |
|
3453 |
||
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
3454 |
if ((_path = libld_malloc(strlen(path) + 1)) == NULL) |
0 | 3455 |
return ((Ifl_desc *)S_ERROR); |
3456 |
(void) strcpy(_path, path); |
|
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3457 |
open_ret = ld_process_open(_path, &_path[dlen], &fd, ofl, |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3458 |
0, rej, &ifl); |
2978
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3459 |
if (fd != -1) |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3460 |
(void) close(fd); |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3461 |
if (open_ret != 1) |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3462 |
return ((Ifl_desc *)open_ret); |
0 | 3463 |
return (ifl); |
3464 |
} |
|
3465 |
} |
|
3466 |
||
3467 |
/* |
|
3468 |
* Finish any library processing. Walk the list of so's that have been listed |
|
3469 |
* as "included" by shared objects we have previously processed. Examine them, |
|
3470 |
* without adding them as explicit dependents of this program, in order to |
|
3471 |
* complete our symbol definition process. The search path rules are: |
|
3472 |
* |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
3473 |
* - use any user supplied paths, i.e. LD_LIBRARY_PATH and -L, then |
0 | 3474 |
* |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
3475 |
* - use any RPATH defined within the parent shared object, then |
0 | 3476 |
* |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
3477 |
* - use the default directories, i.e. LIBPATH or -YP. |
0 | 3478 |
*/ |
3479 |
uintptr_t |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3480 |
ld_finish_libs(Ofl_desc *ofl) |
0 | 3481 |
{ |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3482 |
Aliste idx1; |
0 | 3483 |
Sdf_desc *sdf; |
3484 |
Rej_desc rej = { 0 }; |
|
3485 |
||
3486 |
/* |
|
3487 |
* Make sure we are back in dynamic mode. |
|
3488 |
*/ |
|
3489 |
ofl->ofl_flags |= FLG_OF_DYNLIBS; |
|
3490 |
||
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3491 |
for (APLIST_TRAVERSE(ofl->ofl_soneed, idx1, sdf)) { |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3492 |
Aliste idx2; |
2850 | 3493 |
char *path, *slash = NULL; |
0 | 3494 |
int fd; |
3495 |
Ifl_desc *ifl; |
|
2850 | 3496 |
char *file = (char *)sdf->sdf_name; |
0 | 3497 |
|
3498 |
/* |
|
3499 |
* See if this file has already been processed. At the time |
|
3500 |
* this implicit dependency was determined there may still have |
|
1109
1a3bd84f03cd
6362044 ld(1) inconsistencies with LD_DEBUG=-Dunused and -zignore
rie
parents:
574
diff
changeset
|
3501 |
* been more explicit dependencies to process. Note, if we ever |
0 | 3502 |
* do parse the command line three times we would be able to |
1109
1a3bd84f03cd
6362044 ld(1) inconsistencies with LD_DEBUG=-Dunused and -zignore
rie
parents:
574
diff
changeset
|
3503 |
* do all this checking when processing the dynamic section. |
0 | 3504 |
*/ |
3505 |
if (sdf->sdf_file) |
|
3506 |
continue; |
|
3507 |
||
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3508 |
for (APLIST_TRAVERSE(ofl->ofl_sos, idx2, ifl)) { |
0 | 3509 |
if (!(ifl->ifl_flags & FLG_IF_NEEDSTR) && |
3510 |
(strcmp(file, ifl->ifl_soname) == 0)) { |
|
3511 |
sdf->sdf_file = ifl; |
|
3512 |
break; |
|
3513 |
} |
|
3514 |
} |
|
3515 |
if (sdf->sdf_file) |
|
3516 |
continue; |
|
3517 |
||
3518 |
/* |
|
2850 | 3519 |
* If the current path name element embeds a "/", then it's to |
3520 |
* be taken "as is", with no searching involved. Process all |
|
3521 |
* "/" occurrences, so that we can deduce the base file name. |
|
0 | 3522 |
*/ |
2850 | 3523 |
for (path = file; *path; path++) { |
0 | 3524 |
if (*path == '/') |
2850 | 3525 |
slash = path; |
3526 |
} |
|
3527 |
if (slash) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3528 |
DBG_CALL(Dbg_libs_req(ofl->ofl_lml, sdf->sdf_name, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3529 |
sdf->sdf_rfile, file)); |
0 | 3530 |
if ((fd = open(file, O_RDONLY)) == -1) { |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3531 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3532 |
MSG_INTL(MSG_FIL_NOTFOUND), file, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3533 |
sdf->sdf_rfile); |
0 | 3534 |
} else { |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3535 |
uintptr_t open_ret; |
0 | 3536 |
Rej_desc _rej = { 0 }; |
3537 |
||
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3538 |
open_ret = ld_process_open(file, ++slash, &fd, |
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3539 |
ofl, 0, &_rej, &ifl); |
2978
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3540 |
if (fd != -1) |
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2850
diff
changeset
|
3541 |
(void) close(fd); |
12254
ff5bb54e2a40
6932220 ld -z allextract skips objects that lack global symbols
Ali Bahrami <Ali.Bahrami@Oracle.COM>
parents:
11993
diff
changeset
|
3542 |
if (open_ret == S_ERROR) |
7359
d738a7f7d21f
6734598 ld(1) archive processing failure due to mismatched file descriptors
Rod Evans <Rod.Evans@Sun.COM>
parents:
6206
diff
changeset
|
3543 |
return (S_ERROR); |
0 | 3544 |
|
3545 |
if (_rej.rej_type) { |
|
4734
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
3546 |
Conv_reject_desc_buf_t rej_buf; |
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
3547 |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3548 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
0 | 3549 |
MSG_INTL(reject[_rej.rej_type]), |
3550 |
_rej.rej_name ? rej.rej_name : |
|
3551 |
MSG_INTL(MSG_STR_UNKNOWN), |
|
6206 | 3552 |
conv_reject_desc(&_rej, &rej_buf, |
3553 |
ld_targ.t_m.m_mach)); |
|
0 | 3554 |
} else |
3555 |
sdf->sdf_file = ifl; |
|
3556 |
} |
|
3557 |
continue; |
|
3558 |
} |
|
3559 |
||
3560 |
/* |
|
3561 |
* Now search for this file in any user defined directories. |
|
3562 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3563 |
for (APLIST_TRAVERSE(ofl->ofl_ulibdirs, idx2, path)) { |
0 | 3564 |
Rej_desc _rej = { 0 }; |
3565 |
||
3566 |
ifl = process_req_lib(sdf, path, file, ofl, &_rej); |
|
3567 |
if (ifl == (Ifl_desc *)S_ERROR) { |
|
3568 |
return (S_ERROR); |
|
3569 |
} |
|
3570 |
if (_rej.rej_type) { |
|
3571 |
if (rej.rej_type == 0) { |
|
3572 |
rej = _rej; |
|
3573 |
rej.rej_name = strdup(_rej.rej_name); |
|
3574 |
} |
|
3575 |
} |
|
3576 |
if (ifl) { |
|
3577 |
sdf->sdf_file = ifl; |
|
3578 |
break; |
|
3579 |
} |
|
3580 |
} |
|
3581 |
if (sdf->sdf_file) |
|
3582 |
continue; |
|
3583 |
||
3584 |
/* |
|
3585 |
* Next use the local rules defined within the parent shared |
|
3586 |
* object. |
|
3587 |
*/ |
|
3588 |
if (sdf->sdf_rpath != NULL) { |
|
3589 |
char *rpath, *next; |
|
3590 |
||
3591 |
rpath = libld_malloc(strlen(sdf->sdf_rpath) + 1); |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10454
diff
changeset
|
3592 |
if (rpath == NULL) |
0 | 3593 |
return (S_ERROR); |
3594 |
(void) strcpy(rpath, sdf->sdf_rpath); |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3595 |
DBG_CALL(Dbg_libs_path(ofl->ofl_lml, rpath, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3596 |
LA_SER_RUNPATH, sdf->sdf_rfile)); |
0 | 3597 |
if ((path = strtok_r(rpath, |
3598 |
MSG_ORIG(MSG_STR_COLON), &next)) != NULL) { |
|
3599 |
do { |
|
3600 |
Rej_desc _rej = { 0 }; |
|
3601 |
||
3602 |
path = expand(sdf->sdf_rfile, path, |
|
3603 |
&next); |
|
3604 |
||
3605 |
ifl = process_req_lib(sdf, path, |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
3606 |
file, ofl, &_rej); |
0 | 3607 |
if (ifl == (Ifl_desc *)S_ERROR) { |
3608 |
return (S_ERROR); |
|
3609 |
} |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
3610 |
if ((_rej.rej_type) && |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
3611 |
(rej.rej_type == 0)) { |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
3612 |
rej = _rej; |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
3613 |
rej.rej_name = |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
3731
diff
changeset
|
3614 |
strdup(_rej.rej_name); |
0 | 3615 |
} |
3616 |
if (ifl) { |
|
3617 |
sdf->sdf_file = ifl; |
|
3618 |
break; |
|
3619 |
} |
|
3620 |
} while ((path = strtok_r(NULL, |
|
3621 |
MSG_ORIG(MSG_STR_COLON), &next)) != NULL); |
|
3622 |
} |
|
3623 |
} |
|
3624 |
if (sdf->sdf_file) |
|
3625 |
continue; |
|
3626 |
||
3627 |
/* |
|
3628 |
* Finally try the default library search directories. |
|
3629 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3630 |
for (APLIST_TRAVERSE(ofl->ofl_dlibdirs, idx2, path)) { |
0 | 3631 |
Rej_desc _rej = { 0 }; |
3632 |
||
3633 |
ifl = process_req_lib(sdf, path, file, ofl, &rej); |
|
3634 |
if (ifl == (Ifl_desc *)S_ERROR) { |
|
3635 |
return (S_ERROR); |
|
3636 |
} |
|
3637 |
if (_rej.rej_type) { |
|
3638 |
if (rej.rej_type == 0) { |
|
3639 |
rej = _rej; |
|
3640 |
rej.rej_name = strdup(_rej.rej_name); |
|
3641 |
} |
|
3642 |
} |
|
3643 |
if (ifl) { |
|
3644 |
sdf->sdf_file = ifl; |
|
3645 |
break; |
|
3646 |
} |
|
3647 |
} |
|
3648 |
if (sdf->sdf_file) |
|
3649 |
continue; |
|
3650 |
||
3651 |
/* |
|
3652 |
* If we've got this far we haven't found the shared object. |
|
3653 |
* If an object was found, but was rejected for some reason, |
|
3654 |
* print a diagnostic to that effect, otherwise generate a |
|
3655 |
* generic "not found" diagnostic. |
|
3656 |
*/ |
|
3657 |
if (rej.rej_type) { |
|
4734
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
3658 |
Conv_reject_desc_buf_t rej_buf; |
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
3659 |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3660 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3661 |
MSG_INTL(reject[rej.rej_type]), |
0 | 3662 |
rej.rej_name ? rej.rej_name : |
4734
a4708faa3e85
6583742 ELF string conversion library needs to lose static writable buffers
ab196087
parents:
4716
diff
changeset
|
3663 |
MSG_INTL(MSG_STR_UNKNOWN), |
6206 | 3664 |
conv_reject_desc(&rej, &rej_buf, |
3665 |
ld_targ.t_m.m_mach)); |
|
0 | 3666 |
} else { |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3667 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3668 |
MSG_INTL(MSG_FIL_NOTFOUND), file, sdf->sdf_rfile); |
0 | 3669 |
} |
3670 |
} |
|
3671 |
||
3672 |
/* |
|
3673 |
* Finally, now that all objects have been input, make sure any version |
|
3674 |
* requirements have been met. |
|
3675 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
1109
diff
changeset
|
3676 |
return (ld_vers_verify(ofl)); |
0 | 3677 |
} |