author | Rod Evans <Rod.Evans@Sun.COM> |
Wed, 19 May 2010 22:33:49 -0700 | |
changeset 12449 | a87750d92895 |
parent 12029 | 3202400f09a4 |
child 13004 | 92dfdb3a48cc |
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:
574
diff
changeset
|
5 |
* Common Development and Distribution License (the "License"). |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
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 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
21 |
|
0 | 22 |
/* |
23 |
* Copyright (c) 1988 AT&T |
|
24 |
* All Rights Reserved |
|
25 |
* |
|
12449
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
26 |
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved. |
0 | 27 |
*/ |
28 |
||
29 |
/* |
|
30 |
* Update the new output file image, perform virtual address, offset and |
|
31 |
* displacement calculations on the program headers and sections headers, |
|
32 |
* and generate any new output section information. |
|
33 |
*/ |
|
6206 | 34 |
|
35 |
#define ELF_TARGET_AMD64 |
|
36 |
||
0 | 37 |
#include <stdio.h> |
38 |
#include <string.h> |
|
1722
7b9a53f2503b
6327926 ld does not set etext symbol correctly for AMD64 medium model
seizo
parents:
1698
diff
changeset
|
39 |
#include <unistd.h> |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
40 |
#include <debug.h> |
0 | 41 |
#include "msg.h" |
42 |
#include "_libld.h" |
|
43 |
||
44 |
/* |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
45 |
* Comparison routine used by qsort() for sorting of the global symbol list |
0 | 46 |
* based off of the hashbuckets the symbol will eventually be deposited in. |
47 |
*/ |
|
48 |
static int |
|
49 |
sym_hash_compare(Sym_s_list * s1, Sym_s_list * s2) |
|
50 |
{ |
|
51 |
return (s1->sl_hval - s2->sl_hval); |
|
52 |
} |
|
53 |
||
54 |
/* |
|
3492 | 55 |
* Comparison routine used by qsort() for sorting of dyn[sym|tls]sort section |
56 |
* indices based on the address of the symbols they reference. The |
|
57 |
* use of the global dynsort_compare_syms variable is needed because |
|
58 |
* we need to examine the symbols the indices reference. It is safe, because |
|
59 |
* the linker is single threaded. |
|
60 |
*/ |
|
61 |
Sym *dynsort_compare_syms; |
|
62 |
||
63 |
static int |
|
64 |
dynsort_compare(const void *idx1, const void *idx2) |
|
65 |
{ |
|
66 |
Sym *s1 = dynsort_compare_syms + *((const Word *) idx1); |
|
67 |
Sym *s2 = dynsort_compare_syms + *((const Word *) idx2); |
|
68 |
||
69 |
/* |
|
70 |
* Note: the logical computation for this is |
|
71 |
* (st_value1 - st_value2) |
|
72 |
* However, that is only correct if the address type is smaller |
|
73 |
* than a pointer. Writing it this way makes it immune to the |
|
74 |
* class (32 or 64-bit) of the linker. |
|
75 |
*/ |
|
76 |
return ((s1->st_value < s2->st_value) ? -1 : |
|
77 |
(s1->st_value > s2->st_value)); |
|
78 |
} |
|
79 |
||
80 |
/* |
|
81 |
* Scan the sorted symbols, and issue warnings if there are any duplicate |
|
82 |
* values in the list. We only do this if -zverbose is set, or we are |
|
83 |
* running with LD_DEBUG defined |
|
84 |
* |
|
85 |
* entry: |
|
86 |
* ofl - Output file descriptor |
|
87 |
* ldynsym - Pointer to start of .SUNW_ldynsym section that the |
|
88 |
* sort section indexes reference. |
|
89 |
* symsort - Pointer to start of .SUNW_dynsymsort or .SUNW_dyntlssort |
|
90 |
* section. |
|
91 |
* n - # of indices in symsort array |
|
92 |
* secname - Name of the symsort section. |
|
93 |
* |
|
94 |
* exit: |
|
95 |
* If the symsort section contains indexes to more than one |
|
96 |
* symbol with the same address value, a warning is issued. |
|
97 |
*/ |
|
98 |
static void |
|
99 |
dynsort_dupwarn(Ofl_desc *ofl, Sym *ldynsym, const char *str, |
|
100 |
Word *symsort, Word n, const char *secname) |
|
101 |
{ |
|
102 |
int zverbose = (ofl->ofl_flags & FLG_OF_VERBOSE) != 0; |
|
103 |
Word ndx, cmp_ndx; |
|
104 |
Addr addr, cmp_addr; |
|
105 |
||
106 |
/* Nothing to do if -zverbose or LD_DEBUG are not active */ |
|
107 |
if (!(zverbose || DBG_ENABLED)) |
|
108 |
return; |
|
109 |
||
110 |
cmp_ndx = 0; |
|
111 |
cmp_addr = ldynsym[symsort[cmp_ndx]].st_value; |
|
112 |
for (ndx = 1; ndx < n; ndx++) { |
|
113 |
addr = ldynsym[symsort[ndx]].st_value; |
|
114 |
if (cmp_addr == addr) { |
|
115 |
if (zverbose) |
|
116 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
|
117 |
MSG_INTL(MSG_SYM_DUPSORTADDR), secname, |
|
118 |
str + ldynsym[symsort[cmp_ndx]].st_name, |
|
119 |
str + ldynsym[symsort[ndx]].st_name, |
|
120 |
EC_ADDR(addr)); |
|
121 |
DBG_CALL(Dbg_syms_dup_sort_addr(ofl->ofl_lml, secname, |
|
122 |
str + ldynsym[symsort[cmp_ndx]].st_name, |
|
123 |
str + ldynsym[symsort[ndx]].st_name, |
|
124 |
EC_ADDR(addr))); |
|
125 |
} else { /* Not a dup. Move reference up */ |
|
126 |
cmp_ndx = ndx; |
|
127 |
cmp_addr = addr; |
|
128 |
} |
|
129 |
} |
|
130 |
} |
|
131 |
||
132 |
/* |
|
0 | 133 |
* Build and update any output symbol tables. Here we work on all the symbol |
134 |
* tables at once to reduce the duplication of symbol and string manipulation. |
|
135 |
* Symbols and their associated strings are copied from the read-only input |
|
136 |
* file images to the output image and their values and index's updated in the |
|
137 |
* output image. |
|
138 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
139 |
static Addr |
0 | 140 |
update_osym(Ofl_desc *ofl) |
141 |
{ |
|
3492 | 142 |
/* |
143 |
* There are several places in this function where we wish |
|
144 |
* to insert a symbol index to the combined .SUNW_ldynsym/.dynsym |
|
145 |
* symbol table into one of the two sort sections (.SUNW_dynsymsort |
|
146 |
* or .SUNW_dyntlssort), if that symbol has the right attributes. |
|
147 |
* This macro is used to generate the necessary code from a single |
|
148 |
* specification. |
|
149 |
* |
|
150 |
* entry: |
|
151 |
* _sdp, _sym, _type - As per DYNSORT_COUNT. See _libld.h |
|
152 |
* _sym_ndx - Index that _sym will have in the combined |
|
153 |
* .SUNW_ldynsym/.dynsym symbol table. |
|
154 |
*/ |
|
155 |
#define ADD_TO_DYNSORT(_sdp, _sym, _type, _sym_ndx) \ |
|
156 |
{ \ |
|
157 |
Word *_dynsort_arr, *_dynsort_ndx; \ |
|
158 |
\ |
|
159 |
if (dynsymsort_symtype[_type]) { \ |
|
160 |
_dynsort_arr = dynsymsort; \ |
|
161 |
_dynsort_ndx = &dynsymsort_ndx; \ |
|
162 |
} else if (_type == STT_TLS) { \ |
|
163 |
_dynsort_arr = dyntlssort; \ |
|
164 |
_dynsort_ndx = &dyntlssort_ndx; \ |
|
165 |
} else { \ |
|
166 |
_dynsort_arr = NULL; \ |
|
167 |
} \ |
|
168 |
if ((_dynsort_arr != NULL) && DYNSORT_TEST_ATTR(_sdp, _sym)) \ |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
169 |
_dynsort_arr[(*_dynsort_ndx)++] = _sym_ndx; \ |
3492 | 170 |
} |
171 |
||
0 | 172 |
Sym_desc *sdp; |
173 |
Sym_avlnode *sav; |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
174 |
Sg_desc *sgp, *tsgp = NULL, *dsgp = NULL, *esgp = NULL; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
175 |
Os_desc *osp, *iosp = NULL, *fosp = NULL; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
176 |
Is_desc *isc; |
0 | 177 |
Ifl_desc *ifl; |
178 |
Word bssndx, etext_ndx, edata_ndx = 0, end_ndx, start_ndx; |
|
179 |
Word end_abs = 0, etext_abs = 0, edata_abs; |
|
8159
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
180 |
Word tlsbssndx = 0, parexpnndx; |
6206 | 181 |
#if defined(_ELF64) |
574 | 182 |
Word lbssndx = 0; |
183 |
Addr lbssaddr = 0; |
|
184 |
#endif |
|
0 | 185 |
Addr bssaddr, etext = 0, edata = 0, end = 0, start = 0; |
186 |
Addr tlsbssaddr = 0; |
|
8369
7536f6823d94
6773695 ld -z nopartial can break non-pic objects
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8159
diff
changeset
|
187 |
Addr parexpnbase, parexpnaddr; |
0 | 188 |
int start_set = 0; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
189 |
Sym _sym = {0}, *sym, *symtab = NULL; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
190 |
Sym *dynsym = NULL, *ldynsym = NULL; |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
191 |
Word symtab_ndx = 0; /* index into .symtab */ |
8140
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
192 |
Word symtab_gbl_bndx; /* .symtab ndx 1st global */ |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
193 |
Word ldynsym_ndx = 0; /* index into .SUNW_ldynsym */ |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
194 |
Word dynsym_ndx = 0; /* index into .dynsym */ |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
195 |
Word scopesym_ndx = 0; /* index into scoped symbols */ |
8140
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
196 |
Word scopesym_bndx = 0; /* .symtab ndx 1st scoped sym */ |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
197 |
Word ldynscopesym_ndx = 0; /* index to ldynsym scoped */ |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
198 |
/* symbols */ |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
199 |
Word *dynsymsort = NULL; /* SUNW_dynsymsort index */ |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
200 |
/* vector */ |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
201 |
Word *dyntlssort = NULL; /* SUNW_dyntlssort index */ |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
202 |
/* vector */ |
3492 | 203 |
Word dynsymsort_ndx; /* index dynsymsort array */ |
204 |
Word dyntlssort_ndx; /* index dyntlssort array */ |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
205 |
Word *symndx; /* symbol index (for */ |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
206 |
/* relocation use) */ |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
207 |
Word *symshndx = NULL; /* .symtab_shndx table */ |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
208 |
Word *dynshndx = NULL; /* .dynsym_shndx table */ |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
209 |
Word *ldynshndx = NULL; /* .SUNW_ldynsym_shndx table */ |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
210 |
Word ldynsym_cnt = NULL; /* number of items in */ |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
211 |
/* .SUNW_ldynsym */ |
0 | 212 |
Str_tbl *shstrtab; |
213 |
Str_tbl *strtab; |
|
214 |
Str_tbl *dynstr; |
|
215 |
Word *hashtab; /* hash table pointer */ |
|
216 |
Word *hashbkt; /* hash table bucket pointer */ |
|
217 |
Word *hashchain; /* hash table chain pointer */ |
|
218 |
Wk_desc *wkp; |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
219 |
Alist *weak = NULL; |
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
220 |
ofl_flag_t flags = ofl->ofl_flags; |
0 | 221 |
Versym *versym; |
222 |
Gottable *gottable; /* used for display got debugging */ |
|
223 |
/* information */ |
|
224 |
Syminfo *syminfo; |
|
225 |
Sym_s_list *sorted_syms; /* table to hold sorted symbols */ |
|
226 |
Word ssndx; /* global index into sorted_syms */ |
|
227 |
Word scndx; /* scoped index into sorted_syms */ |
|
5892
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
228 |
size_t stoff; /* string offset */ |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
229 |
Aliste idx1; |
0 | 230 |
|
231 |
/* |
|
232 |
* Initialize pointers to the symbol table entries and the symbol |
|
233 |
* table strings. Skip the first symbol entry and the first string |
|
234 |
* table byte. Note that if we are not generating any output symbol |
|
11227
cd2ac59c39f2
6900241 ld should track SHT_GROUP sections by symbol name, not section name
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
235 |
* tables we must still generate and update internal copies so |
0 | 236 |
* that the relocation phase has the correct information. |
237 |
*/ |
|
238 |
if (!(flags & FLG_OF_STRIP) || (flags & FLG_OF_RELOBJ) || |
|
239 |
((flags & FLG_OF_STATIC) && ofl->ofl_osversym)) { |
|
240 |
symtab = (Sym *)ofl->ofl_ossymtab->os_outdata->d_buf; |
|
241 |
symtab[symtab_ndx++] = _sym; |
|
242 |
if (ofl->ofl_ossymshndx) |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
243 |
symshndx = |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
244 |
(Word *)ofl->ofl_ossymshndx->os_outdata->d_buf; |
0 | 245 |
} |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
246 |
if (OFL_ALLOW_DYNSYM(ofl)) { |
0 | 247 |
dynsym = (Sym *)ofl->ofl_osdynsym->os_outdata->d_buf; |
248 |
dynsym[dynsym_ndx++] = _sym; |
|
249 |
/* |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
250 |
* If we are also constructing a .SUNW_ldynsym section |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
251 |
* to contain local function symbols, then set it up too. |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
252 |
*/ |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
253 |
if (ofl->ofl_osldynsym) { |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
254 |
ldynsym = (Sym *)ofl->ofl_osldynsym->os_outdata->d_buf; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
255 |
ldynsym[ldynsym_ndx++] = _sym; |
3492 | 256 |
ldynsym_cnt = 1 + ofl->ofl_dynlocscnt + |
257 |
ofl->ofl_dynscopecnt; |
|
258 |
||
259 |
/* |
|
260 |
* If there is a SUNW_ldynsym, then there may also |
|
261 |
* be a .SUNW_dynsymsort and/or .SUNW_dyntlssort |
|
262 |
* sections, used to collect indices of function |
|
263 |
* and data symbols sorted by address order. |
|
264 |
*/ |
|
265 |
if (ofl->ofl_osdynsymsort) { /* .SUNW_dynsymsort */ |
|
266 |
dynsymsort = (Word *) |
|
267 |
ofl->ofl_osdynsymsort->os_outdata->d_buf; |
|
268 |
dynsymsort_ndx = 0; |
|
269 |
} |
|
270 |
if (ofl->ofl_osdyntlssort) { /* .SUNW_dyntlssort */ |
|
271 |
dyntlssort = (Word *) |
|
272 |
ofl->ofl_osdyntlssort->os_outdata->d_buf; |
|
273 |
dyntlssort_ndx = 0; |
|
274 |
} |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
275 |
} |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
276 |
|
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
277 |
/* |
0 | 278 |
* Initialize the hash table. |
279 |
*/ |
|
280 |
hashtab = (Word *)(ofl->ofl_oshash->os_outdata->d_buf); |
|
281 |
hashbkt = &hashtab[2]; |
|
282 |
hashchain = &hashtab[2 + ofl->ofl_hashbkts]; |
|
283 |
hashtab[0] = ofl->ofl_hashbkts; |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
284 |
hashtab[1] = DYNSYM_ALL_CNT(ofl); |
0 | 285 |
if (ofl->ofl_osdynshndx) |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
286 |
dynshndx = |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
287 |
(Word *)ofl->ofl_osdynshndx->os_outdata->d_buf; |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
288 |
if (ofl->ofl_osldynshndx) |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
289 |
ldynshndx = |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
290 |
(Word *)ofl->ofl_osldynshndx->os_outdata->d_buf; |
0 | 291 |
} |
292 |
||
293 |
/* |
|
294 |
* symndx is the symbol index to be used for relocation processing. It |
|
295 |
* points to the relevant symtab's (.dynsym or .symtab) symbol ndx. |
|
296 |
*/ |
|
297 |
if (dynsym) |
|
298 |
symndx = &dynsym_ndx; |
|
299 |
else |
|
300 |
symndx = &symtab_ndx; |
|
301 |
||
302 |
/* |
|
303 |
* If we have version definitions initialize the version symbol index |
|
304 |
* table. There is one entry for each symbol which contains the symbols |
|
305 |
* version index. |
|
306 |
*/ |
|
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
307 |
if (!(flags & FLG_OF_NOVERSEC) && |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
308 |
(flags & (FLG_OF_VERNEED | FLG_OF_VERDEF))) { |
0 | 309 |
versym = (Versym *)ofl->ofl_osversym->os_outdata->d_buf; |
10167
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
310 |
versym[0] = NULL; |
0 | 311 |
} else |
10167
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
312 |
versym = NULL; |
0 | 313 |
|
314 |
/* |
|
315 |
* If syminfo section exists be prepared to fill it in. |
|
316 |
*/ |
|
317 |
if (ofl->ofl_ossyminfo) { |
|
318 |
syminfo = ofl->ofl_ossyminfo->os_outdata->d_buf; |
|
319 |
syminfo[0].si_flags = SYMINFO_CURRENT; |
|
320 |
} else |
|
10167
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
321 |
syminfo = NULL; |
0 | 322 |
|
323 |
/* |
|
324 |
* Setup our string tables. |
|
325 |
*/ |
|
326 |
shstrtab = ofl->ofl_shdrsttab; |
|
327 |
strtab = ofl->ofl_strtab; |
|
328 |
dynstr = ofl->ofl_dynstrtab; |
|
329 |
||
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
330 |
DBG_CALL(Dbg_syms_sec_title(ofl->ofl_lml)); |
0 | 331 |
|
332 |
/* |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
333 |
* Put output file name to the first .symtab and .SUNW_ldynsym symbol. |
0 | 334 |
*/ |
335 |
if (symtab) { |
|
336 |
(void) st_setstring(strtab, ofl->ofl_name, &stoff); |
|
337 |
sym = &symtab[symtab_ndx++]; |
|
338 |
/* LINTED */ |
|
339 |
sym->st_name = stoff; |
|
340 |
sym->st_value = 0; |
|
341 |
sym->st_size = 0; |
|
342 |
sym->st_info = ELF_ST_INFO(STB_LOCAL, STT_FILE); |
|
343 |
sym->st_other = 0; |
|
344 |
sym->st_shndx = SHN_ABS; |
|
345 |
||
346 |
if (versym && !dynsym) |
|
347 |
versym[1] = 0; |
|
348 |
} |
|
3492 | 349 |
if (ldynsym) { |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
350 |
(void) st_setstring(dynstr, ofl->ofl_name, &stoff); |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
351 |
sym = &ldynsym[ldynsym_ndx]; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
352 |
/* LINTED */ |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
353 |
sym->st_name = stoff; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
354 |
sym->st_value = 0; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
355 |
sym->st_size = 0; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
356 |
sym->st_info = ELF_ST_INFO(STB_LOCAL, STT_FILE); |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
357 |
sym->st_other = 0; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
358 |
sym->st_shndx = SHN_ABS; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
359 |
|
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
360 |
/* Scoped symbols get filled in global loop below */ |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
361 |
ldynscopesym_ndx = ldynsym_ndx + 1; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
362 |
ldynsym_ndx += ofl->ofl_dynscopecnt; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
363 |
} |
0 | 364 |
|
365 |
/* |
|
366 |
* If we are to display GOT summary information, then allocate |
|
367 |
* the buffer to 'cache' the GOT symbols into now. |
|
368 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
369 |
if (DBG_ENABLED) { |
2145
f3828f946507
6423051 static TLS support within the link-editors needs a major face lift
rie
parents:
1722
diff
changeset
|
370 |
if ((ofl->ofl_gottable = gottable = |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
371 |
libld_calloc(ofl->ofl_gotcnt, sizeof (Gottable))) == NULL) |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
372 |
return ((Addr)S_ERROR); |
0 | 373 |
} |
374 |
||
375 |
/* |
|
376 |
* Traverse the program headers. Determine the last executable segment |
|
377 |
* and the last data segment so that we can update etext and edata. If |
|
378 |
* we have empty segments (reservations) record them for setting _end. |
|
379 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
380 |
for (APLIST_TRAVERSE(ofl->ofl_segs, idx1, sgp)) { |
1682 | 381 |
Phdr *phd = &(sgp->sg_phdr); |
5892
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
382 |
Os_desc *osp; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
383 |
Aliste idx2; |
0 | 384 |
|
385 |
if (phd->p_type == PT_LOAD) { |
|
1682 | 386 |
if (sgp->sg_osdescs != NULL) { |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
387 |
Word _flags = phd->p_flags & (PF_W | PF_R); |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
388 |
|
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
389 |
if (_flags == PF_R) |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
390 |
tsgp = sgp; |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
391 |
else if (_flags == (PF_W | PF_R)) |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
392 |
dsgp = sgp; |
0 | 393 |
} else if (sgp->sg_flags & FLG_SG_EMPTY) |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
394 |
esgp = sgp; |
0 | 395 |
} |
396 |
||
397 |
/* |
|
398 |
* Generate a section symbol for each output section. |
|
399 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
400 |
for (APLIST_TRAVERSE(sgp->sg_osdescs, idx2, osp)) { |
0 | 401 |
Word sectndx; |
402 |
||
403 |
sym = &_sym; |
|
404 |
sym->st_value = osp->os_shdr->sh_addr; |
|
405 |
sym->st_info = ELF_ST_INFO(STB_LOCAL, STT_SECTION); |
|
406 |
/* LINTED */ |
|
407 |
sectndx = elf_ndxscn(osp->os_scn); |
|
408 |
||
409 |
if (symtab) { |
|
410 |
if (sectndx >= SHN_LORESERVE) { |
|
411 |
symshndx[symtab_ndx] = sectndx; |
|
412 |
sym->st_shndx = SHN_XINDEX; |
|
413 |
} else { |
|
414 |
/* LINTED */ |
|
415 |
sym->st_shndx = (Half)sectndx; |
|
416 |
} |
|
417 |
symtab[symtab_ndx++] = *sym; |
|
418 |
} |
|
419 |
||
420 |
if (dynsym && (osp->os_flags & FLG_OS_OUTREL)) |
|
421 |
dynsym[dynsym_ndx++] = *sym; |
|
422 |
||
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
423 |
if ((dynsym == NULL) || |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
424 |
(osp->os_flags & FLG_OS_OUTREL)) { |
0 | 425 |
if (versym) |
426 |
versym[*symndx - 1] = 0; |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
427 |
osp->os_identndx = *symndx - 1; |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
428 |
DBG_CALL(Dbg_syms_sec_entry(ofl->ofl_lml, |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
429 |
osp->os_identndx, sgp, osp)); |
0 | 430 |
} |
431 |
||
432 |
/* |
|
433 |
* Generate the .shstrtab for this section. |
|
434 |
*/ |
|
435 |
(void) st_setstring(shstrtab, osp->os_name, &stoff); |
|
436 |
osp->os_shdr->sh_name = (Word)stoff; |
|
437 |
||
438 |
/* |
|
439 |
* Find the section index for our special symbols. |
|
440 |
*/ |
|
441 |
if (sgp == tsgp) { |
|
442 |
/* LINTED */ |
|
443 |
etext_ndx = elf_ndxscn(osp->os_scn); |
|
444 |
} else if (dsgp == sgp) { |
|
445 |
if (osp->os_shdr->sh_type != SHT_NOBITS) { |
|
446 |
/* LINTED */ |
|
447 |
edata_ndx = elf_ndxscn(osp->os_scn); |
|
448 |
} |
|
449 |
} |
|
450 |
||
451 |
if (start_set == 0) { |
|
452 |
start = sgp->sg_phdr.p_vaddr; |
|
453 |
/* LINTED */ |
|
454 |
start_ndx = elf_ndxscn(osp->os_scn); |
|
455 |
start_set++; |
|
456 |
} |
|
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
457 |
|
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
458 |
/* |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
459 |
* While we're here, determine whether a .init or .fini |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
460 |
* section exist. |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
461 |
*/ |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
462 |
if ((iosp == NULL) && (strcmp(osp->os_name, |
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
463 |
MSG_ORIG(MSG_SCN_INIT)) == 0)) |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
464 |
iosp = osp; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
465 |
if ((fosp == NULL) && (strcmp(osp->os_name, |
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
466 |
MSG_ORIG(MSG_SCN_FINI)) == 0)) |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
467 |
fosp = osp; |
0 | 468 |
} |
469 |
} |
|
470 |
||
471 |
/* |
|
472 |
* Add local register symbols to the .dynsym. These are required as |
|
473 |
* DT_REGISTER .dynamic entries must have a symbol to reference. |
|
474 |
*/ |
|
475 |
if (ofl->ofl_regsyms && dynsym) { |
|
476 |
int ndx; |
|
477 |
||
478 |
for (ndx = 0; ndx < ofl->ofl_regsymsno; ndx++) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
479 |
Sym_desc *rsdp; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
480 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
481 |
if ((rsdp = ofl->ofl_regsyms[ndx]) == NULL) |
0 | 482 |
continue; |
483 |
||
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
484 |
if (!SYM_IS_HIDDEN(rsdp) && |
0 | 485 |
(ELF_ST_BIND(rsdp->sd_sym->st_info) != STB_LOCAL)) |
486 |
continue; |
|
487 |
||
488 |
dynsym[dynsym_ndx] = *(rsdp->sd_sym); |
|
489 |
rsdp->sd_symndx = *symndx; |
|
490 |
||
491 |
if (dynsym[dynsym_ndx].st_name) { |
|
492 |
(void) st_setstring(dynstr, rsdp->sd_name, |
|
493 |
&stoff); |
|
494 |
dynsym[dynsym_ndx].st_name = stoff; |
|
495 |
} |
|
496 |
dynsym_ndx++; |
|
497 |
} |
|
498 |
} |
|
499 |
||
500 |
/* |
|
501 |
* Having traversed all the output segments, warn the user if the |
|
502 |
* traditional text or data segments don't exist. Otherwise from these |
|
503 |
* segments establish the values for `etext', `edata', `end', `END', |
|
504 |
* and `START'. |
|
505 |
*/ |
|
506 |
if (!(flags & FLG_OF_RELOBJ)) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
507 |
Sg_desc *sgp; |
0 | 508 |
|
509 |
if (tsgp) |
|
510 |
etext = tsgp->sg_phdr.p_vaddr + tsgp->sg_phdr.p_filesz; |
|
511 |
else { |
|
512 |
etext = (Addr)0; |
|
513 |
etext_ndx = SHN_ABS; |
|
514 |
etext_abs = 1; |
|
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
515 |
if (flags & FLG_OF_VERBOSE) |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
516 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
0 | 517 |
MSG_INTL(MSG_UPD_NOREADSEG)); |
518 |
} |
|
519 |
if (dsgp) { |
|
520 |
edata = dsgp->sg_phdr.p_vaddr + dsgp->sg_phdr.p_filesz; |
|
521 |
} else { |
|
522 |
edata = (Addr)0; |
|
523 |
edata_ndx = SHN_ABS; |
|
524 |
edata_abs = 1; |
|
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
525 |
if (flags & FLG_OF_VERBOSE) |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
526 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
0 | 527 |
MSG_INTL(MSG_UPD_NORDWRSEG)); |
528 |
} |
|
529 |
||
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
530 |
if (dsgp == NULL) { |
0 | 531 |
if (tsgp) |
532 |
sgp = tsgp; |
|
533 |
else |
|
534 |
sgp = 0; |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
535 |
} else if (tsgp == NULL) |
0 | 536 |
sgp = dsgp; |
537 |
else if (dsgp->sg_phdr.p_vaddr > tsgp->sg_phdr.p_vaddr) |
|
538 |
sgp = dsgp; |
|
539 |
else if (dsgp->sg_phdr.p_vaddr < tsgp->sg_phdr.p_vaddr) |
|
540 |
sgp = tsgp; |
|
541 |
else { |
|
542 |
/* |
|
543 |
* One of the segments must be of zero size. |
|
544 |
*/ |
|
545 |
if (tsgp->sg_phdr.p_memsz) |
|
546 |
sgp = tsgp; |
|
547 |
else |
|
548 |
sgp = dsgp; |
|
549 |
} |
|
550 |
||
551 |
if (esgp && (esgp->sg_phdr.p_vaddr > sgp->sg_phdr.p_vaddr)) |
|
552 |
sgp = esgp; |
|
553 |
||
554 |
if (sgp) { |
|
555 |
end = sgp->sg_phdr.p_vaddr + sgp->sg_phdr.p_memsz; |
|
556 |
||
557 |
/* |
|
1722
7b9a53f2503b
6327926 ld does not set etext symbol correctly for AMD64 medium model
seizo
parents:
1698
diff
changeset
|
558 |
* If the last loadable segment is a read-only segment, |
7b9a53f2503b
6327926 ld does not set etext symbol correctly for AMD64 medium model
seizo
parents:
1698
diff
changeset
|
559 |
* then the application which uses the symbol _end to |
7b9a53f2503b
6327926 ld does not set etext symbol correctly for AMD64 medium model
seizo
parents:
1698
diff
changeset
|
560 |
* find the beginning of writable heap area may cause |
7b9a53f2503b
6327926 ld does not set etext symbol correctly for AMD64 medium model
seizo
parents:
1698
diff
changeset
|
561 |
* segmentation violation. We adjust the value of the |
7b9a53f2503b
6327926 ld does not set etext symbol correctly for AMD64 medium model
seizo
parents:
1698
diff
changeset
|
562 |
* _end to skip to the next page boundary. |
7b9a53f2503b
6327926 ld does not set etext symbol correctly for AMD64 medium model
seizo
parents:
1698
diff
changeset
|
563 |
* |
7b9a53f2503b
6327926 ld does not set etext symbol correctly for AMD64 medium model
seizo
parents:
1698
diff
changeset
|
564 |
* 6401812 System interface which returs beginning |
7b9a53f2503b
6327926 ld does not set etext symbol correctly for AMD64 medium model
seizo
parents:
1698
diff
changeset
|
565 |
* heap would be nice. |
7b9a53f2503b
6327926 ld does not set etext symbol correctly for AMD64 medium model
seizo
parents:
1698
diff
changeset
|
566 |
* When the above RFE is implemented, the changes below |
7b9a53f2503b
6327926 ld does not set etext symbol correctly for AMD64 medium model
seizo
parents:
1698
diff
changeset
|
567 |
* could be changed in a better way. |
7b9a53f2503b
6327926 ld does not set etext symbol correctly for AMD64 medium model
seizo
parents:
1698
diff
changeset
|
568 |
*/ |
7b9a53f2503b
6327926 ld does not set etext symbol correctly for AMD64 medium model
seizo
parents:
1698
diff
changeset
|
569 |
if ((sgp->sg_phdr.p_flags & PF_W) == 0) |
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
570 |
end = (Addr)S_ROUND(end, sysconf(_SC_PAGESIZE)); |
1722
7b9a53f2503b
6327926 ld does not set etext symbol correctly for AMD64 medium model
seizo
parents:
1698
diff
changeset
|
571 |
|
7b9a53f2503b
6327926 ld does not set etext symbol correctly for AMD64 medium model
seizo
parents:
1698
diff
changeset
|
572 |
/* |
0 | 573 |
* If we're dealing with a memory reservation there are |
574 |
* no sections to establish an index for _end, so assign |
|
575 |
* it as an absolute. |
|
576 |
*/ |
|
1682 | 577 |
if (sgp->sg_osdescs != NULL) { |
578 |
/* |
|
579 |
* Determine the last section for this segment. |
|
580 |
*/ |
|
5892
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
581 |
Os_desc *osp = sgp->sg_osdescs->apl_data |
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
582 |
[sgp->sg_osdescs->apl_nitems - 1]; |
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
583 |
|
0 | 584 |
/* LINTED */ |
5892
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
585 |
end_ndx = elf_ndxscn(osp->os_scn); |
0 | 586 |
} else { |
587 |
end_ndx = SHN_ABS; |
|
588 |
end_abs = 1; |
|
589 |
} |
|
590 |
} else { |
|
591 |
end = (Addr) 0; |
|
592 |
end_ndx = SHN_ABS; |
|
593 |
end_abs = 1; |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
594 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
595 |
MSG_INTL(MSG_UPD_NOSEG)); |
0 | 596 |
} |
597 |
} |
|
598 |
||
599 |
/* |
|
600 |
* Initialize the scoped symbol table entry point. This is for all |
|
601 |
* the global symbols that have been scoped to locals and will be |
|
602 |
* filled in during global symbol processing so that we don't have |
|
603 |
* to traverse the globals symbol hash array more than once. |
|
604 |
*/ |
|
605 |
if (symtab) { |
|
8140
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
606 |
scopesym_bndx = symtab_ndx; |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
607 |
scopesym_ndx = scopesym_bndx; |
0 | 608 |
symtab_ndx += ofl->ofl_scopecnt; |
609 |
} |
|
610 |
||
611 |
/* |
|
8159
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
612 |
* If expanding partially expanded symbols under '-z nopartial', |
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
613 |
* prepare to do that. |
0 | 614 |
*/ |
8159
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
615 |
if (ofl->ofl_isparexpn) { |
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
616 |
osp = ofl->ofl_isparexpn->is_osdesc; |
8369
7536f6823d94
6773695 ld -z nopartial can break non-pic objects
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8159
diff
changeset
|
617 |
parexpnbase = parexpnaddr = (Addr)(osp->os_shdr->sh_addr + |
8159
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
618 |
ofl->ofl_isparexpn->is_indata->d_off); |
0 | 619 |
/* LINTED */ |
8159
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
620 |
parexpnndx = elf_ndxscn(osp->os_scn); |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
621 |
ofl->ofl_parexpnndx = osp->os_identndx; |
0 | 622 |
} |
623 |
||
624 |
/* |
|
625 |
* If we are generating a .symtab collect all the local symbols, |
|
626 |
* assigning a new virtual address or displacement (value). |
|
627 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
628 |
for (APLIST_TRAVERSE(ofl->ofl_objs, idx1, ifl)) { |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
629 |
Xword lndx, local = ifl->ifl_locscnt; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
630 |
Cap_desc *cdp = ifl->ifl_caps; |
0 | 631 |
|
632 |
for (lndx = 1; lndx < local; lndx++) { |
|
633 |
Gotndx *gnp; |
|
3492 | 634 |
uchar_t type; |
0 | 635 |
Word *_symshndx; |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
636 |
int enter_in_symtab, enter_in_ldynsym; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
637 |
int update_done; |
0 | 638 |
|
639 |
sdp = ifl->ifl_oldndx[lndx]; |
|
640 |
sym = sdp->sd_sym; |
|
641 |
||
642 |
/* |
|
643 |
* Assign a got offset if necessary. |
|
644 |
*/ |
|
6206 | 645 |
if ((ld_targ.t_mr.mr_assign_got != NULL) && |
646 |
(*ld_targ.t_mr.mr_assign_got)(ofl, sdp) == S_ERROR) |
|
0 | 647 |
return ((Addr)S_ERROR); |
6206 | 648 |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
649 |
if (DBG_ENABLED) { |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
650 |
Aliste idx2; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
651 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
652 |
for (ALIST_TRAVERSE(sdp->sd_GOTndxs, |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
653 |
idx2, gnp)) { |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
654 |
gottable->gt_sym = sdp; |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
655 |
gottable->gt_gndx.gn_gotndx = |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
656 |
gnp->gn_gotndx; |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
657 |
gottable->gt_gndx.gn_addend = |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
658 |
gnp->gn_addend; |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
659 |
gottable++; |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
660 |
} |
0 | 661 |
} |
662 |
||
663 |
if ((type = ELF_ST_TYPE(sym->st_info)) == STT_SECTION) |
|
664 |
continue; |
|
665 |
||
666 |
/* |
|
667 |
* Ignore any symbols that have been marked as invalid |
|
668 |
* during input processing. Providing these aren't used |
|
669 |
* for relocation they'll just be dropped from the |
|
670 |
* output image. |
|
671 |
*/ |
|
672 |
if (sdp->sd_flags & FLG_SY_INVALID) |
|
673 |
continue; |
|
674 |
||
675 |
/* |
|
676 |
* If the section that this symbol was associated |
|
677 |
* with has been discarded - then we discard |
|
678 |
* the local symbol along with it. |
|
679 |
*/ |
|
680 |
if (sdp->sd_flags & FLG_SY_ISDISC) |
|
681 |
continue; |
|
682 |
||
683 |
/* |
|
8140
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
684 |
* If this symbol is from a different file |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
685 |
* than the input descriptor we are processing, |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
686 |
* treat it as if it has FLG_SY_ISDISC set. |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
687 |
* This happens when sloppy_comdat_reloc() |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
688 |
* replaces a symbol to a discarded comdat section |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
689 |
* with an equivalent symbol from a different |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
690 |
* file. We only want to enter such a symbol |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
691 |
* once --- as part of the file that actually |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
692 |
* supplies it. |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
693 |
*/ |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
694 |
if (ifl != sdp->sd_file) |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
695 |
continue; |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
696 |
|
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
697 |
/* |
0 | 698 |
* Generate an output symbol to represent this input |
699 |
* symbol. Even if the symbol table is to be stripped |
|
700 |
* we still need to update any local symbols that are |
|
701 |
* used during relocation. |
|
702 |
*/ |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
703 |
enter_in_symtab = symtab && |
6614
144184774564
6699594 The ld command has a problem handling 'protected' mapfile keyword.
rie
parents:
6299
diff
changeset
|
704 |
(!(ofl->ofl_flags & FLG_OF_REDLSYM) || |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
705 |
sdp->sd_move); |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
706 |
enter_in_ldynsym = ldynsym && sdp->sd_name && |
3492 | 707 |
ldynsym_symtype[type] && |
6614
144184774564
6699594 The ld command has a problem handling 'protected' mapfile keyword.
rie
parents:
6299
diff
changeset
|
708 |
!(ofl->ofl_flags & FLG_OF_REDLSYM); |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
709 |
_symshndx = NULL; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
710 |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
711 |
if (enter_in_symtab) { |
0 | 712 |
if (!dynsym) |
713 |
sdp->sd_symndx = *symndx; |
|
714 |
symtab[symtab_ndx] = *sym; |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
715 |
|
0 | 716 |
/* |
717 |
* Provided this isn't an unnamed register |
|
718 |
* symbol, update its name. |
|
719 |
*/ |
|
720 |
if (((sdp->sd_flags & FLG_SY_REGSYM) == 0) || |
|
721 |
symtab[symtab_ndx].st_name) { |
|
722 |
(void) st_setstring(strtab, |
|
723 |
sdp->sd_name, &stoff); |
|
724 |
symtab[symtab_ndx].st_name = stoff; |
|
725 |
} |
|
726 |
sdp->sd_flags &= ~FLG_SY_CLEAN; |
|
727 |
if (symshndx) |
|
728 |
_symshndx = &symshndx[symtab_ndx]; |
|
729 |
sdp->sd_sym = sym = &symtab[symtab_ndx++]; |
|
730 |
||
731 |
if ((sdp->sd_flags & FLG_SY_SPECSEC) && |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
732 |
(sym->st_shndx == SHN_ABS) && |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
733 |
!enter_in_ldynsym) |
0 | 734 |
continue; |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
735 |
} else if (enter_in_ldynsym) { |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
736 |
/* |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
737 |
* Not using symtab, but we do have ldynsym |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
738 |
* available. |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
739 |
*/ |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
740 |
ldynsym[ldynsym_ndx] = *sym; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
741 |
(void) st_setstring(dynstr, sdp->sd_name, |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
742 |
&stoff); |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
743 |
ldynsym[ldynsym_ndx].st_name = stoff; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
744 |
|
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
745 |
sdp->sd_flags &= ~FLG_SY_CLEAN; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
746 |
if (ldynshndx) |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
747 |
_symshndx = &ldynshndx[ldynsym_ndx]; |
3492 | 748 |
sdp->sd_sym = sym = &ldynsym[ldynsym_ndx]; |
749 |
/* Add it to sort section if it qualifies */ |
|
750 |
ADD_TO_DYNSORT(sdp, sym, type, ldynsym_ndx); |
|
751 |
ldynsym_ndx++; |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
752 |
} else { /* Not using symtab or ldynsym */ |
0 | 753 |
/* |
754 |
* If this symbol requires modifying to provide |
|
755 |
* for a relocation or move table update, make |
|
756 |
* a copy of it. |
|
757 |
*/ |
|
758 |
if (!(sdp->sd_flags & FLG_SY_UPREQD) && |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
759 |
!(sdp->sd_move)) |
0 | 760 |
continue; |
761 |
if ((sdp->sd_flags & FLG_SY_SPECSEC) && |
|
762 |
(sym->st_shndx == SHN_ABS)) |
|
763 |
continue; |
|
764 |
||
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
765 |
if (ld_sym_copy(sdp) == S_ERROR) |
0 | 766 |
return ((Addr)S_ERROR); |
767 |
sym = sdp->sd_sym; |
|
768 |
} |
|
769 |
||
770 |
/* |
|
771 |
* Update the symbols contents if necessary. |
|
772 |
*/ |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
773 |
update_done = 0; |
0 | 774 |
if (type == STT_FILE) { |
775 |
sdp->sd_shndx = sym->st_shndx = SHN_ABS; |
|
776 |
sdp->sd_flags |= FLG_SY_SPECSEC; |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
777 |
update_done = 1; |
0 | 778 |
} |
779 |
||
780 |
/* |
|
781 |
* If we are expanding the locally bound partially |
|
782 |
* initialized symbols, then update the address here. |
|
783 |
*/ |
|
8159
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
784 |
if (ofl->ofl_isparexpn && |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
785 |
(sdp->sd_flags & FLG_SY_PAREXPN) && !update_done) { |
8159
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
786 |
sym->st_shndx = parexpnndx; |
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
787 |
sdp->sd_isc = ofl->ofl_isparexpn; |
8369
7536f6823d94
6773695 ld -z nopartial can break non-pic objects
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8159
diff
changeset
|
788 |
sym->st_value = parexpnaddr; |
8159
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
789 |
parexpnaddr += sym->st_size; |
8369
7536f6823d94
6773695 ld -z nopartial can break non-pic objects
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8159
diff
changeset
|
790 |
if ((flags & FLG_OF_RELOBJ) == 0) |
7536f6823d94
6773695 ld -z nopartial can break non-pic objects
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8159
diff
changeset
|
791 |
sym->st_value -= parexpnbase; |
0 | 792 |
} |
793 |
||
794 |
/* |
|
795 |
* If this isn't an UNDEF symbol (ie. an input section |
|
796 |
* is associated), update the symbols value and index. |
|
797 |
*/ |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
798 |
if (((isc = sdp->sd_isc) != NULL) && !update_done) { |
0 | 799 |
Word sectndx; |
800 |
||
801 |
osp = isc->is_osdesc; |
|
802 |
/* LINTED */ |
|
803 |
sym->st_value += |
|
804 |
(Off)_elf_getxoff(isc->is_indata); |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
805 |
if ((flags & FLG_OF_RELOBJ) == 0) { |
0 | 806 |
sym->st_value += osp->os_shdr->sh_addr; |
807 |
/* |
|
808 |
* TLS symbols are relative to |
|
809 |
* the TLS segment. |
|
810 |
*/ |
|
3492 | 811 |
if ((type == STT_TLS) && |
812 |
(ofl->ofl_tlsphdr)) { |
|
0 | 813 |
sym->st_value -= |
814 |
ofl->ofl_tlsphdr->p_vaddr; |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
815 |
} |
0 | 816 |
} |
817 |
/* LINTED */ |
|
818 |
if ((sdp->sd_shndx = sectndx = |
|
819 |
elf_ndxscn(osp->os_scn)) >= SHN_LORESERVE) { |
|
820 |
if (_symshndx) { |
|
821 |
*_symshndx = sectndx; |
|
822 |
} |
|
823 |
sym->st_shndx = SHN_XINDEX; |
|
824 |
} else { |
|
825 |
/* LINTED */ |
|
826 |
sym->st_shndx = sectndx; |
|
827 |
} |
|
828 |
} |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
829 |
|
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
830 |
/* |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
831 |
* If entering the symbol in both the symtab and the |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
832 |
* ldynsym, then the one in symtab needs to be |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
833 |
* copied to ldynsym. If it is only in the ldynsym, |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
834 |
* then the code above already set it up and we have |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
835 |
* nothing more to do here. |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
836 |
*/ |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
837 |
if (enter_in_symtab && enter_in_ldynsym) { |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
838 |
ldynsym[ldynsym_ndx] = *sym; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
839 |
(void) st_setstring(dynstr, sdp->sd_name, |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
840 |
&stoff); |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
841 |
ldynsym[ldynsym_ndx].st_name = stoff; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
842 |
|
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
843 |
if (_symshndx && ldynshndx) |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
844 |
ldynshndx[ldynsym_ndx] = *_symshndx; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
845 |
|
3492 | 846 |
/* Add it to sort section if it qualifies */ |
847 |
ADD_TO_DYNSORT(sdp, sym, type, ldynsym_ndx); |
|
848 |
||
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
849 |
ldynsym_ndx++; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
850 |
} |
0 | 851 |
} |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
852 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
853 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
854 |
* If this input file has undergone object to symbol |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
855 |
* capabilities conversion, supply any new capabilities symbols. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
856 |
* These symbols are copies of the original global symbols, and |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
857 |
* follow the existing local symbols that are supplied from this |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
858 |
* input file (which are identified with a preceding STT_FILE). |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
859 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
860 |
if (symtab && cdp && cdp->ca_syms) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
861 |
Aliste idx2; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
862 |
Cap_sym *csp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
863 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
864 |
for (APLIST_TRAVERSE(cdp->ca_syms, idx2, csp)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
865 |
Is_desc *isp; |
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 |
sdp = csp->cs_sdp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
868 |
sym = sdp->sd_sym; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
869 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
870 |
if ((isp = sdp->sd_isc) != NULL) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
871 |
Os_desc *osp = isp->is_osdesc; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
872 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
873 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
874 |
* Update the symbols value. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
875 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
876 |
/* LINTED */ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
877 |
sym->st_value += |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
878 |
(Off)_elf_getxoff(isp->is_indata); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
879 |
if ((flags & FLG_OF_RELOBJ) == 0) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
880 |
sym->st_value += |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
881 |
osp->os_shdr->sh_addr; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
882 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
883 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
884 |
* Update the symbols section index. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
885 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
886 |
sdp->sd_shndx = sym->st_shndx = |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
887 |
elf_ndxscn(osp->os_scn); |
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 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
890 |
symtab[symtab_ndx] = *sym; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
891 |
(void) st_setstring(strtab, sdp->sd_name, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
892 |
&stoff); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
893 |
symtab[symtab_ndx].st_name = stoff; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
894 |
sdp->sd_symndx = symtab_ndx++; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
895 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
896 |
} |
0 | 897 |
} |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
898 |
|
8140
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
899 |
symtab_gbl_bndx = symtab_ndx; /* .symtab index of 1st global entry */ |
0 | 900 |
|
901 |
/* |
|
902 |
* Two special symbols are `_init' and `_fini'. If these are supplied |
|
903 |
* by crti.o then they are used to represent the total concatenation of |
|
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
904 |
* the `.init' and `.fini' sections. |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
905 |
* |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
906 |
* Determine whether any .init or .fini sections exist. If these |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
907 |
* sections exist and a dynamic object is being built, but no `_init' |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
908 |
* or `_fini' symbols are found, then the user is probably building |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
909 |
* this object directly from ld(1) rather than using a compiler driver |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
910 |
* that provides the symbols via crt's. |
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
911 |
* |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
912 |
* If the .init or .fini section exist, and their associated symbols, |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
913 |
* determine the size of the sections and updated the symbols value |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
914 |
* accordingly. |
0 | 915 |
*/ |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
916 |
if (((sdp = ld_sym_find(MSG_ORIG(MSG_SYM_INIT_U), SYM_NOHASH, 0, |
0 | 917 |
ofl)) != NULL) && (sdp->sd_ref == REF_REL_NEED) && sdp->sd_isc && |
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
918 |
(sdp->sd_isc->is_osdesc == iosp)) { |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
919 |
if (ld_sym_copy(sdp) == S_ERROR) |
0 | 920 |
return ((Addr)S_ERROR); |
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
921 |
sdp->sd_sym->st_size = sdp->sd_isc->is_osdesc->os_shdr->sh_size; |
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
922 |
|
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
923 |
} else if (iosp && !(flags & FLG_OF_RELOBJ)) { |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
924 |
eprintf(ofl->ofl_lml, ERR_WARNING, MSG_INTL(MSG_SYM_NOCRT), |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
925 |
MSG_ORIG(MSG_SYM_INIT_U), MSG_ORIG(MSG_SCN_INIT)); |
0 | 926 |
} |
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
927 |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
928 |
if (((sdp = ld_sym_find(MSG_ORIG(MSG_SYM_FINI_U), SYM_NOHASH, 0, |
0 | 929 |
ofl)) != NULL) && (sdp->sd_ref == REF_REL_NEED) && sdp->sd_isc && |
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
930 |
(sdp->sd_isc->is_osdesc == fosp)) { |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
931 |
if (ld_sym_copy(sdp) == S_ERROR) |
0 | 932 |
return ((Addr)S_ERROR); |
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
933 |
sdp->sd_sym->st_size = sdp->sd_isc->is_osdesc->os_shdr->sh_size; |
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
934 |
|
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
935 |
} else if (fosp && !(flags & FLG_OF_RELOBJ)) { |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
936 |
eprintf(ofl->ofl_lml, ERR_WARNING, MSG_INTL(MSG_SYM_NOCRT), |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
937 |
MSG_ORIG(MSG_SYM_FINI_U), MSG_ORIG(MSG_SCN_FINI)); |
0 | 938 |
} |
939 |
||
940 |
/* |
|
941 |
* Assign .bss information for use with updating COMMON symbols. |
|
942 |
*/ |
|
943 |
if (ofl->ofl_isbss) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
944 |
isc = ofl->ofl_isbss; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
945 |
osp = isc->is_osdesc; |
0 | 946 |
|
947 |
bssaddr = osp->os_shdr->sh_addr + |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
948 |
(Off)_elf_getxoff(isc->is_indata); |
0 | 949 |
/* LINTED */ |
950 |
bssndx = elf_ndxscn(osp->os_scn); |
|
951 |
} |
|
952 |
||
6206 | 953 |
#if defined(_ELF64) |
574 | 954 |
/* |
6206 | 955 |
* For amd64 target, assign .lbss information for use |
956 |
* with updating LCOMMON symbols. |
|
574 | 957 |
*/ |
6206 | 958 |
if ((ld_targ.t_m.m_mach == EM_AMD64) && ofl->ofl_islbss) { |
574 | 959 |
osp = ofl->ofl_islbss->is_osdesc; |
960 |
||
961 |
lbssaddr = osp->os_shdr->sh_addr + |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
962 |
(Off)_elf_getxoff(ofl->ofl_islbss->is_indata); |
574 | 963 |
/* LINTED */ |
964 |
lbssndx = elf_ndxscn(osp->os_scn); |
|
965 |
} |
|
966 |
#endif |
|
0 | 967 |
/* |
968 |
* Assign .tlsbss information for use with updating COMMON symbols. |
|
969 |
*/ |
|
970 |
if (ofl->ofl_istlsbss) { |
|
971 |
osp = ofl->ofl_istlsbss->is_osdesc; |
|
972 |
tlsbssaddr = osp->os_shdr->sh_addr + |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
973 |
(Off)_elf_getxoff(ofl->ofl_istlsbss->is_indata); |
0 | 974 |
/* LINTED */ |
975 |
tlsbssndx = elf_ndxscn(osp->os_scn); |
|
976 |
} |
|
977 |
||
978 |
if ((sorted_syms = libld_calloc(ofl->ofl_globcnt + |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
979 |
ofl->ofl_elimcnt + ofl->ofl_scopecnt, |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
980 |
sizeof (*sorted_syms))) == NULL) |
0 | 981 |
return ((Addr)S_ERROR); |
982 |
||
983 |
scndx = 0; |
|
984 |
ssndx = ofl->ofl_scopecnt + ofl->ofl_elimcnt; |
|
985 |
||
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
986 |
DBG_CALL(Dbg_syms_up_title(ofl->ofl_lml)); |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
987 |
|
0 | 988 |
/* |
10167
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
989 |
* Traverse the internal symbol table updating global symbol information |
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
990 |
* and allocating common. |
0 | 991 |
*/ |
992 |
for (sav = avl_first(&ofl->ofl_symavl); sav; |
|
993 |
sav = AVL_NEXT(&ofl->ofl_symavl, sav)) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
994 |
Sym *symptr; |
0 | 995 |
int local; |
574 | 996 |
int restore; |
0 | 997 |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
998 |
sdp = sav->sav_sdp; |
0 | 999 |
|
1000 |
/* |
|
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1001 |
* Ignore any symbols that have been marked as invalid during |
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1002 |
* input processing. Providing these aren't used for |
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1003 |
* relocation, they will be dropped from the output image. |
0 | 1004 |
*/ |
1005 |
if (sdp->sd_flags & FLG_SY_INVALID) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
1006 |
DBG_CALL(Dbg_syms_old(ofl, sdp)); |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
1007 |
DBG_CALL(Dbg_syms_ignore(ofl, sdp)); |
0 | 1008 |
continue; |
1009 |
} |
|
1010 |
||
1011 |
/* |
|
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1012 |
* Only needed symbols are copied to the output symbol table. |
0 | 1013 |
*/ |
1014 |
if (sdp->sd_ref == REF_DYN_SEEN) |
|
1015 |
continue; |
|
1016 |
||
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1017 |
if (SYM_IS_HIDDEN(sdp) && (flags & FLG_OF_PROCRED)) |
0 | 1018 |
local = 1; |
1019 |
else |
|
1020 |
local = 0; |
|
1021 |
||
1022 |
if (local || (ofl->ofl_hashbkts == 0)) { |
|
1023 |
sorted_syms[scndx++].sl_sdp = sdp; |
|
1024 |
} else { |
|
1025 |
sorted_syms[ssndx].sl_hval = sdp->sd_aux->sa_hash % |
|
1026 |
ofl->ofl_hashbkts; |
|
1027 |
sorted_syms[ssndx].sl_sdp = sdp; |
|
1028 |
ssndx++; |
|
1029 |
} |
|
1030 |
||
1031 |
/* |
|
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1032 |
* Note - expand the COMMON symbols here because an address |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1033 |
* must be assigned to them in the same order that space was |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1034 |
* calculated in sym_validate(). If this ordering isn't |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1035 |
* followed differing alignment requirements can throw us all |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1036 |
* out of whack. |
0 | 1037 |
* |
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1038 |
* The expanded .bss global symbol is handled here as well. |
0 | 1039 |
* |
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1040 |
* The actual adding entries into the symbol table still occurs |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1041 |
* below in hashbucket order. |
0 | 1042 |
*/ |
1043 |
symptr = sdp->sd_sym; |
|
574 | 1044 |
restore = 0; |
0 | 1045 |
if ((sdp->sd_flags & FLG_SY_PAREXPN) || |
1046 |
((sdp->sd_flags & FLG_SY_SPECSEC) && |
|
1047 |
(sdp->sd_shndx = symptr->st_shndx) == SHN_COMMON)) { |
|
1048 |
||
1049 |
/* |
|
8159
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
1050 |
* An expanded symbol goes to a special .data section |
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
1051 |
* prepared for that purpose (ofl->ofl_isparexpn). |
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1052 |
* Assign COMMON allocations to .bss. |
0 | 1053 |
* Otherwise leave it as is. |
1054 |
*/ |
|
1055 |
if (sdp->sd_flags & FLG_SY_PAREXPN) { |
|
1056 |
restore = 1; |
|
8159
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
1057 |
sdp->sd_shndx = parexpnndx; |
0 | 1058 |
sdp->sd_flags &= ~FLG_SY_SPECSEC; |
1059 |
symptr->st_value = (Xword) S_ROUND( |
|
8159
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
1060 |
parexpnaddr, symptr->st_value); |
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
1061 |
parexpnaddr = symptr->st_value + |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1062 |
symptr->st_size; |
8159
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
1063 |
sdp->sd_isc = ofl->ofl_isparexpn; |
0 | 1064 |
sdp->sd_flags |= FLG_SY_COMMEXP; |
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1065 |
|
0 | 1066 |
} else if (ELF_ST_TYPE(symptr->st_info) != STT_TLS && |
1067 |
(local || !(flags & FLG_OF_RELOBJ))) { |
|
1068 |
restore = 1; |
|
1069 |
sdp->sd_shndx = bssndx; |
|
1070 |
sdp->sd_flags &= ~FLG_SY_SPECSEC; |
|
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1071 |
symptr->st_value = (Xword)S_ROUND(bssaddr, |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1072 |
symptr->st_value); |
0 | 1073 |
bssaddr = symptr->st_value + symptr->st_size; |
1074 |
sdp->sd_isc = ofl->ofl_isbss; |
|
1075 |
sdp->sd_flags |= FLG_SY_COMMEXP; |
|
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1076 |
|
0 | 1077 |
} else if (ELF_ST_TYPE(symptr->st_info) == STT_TLS && |
1078 |
(local || !(flags & FLG_OF_RELOBJ))) { |
|
1079 |
restore = 1; |
|
1080 |
sdp->sd_shndx = tlsbssndx; |
|
1081 |
sdp->sd_flags &= ~FLG_SY_SPECSEC; |
|
1082 |
symptr->st_value = (Xword)S_ROUND(tlsbssaddr, |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1083 |
symptr->st_value); |
0 | 1084 |
tlsbssaddr = symptr->st_value + symptr->st_size; |
1085 |
sdp->sd_isc = ofl->ofl_istlsbss; |
|
1086 |
sdp->sd_flags |= FLG_SY_COMMEXP; |
|
1087 |
/* |
|
542 | 1088 |
* TLS symbols are relative to the TLS segment. |
0 | 1089 |
*/ |
1090 |
symptr->st_value -= ofl->ofl_tlsphdr->p_vaddr; |
|
1091 |
} |
|
6206 | 1092 |
#if defined(_ELF64) |
1093 |
} else if ((ld_targ.t_m.m_mach == EM_AMD64) && |
|
1094 |
(sdp->sd_flags & FLG_SY_SPECSEC) && |
|
574 | 1095 |
((sdp->sd_shndx = symptr->st_shndx) == |
1096 |
SHN_X86_64_LCOMMON) && |
|
1097 |
((local || !(flags & FLG_OF_RELOBJ)))) { |
|
1098 |
restore = 1; |
|
1099 |
sdp->sd_shndx = lbssndx; |
|
1100 |
sdp->sd_flags &= ~FLG_SY_SPECSEC; |
|
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1101 |
symptr->st_value = (Xword)S_ROUND(lbssaddr, |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1102 |
symptr->st_value); |
574 | 1103 |
lbssaddr = symptr->st_value + symptr->st_size; |
1104 |
sdp->sd_isc = ofl->ofl_islbss; |
|
1105 |
sdp->sd_flags |= FLG_SY_COMMEXP; |
|
1106 |
#endif |
|
1107 |
} |
|
1108 |
||
1109 |
if (restore != 0) { |
|
3492 | 1110 |
uchar_t type, bind; |
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1111 |
|
574 | 1112 |
/* |
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1113 |
* Make sure this COMMON symbol is returned to the same |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1114 |
* binding as was defined in the original relocatable |
574 | 1115 |
* object reference. |
1116 |
*/ |
|
1117 |
type = ELF_ST_TYPE(symptr->st_info); |
|
1118 |
if (sdp->sd_flags & FLG_SY_GLOBREF) |
|
1119 |
bind = STB_GLOBAL; |
|
1120 |
else |
|
1121 |
bind = STB_WEAK; |
|
1122 |
||
1123 |
symptr->st_info = ELF_ST_INFO(bind, type); |
|
0 | 1124 |
} |
1125 |
} |
|
1126 |
||
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1127 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1128 |
* If this is a dynamic object then add any local capabilities symbols. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1129 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1130 |
if (dynsym && ofl->ofl_capfamilies) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1131 |
Cap_avlnode *cav; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1132 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1133 |
for (cav = avl_first(ofl->ofl_capfamilies); cav; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1134 |
cav = AVL_NEXT(ofl->ofl_capfamilies, cav)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1135 |
Cap_sym *csp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1136 |
Aliste idx; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1137 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1138 |
for (APLIST_TRAVERSE(cav->cn_members, idx, csp)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1139 |
sdp = csp->cs_sdp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1140 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1141 |
DBG_CALL(Dbg_syms_created(ofl->ofl_lml, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1142 |
sdp->sd_name)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1143 |
DBG_CALL(Dbg_syms_entered(ofl, sdp->sd_sym, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1144 |
sdp)); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1145 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1146 |
dynsym[dynsym_ndx] = *sdp->sd_sym; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1147 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1148 |
(void) st_setstring(dynstr, sdp->sd_name, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1149 |
&stoff); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1150 |
dynsym[dynsym_ndx].st_name = stoff; |
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 |
sdp->sd_sym = &dynsym[dynsym_ndx]; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1153 |
sdp->sd_symndx = dynsym_ndx; |
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 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1156 |
* Indicate that this is a capabilities symbol. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1157 |
* Note, that this identification only provides |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1158 |
* information regarding the symbol that is |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1159 |
* visible from elfdump(1) -y. The association |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1160 |
* of a symbol to its capabilities is derived |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1161 |
* from a .SUNW_capinfo entry. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1162 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1163 |
if (syminfo) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1164 |
syminfo[dynsym_ndx].si_flags |= |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1165 |
SYMINFO_FLG_CAP; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1166 |
} |
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 |
dynsym_ndx++; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1169 |
} |
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 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1172 |
|
0 | 1173 |
if (ofl->ofl_hashbkts) { |
1174 |
qsort(sorted_syms + ofl->ofl_scopecnt + ofl->ofl_elimcnt, |
|
1175 |
ofl->ofl_globcnt, sizeof (Sym_s_list), |
|
1176 |
(int (*)(const void *, const void *))sym_hash_compare); |
|
1177 |
} |
|
1178 |
||
1179 |
for (ssndx = 0; ssndx < (ofl->ofl_elimcnt + ofl->ofl_scopecnt + |
|
1180 |
ofl->ofl_globcnt); ssndx++) { |
|
1181 |
const char *name; |
|
1182 |
Sym *sym; |
|
1183 |
Sym_aux *sap; |
|
1184 |
Half spec; |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1185 |
int local = 0, dynlocal = 0, enter_in_symtab; |
0 | 1186 |
Gotndx *gnp; |
1187 |
Word sectndx; |
|
1188 |
||
1189 |
sdp = sorted_syms[ssndx].sl_sdp; |
|
1190 |
sectndx = 0; |
|
1191 |
||
1192 |
if (symtab) |
|
1193 |
enter_in_symtab = 1; |
|
1194 |
else |
|
1195 |
enter_in_symtab = 0; |
|
1196 |
||
1197 |
/* |
|
1198 |
* Assign a got offset if necessary. |
|
1199 |
*/ |
|
6206 | 1200 |
if ((ld_targ.t_mr.mr_assign_got != NULL) && |
1201 |
(*ld_targ.t_mr.mr_assign_got)(ofl, sdp) == S_ERROR) |
|
0 | 1202 |
return ((Addr)S_ERROR); |
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1203 |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
1204 |
if (DBG_ENABLED) { |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1205 |
Aliste idx2; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1206 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1207 |
for (ALIST_TRAVERSE(sdp->sd_GOTndxs, idx2, gnp)) { |
2145
f3828f946507
6423051 static TLS support within the link-editors needs a major face lift
rie
parents:
1722
diff
changeset
|
1208 |
gottable->gt_sym = sdp; |
f3828f946507
6423051 static TLS support within the link-editors needs a major face lift
rie
parents:
1722
diff
changeset
|
1209 |
gottable->gt_gndx.gn_gotndx = gnp->gn_gotndx; |
f3828f946507
6423051 static TLS support within the link-editors needs a major face lift
rie
parents:
1722
diff
changeset
|
1210 |
gottable->gt_gndx.gn_addend = gnp->gn_addend; |
f3828f946507
6423051 static TLS support within the link-editors needs a major face lift
rie
parents:
1722
diff
changeset
|
1211 |
gottable++; |
0 | 1212 |
} |
1213 |
||
1214 |
if (sdp->sd_aux && sdp->sd_aux->sa_PLTGOTndx) { |
|
2145
f3828f946507
6423051 static TLS support within the link-editors needs a major face lift
rie
parents:
1722
diff
changeset
|
1215 |
gottable->gt_sym = sdp; |
f3828f946507
6423051 static TLS support within the link-editors needs a major face lift
rie
parents:
1722
diff
changeset
|
1216 |
gottable->gt_gndx.gn_gotndx = |
0 | 1217 |
sdp->sd_aux->sa_PLTGOTndx; |
2145
f3828f946507
6423051 static TLS support within the link-editors needs a major face lift
rie
parents:
1722
diff
changeset
|
1218 |
gottable++; |
0 | 1219 |
} |
1220 |
} |
|
1221 |
||
1222 |
/* |
|
1223 |
* If this symbol has been marked as being reduced to local |
|
1224 |
* scope then it will have to be placed in the scoped portion |
|
1225 |
* of the .symtab. Retain the appropriate index for use in |
|
1226 |
* version symbol indexing and relocation. |
|
1227 |
*/ |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1228 |
if (SYM_IS_HIDDEN(sdp) && (flags & FLG_OF_PROCRED)) { |
0 | 1229 |
local = 1; |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1230 |
if (!(sdp->sd_flags & FLG_SY_ELIM) && !dynsym) |
0 | 1231 |
sdp->sd_symndx = scopesym_ndx; |
1232 |
else |
|
1233 |
sdp->sd_symndx = 0; |
|
1234 |
||
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1235 |
if (sdp->sd_flags & FLG_SY_ELIM) { |
0 | 1236 |
enter_in_symtab = 0; |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1237 |
} else if (ldynsym && sdp->sd_sym->st_name && |
3492 | 1238 |
ldynsym_symtype[ |
1239 |
ELF_ST_TYPE(sdp->sd_sym->st_info)]) { |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1240 |
dynlocal = 1; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1241 |
} |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1242 |
} else { |
0 | 1243 |
sdp->sd_symndx = *symndx; |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1244 |
} |
0 | 1245 |
|
1246 |
/* |
|
1247 |
* Copy basic symbol and string information. |
|
1248 |
*/ |
|
1249 |
name = sdp->sd_name; |
|
1250 |
sap = sdp->sd_aux; |
|
1251 |
||
1252 |
/* |
|
1253 |
* If we require to record version symbol indexes, update the |
|
1254 |
* associated version symbol information for all defined |
|
1255 |
* symbols. If a version definition is required any zero value |
|
1256 |
* symbol indexes would have been flagged as undefined symbol |
|
1257 |
* errors, however if we're just scoping these need to fall into |
|
1258 |
* the base of global symbols. |
|
1259 |
*/ |
|
1260 |
if (sdp->sd_symndx && versym) { |
|
1261 |
Half vndx = 0; |
|
1262 |
||
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
1263 |
if (sdp->sd_flags & FLG_SY_MVTOCOMM) { |
0 | 1264 |
vndx = VER_NDX_GLOBAL; |
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
1265 |
} else if (sdp->sd_ref == REF_REL_NEED) { |
0 | 1266 |
vndx = sap->sa_overndx; |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1267 |
|
0 | 1268 |
if ((vndx == 0) && |
1269 |
(sdp->sd_sym->st_shndx != SHN_UNDEF)) { |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1270 |
if (SYM_IS_HIDDEN(sdp)) |
0 | 1271 |
vndx = VER_NDX_LOCAL; |
1272 |
else |
|
1273 |
vndx = VER_NDX_GLOBAL; |
|
1274 |
} |
|
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
1275 |
} else if ((sdp->sd_ref == REF_DYN_NEED) && |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
1276 |
(sap->sa_dverndx > 0) && |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
1277 |
(sap->sa_dverndx <= sdp->sd_file->ifl_vercnt) && |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
1278 |
(sdp->sd_file->ifl_verndx != NULL)) { |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
1279 |
/* Use index of verneed record */ |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
1280 |
vndx = sdp->sd_file->ifl_verndx |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
1281 |
[sap->sa_dverndx].vi_overndx; |
0 | 1282 |
} |
1283 |
versym[sdp->sd_symndx] = vndx; |
|
1284 |
} |
|
1285 |
||
1286 |
/* |
|
1287 |
* If we are creating the .syminfo section then set per symbol |
|
1288 |
* flags here. |
|
1289 |
*/ |
|
1290 |
if (sdp->sd_symndx && syminfo && |
|
1291 |
!(sdp->sd_flags & FLG_SY_NOTAVAIL)) { |
|
1292 |
int ndx = sdp->sd_symndx; |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1293 |
APlist **alpp = &(ofl->ofl_symdtent); |
0 | 1294 |
|
1295 |
if (sdp->sd_flags & FLG_SY_MVTOCOMM) |
|
1296 |
/* |
|
1297 |
* Identify a copy relocation symbol. |
|
1298 |
*/ |
|
1299 |
syminfo[ndx].si_flags |= SYMINFO_FLG_COPY; |
|
1300 |
||
1301 |
if (sdp->sd_ref == REF_DYN_NEED) { |
|
1302 |
/* |
|
1303 |
* A reference is bound to a needed dependency. |
|
10167
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
1304 |
* Save the syminfo entry, so that when the |
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
1305 |
* .dynamic section has been updated, a |
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
1306 |
* DT_NEEDED entry can be associated |
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
1307 |
* (see update_osyminfo()). |
0 | 1308 |
*/ |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1309 |
if (aplist_append(alpp, sdp, |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1310 |
AL_CNT_OFL_SYMINFOSYMS) == NULL) |
0 | 1311 |
return (0); |
1312 |
||
10167
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
1313 |
/* |
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
1314 |
* Flag that the symbol has a direct association |
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
1315 |
* with the external reference (this is an old |
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
1316 |
* tagging, that has no real effect by itself). |
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
1317 |
*/ |
0 | 1318 |
syminfo[ndx].si_flags |= SYMINFO_FLG_DIRECT; |
12449
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1319 |
|
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1320 |
/* |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1321 |
* Flag any lazy or deferred reference. |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1322 |
*/ |
0 | 1323 |
if (sdp->sd_flags & FLG_SY_LAZYLD) |
1324 |
syminfo[ndx].si_flags |= |
|
1325 |
SYMINFO_FLG_LAZYLOAD; |
|
12449
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1326 |
if (sdp->sd_flags & FLG_SY_DEFERRED) |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1327 |
syminfo[ndx].si_flags |= |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1328 |
SYMINFO_FLG_DEFERRED; |
0 | 1329 |
|
1330 |
/* |
|
1331 |
* Enable direct symbol bindings if: |
|
1332 |
* |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1333 |
* - Symbol was identified with the DIRECT |
0 | 1334 |
* keyword in a mapfile. |
1335 |
* |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1336 |
* - Symbol reference has been bound to a |
0 | 1337 |
* dependency which was specified as |
1338 |
* requiring direct bindings with -zdirect. |
|
1339 |
* |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1340 |
* - All symbol references are required to |
0 | 1341 |
* use direct bindings via -Bdirect. |
1342 |
*/ |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1343 |
if (sdp->sd_flags & FLG_SY_DIR) |
0 | 1344 |
syminfo[ndx].si_flags |= |
1345 |
SYMINFO_FLG_DIRECTBIND; |
|
1346 |
||
1347 |
} else if ((sdp->sd_flags & FLG_SY_EXTERN) && |
|
1348 |
(sdp->sd_sym->st_shndx == SHN_UNDEF)) { |
|
1349 |
/* |
|
1350 |
* If this symbol has been explicitly defined |
|
1351 |
* as external, and remains unresolved, mark |
|
1352 |
* it as external. |
|
1353 |
*/ |
|
1354 |
syminfo[ndx].si_boundto = SYMINFO_BT_EXTERN; |
|
1355 |
||
3466
4cc6ca6917b5
PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents:
2978
diff
changeset
|
1356 |
} else if ((sdp->sd_flags & FLG_SY_PARENT) && |
4cc6ca6917b5
PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents:
2978
diff
changeset
|
1357 |
(sdp->sd_sym->st_shndx == SHN_UNDEF)) { |
0 | 1358 |
/* |
3466
4cc6ca6917b5
PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents:
2978
diff
changeset
|
1359 |
* If this symbol has been explicitly defined |
4cc6ca6917b5
PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents:
2978
diff
changeset
|
1360 |
* to be a reference to a parent object, |
4cc6ca6917b5
PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents:
2978
diff
changeset
|
1361 |
* indicate whether a direct binding should be |
0 | 1362 |
* established. |
1363 |
*/ |
|
1364 |
syminfo[ndx].si_flags |= SYMINFO_FLG_DIRECT; |
|
1365 |
syminfo[ndx].si_boundto = SYMINFO_BT_PARENT; |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1366 |
if (sdp->sd_flags & FLG_SY_DIR) |
0 | 1367 |
syminfo[ndx].si_flags |= |
1368 |
SYMINFO_FLG_DIRECTBIND; |
|
1369 |
||
1370 |
} else if (sdp->sd_flags & FLG_SY_STDFLTR) { |
|
1371 |
/* |
|
1372 |
* A filter definition. Although this symbol |
|
1373 |
* can only be a stub, it might be necessary to |
|
1374 |
* prevent external direct bindings. |
|
1375 |
*/ |
|
1376 |
syminfo[ndx].si_flags |= SYMINFO_FLG_FILTER; |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1377 |
if (sdp->sd_flags & FLG_SY_NDIR) |
0 | 1378 |
syminfo[ndx].si_flags |= |
1379 |
SYMINFO_FLG_NOEXTDIRECT; |
|
1380 |
||
1381 |
} else if (sdp->sd_flags & FLG_SY_AUXFLTR) { |
|
1382 |
/* |
|
1383 |
* An auxiliary filter definition. By nature, |
|
1384 |
* this definition is direct, in that should the |
|
1385 |
* filtee lookup fail, we'll fall back to this |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1386 |
* object. It may still be necessary to |
0 | 1387 |
* prevent external direct bindings. |
1388 |
*/ |
|
1389 |
syminfo[ndx].si_flags |= SYMINFO_FLG_AUXILIARY; |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1390 |
if (sdp->sd_flags & FLG_SY_NDIR) |
0 | 1391 |
syminfo[ndx].si_flags |= |
1392 |
SYMINFO_FLG_NOEXTDIRECT; |
|
1393 |
||
1394 |
} else if ((sdp->sd_ref == REF_REL_NEED) && |
|
1395 |
(sdp->sd_sym->st_shndx != SHN_UNDEF)) { |
|
1396 |
/* |
|
1397 |
* This definition exists within the object |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1398 |
* being created. Provide a default boundto |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1399 |
* definition, which may be overridden later. |
0 | 1400 |
*/ |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1401 |
syminfo[ndx].si_boundto = SYMINFO_BT_NONE; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1402 |
|
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1403 |
/* |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1404 |
* Indicate whether it is necessary to prevent |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1405 |
* external direct bindings. |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1406 |
*/ |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1407 |
if (sdp->sd_flags & FLG_SY_NDIR) { |
0 | 1408 |
syminfo[ndx].si_flags |= |
1409 |
SYMINFO_FLG_NOEXTDIRECT; |
|
1410 |
} |
|
1411 |
||
1412 |
/* |
|
3466
4cc6ca6917b5
PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents:
2978
diff
changeset
|
1413 |
* Indicate that this symbol is acting as an |
4cc6ca6917b5
PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents:
2978
diff
changeset
|
1414 |
* individual interposer. |
4cc6ca6917b5
PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents:
2978
diff
changeset
|
1415 |
*/ |
4cc6ca6917b5
PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents:
2978
diff
changeset
|
1416 |
if (sdp->sd_flags & FLG_SY_INTPOSE) { |
4cc6ca6917b5
PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents:
2978
diff
changeset
|
1417 |
syminfo[ndx].si_flags |= |
4cc6ca6917b5
PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents:
2978
diff
changeset
|
1418 |
SYMINFO_FLG_INTERPOSE; |
4cc6ca6917b5
PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents:
2978
diff
changeset
|
1419 |
} |
4cc6ca6917b5
PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents:
2978
diff
changeset
|
1420 |
|
4cc6ca6917b5
PSARC/2006/714 ld(1) mapfile: symbol interpose definition
rie
parents:
2978
diff
changeset
|
1421 |
/* |
12449
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1422 |
* Indicate that this symbol is deferred, and |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1423 |
* hence should not be bound to during BIND_NOW |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1424 |
* relocations. |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1425 |
*/ |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1426 |
if (sdp->sd_flags & FLG_SY_DEFERRED) { |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1427 |
syminfo[ndx].si_flags |= |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1428 |
SYMINFO_FLG_DEFERRED; |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1429 |
} |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1430 |
|
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
1431 |
/* |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1432 |
* If external bindings are allowed, indicate |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1433 |
* the binding, and a direct binding if |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1434 |
* necessary. |
0 | 1435 |
*/ |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1436 |
if ((sdp->sd_flags & FLG_SY_NDIR) == 0) { |
0 | 1437 |
syminfo[ndx].si_flags |= |
1438 |
SYMINFO_FLG_DIRECT; |
|
1439 |
||
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1440 |
if (sdp->sd_flags & FLG_SY_DIR) |
0 | 1441 |
syminfo[ndx].si_flags |= |
1442 |
SYMINFO_FLG_DIRECTBIND; |
|
1443 |
||
1444 |
/* |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1445 |
* Provide a default boundto definition, |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1446 |
* which may be overridden later. |
0 | 1447 |
*/ |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1448 |
syminfo[ndx].si_boundto = |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1449 |
SYMINFO_BT_SELF; |
0 | 1450 |
} |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1451 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1452 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1453 |
* Indicate that this is a capabilities symbol. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1454 |
* Note, that this identification only provides |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1455 |
* information regarding the symbol that is |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1456 |
* visible from elfdump(1) -y. The association |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1457 |
* of a symbol to its capabilities is derived |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1458 |
* from a .SUNW_capinfo entry. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1459 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1460 |
if ((sdp->sd_flags & FLG_SY_CAP) && |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1461 |
ofl->ofl_oscapinfo) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1462 |
syminfo[ndx].si_flags |= |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1463 |
SYMINFO_FLG_CAP; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1464 |
} |
0 | 1465 |
} |
1466 |
} |
|
1467 |
||
1468 |
/* |
|
1469 |
* Note that the `sym' value is reset to be one of the new |
|
1470 |
* symbol table entries. This symbol will be updated further |
|
1471 |
* depending on the type of the symbol. Process the .symtab |
|
1472 |
* first, followed by the .dynsym, thus the `sym' value will |
|
1473 |
* remain as the .dynsym value when the .dynsym is present. |
|
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
1474 |
* This ensures that any versioning symbols st_name value will |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1475 |
* be appropriate for the string table used by version |
0 | 1476 |
* entries. |
1477 |
*/ |
|
1478 |
if (enter_in_symtab) { |
|
1479 |
Word _symndx; |
|
1480 |
||
1481 |
if (local) |
|
1482 |
_symndx = scopesym_ndx; |
|
1483 |
else |
|
1484 |
_symndx = symtab_ndx; |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1485 |
|
0 | 1486 |
symtab[_symndx] = *sdp->sd_sym; |
1487 |
sdp->sd_sym = sym = &symtab[_symndx]; |
|
1488 |
(void) st_setstring(strtab, name, &stoff); |
|
1489 |
sym->st_name = stoff; |
|
1490 |
} |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1491 |
if (dynlocal) { |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1492 |
ldynsym[ldynscopesym_ndx] = *sdp->sd_sym; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1493 |
sdp->sd_sym = sym = &ldynsym[ldynscopesym_ndx]; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1494 |
(void) st_setstring(dynstr, name, &stoff); |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1495 |
ldynsym[ldynscopesym_ndx].st_name = stoff; |
3492 | 1496 |
/* Add it to sort section if it qualifies */ |
1497 |
ADD_TO_DYNSORT(sdp, sym, ELF_ST_TYPE(sym->st_info), |
|
1498 |
ldynscopesym_ndx); |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1499 |
} |
0 | 1500 |
|
1501 |
if (dynsym && !local) { |
|
1502 |
dynsym[dynsym_ndx] = *sdp->sd_sym; |
|
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1503 |
|
0 | 1504 |
/* |
1505 |
* Provided this isn't an unnamed register symbol, |
|
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1506 |
* update the symbols name and hash value. |
0 | 1507 |
*/ |
1508 |
if (((sdp->sd_flags & FLG_SY_REGSYM) == 0) || |
|
1509 |
dynsym[dynsym_ndx].st_name) { |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1510 |
(void) st_setstring(dynstr, name, &stoff); |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1511 |
dynsym[dynsym_ndx].st_name = stoff; |
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1512 |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1513 |
if (stoff) { |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1514 |
Word hashval, _hashndx; |
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1515 |
|
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1516 |
hashval = |
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1517 |
sap->sa_hash % ofl->ofl_hashbkts; |
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1518 |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1519 |
/* LINTED */ |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1520 |
if (_hashndx = hashbkt[hashval]) { |
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1521 |
while (hashchain[_hashndx]) { |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1522 |
_hashndx = |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1523 |
hashchain[_hashndx]; |
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1524 |
} |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1525 |
hashchain[_hashndx] = |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1526 |
sdp->sd_symndx; |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1527 |
} else { |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1528 |
hashbkt[hashval] = |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1529 |
sdp->sd_symndx; |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1530 |
} |
0 | 1531 |
} |
1532 |
} |
|
1533 |
sdp->sd_sym = sym = &dynsym[dynsym_ndx]; |
|
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1534 |
|
3492 | 1535 |
/* |
1536 |
* Add it to sort section if it qualifies. |
|
1537 |
* The indexes in that section are relative to the |
|
1538 |
* the adjacent SUNW_ldynsym/dymsym pair, so we |
|
1539 |
* add the number of items in SUNW_ldynsym to the |
|
1540 |
* dynsym index. |
|
1541 |
*/ |
|
1542 |
ADD_TO_DYNSORT(sdp, sym, ELF_ST_TYPE(sym->st_info), |
|
1543 |
ldynsym_cnt + dynsym_ndx); |
|
0 | 1544 |
} |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1545 |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1546 |
if (!enter_in_symtab && (!dynsym || (local && !dynlocal))) { |
0 | 1547 |
if (!(sdp->sd_flags & FLG_SY_UPREQD)) |
1548 |
continue; |
|
1549 |
sym = sdp->sd_sym; |
|
1550 |
} else |
|
1551 |
sdp->sd_flags &= ~FLG_SY_CLEAN; |
|
1552 |
||
1553 |
/* |
|
1554 |
* If we have a weak data symbol for which we need the real |
|
1555 |
* symbol also, save this processing until later. |
|
1556 |
* |
|
1557 |
* The exception to this is if the weak/strong have PLT's |
|
1558 |
* assigned to them. In that case we don't do the post-weak |
|
1559 |
* processing because the PLT's must be maintained so that we |
|
1560 |
* can do 'interpositioning' on both of the symbols. |
|
1561 |
*/ |
|
1562 |
if ((sap->sa_linkndx) && |
|
1563 |
(ELF_ST_BIND(sym->st_info) == STB_WEAK) && |
|
1564 |
(!sap->sa_PLTndx)) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1565 |
Sym_desc *_sdp; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1566 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1567 |
_sdp = sdp->sd_file->ifl_oldndx[sap->sa_linkndx]; |
0 | 1568 |
|
1569 |
if (_sdp->sd_ref != REF_DYN_SEEN) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1570 |
Wk_desc wk; |
0 | 1571 |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1572 |
if (enter_in_symtab) { |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1573 |
if (local) { |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1574 |
wk.wk_symtab = |
0 | 1575 |
&symtab[scopesym_ndx]; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1576 |
scopesym_ndx++; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1577 |
} else { |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1578 |
wk.wk_symtab = |
0 | 1579 |
&symtab[symtab_ndx]; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1580 |
symtab_ndx++; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1581 |
} |
9313
d92b0c5ba25b
6827468 6801536 breaks 'ld -s' if there are weak/strong symbol pairs
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9131
diff
changeset
|
1582 |
} else { |
d92b0c5ba25b
6827468 6801536 breaks 'ld -s' if there are weak/strong symbol pairs
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9131
diff
changeset
|
1583 |
wk.wk_symtab = NULL; |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1584 |
} |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1585 |
if (dynsym) { |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1586 |
if (!local) { |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1587 |
wk.wk_dynsym = |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1588 |
&dynsym[dynsym_ndx]; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1589 |
dynsym_ndx++; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1590 |
} else if (dynlocal) { |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1591 |
wk.wk_dynsym = |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1592 |
&ldynsym[ldynscopesym_ndx]; |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1593 |
ldynscopesym_ndx++; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1594 |
} |
9313
d92b0c5ba25b
6827468 6801536 breaks 'ld -s' if there are weak/strong symbol pairs
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9131
diff
changeset
|
1595 |
} else { |
d92b0c5ba25b
6827468 6801536 breaks 'ld -s' if there are weak/strong symbol pairs
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9131
diff
changeset
|
1596 |
wk.wk_dynsym = NULL; |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1597 |
} |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1598 |
wk.wk_weak = sdp; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1599 |
wk.wk_alias = _sdp; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1600 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1601 |
if (alist_append(&weak, &wk, |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1602 |
sizeof (Wk_desc), AL_CNT_WEAK) == NULL) |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1603 |
return ((Addr)S_ERROR); |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1604 |
|
0 | 1605 |
continue; |
1606 |
} |
|
1607 |
} |
|
1608 |
||
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
1609 |
DBG_CALL(Dbg_syms_old(ofl, sdp)); |
0 | 1610 |
|
1611 |
spec = NULL; |
|
1612 |
/* |
|
1613 |
* assign new symbol value. |
|
1614 |
*/ |
|
1615 |
sectndx = sdp->sd_shndx; |
|
1616 |
if (sectndx == SHN_UNDEF) { |
|
1617 |
if (((sdp->sd_flags & FLG_SY_REGSYM) == 0) && |
|
1618 |
(sym->st_value != 0)) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
1619 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
1620 |
MSG_INTL(MSG_SYM_NOTNULL), |
0 | 1621 |
demangle(name), sdp->sd_file->ifl_name); |
1622 |
} |
|
1623 |
||
1624 |
/* |
|
1625 |
* Undefined weak global, if we are generating a static |
|
1626 |
* executable, output as an absolute zero. Otherwise |
|
1627 |
* leave it as is, ld.so.1 will skip symbols of this |
|
1628 |
* type (this technique allows applications and |
|
1629 |
* libraries to test for the existence of a symbol as an |
|
1630 |
* indication of the presence or absence of certain |
|
1631 |
* functionality). |
|
1632 |
*/ |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1633 |
if (OFL_IS_STATIC_EXEC(ofl) && |
0 | 1634 |
(ELF_ST_BIND(sym->st_info) == STB_WEAK)) { |
1635 |
sdp->sd_flags |= FLG_SY_SPECSEC; |
|
1636 |
sdp->sd_shndx = sectndx = SHN_ABS; |
|
1637 |
} |
|
1638 |
} else if ((sdp->sd_flags & FLG_SY_SPECSEC) && |
|
1639 |
(sectndx == SHN_COMMON)) { |
|
1640 |
/* COMMONs have already been processed */ |
|
1641 |
/* EMPTY */ |
|
1642 |
; |
|
1643 |
} else { |
|
1644 |
if ((sdp->sd_flags & FLG_SY_SPECSEC) && |
|
1645 |
(sectndx == SHN_ABS)) |
|
1646 |
spec = sdp->sd_aux->sa_symspec; |
|
1647 |
||
1648 |
/* LINTED */ |
|
1649 |
if (sdp->sd_flags & FLG_SY_COMMEXP) { |
|
1650 |
/* |
|
1651 |
* This is (or was) a COMMON symbol which was |
|
1652 |
* processed above - no processing |
|
1653 |
* required here. |
|
1654 |
*/ |
|
1655 |
; |
|
1656 |
} else if (sdp->sd_ref == REF_DYN_NEED) { |
|
3492 | 1657 |
uchar_t type, bind; |
0 | 1658 |
|
1659 |
sectndx = SHN_UNDEF; |
|
1660 |
sym->st_value = 0; |
|
1661 |
sym->st_size = 0; |
|
1662 |
||
1663 |
/* |
|
1664 |
* Make sure this undefined symbol is returned |
|
1665 |
* to the same binding as was defined in the |
|
1666 |
* original relocatable object reference. |
|
1667 |
*/ |
|
1668 |
type = ELF_ST_TYPE(sym-> st_info); |
|
1669 |
if (sdp->sd_flags & FLG_SY_GLOBREF) |
|
1670 |
bind = STB_GLOBAL; |
|
1671 |
else |
|
1672 |
bind = STB_WEAK; |
|
1673 |
||
1674 |
sym->st_info = ELF_ST_INFO(bind, type); |
|
1675 |
||
1676 |
} else if (((sdp->sd_flags & FLG_SY_SPECSEC) == 0) && |
|
1677 |
(sdp->sd_ref == REF_REL_NEED)) { |
|
1678 |
osp = sdp->sd_isc->is_osdesc; |
|
1679 |
/* LINTED */ |
|
1680 |
sectndx = elf_ndxscn(osp->os_scn); |
|
1681 |
||
1682 |
/* |
|
1683 |
* In an executable, the new symbol value is the |
|
1684 |
* old value (offset into defining section) plus |
|
1685 |
* virtual address of defining section. In a |
|
1686 |
* relocatable, the new value is the old value |
|
1687 |
* plus the displacement of the section within |
|
1688 |
* the file. |
|
1689 |
*/ |
|
1690 |
/* LINTED */ |
|
1691 |
sym->st_value += |
|
1692 |
(Off)_elf_getxoff(sdp->sd_isc->is_indata); |
|
1693 |
||
1694 |
if (!(flags & FLG_OF_RELOBJ)) { |
|
1695 |
sym->st_value += osp->os_shdr->sh_addr; |
|
1696 |
/* |
|
1697 |
* TLS symbols are relative to |
|
1698 |
* the TLS segment. |
|
1699 |
*/ |
|
1700 |
if ((ELF_ST_TYPE(sym->st_info) == |
|
1701 |
STT_TLS) && (ofl->ofl_tlsphdr)) |
|
1702 |
sym->st_value -= |
|
1703 |
ofl->ofl_tlsphdr->p_vaddr; |
|
1704 |
} |
|
1705 |
} |
|
1706 |
} |
|
1707 |
||
1708 |
if (spec) { |
|
1709 |
switch (spec) { |
|
1710 |
case SDAUX_ID_ETEXT: |
|
1711 |
sym->st_value = etext; |
|
1712 |
sectndx = etext_ndx; |
|
1713 |
if (etext_abs) |
|
1714 |
sdp->sd_flags |= FLG_SY_SPECSEC; |
|
1715 |
else |
|
1716 |
sdp->sd_flags &= ~FLG_SY_SPECSEC; |
|
1717 |
break; |
|
1718 |
case SDAUX_ID_EDATA: |
|
1719 |
sym->st_value = edata; |
|
1720 |
sectndx = edata_ndx; |
|
1721 |
if (edata_abs) |
|
1722 |
sdp->sd_flags |= FLG_SY_SPECSEC; |
|
1723 |
else |
|
1724 |
sdp->sd_flags &= ~FLG_SY_SPECSEC; |
|
1725 |
break; |
|
1726 |
case SDAUX_ID_END: |
|
1727 |
sym->st_value = end; |
|
1728 |
sectndx = end_ndx; |
|
1729 |
if (end_abs) |
|
1730 |
sdp->sd_flags |= FLG_SY_SPECSEC; |
|
1731 |
else |
|
1732 |
sdp->sd_flags &= ~FLG_SY_SPECSEC; |
|
1733 |
break; |
|
1734 |
case SDAUX_ID_START: |
|
1735 |
sym->st_value = start; |
|
1736 |
sectndx = start_ndx; |
|
1737 |
sdp->sd_flags &= ~FLG_SY_SPECSEC; |
|
1738 |
break; |
|
1739 |
case SDAUX_ID_DYN: |
|
1740 |
if (flags & FLG_OF_DYNAMIC) { |
|
1741 |
sym->st_value = ofl-> |
|
1742 |
ofl_osdynamic->os_shdr->sh_addr; |
|
1743 |
/* LINTED */ |
|
1744 |
sectndx = elf_ndxscn( |
|
1745 |
ofl->ofl_osdynamic->os_scn); |
|
1746 |
sdp->sd_flags &= ~FLG_SY_SPECSEC; |
|
1747 |
} |
|
1748 |
break; |
|
1749 |
case SDAUX_ID_PLT: |
|
1750 |
if (ofl->ofl_osplt) { |
|
1751 |
sym->st_value = ofl-> |
|
1752 |
ofl_osplt->os_shdr->sh_addr; |
|
1753 |
/* LINTED */ |
|
1754 |
sectndx = elf_ndxscn( |
|
1755 |
ofl->ofl_osplt->os_scn); |
|
1756 |
sdp->sd_flags &= ~FLG_SY_SPECSEC; |
|
1757 |
} |
|
1758 |
break; |
|
1759 |
case SDAUX_ID_GOT: |
|
1760 |
/* |
|
1761 |
* Symbol bias for negative growing tables is |
|
1762 |
* stored in symbol's value during |
|
1763 |
* allocate_got(). |
|
1764 |
*/ |
|
1765 |
sym->st_value += ofl-> |
|
1766 |
ofl_osgot->os_shdr->sh_addr; |
|
1767 |
/* LINTED */ |
|
1768 |
sectndx = elf_ndxscn(ofl-> |
|
1769 |
ofl_osgot->os_scn); |
|
1770 |
sdp->sd_flags &= ~FLG_SY_SPECSEC; |
|
1771 |
break; |
|
1772 |
default: |
|
1773 |
/* NOTHING */ |
|
1774 |
; |
|
1775 |
} |
|
1776 |
} |
|
1777 |
||
1778 |
/* |
|
1779 |
* If a plt index has been assigned to an undefined function, |
|
1780 |
* update the symbols value to the appropriate .plt address. |
|
1781 |
*/ |
|
1782 |
if ((flags & FLG_OF_DYNAMIC) && (flags & FLG_OF_EXEC) && |
|
1783 |
(sdp->sd_file) && |
|
1784 |
(sdp->sd_file->ifl_ehdr->e_type == ET_DYN) && |
|
1785 |
(ELF_ST_TYPE(sym->st_info) == STT_FUNC) && |
|
1786 |
!(flags & FLG_OF_BFLAG)) { |
|
1787 |
if (sap->sa_PLTndx) |
|
6206 | 1788 |
sym->st_value = |
1789 |
(*ld_targ.t_mr.mr_calc_plt_addr)(sdp, ofl); |
|
0 | 1790 |
} |
1791 |
||
1792 |
/* |
|
1793 |
* Finish updating the symbols. |
|
1794 |
*/ |
|
1795 |
||
1796 |
/* |
|
1797 |
* Sym Update: if scoped local - set local binding |
|
1798 |
*/ |
|
1799 |
if (local) |
|
1800 |
sym->st_info = ELF_ST_INFO(STB_LOCAL, |
|
1801 |
ELF_ST_TYPE(sym->st_info)); |
|
1802 |
||
1803 |
/* |
|
1804 |
* Sym Updated: If both the .symtab and .dynsym |
|
1805 |
* are present then we've actually updated the information in |
|
1806 |
* the .dynsym, therefore copy this same information to the |
|
1807 |
* .symtab entry. |
|
1808 |
*/ |
|
1809 |
sdp->sd_shndx = sectndx; |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1810 |
if (enter_in_symtab && dynsym && (!local || dynlocal)) { |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1811 |
Word _symndx = dynlocal ? scopesym_ndx : symtab_ndx; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1812 |
|
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1813 |
symtab[_symndx].st_value = sym->st_value; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1814 |
symtab[_symndx].st_size = sym->st_size; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1815 |
symtab[_symndx].st_info = sym->st_info; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1816 |
symtab[_symndx].st_other = sym->st_other; |
0 | 1817 |
} |
1818 |
||
1819 |
if (enter_in_symtab) { |
|
1820 |
Word _symndx; |
|
1821 |
||
1822 |
if (local) |
|
1823 |
_symndx = scopesym_ndx++; |
|
1824 |
else |
|
1825 |
_symndx = symtab_ndx++; |
|
1826 |
if (((sdp->sd_flags & FLG_SY_SPECSEC) == 0) && |
|
1827 |
(sectndx >= SHN_LORESERVE)) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1828 |
assert(symshndx != NULL); |
0 | 1829 |
symshndx[_symndx] = sectndx; |
1830 |
symtab[_symndx].st_shndx = SHN_XINDEX; |
|
1831 |
} else { |
|
1832 |
/* LINTED */ |
|
1833 |
symtab[_symndx].st_shndx = (Half)sectndx; |
|
1834 |
} |
|
1835 |
} |
|
1836 |
||
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1837 |
if (dynsym && (!local || dynlocal)) { |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1838 |
/* |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1839 |
* dynsym and ldynsym are distinct tables, so |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1840 |
* we use indirection to access the right one |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1841 |
* and the related extended section index array. |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1842 |
*/ |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1843 |
Word _symndx; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1844 |
Sym *_dynsym; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1845 |
Word *_dynshndx; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1846 |
|
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1847 |
if (!local) { |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1848 |
_symndx = dynsym_ndx++; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1849 |
_dynsym = dynsym; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1850 |
_dynshndx = dynshndx; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1851 |
} else { |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1852 |
_symndx = ldynscopesym_ndx++; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1853 |
_dynsym = ldynsym; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1854 |
_dynshndx = ldynshndx; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1855 |
} |
0 | 1856 |
if (((sdp->sd_flags & FLG_SY_SPECSEC) == 0) && |
1857 |
(sectndx >= SHN_LORESERVE)) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1858 |
assert(_dynshndx != NULL); |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1859 |
_dynshndx[_symndx] = sectndx; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1860 |
_dynsym[_symndx].st_shndx = SHN_XINDEX; |
0 | 1861 |
} else { |
1862 |
/* LINTED */ |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1863 |
_dynsym[_symndx].st_shndx = (Half)sectndx; |
0 | 1864 |
} |
1865 |
} |
|
1866 |
||
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
1867 |
DBG_CALL(Dbg_syms_new(ofl, sym, sdp)); |
0 | 1868 |
} |
1869 |
||
1870 |
/* |
|
1871 |
* Now that all the symbols have been processed update any weak symbols |
|
1872 |
* information (ie. copy all information except `st_name'). As both |
|
1873 |
* symbols will be represented in the output, return the weak symbol to |
|
1874 |
* its correct type. |
|
1875 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1876 |
for (ALIST_TRAVERSE(weak, idx1, wkp)) { |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1877 |
Sym_desc *sdp, *_sdp; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
1878 |
Sym *sym, *_sym, *__sym; |
3492 | 1879 |
uchar_t bind; |
0 | 1880 |
|
1881 |
sdp = wkp->wk_weak; |
|
1882 |
_sdp = wkp->wk_alias; |
|
9313
d92b0c5ba25b
6827468 6801536 breaks 'ld -s' if there are weak/strong symbol pairs
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9131
diff
changeset
|
1883 |
_sym = __sym = _sdp->sd_sym; |
0 | 1884 |
|
1885 |
sdp->sd_flags |= FLG_SY_WEAKDEF; |
|
1886 |
||
1887 |
/* |
|
1888 |
* If the symbol definition has been scoped then assign it to |
|
1889 |
* be local, otherwise if it's from a shared object then we need |
|
1890 |
* to maintain the binding of the original reference. |
|
1891 |
*/ |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
1892 |
if (SYM_IS_HIDDEN(sdp)) { |
0 | 1893 |
if (flags & FLG_OF_PROCRED) |
1894 |
bind = STB_LOCAL; |
|
1895 |
else |
|
1896 |
bind = STB_WEAK; |
|
1897 |
} else if ((sdp->sd_ref == REF_DYN_NEED) && |
|
1898 |
(sdp->sd_flags & FLG_SY_GLOBREF)) |
|
1899 |
bind = STB_GLOBAL; |
|
1900 |
else |
|
1901 |
bind = STB_WEAK; |
|
1902 |
||
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
1903 |
DBG_CALL(Dbg_syms_old(ofl, sdp)); |
9313
d92b0c5ba25b
6827468 6801536 breaks 'ld -s' if there are weak/strong symbol pairs
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9131
diff
changeset
|
1904 |
if ((sym = wkp->wk_symtab) != NULL) { |
0 | 1905 |
sym->st_value = _sym->st_value; |
1906 |
sym->st_size = _sym->st_size; |
|
1907 |
sym->st_other = _sym->st_other; |
|
1908 |
sym->st_shndx = _sym->st_shndx; |
|
1909 |
sym->st_info = ELF_ST_INFO(bind, |
|
1910 |
ELF_ST_TYPE(sym->st_info)); |
|
1911 |
__sym = sym; |
|
1912 |
} |
|
9313
d92b0c5ba25b
6827468 6801536 breaks 'ld -s' if there are weak/strong symbol pairs
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9131
diff
changeset
|
1913 |
if ((sym = wkp->wk_dynsym) != NULL) { |
0 | 1914 |
sym->st_value = _sym->st_value; |
1915 |
sym->st_size = _sym->st_size; |
|
1916 |
sym->st_other = _sym->st_other; |
|
1917 |
sym->st_shndx = _sym->st_shndx; |
|
1918 |
sym->st_info = ELF_ST_INFO(bind, |
|
1919 |
ELF_ST_TYPE(sym->st_info)); |
|
1920 |
__sym = sym; |
|
1921 |
} |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
1922 |
DBG_CALL(Dbg_syms_new(ofl, __sym, sdp)); |
0 | 1923 |
} |
1924 |
||
1925 |
/* |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
1926 |
* Now display GOT debugging information if required. |
0 | 1927 |
*/ |
6206 | 1928 |
DBG_CALL(Dbg_got_display(ofl, 0, 0, |
1929 |
ld_targ.t_m.m_got_xnumber, ld_targ.t_m.m_got_entsize)); |
|
0 | 1930 |
|
1931 |
/* |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1932 |
* Update the section headers information. sh_info is |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1933 |
* supposed to contain the offset at which the first |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1934 |
* global symbol resides in the symbol table, while |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1935 |
* sh_link contains the section index of the associated |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1936 |
* string table. |
0 | 1937 |
*/ |
1938 |
if (symtab) { |
|
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1939 |
Shdr *shdr = ofl->ofl_ossymtab->os_shdr; |
0 | 1940 |
|
8140
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
1941 |
shdr->sh_info = symtab_gbl_bndx; |
0 | 1942 |
/* LINTED */ |
1943 |
shdr->sh_link = (Word)elf_ndxscn(ofl->ofl_osstrtab->os_scn); |
|
11227
cd2ac59c39f2
6900241 ld should track SHT_GROUP sections by symbol name, not section name
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
1944 |
if (symshndx) |
cd2ac59c39f2
6900241 ld should track SHT_GROUP sections by symbol name, not section name
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
10792
diff
changeset
|
1945 |
ofl->ofl_ossymshndx->os_shdr->sh_link = |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1946 |
(Word)elf_ndxscn(ofl->ofl_ossymtab->os_scn); |
8140
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
1947 |
|
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
1948 |
/* |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
1949 |
* Ensure that the expected number of symbols |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
1950 |
* were entered into the right spots: |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
1951 |
* - Scoped symbols in the right range |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
1952 |
* - Globals start at the right spot |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
1953 |
* (correct number of locals entered) |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
1954 |
* - The table is exactly filled |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
1955 |
* (correct number of globals entered) |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
1956 |
*/ |
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
1957 |
assert((scopesym_bndx + ofl->ofl_scopecnt) == scopesym_ndx); |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1958 |
assert(shdr->sh_info == SYMTAB_LOC_CNT(ofl)); |
8140
5932af7fc25c
6763342 sloppy relocations need to get sloppier
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7682
diff
changeset
|
1959 |
assert((shdr->sh_info + ofl->ofl_globcnt) == symtab_ndx); |
0 | 1960 |
} |
1961 |
if (dynsym) { |
|
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1962 |
Shdr *shdr = ofl->ofl_osdynsym->os_shdr; |
0 | 1963 |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
1964 |
shdr->sh_info = DYNSYM_LOC_CNT(ofl); |
0 | 1965 |
/* LINTED */ |
1966 |
shdr->sh_link = (Word)elf_ndxscn(ofl->ofl_osdynstr->os_scn); |
|
1967 |
||
1968 |
ofl->ofl_oshash->os_shdr->sh_link = |
|
1969 |
/* LINTED */ |
|
1970 |
(Word)elf_ndxscn(ofl->ofl_osdynsym->os_scn); |
|
1971 |
if (dynshndx) { |
|
1972 |
shdr = ofl->ofl_osdynshndx->os_shdr; |
|
1973 |
shdr->sh_link = |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
1974 |
(Word)elf_ndxscn(ofl->ofl_osdynsym->os_scn); |
0 | 1975 |
} |
1976 |
} |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1977 |
if (ldynsym) { |
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
1978 |
Shdr *shdr = ofl->ofl_osldynsym->os_shdr; |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1979 |
|
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1980 |
/* ldynsym has no globals, so give index one past the end */ |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1981 |
shdr->sh_info = ldynsym_ndx; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1982 |
|
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1983 |
/* |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1984 |
* The ldynsym and dynsym must be adjacent. The |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1985 |
* idea is that rtld should be able to start with |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1986 |
* the ldynsym and march straight through the end |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1987 |
* of dynsym, seeing them as a single symbol table, |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1988 |
* despite the fact that they are in distinct sections. |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1989 |
* Ensure that this happened correctly. |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1990 |
* |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1991 |
* Note that I use ldynsym_ndx here instead of the |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1992 |
* computation I used to set the section size |
3492 | 1993 |
* (found in ldynsym_cnt). The two will agree, unless |
1994 |
* we somehow miscounted symbols or failed to insert them |
|
1995 |
* all. Using ldynsym_ndx here catches that error in |
|
1996 |
* addition to checking for adjacency. |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1997 |
*/ |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1998 |
assert(dynsym == (ldynsym + ldynsym_ndx)); |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
1999 |
|
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2000 |
|
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2001 |
/* LINTED */ |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2002 |
shdr->sh_link = (Word)elf_ndxscn(ofl->ofl_osdynstr->os_scn); |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2003 |
|
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2004 |
if (ldynshndx) { |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2005 |
shdr = ofl->ofl_osldynshndx->os_shdr; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2006 |
shdr->sh_link = |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2007 |
(Word)elf_ndxscn(ofl->ofl_osldynsym->os_scn); |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2008 |
} |
3492 | 2009 |
|
2010 |
/* |
|
2011 |
* The presence of .SUNW_ldynsym means that there may be |
|
2012 |
* associated sort sections, one for regular symbols |
|
2013 |
* and the other for TLS. Each sort section needs the |
|
2014 |
* following done: |
|
2015 |
* - Section header link references .SUNW_ldynsym |
|
2016 |
* - Should have received the expected # of items |
|
2017 |
* - Sorted by increasing address |
|
2018 |
*/ |
|
2019 |
if (ofl->ofl_osdynsymsort) { /* .SUNW_dynsymsort */ |
|
2020 |
ofl->ofl_osdynsymsort->os_shdr->sh_link = |
|
2021 |
(Word)elf_ndxscn(ofl->ofl_osldynsym->os_scn); |
|
2022 |
assert(ofl->ofl_dynsymsortcnt == dynsymsort_ndx); |
|
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
2023 |
|
3492 | 2024 |
if (dynsymsort_ndx > 1) { |
2025 |
dynsort_compare_syms = ldynsym; |
|
2026 |
qsort(dynsymsort, dynsymsort_ndx, |
|
2027 |
sizeof (*dynsymsort), dynsort_compare); |
|
5549 | 2028 |
dynsort_dupwarn(ofl, ldynsym, |
2029 |
st_getstrbuf(dynstr), |
|
3492 | 2030 |
dynsymsort, dynsymsort_ndx, |
2031 |
MSG_ORIG(MSG_SCN_DYNSYMSORT)); |
|
2032 |
} |
|
2033 |
} |
|
2034 |
if (ofl->ofl_osdyntlssort) { /* .SUNW_dyntlssort */ |
|
2035 |
ofl->ofl_osdyntlssort->os_shdr->sh_link = |
|
2036 |
(Word)elf_ndxscn(ofl->ofl_osldynsym->os_scn); |
|
2037 |
assert(ofl->ofl_dyntlssortcnt == dyntlssort_ndx); |
|
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
2038 |
|
3492 | 2039 |
if (dyntlssort_ndx > 1) { |
2040 |
dynsort_compare_syms = ldynsym; |
|
2041 |
qsort(dyntlssort, dyntlssort_ndx, |
|
2042 |
sizeof (*dyntlssort), dynsort_compare); |
|
5549 | 2043 |
dynsort_dupwarn(ofl, ldynsym, |
2044 |
st_getstrbuf(dynstr), |
|
3492 | 2045 |
dyntlssort, dyntlssort_ndx, |
2046 |
MSG_ORIG(MSG_SCN_DYNTLSSORT)); |
|
2047 |
} |
|
2048 |
} |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2049 |
} |
0 | 2050 |
|
2051 |
/* |
|
2052 |
* Used by ld.so.1 only. |
|
2053 |
*/ |
|
2054 |
return (etext); |
|
3492 | 2055 |
|
2056 |
#undef ADD_TO_DYNSORT |
|
0 | 2057 |
} |
2058 |
||
2059 |
/* |
|
2060 |
* Build the dynamic section. |
|
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2061 |
* |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2062 |
* This routine must be maintained in parallel with make_dynamic() |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2063 |
* in sections.c |
0 | 2064 |
*/ |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
2065 |
static int |
0 | 2066 |
update_odynamic(Ofl_desc *ofl) |
2067 |
{ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2068 |
Aliste idx; |
0 | 2069 |
Ifl_desc *ifl; |
2070 |
Sym_desc *sdp; |
|
2071 |
Shdr *shdr; |
|
2072 |
Dyn *_dyn = (Dyn *)ofl->ofl_osdynamic->os_outdata->d_buf; |
|
2073 |
Dyn *dyn; |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2074 |
Os_desc *symosp, *strosp; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2075 |
Str_tbl *strtbl; |
5892
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
2076 |
size_t stoff; |
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2077 |
ofl_flag_t flags = ofl->ofl_flags; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2078 |
int not_relobj = !(flags & FLG_OF_RELOBJ); |
3850
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
2079 |
Word cnt; |
0 | 2080 |
|
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2081 |
/* |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2082 |
* Relocatable objects can be built with -r and -dy to trigger the |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2083 |
* creation of a .dynamic section. This model is used to create kernel |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2084 |
* device drivers. The .dynamic section provides a subset of userland |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2085 |
* .dynamic entries, typically entries such as DT_NEEDED and DT_RUNPATH. |
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2086 |
* |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2087 |
* Within a dynamic object, any .dynamic string references are to the |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2088 |
* .dynstr table. Within a relocatable object, these strings can reside |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2089 |
* within the .strtab. |
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2090 |
*/ |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2091 |
if (OFL_IS_STATIC_OBJ(ofl)) { |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2092 |
symosp = ofl->ofl_ossymtab; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2093 |
strosp = ofl->ofl_osstrtab; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2094 |
strtbl = ofl->ofl_strtab; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2095 |
} else { |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2096 |
symosp = ofl->ofl_osdynsym; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2097 |
strosp = ofl->ofl_osdynstr; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2098 |
strtbl = ofl->ofl_dynstrtab; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2099 |
} |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2100 |
|
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2101 |
/* LINTED */ |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2102 |
ofl->ofl_osdynamic->os_shdr->sh_link = (Word)elf_ndxscn(strosp->os_scn); |
0 | 2103 |
|
2104 |
dyn = _dyn; |
|
2105 |
||
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2106 |
for (APLIST_TRAVERSE(ofl->ofl_sos, idx, ifl)) { |
0 | 2107 |
if ((ifl->ifl_flags & |
2108 |
(FLG_IF_IGNORE | FLG_IF_DEPREQD)) == FLG_IF_IGNORE) |
|
2109 |
continue; |
|
2110 |
||
2111 |
/* |
|
2112 |
* Create and set up the DT_POSFLAG_1 entry here if required. |
|
2113 |
*/ |
|
12449
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
2114 |
if ((ifl->ifl_flags & MSK_IF_POSFLAG1) && |
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
2115 |
(ifl->ifl_flags & FLG_IF_NEEDED) && not_relobj) { |
0 | 2116 |
dyn->d_tag = DT_POSFLAG_1; |
2117 |
if (ifl->ifl_flags & FLG_IF_LAZYLD) |
|
2118 |
dyn->d_un.d_val = DF_P1_LAZYLOAD; |
|
2119 |
if (ifl->ifl_flags & FLG_IF_GRPPRM) |
|
2120 |
dyn->d_un.d_val |= DF_P1_GROUPPERM; |
|
12449
a87750d92895
6943772 Testing for a symbols existence with RTLD_PROBE is compromised by RTLD_BIND_NOW
Rod Evans <Rod.Evans@Sun.COM>
parents:
12029
diff
changeset
|
2121 |
if (ifl->ifl_flags & 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:
12029
diff
changeset
|
2122 |
dyn->d_un.d_val |= DF_P1_DEFERRED; |
0 | 2123 |
dyn++; |
2124 |
} |
|
2125 |
||
2126 |
if (ifl->ifl_flags & (FLG_IF_NEEDED | FLG_IF_NEEDSTR)) |
|
2127 |
dyn->d_tag = DT_NEEDED; |
|
2128 |
else |
|
2129 |
continue; |
|
2130 |
||
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2131 |
(void) st_setstring(strtbl, ifl->ifl_soname, &stoff); |
0 | 2132 |
dyn->d_un.d_val = stoff; |
2133 |
/* LINTED */ |
|
2134 |
ifl->ifl_neededndx = (Half)(((uintptr_t)dyn - (uintptr_t)_dyn) / |
|
2135 |
sizeof (Dyn)); |
|
2136 |
dyn++; |
|
2137 |
} |
|
2138 |
||
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2139 |
if (not_relobj) { |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2140 |
if (ofl->ofl_dtsfltrs != NULL) { |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2141 |
Dfltr_desc *dftp; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2142 |
|
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2143 |
for (ALIST_TRAVERSE(ofl->ofl_dtsfltrs, idx, dftp)) { |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2144 |
if (dftp->dft_flag == FLG_SY_AUXFLTR) |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2145 |
dyn->d_tag = DT_SUNW_AUXILIARY; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2146 |
else |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2147 |
dyn->d_tag = DT_SUNW_FILTER; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2148 |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2149 |
(void) st_setstring(strtbl, dftp->dft_str, |
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2150 |
&stoff); |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2151 |
dyn->d_un.d_val = stoff; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2152 |
dftp->dft_ndx = (Half)(((uintptr_t)dyn - |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2153 |
(uintptr_t)_dyn) / sizeof (Dyn)); |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2154 |
dyn++; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2155 |
} |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2156 |
} |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2157 |
if (((sdp = ld_sym_find(MSG_ORIG(MSG_SYM_INIT_U), |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2158 |
SYM_NOHASH, 0, ofl)) != NULL) && |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2159 |
(sdp->sd_ref == REF_REL_NEED) && |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2160 |
(sdp->sd_sym->st_shndx != SHN_UNDEF)) { |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2161 |
dyn->d_tag = DT_INIT; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2162 |
dyn->d_un.d_ptr = sdp->sd_sym->st_value; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2163 |
dyn++; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2164 |
} |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2165 |
if (((sdp = ld_sym_find(MSG_ORIG(MSG_SYM_FINI_U), |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2166 |
SYM_NOHASH, 0, ofl)) != NULL) && |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2167 |
(sdp->sd_ref == REF_REL_NEED) && |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2168 |
(sdp->sd_sym->st_shndx != SHN_UNDEF)) { |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2169 |
dyn->d_tag = DT_FINI; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2170 |
dyn->d_un.d_ptr = sdp->sd_sym->st_value; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2171 |
dyn++; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2172 |
} |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2173 |
if (ofl->ofl_soname) { |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2174 |
dyn->d_tag = DT_SONAME; |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2175 |
(void) st_setstring(strtbl, ofl->ofl_soname, &stoff); |
0 | 2176 |
dyn->d_un.d_val = stoff; |
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2177 |
dyn++; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2178 |
} |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2179 |
if (ofl->ofl_filtees) { |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2180 |
if (flags & FLG_OF_AUX) { |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2181 |
dyn->d_tag = DT_AUXILIARY; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2182 |
} else { |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2183 |
dyn->d_tag = DT_FILTER; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2184 |
} |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2185 |
(void) st_setstring(strtbl, ofl->ofl_filtees, &stoff); |
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2186 |
dyn->d_un.d_val = stoff; |
0 | 2187 |
dyn++; |
2188 |
} |
|
2189 |
} |
|
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2190 |
|
0 | 2191 |
if (ofl->ofl_rpath) { |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2192 |
(void) st_setstring(strtbl, ofl->ofl_rpath, &stoff); |
0 | 2193 |
dyn->d_tag = DT_RUNPATH; |
2194 |
dyn->d_un.d_val = stoff; |
|
2195 |
dyn++; |
|
2196 |
dyn->d_tag = DT_RPATH; |
|
2197 |
dyn->d_un.d_val = stoff; |
|
2198 |
dyn++; |
|
2199 |
} |
|
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2200 |
|
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2201 |
if (not_relobj) { |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2202 |
Aliste idx; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2203 |
|
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2204 |
if (ofl->ofl_config) { |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2205 |
dyn->d_tag = DT_CONFIG; |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2206 |
(void) st_setstring(strtbl, ofl->ofl_config, &stoff); |
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2207 |
dyn->d_un.d_val = stoff; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2208 |
dyn++; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2209 |
} |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2210 |
if (ofl->ofl_depaudit) { |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2211 |
dyn->d_tag = DT_DEPAUDIT; |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2212 |
(void) st_setstring(strtbl, ofl->ofl_depaudit, &stoff); |
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2213 |
dyn->d_un.d_val = stoff; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2214 |
dyn++; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2215 |
} |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2216 |
if (ofl->ofl_audit) { |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2217 |
dyn->d_tag = DT_AUDIT; |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2218 |
(void) st_setstring(strtbl, ofl->ofl_audit, &stoff); |
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2219 |
dyn->d_un.d_val = stoff; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2220 |
dyn++; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2221 |
} |
0 | 2222 |
|
2223 |
dyn->d_tag = DT_HASH; |
|
2224 |
dyn->d_un.d_ptr = ofl->ofl_oshash->os_shdr->sh_addr; |
|
2225 |
dyn++; |
|
2226 |
||
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2227 |
shdr = strosp->os_shdr; |
0 | 2228 |
dyn->d_tag = DT_STRTAB; |
2229 |
dyn->d_un.d_ptr = shdr->sh_addr; |
|
2230 |
dyn++; |
|
2231 |
||
2232 |
dyn->d_tag = DT_STRSZ; |
|
2233 |
dyn->d_un.d_ptr = shdr->sh_size; |
|
2234 |
dyn++; |
|
2235 |
||
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2236 |
/* |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2237 |
* Note, the shdr is set and used in the ofl->ofl_osldynsym case |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2238 |
* that follows. |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2239 |
*/ |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2240 |
shdr = symosp->os_shdr; |
0 | 2241 |
dyn->d_tag = DT_SYMTAB; |
2242 |
dyn->d_un.d_ptr = shdr->sh_addr; |
|
2243 |
dyn++; |
|
2244 |
||
2245 |
dyn->d_tag = DT_SYMENT; |
|
2246 |
dyn->d_un.d_ptr = shdr->sh_entsize; |
|
2247 |
dyn++; |
|
2248 |
||
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2249 |
if (ofl->ofl_osldynsym) { |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2250 |
Shdr *lshdr = ofl->ofl_osldynsym->os_shdr; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2251 |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2252 |
/* |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2253 |
* We have arranged for the .SUNW_ldynsym data to be |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2254 |
* immediately in front of the .dynsym data. |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2255 |
* This means that you could start at the top |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2256 |
* of .SUNW_ldynsym and see the data for both tables |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2257 |
* without a break. This is the view we want to |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2258 |
* provide for DT_SUNW_SYMTAB, which is why we |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2259 |
* add the lengths together. |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2260 |
*/ |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2261 |
dyn->d_tag = DT_SUNW_SYMTAB; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2262 |
dyn->d_un.d_ptr = lshdr->sh_addr; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2263 |
dyn++; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2264 |
|
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2265 |
dyn->d_tag = DT_SUNW_SYMSZ; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2266 |
dyn->d_un.d_val = lshdr->sh_size + shdr->sh_size; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2267 |
dyn++; |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2268 |
} |
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
2269 |
|
3492 | 2270 |
if (ofl->ofl_osdynsymsort || ofl->ofl_osdyntlssort) { |
2271 |
dyn->d_tag = DT_SUNW_SORTENT; |
|
2272 |
dyn->d_un.d_val = sizeof (Word); |
|
2273 |
dyn++; |
|
2274 |
} |
|
2275 |
||
2276 |
if (ofl->ofl_osdynsymsort) { |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2277 |
shdr = ofl->ofl_osdynsymsort->os_shdr; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2278 |
|
3492 | 2279 |
dyn->d_tag = DT_SUNW_SYMSORT; |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2280 |
dyn->d_un.d_ptr = shdr->sh_addr; |
3492 | 2281 |
dyn++; |
2282 |
||
2283 |
dyn->d_tag = DT_SUNW_SYMSORTSZ; |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2284 |
dyn->d_un.d_val = shdr->sh_size; |
3492 | 2285 |
dyn++; |
2286 |
} |
|
2287 |
||
2288 |
if (ofl->ofl_osdyntlssort) { |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2289 |
shdr = ofl->ofl_osdyntlssort->os_shdr; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2290 |
|
3492 | 2291 |
dyn->d_tag = DT_SUNW_TLSSORT; |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2292 |
dyn->d_un.d_ptr = shdr->sh_addr; |
3492 | 2293 |
dyn++; |
2294 |
||
2295 |
dyn->d_tag = DT_SUNW_TLSSORTSZ; |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2296 |
dyn->d_un.d_val = shdr->sh_size; |
3492 | 2297 |
dyn++; |
2298 |
} |
|
2299 |
||
0 | 2300 |
/* |
2301 |
* Reserve the DT_CHECKSUM entry. Its value will be filled in |
|
2302 |
* after the complete image is built. |
|
2303 |
*/ |
|
2304 |
dyn->d_tag = DT_CHECKSUM; |
|
2305 |
ofl->ofl_checksum = &dyn->d_un.d_val; |
|
2306 |
dyn++; |
|
2307 |
||
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2308 |
/* |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2309 |
* Versioning sections: DT_VERDEF and DT_VERNEED. |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2310 |
* |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2311 |
* The Solaris ld does not produce DT_VERSYM, but the GNU ld |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2312 |
* does, in order to support their style of versioning, which |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2313 |
* differs from ours: |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2314 |
* |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2315 |
* - The top bit of the 16-bit Versym index is |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2316 |
* not part of the version, but is interpreted |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2317 |
* as a "hidden bit". |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2318 |
* |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2319 |
* - External (SHN_UNDEF) symbols can have non-zero |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2320 |
* Versym values, which specify versions in |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2321 |
* referenced objects, via the Verneed section. |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2322 |
* |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2323 |
* - The vna_other field of the Vernaux structures |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2324 |
* found in the Verneed section are not zero as |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2325 |
* with Solaris, but instead contain the version |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2326 |
* index to be used by Versym indices to reference |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2327 |
* the given external version. |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2328 |
* |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2329 |
* The Solaris ld, rtld, and elfdump programs all interpret the |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2330 |
* presence of DT_VERSYM as meaning that GNU versioning rules |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2331 |
* apply to the given file. If DT_VERSYM is not present, |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2332 |
* then Solaris versioning rules apply. If we should ever need |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2333 |
* to change our ld so that it does issue DT_VERSYM, then |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2334 |
* this rule for detecting GNU versioning will no longer work. |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2335 |
* In that case, we will have to invent a way to explicitly |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2336 |
* specify the style of versioning in use, perhaps via a |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2337 |
* new dynamic entry named something like DT_SUNW_VERSIONSTYLE, |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2338 |
* where the d_un.d_val value specifies which style is to be |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2339 |
* used. |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2340 |
*/ |
0 | 2341 |
if ((flags & (FLG_OF_VERDEF | FLG_OF_NOVERSEC)) == |
2342 |
FLG_OF_VERDEF) { |
|
2343 |
shdr = ofl->ofl_osverdef->os_shdr; |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2344 |
|
0 | 2345 |
dyn->d_tag = DT_VERDEF; |
2346 |
dyn->d_un.d_ptr = shdr->sh_addr; |
|
2347 |
dyn++; |
|
2348 |
dyn->d_tag = DT_VERDEFNUM; |
|
2349 |
dyn->d_un.d_ptr = shdr->sh_info; |
|
2350 |
dyn++; |
|
2351 |
} |
|
2352 |
if ((flags & (FLG_OF_VERNEED | FLG_OF_NOVERSEC)) == |
|
2353 |
FLG_OF_VERNEED) { |
|
2354 |
shdr = ofl->ofl_osverneed->os_shdr; |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2355 |
|
0 | 2356 |
dyn->d_tag = DT_VERNEED; |
2357 |
dyn->d_un.d_ptr = shdr->sh_addr; |
|
2358 |
dyn++; |
|
2359 |
dyn->d_tag = DT_VERNEEDNUM; |
|
2360 |
dyn->d_un.d_ptr = shdr->sh_info; |
|
2361 |
dyn++; |
|
2362 |
} |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2363 |
|
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2364 |
if ((flags & FLG_OF_COMREL) && ofl->ofl_relocrelcnt) { |
6206 | 2365 |
dyn->d_tag = ld_targ.t_m.m_rel_dt_count; |
0 | 2366 |
dyn->d_un.d_val = ofl->ofl_relocrelcnt; |
2367 |
dyn++; |
|
2368 |
} |
|
2369 |
if (flags & FLG_OF_TEXTREL) { |
|
2370 |
/* |
|
2371 |
* Only the presence of this entry is used in this |
|
2372 |
* implementation, not the value stored. |
|
2373 |
*/ |
|
2374 |
dyn->d_tag = DT_TEXTREL; |
|
2375 |
dyn->d_un.d_val = 0; |
|
2376 |
dyn++; |
|
2377 |
} |
|
2378 |
||
2379 |
if (ofl->ofl_osfiniarray) { |
|
2380 |
shdr = ofl->ofl_osfiniarray->os_shdr; |
|
2381 |
||
2382 |
dyn->d_tag = DT_FINI_ARRAY; |
|
2383 |
dyn->d_un.d_ptr = shdr->sh_addr; |
|
2384 |
dyn++; |
|
2385 |
||
2386 |
dyn->d_tag = DT_FINI_ARRAYSZ; |
|
2387 |
dyn->d_un.d_val = shdr->sh_size; |
|
2388 |
dyn++; |
|
2389 |
} |
|
2390 |
||
2391 |
if (ofl->ofl_osinitarray) { |
|
2392 |
shdr = ofl->ofl_osinitarray->os_shdr; |
|
2393 |
||
2394 |
dyn->d_tag = DT_INIT_ARRAY; |
|
2395 |
dyn->d_un.d_ptr = shdr->sh_addr; |
|
2396 |
dyn++; |
|
2397 |
||
2398 |
dyn->d_tag = DT_INIT_ARRAYSZ; |
|
2399 |
dyn->d_un.d_val = shdr->sh_size; |
|
2400 |
dyn++; |
|
2401 |
} |
|
2402 |
||
2403 |
if (ofl->ofl_ospreinitarray) { |
|
2404 |
shdr = ofl->ofl_ospreinitarray->os_shdr; |
|
2405 |
||
2406 |
dyn->d_tag = DT_PREINIT_ARRAY; |
|
2407 |
dyn->d_un.d_ptr = shdr->sh_addr; |
|
2408 |
dyn++; |
|
2409 |
||
2410 |
dyn->d_tag = DT_PREINIT_ARRAYSZ; |
|
2411 |
dyn->d_un.d_val = shdr->sh_size; |
|
2412 |
dyn++; |
|
2413 |
} |
|
2414 |
||
2415 |
if (ofl->ofl_pltcnt) { |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2416 |
shdr = ofl->ofl_osplt->os_relosdesc->os_shdr; |
0 | 2417 |
|
2418 |
dyn->d_tag = DT_PLTRELSZ; |
|
2419 |
dyn->d_un.d_ptr = shdr->sh_size; |
|
2420 |
dyn++; |
|
2421 |
dyn->d_tag = DT_PLTREL; |
|
6206 | 2422 |
dyn->d_un.d_ptr = ld_targ.t_m.m_rel_dt_type; |
0 | 2423 |
dyn++; |
2424 |
dyn->d_tag = DT_JMPREL; |
|
2425 |
dyn->d_un.d_ptr = shdr->sh_addr; |
|
2426 |
dyn++; |
|
2427 |
} |
|
2428 |
if (ofl->ofl_pltpad) { |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2429 |
shdr = ofl->ofl_osplt->os_shdr; |
0 | 2430 |
|
2431 |
dyn->d_tag = DT_PLTPAD; |
|
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
2432 |
if (ofl->ofl_pltcnt) { |
0 | 2433 |
dyn->d_un.d_ptr = shdr->sh_addr + |
6206 | 2434 |
ld_targ.t_m.m_plt_reservsz + |
2435 |
ofl->ofl_pltcnt * ld_targ.t_m.m_plt_entsize; |
|
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
2436 |
} else |
0 | 2437 |
dyn->d_un.d_ptr = shdr->sh_addr; |
2438 |
dyn++; |
|
2439 |
dyn->d_tag = DT_PLTPADSZ; |
|
6206 | 2440 |
dyn->d_un.d_val = ofl->ofl_pltpad * |
2441 |
ld_targ.t_m.m_plt_entsize; |
|
0 | 2442 |
dyn++; |
2443 |
} |
|
2444 |
if (ofl->ofl_relocsz) { |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2445 |
shdr = ofl->ofl_osrelhead->os_shdr; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2446 |
|
6206 | 2447 |
dyn->d_tag = ld_targ.t_m.m_rel_dt_type; |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2448 |
dyn->d_un.d_ptr = shdr->sh_addr; |
0 | 2449 |
dyn++; |
6206 | 2450 |
dyn->d_tag = ld_targ.t_m.m_rel_dt_size; |
0 | 2451 |
dyn->d_un.d_ptr = ofl->ofl_relocsz; |
2452 |
dyn++; |
|
6206 | 2453 |
dyn->d_tag = ld_targ.t_m.m_rel_dt_ent; |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2454 |
if (shdr->sh_type == SHT_REL) |
0 | 2455 |
dyn->d_un.d_ptr = sizeof (Rel); |
2456 |
else |
|
2457 |
dyn->d_un.d_ptr = sizeof (Rela); |
|
2458 |
dyn++; |
|
2459 |
} |
|
2460 |
if (ofl->ofl_ossyminfo) { |
|
2461 |
shdr = ofl->ofl_ossyminfo->os_shdr; |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2462 |
|
0 | 2463 |
dyn->d_tag = DT_SYMINFO; |
2464 |
dyn->d_un.d_ptr = shdr->sh_addr; |
|
2465 |
dyn++; |
|
2466 |
dyn->d_tag = DT_SYMINSZ; |
|
2467 |
dyn->d_un.d_val = shdr->sh_size; |
|
2468 |
dyn++; |
|
2469 |
dyn->d_tag = DT_SYMINENT; |
|
2470 |
dyn->d_un.d_val = sizeof (Syminfo); |
|
2471 |
dyn++; |
|
2472 |
} |
|
2473 |
if (ofl->ofl_osmove) { |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2474 |
shdr = ofl->ofl_osmove->os_shdr; |
0 | 2475 |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2476 |
dyn->d_tag = DT_MOVETAB; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2477 |
dyn->d_un.d_val = shdr->sh_addr; |
0 | 2478 |
dyn++; |
2479 |
dyn->d_tag = DT_MOVESZ; |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2480 |
dyn->d_un.d_val = shdr->sh_size; |
0 | 2481 |
dyn++; |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2482 |
dyn->d_tag = DT_MOVEENT; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2483 |
dyn->d_un.d_val = shdr->sh_entsize; |
0 | 2484 |
dyn++; |
2485 |
} |
|
2486 |
if (ofl->ofl_regsymcnt) { |
|
2487 |
int ndx; |
|
2488 |
||
2489 |
for (ndx = 0; ndx < ofl->ofl_regsymsno; ndx++) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2490 |
if ((sdp = ofl->ofl_regsyms[ndx]) == NULL) |
0 | 2491 |
continue; |
2492 |
||
6206 | 2493 |
dyn->d_tag = ld_targ.t_m.m_dt_register; |
0 | 2494 |
dyn->d_un.d_val = sdp->sd_symndx; |
2495 |
dyn++; |
|
2496 |
} |
|
2497 |
} |
|
2498 |
||
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2499 |
for (APLIST_TRAVERSE(ofl->ofl_rtldinfo, idx, sdp)) { |
0 | 2500 |
dyn->d_tag = DT_SUNW_RTLDINF; |
2501 |
dyn->d_un.d_ptr = sdp->sd_sym->st_value; |
|
2502 |
dyn++; |
|
2503 |
} |
|
2504 |
||
2505 |
if (ofl->ofl_osdynamic->os_sgdesc && |
|
2506 |
(ofl->ofl_osdynamic->os_sgdesc->sg_phdr.p_flags & PF_W)) { |
|
2507 |
if (ofl->ofl_osinterp) { |
|
2508 |
dyn->d_tag = DT_DEBUG; |
|
2509 |
dyn->d_un.d_ptr = 0; |
|
2510 |
dyn++; |
|
2511 |
} |
|
2512 |
||
2513 |
dyn->d_tag = DT_FEATURE_1; |
|
2514 |
if (ofl->ofl_osmove) |
|
2515 |
dyn->d_un.d_val = 0; |
|
2516 |
else |
|
2517 |
dyn->d_un.d_val = DTF_1_PARINIT; |
|
2518 |
dyn++; |
|
2519 |
} |
|
2520 |
||
2521 |
if (ofl->ofl_oscap) { |
|
2522 |
dyn->d_tag = DT_SUNW_CAP; |
|
2523 |
dyn->d_un.d_val = ofl->ofl_oscap->os_shdr->sh_addr; |
|
2524 |
dyn++; |
|
2525 |
} |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2526 |
if (ofl->ofl_oscapinfo) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2527 |
dyn->d_tag = DT_SUNW_CAPINFO; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2528 |
dyn->d_un.d_val = ofl->ofl_oscapinfo->os_shdr->sh_addr; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2529 |
dyn++; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2530 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2531 |
if (ofl->ofl_oscapchain) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2532 |
shdr = ofl->ofl_oscapchain->os_shdr; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2533 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2534 |
dyn->d_tag = DT_SUNW_CAPCHAIN; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2535 |
dyn->d_un.d_val = shdr->sh_addr; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2536 |
dyn++; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2537 |
dyn->d_tag = DT_SUNW_CAPCHAINSZ; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2538 |
dyn->d_un.d_val = shdr->sh_size; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2539 |
dyn++; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2540 |
dyn->d_tag = DT_SUNW_CAPCHAINENT; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2541 |
dyn->d_un.d_val = shdr->sh_entsize; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2542 |
dyn++; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
2543 |
} |
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2544 |
if (flags & FLG_OF_SYMBOLIC) { |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2545 |
dyn->d_tag = DT_SYMBOLIC; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2546 |
dyn->d_un.d_val = 0; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2547 |
dyn++; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
2548 |
} |
0 | 2549 |
} |
2550 |
||
2551 |
dyn->d_tag = DT_FLAGS; |
|
2552 |
dyn->d_un.d_val = ofl->ofl_dtflags; |
|
2553 |
dyn++; |
|
2554 |
||
2555 |
/* |
|
2556 |
* If -Bdirect was specified, but some NODIRECT symbols were specified |
|
2557 |
* via a mapfile, or -znodirect was used on the command line, then |
|
2558 |
* clear the DF_1_DIRECT flag. The resultant object will use per-symbol |
|
2559 |
* direct bindings rather than be enabled for global direct bindings. |
|
10167
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
2560 |
* |
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
2561 |
* If any no-direct bindings exist within this object, set the |
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
2562 |
* DF_1_NODIRECT flag. ld(1) recognizes this flag when processing |
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
2563 |
* dependencies, and performs extra work to ensure that no direct |
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
2564 |
* bindings are established to the no-direct symbols that exist |
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
2565 |
* within these dependencies. |
0 | 2566 |
*/ |
10167
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
2567 |
if (ofl->ofl_flags1 & FLG_OF1_NGLBDIR) |
0 | 2568 |
ofl->ofl_dtflags_1 &= ~DF_1_DIRECT; |
10167
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
2569 |
if (ofl->ofl_flags1 & FLG_OF1_NDIRECT) |
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
2570 |
ofl->ofl_dtflags_1 |= DF_1_NODIRECT; |
0 | 2571 |
|
2572 |
dyn->d_tag = DT_FLAGS_1; |
|
2573 |
dyn->d_un.d_val = ofl->ofl_dtflags_1; |
|
2574 |
dyn++; |
|
2575 |
||
3850
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
2576 |
dyn->d_tag = DT_SUNW_STRPAD; |
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
2577 |
dyn->d_un.d_val = DYNSTR_EXTRA_PAD; |
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
2578 |
dyn++; |
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
2579 |
|
6206 | 2580 |
dyn->d_tag = DT_SUNW_LDMACH; |
2581 |
dyn->d_un.d_val = ld_sunw_ldmach(); |
|
2582 |
dyn++; |
|
2583 |
||
2584 |
(*ld_targ.t_mr.mr_mach_update_odynamic)(ofl, &dyn); |
|
0 | 2585 |
|
3850
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
2586 |
for (cnt = 1 + DYNAMIC_EXTRA_ELTS; cnt--; dyn++) { |
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
2587 |
dyn->d_tag = DT_NULL; |
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
2588 |
dyn->d_un.d_val = 0; |
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
2589 |
} |
0 | 2590 |
|
3788
9947e7abaaca
6518359 extern mapfiles references to _init/_fini can create INIT/FINI addresses of 0
ab196087
parents:
3731
diff
changeset
|
2591 |
/* |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2592 |
* Ensure that we wrote the right number of entries. If not, we either |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2593 |
* miscounted in make_dynamic(), or we did something wrong in this |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2594 |
* function. |
3788
9947e7abaaca
6518359 extern mapfiles references to _init/_fini can create INIT/FINI addresses of 0
ab196087
parents:
3731
diff
changeset
|
2595 |
*/ |
9947e7abaaca
6518359 extern mapfiles references to _init/_fini can create INIT/FINI addresses of 0
ab196087
parents:
3731
diff
changeset
|
2596 |
assert((ofl->ofl_osdynamic->os_shdr->sh_size / |
9947e7abaaca
6518359 extern mapfiles references to _init/_fini can create INIT/FINI addresses of 0
ab196087
parents:
3731
diff
changeset
|
2597 |
ofl->ofl_osdynamic->os_shdr->sh_entsize) == |
3850
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
2598 |
((uintptr_t)dyn - (uintptr_t)_dyn) / sizeof (*dyn)); |
3788
9947e7abaaca
6518359 extern mapfiles references to _init/_fini can create INIT/FINI addresses of 0
ab196087
parents:
3731
diff
changeset
|
2599 |
|
0 | 2600 |
return (1); |
2601 |
} |
|
2602 |
||
2603 |
/* |
|
2604 |
* Build the version definition section |
|
2605 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
2606 |
static int |
0 | 2607 |
update_overdef(Ofl_desc *ofl) |
2608 |
{ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2609 |
Aliste idx1; |
0 | 2610 |
Ver_desc *vdp, *_vdp; |
2611 |
Verdef *vdf, *_vdf; |
|
2612 |
int num = 0; |
|
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2613 |
Os_desc *strosp; |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2614 |
Str_tbl *strtbl; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2615 |
|
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2616 |
/* |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2617 |
* Determine which string table to use. |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2618 |
*/ |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2619 |
if (OFL_IS_STATIC_OBJ(ofl)) { |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2620 |
strtbl = ofl->ofl_strtab; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2621 |
strosp = ofl->ofl_osstrtab; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2622 |
} else { |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2623 |
strtbl = ofl->ofl_dynstrtab; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2624 |
strosp = ofl->ofl_osdynstr; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2625 |
} |
0 | 2626 |
|
2627 |
/* |
|
2628 |
* Traverse the version descriptors and update the version structures |
|
2629 |
* to point to the dynstr name in preparation for building the version |
|
2630 |
* section structure. |
|
2631 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2632 |
for (APLIST_TRAVERSE(ofl->ofl_verdesc, idx1, vdp)) { |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2633 |
Sym_desc *sdp; |
0 | 2634 |
|
2635 |
if (vdp->vd_flags & VER_FLG_BASE) { |
|
2636 |
const char *name = vdp->vd_name; |
|
5892
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
2637 |
size_t stoff; |
0 | 2638 |
|
2639 |
/* |
|
2640 |
* Create a new string table entry to represent the base |
|
2641 |
* version name (there is no corresponding symbol for |
|
2642 |
* this). |
|
2643 |
*/ |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2644 |
(void) st_setstring(strtbl, name, &stoff); |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2645 |
/* LINTED */ |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2646 |
vdp->vd_name = (const char *)stoff; |
0 | 2647 |
} else { |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
2648 |
sdp = ld_sym_find(vdp->vd_name, vdp->vd_hash, 0, ofl); |
0 | 2649 |
/* LINTED */ |
2650 |
vdp->vd_name = (const char *) |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2651 |
(uintptr_t)sdp->sd_sym->st_name; |
0 | 2652 |
} |
2653 |
} |
|
2654 |
||
2655 |
_vdf = vdf = (Verdef *)ofl->ofl_osverdef->os_outdata->d_buf; |
|
2656 |
||
2657 |
/* |
|
2658 |
* Traverse the version descriptors and update the version section to |
|
2659 |
* reflect each version and its associated dependencies. |
|
2660 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2661 |
for (APLIST_TRAVERSE(ofl->ofl_verdesc, idx1, vdp)) { |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2662 |
Aliste idx2; |
0 | 2663 |
Half cnt = 1; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2664 |
Verdaux *vdap, *_vdap; |
0 | 2665 |
|
2666 |
_vdap = vdap = (Verdaux *)(vdf + 1); |
|
2667 |
||
2668 |
vdf->vd_version = VER_DEF_CURRENT; |
|
2669 |
vdf->vd_flags = vdp->vd_flags & MSK_VER_USER; |
|
2670 |
vdf->vd_ndx = vdp->vd_ndx; |
|
2671 |
vdf->vd_hash = vdp->vd_hash; |
|
2672 |
||
2673 |
/* LINTED */ |
|
2674 |
vdap->vda_name = (uintptr_t)vdp->vd_name; |
|
2675 |
vdap++; |
|
2676 |
/* LINTED */ |
|
2677 |
_vdap->vda_next = (Word)((uintptr_t)vdap - (uintptr_t)_vdap); |
|
2678 |
||
2679 |
/* |
|
2680 |
* Traverse this versions dependency list generating the |
|
2681 |
* appropriate version dependency entries. |
|
2682 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2683 |
for (APLIST_TRAVERSE(vdp->vd_deps, idx2, _vdp)) { |
0 | 2684 |
/* LINTED */ |
2685 |
vdap->vda_name = (uintptr_t)_vdp->vd_name; |
|
2686 |
_vdap = vdap; |
|
2687 |
vdap++, cnt++; |
|
2688 |
/* LINTED */ |
|
2689 |
_vdap->vda_next = (Word)((uintptr_t)vdap - |
|
2690 |
(uintptr_t)_vdap); |
|
2691 |
} |
|
2692 |
_vdap->vda_next = 0; |
|
2693 |
||
2694 |
/* |
|
2695 |
* Record the versions auxiliary array offset and the associated |
|
2696 |
* dependency count. |
|
2697 |
*/ |
|
2698 |
/* LINTED */ |
|
2699 |
vdf->vd_aux = (Word)((uintptr_t)(vdf + 1) - (uintptr_t)vdf); |
|
2700 |
vdf->vd_cnt = cnt; |
|
2701 |
||
2702 |
/* |
|
2703 |
* Record the next versions offset and update the version |
|
2704 |
* pointer. Remember the previous version offset as the very |
|
2705 |
* last structures next pointer should be null. |
|
2706 |
*/ |
|
2707 |
_vdf = vdf; |
|
2708 |
vdf = (Verdef *)vdap, num++; |
|
2709 |
/* LINTED */ |
|
2710 |
_vdf->vd_next = (Word)((uintptr_t)vdf - (uintptr_t)_vdf); |
|
2711 |
} |
|
2712 |
_vdf->vd_next = 0; |
|
2713 |
||
2714 |
/* |
|
2715 |
* Record the string table association with the version definition |
|
2716 |
* section, and the symbol table associated with the version symbol |
|
2717 |
* table (the actual contents of the version symbol table are filled |
|
2718 |
* in during symbol update). |
|
2719 |
*/ |
|
2720 |
/* LINTED */ |
|
2721 |
ofl->ofl_osverdef->os_shdr->sh_link = (Word)elf_ndxscn(strosp->os_scn); |
|
2722 |
||
2723 |
/* |
|
2724 |
* The version definition sections `info' field is used to indicate the |
|
2725 |
* number of entries in this section. |
|
2726 |
*/ |
|
2727 |
ofl->ofl_osverdef->os_shdr->sh_info = num; |
|
2728 |
||
2729 |
return (1); |
|
2730 |
} |
|
2731 |
||
2732 |
/* |
|
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2733 |
* Finish the version symbol index section |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2734 |
*/ |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2735 |
static void |
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2736 |
update_oversym(Ofl_desc *ofl) |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2737 |
{ |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2738 |
Os_desc *osp; |
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2739 |
|
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2740 |
/* |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2741 |
* Record the symbol table associated with the version symbol table. |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2742 |
* The contents of the version symbol table are filled in during |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2743 |
* symbol update. |
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2744 |
*/ |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2745 |
if (OFL_IS_STATIC_OBJ(ofl)) |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2746 |
osp = ofl->ofl_ossymtab; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2747 |
else |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2748 |
osp = ofl->ofl_osdynsym; |
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2749 |
|
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2750 |
/* LINTED */ |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2751 |
ofl->ofl_osversym->os_shdr->sh_link = (Word)elf_ndxscn(osp->os_scn); |
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2752 |
} |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2753 |
|
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2754 |
/* |
0 | 2755 |
* Build the version needed section |
2756 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
2757 |
static int |
0 | 2758 |
update_overneed(Ofl_desc *ofl) |
2759 |
{ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2760 |
Aliste idx1; |
0 | 2761 |
Ifl_desc *ifl; |
2762 |
Verneed *vnd, *_vnd; |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2763 |
Os_desc *strosp; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2764 |
Str_tbl *strtbl; |
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2765 |
Word num = 0; |
0 | 2766 |
|
2767 |
_vnd = vnd = (Verneed *)ofl->ofl_osverneed->os_outdata->d_buf; |
|
2768 |
||
2769 |
/* |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2770 |
* Determine which string table is appropriate. |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2771 |
*/ |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2772 |
if (OFL_IS_STATIC_OBJ(ofl)) { |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2773 |
strosp = ofl->ofl_osstrtab; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2774 |
strtbl = ofl->ofl_strtab; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2775 |
} else { |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2776 |
strosp = ofl->ofl_osdynstr; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2777 |
strtbl = ofl->ofl_dynstrtab; |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2778 |
} |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2779 |
|
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2780 |
/* |
0 | 2781 |
* Traverse the shared object list looking for dependencies that have |
2782 |
* versions defined within them. |
|
2783 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2784 |
for (APLIST_TRAVERSE(ofl->ofl_sos, idx1, ifl)) { |
0 | 2785 |
Half _cnt; |
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2786 |
Word cnt = 0; |
0 | 2787 |
Vernaux *_vnap, *vnap; |
5892
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
2788 |
size_t stoff; |
0 | 2789 |
|
2790 |
if (!(ifl->ifl_flags & FLG_IF_VERNEED)) |
|
2791 |
continue; |
|
2792 |
||
2793 |
vnd->vn_version = VER_NEED_CURRENT; |
|
2794 |
||
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2795 |
(void) st_setstring(strtbl, ifl->ifl_soname, &stoff); |
0 | 2796 |
vnd->vn_file = stoff; |
2797 |
||
2798 |
_vnap = vnap = (Vernaux *)(vnd + 1); |
|
2799 |
||
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2800 |
/* |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2801 |
* Traverse the version index list recording |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2802 |
* each version as a needed dependency. |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2803 |
*/ |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2804 |
for (_cnt = 0; _cnt <= ifl->ifl_vercnt; _cnt++) { |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2805 |
Ver_index *vip = &ifl->ifl_verndx[_cnt]; |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2806 |
|
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2807 |
if (vip->vi_flags & FLG_VER_REFER) { |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2808 |
(void) st_setstring(strtbl, vip->vi_name, |
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2809 |
&stoff); |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2810 |
vnap->vna_name = stoff; |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2811 |
|
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2812 |
if (vip->vi_desc) { |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2813 |
vnap->vna_hash = vip->vi_desc->vd_hash; |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2814 |
vnap->vna_flags = |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2815 |
vip->vi_desc->vd_flags; |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2816 |
} else { |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2817 |
vnap->vna_hash = 0; |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2818 |
vnap->vna_flags = 0; |
0 | 2819 |
} |
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2820 |
vnap->vna_other = vip->vi_overndx; |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2821 |
|
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2822 |
/* |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2823 |
* If version A inherits version B, then |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2824 |
* B is implicit in A. It suffices for ld.so.1 |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2825 |
* to verify A at runtime and skip B. The |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2826 |
* version normalization process sets the INFO |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2827 |
* flag for the versions we want ld.so.1 to |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
2828 |
* skip. |
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2829 |
*/ |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
2830 |
if (vip->vi_flags & VER_FLG_INFO) |
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2831 |
vnap->vna_flags |= VER_FLG_INFO; |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2832 |
|
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2833 |
_vnap = vnap; |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2834 |
vnap++, cnt++; |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2835 |
_vnap->vna_next = |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2836 |
/* LINTED */ |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2837 |
(Word)((uintptr_t)vnap - (uintptr_t)_vnap); |
0 | 2838 |
} |
2839 |
} |
|
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
2840 |
|
0 | 2841 |
_vnap->vna_next = 0; |
2842 |
||
2843 |
/* |
|
2844 |
* Record the versions auxiliary array offset and |
|
2845 |
* the associated dependency count. |
|
2846 |
*/ |
|
2847 |
/* LINTED */ |
|
2848 |
vnd->vn_aux = (Word)((uintptr_t)(vnd + 1) - (uintptr_t)vnd); |
|
2849 |
/* LINTED */ |
|
2850 |
vnd->vn_cnt = (Half)cnt; |
|
2851 |
||
2852 |
/* |
|
2853 |
* Record the next versions offset and update the version |
|
2854 |
* pointer. Remember the previous version offset as the very |
|
2855 |
* last structures next pointer should be null. |
|
2856 |
*/ |
|
2857 |
_vnd = vnd; |
|
2858 |
vnd = (Verneed *)vnap, num++; |
|
2859 |
/* LINTED */ |
|
2860 |
_vnd->vn_next = (Word)((uintptr_t)vnd - (uintptr_t)_vnd); |
|
2861 |
} |
|
2862 |
_vnd->vn_next = 0; |
|
2863 |
||
2864 |
/* |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2865 |
* Use sh_link to record the associated string table section, and |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2866 |
* sh_info to indicate the number of entries contained in the section. |
0 | 2867 |
*/ |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2868 |
/* LINTED */ |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2869 |
ofl->ofl_osverneed->os_shdr->sh_link = (Word)elf_ndxscn(strosp->os_scn); |
0 | 2870 |
ofl->ofl_osverneed->os_shdr->sh_info = num; |
2871 |
||
2872 |
return (1); |
|
2873 |
} |
|
2874 |
||
2875 |
/* |
|
2876 |
* Update syminfo section. |
|
2877 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
2878 |
static uintptr_t |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2879 |
update_osyminfo(Ofl_desc *ofl) |
0 | 2880 |
{ |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2881 |
Os_desc *symosp, *infosp = ofl->ofl_ossyminfo; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2882 |
Syminfo *sip = infosp->os_outdata->d_buf; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2883 |
Shdr *shdr = infosp->os_shdr; |
0 | 2884 |
char *strtab; |
5892
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
2885 |
Aliste idx; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2886 |
Sym_desc *sdp; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2887 |
Sfltr_desc *sftp; |
0 | 2888 |
|
2889 |
if (ofl->ofl_flags & FLG_OF_RELOBJ) { |
|
2890 |
symosp = ofl->ofl_ossymtab; |
|
2891 |
strtab = ofl->ofl_osstrtab->os_outdata->d_buf; |
|
2892 |
} else { |
|
2893 |
symosp = ofl->ofl_osdynsym; |
|
2894 |
strtab = ofl->ofl_osdynstr->os_outdata->d_buf; |
|
2895 |
} |
|
2896 |
||
2897 |
/* LINTED */ |
|
2898 |
infosp->os_shdr->sh_link = (Word)elf_ndxscn(symosp->os_scn); |
|
2899 |
if (ofl->ofl_osdynamic) |
|
2900 |
infosp->os_shdr->sh_info = |
|
2901 |
/* LINTED */ |
|
2902 |
(Word)elf_ndxscn(ofl->ofl_osdynamic->os_scn); |
|
2903 |
||
2904 |
/* |
|
2905 |
* Update any references with the index into the dynamic table. |
|
2906 |
*/ |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2907 |
for (APLIST_TRAVERSE(ofl->ofl_symdtent, idx, sdp)) |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
2908 |
sip[sdp->sd_symndx].si_boundto = sdp->sd_file->ifl_neededndx; |
0 | 2909 |
|
2910 |
/* |
|
2911 |
* Update any filtee references with the index into the dynamic table. |
|
2912 |
*/ |
|
5892
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
2913 |
for (ALIST_TRAVERSE(ofl->ofl_symfltrs, idx, sftp)) { |
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
2914 |
Dfltr_desc *dftp; |
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
2915 |
|
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
2916 |
dftp = alist_item(ofl->ofl_dtsfltrs, sftp->sft_idx); |
0 | 2917 |
sip[sftp->sft_sdp->sd_symndx].si_boundto = dftp->dft_ndx; |
2918 |
} |
|
2919 |
||
2920 |
/* |
|
2921 |
* Display debugging information about section. |
|
2922 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
2923 |
DBG_CALL(Dbg_syminfo_title(ofl->ofl_lml)); |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
2924 |
if (DBG_ENABLED) { |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
2925 |
Word _cnt, cnt = shdr->sh_size / shdr->sh_entsize; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2926 |
Sym *symtab = symosp->os_outdata->d_buf; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2927 |
Dyn *dyn; |
0 | 2928 |
|
2929 |
if (ofl->ofl_osdynamic) |
|
2930 |
dyn = ofl->ofl_osdynamic->os_outdata->d_buf; |
|
2931 |
else |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
2932 |
dyn = NULL; |
0 | 2933 |
|
2934 |
for (_cnt = 1; _cnt < cnt; _cnt++) { |
|
2935 |
if (sip[_cnt].si_flags || sip[_cnt].si_boundto) |
|
2936 |
/* LINTED */ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
2937 |
DBG_CALL(Dbg_syminfo_entry(ofl->ofl_lml, _cnt, |
0 | 2938 |
&sip[_cnt], &symtab[_cnt], strtab, dyn)); |
2939 |
} |
|
2940 |
} |
|
2941 |
return (1); |
|
2942 |
} |
|
2943 |
||
2944 |
/* |
|
2945 |
* Build the output elf header. |
|
2946 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
2947 |
static uintptr_t |
0 | 2948 |
update_oehdr(Ofl_desc * ofl) |
2949 |
{ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
2950 |
Ehdr *ehdr = ofl->ofl_nehdr; |
0 | 2951 |
|
2952 |
/* |
|
2953 |
* If an entry point symbol has already been established (refer |
|
2954 |
* sym_validate()) simply update the elf header entry point with the |
|
2955 |
* symbols value. If no entry point is defined it will have been filled |
|
2956 |
* with the start address of the first section within the text segment |
|
2957 |
* (refer update_outfile()). |
|
2958 |
*/ |
|
2959 |
if (ofl->ofl_entry) |
|
2960 |
ehdr->e_entry = |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
2961 |
((Sym_desc *)(ofl->ofl_entry))->sd_sym->st_value; |
0 | 2962 |
|
12029
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2963 |
ehdr->e_ident[EI_DATA] = ld_targ.t_m.m_data; |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2964 |
ehdr->e_version = ofl->ofl_dehdr->e_version; |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2965 |
|
0 | 2966 |
/* |
12029
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2967 |
* When generating a relocatable object under -z symbolcap, set the |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2968 |
* e_machine to be generic, and remove any e_flags. Input relocatable |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2969 |
* objects may identify alternative e_machine (m.machplus) and e_flags |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2970 |
* values. However, the functions within the created output object |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2971 |
* are selected at runtime using the capabilities mechanism, which |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2972 |
* supersedes the e-machine and e_flags information. Therefore, |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2973 |
* e_machine and e_flag values are not propagated to the output object, |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2974 |
* as these values might prevent the kernel from loading the object |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2975 |
* before the runtime linker gets control. |
0 | 2976 |
*/ |
12029
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2977 |
if (ofl->ofl_flags & FLG_OF_OTOSCAP) { |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2978 |
ehdr->e_machine = ld_targ.t_m.m_mach; |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2979 |
ehdr->e_flags = 0; |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2980 |
} else { |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2981 |
/* |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2982 |
* Note. it may be necessary to update the e_flags field in the |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2983 |
* machine dependent section. |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2984 |
*/ |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2985 |
ehdr->e_machine = ofl->ofl_dehdr->e_machine; |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2986 |
ehdr->e_flags = ofl->ofl_dehdr->e_flags; |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2987 |
|
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2988 |
if (ehdr->e_machine != ld_targ.t_m.m_mach) { |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2989 |
if (ehdr->e_machine != ld_targ.t_m.m_machplus) |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2990 |
return (S_ERROR); |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2991 |
if ((ehdr->e_flags & ld_targ.t_m.m_flagsplus) == 0) |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2992 |
return (S_ERROR); |
3202400f09a4
6938628 ld.so.1 should produce diagnostics for all dl*() entry points
Rod Evans <Rod.Evans@Sun.COM>
parents:
11828
diff
changeset
|
2993 |
} |
0 | 2994 |
} |
2995 |
||
2996 |
if (ofl->ofl_flags & FLG_OF_SHAROBJ) |
|
2997 |
ehdr->e_type = ET_DYN; |
|
2998 |
else if (ofl->ofl_flags & FLG_OF_RELOBJ) |
|
2999 |
ehdr->e_type = ET_REL; |
|
3000 |
else |
|
3001 |
ehdr->e_type = ET_EXEC; |
|
3002 |
||
3003 |
return (1); |
|
3004 |
} |
|
3005 |
||
3006 |
/* |
|
3007 |
* Perform move table expansion. |
|
3008 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3009 |
static void |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3010 |
expand_move(Ofl_desc *ofl, Sym_desc *sdp, Move *mvp) |
0 | 3011 |
{ |
3012 |
Os_desc *osp; |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3013 |
uchar_t *taddr, *taddr0; |
0 | 3014 |
Sxword offset; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3015 |
Half cnt; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3016 |
uint_t stride; |
0 | 3017 |
|
8159
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
3018 |
osp = ofl->ofl_isparexpn->is_osdesc; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3019 |
offset = sdp->sd_sym->st_value - osp->os_shdr->sh_addr; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3020 |
|
0 | 3021 |
taddr0 = taddr = osp->os_outdata->d_buf; |
3022 |
taddr += offset; |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3023 |
taddr = taddr + mvp->m_poffset; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3024 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3025 |
for (cnt = 0; cnt < mvp->m_repeat; cnt++) { |
0 | 3026 |
/* LINTED */ |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3027 |
DBG_CALL(Dbg_move_expand(ofl->ofl_lml, mvp, |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3028 |
(Addr)(taddr - taddr0))); |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3029 |
stride = (uint_t)mvp->m_stride + 1; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3030 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3031 |
/* |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3032 |
* Update the target address based upon the move entry size. |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3033 |
* This size was validated in ld_process_move(). |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3034 |
*/ |
0 | 3035 |
/* LINTED */ |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3036 |
switch (ELF_M_SIZE(mvp->m_info)) { |
0 | 3037 |
case 1: |
3038 |
/* LINTED */ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3039 |
*taddr = (uchar_t)mvp->m_value; |
0 | 3040 |
taddr += stride; |
3041 |
break; |
|
3042 |
case 2: |
|
3043 |
/* LINTED */ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3044 |
*((Half *)taddr) = (Half)mvp->m_value; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3045 |
taddr += 2 * stride; |
0 | 3046 |
break; |
3047 |
case 4: |
|
3048 |
/* LINTED */ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3049 |
*((Word *)taddr) = (Word)mvp->m_value; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3050 |
taddr += 4 * stride; |
0 | 3051 |
break; |
3052 |
case 8: |
|
3053 |
/* LINTED */ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3054 |
*((u_longlong_t *)taddr) = mvp->m_value; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3055 |
taddr += 8 * stride; |
0 | 3056 |
break; |
3057 |
} |
|
3058 |
} |
|
3059 |
} |
|
3060 |
||
3061 |
/* |
|
3062 |
* Update Move sections. |
|
3063 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3064 |
static void |
0 | 3065 |
update_move(Ofl_desc *ofl) |
3066 |
{ |
|
3067 |
Word ndx = 0; |
|
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
3068 |
ofl_flag_t flags = ofl->ofl_flags; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3069 |
Move *omvp; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3070 |
Aliste idx1; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3071 |
Sym_desc *sdp; |
0 | 3072 |
|
3073 |
/* |
|
3074 |
* Determine the index of the symbol table that will be referenced by |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3075 |
* the Move section. |
0 | 3076 |
*/ |
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
3077 |
if (OFL_ALLOW_DYNSYM(ofl)) |
0 | 3078 |
/* LINTED */ |
3079 |
ndx = (Word) elf_ndxscn(ofl->ofl_osdynsym->os_scn); |
|
3080 |
else if (!(flags & FLG_OF_STRIP) || (flags & FLG_OF_RELOBJ)) |
|
3081 |
/* LINTED */ |
|
3082 |
ndx = (Word) elf_ndxscn(ofl->ofl_ossymtab->os_scn); |
|
3083 |
||
3084 |
/* |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3085 |
* Update sh_link of the Move section, and point to the new Move data. |
0 | 3086 |
*/ |
3087 |
if (ofl->ofl_osmove) { |
|
3088 |
ofl->ofl_osmove->os_shdr->sh_link = ndx; |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3089 |
omvp = (Move *)ofl->ofl_osmove->os_outdata->d_buf; |
0 | 3090 |
} |
3091 |
||
3092 |
/* |
|
3093 |
* Update symbol entry index |
|
3094 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3095 |
for (APLIST_TRAVERSE(ofl->ofl_parsyms, idx1, sdp)) { |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3096 |
Aliste idx2; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3097 |
Mv_desc *mdp; |
0 | 3098 |
|
3099 |
/* |
|
3100 |
* Expand move table |
|
3101 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3102 |
if (sdp->sd_flags & FLG_SY_PAREXPN) { |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3103 |
const char *str; |
0 | 3104 |
|
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
3105 |
if (flags & FLG_OF_STATIC) |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3106 |
str = MSG_INTL(MSG_PSYM_EXPREASON1); |
0 | 3107 |
else if (ofl->ofl_flags1 & FLG_OF1_NOPARTI) |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3108 |
str = MSG_INTL(MSG_PSYM_EXPREASON2); |
0 | 3109 |
else |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3110 |
str = MSG_INTL(MSG_PSYM_EXPREASON3); |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3111 |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3112 |
DBG_CALL(Dbg_move_parexpn(ofl->ofl_lml, |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3113 |
sdp->sd_name, str)); |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3114 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3115 |
for (ALIST_TRAVERSE(sdp->sd_move, idx2, mdp)) { |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3116 |
DBG_CALL(Dbg_move_entry1(ofl->ofl_lml, 0, |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3117 |
mdp->md_move, sdp)); |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3118 |
expand_move(ofl, sdp, mdp->md_move); |
0 | 3119 |
} |
3120 |
continue; |
|
3121 |
} |
|
3122 |
||
3123 |
/* |
|
3124 |
* Process move table |
|
3125 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3126 |
DBG_CALL(Dbg_move_outmove(ofl->ofl_lml, sdp->sd_name)); |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3127 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3128 |
for (ALIST_TRAVERSE(sdp->sd_move, idx2, mdp)) { |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3129 |
Move *imvp; |
0 | 3130 |
int idx = 1; |
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
3131 |
Sym *sym; |
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
3132 |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3133 |
imvp = mdp->md_move; |
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
3134 |
sym = sdp->sd_sym; |
0 | 3135 |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3136 |
DBG_CALL(Dbg_move_entry1(ofl->ofl_lml, 1, imvp, sdp)); |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3137 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3138 |
*omvp = *imvp; |
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
3139 |
if ((flags & FLG_OF_RELOBJ) == 0) { |
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
3140 |
if (ELF_ST_BIND(sym->st_info) == STB_LOCAL) { |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3141 |
Os_desc *osp = sdp->sd_isc->is_osdesc; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3142 |
Word ndx = osp->os_identndx; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3143 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3144 |
omvp->m_info = |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
3145 |
/* LINTED */ |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3146 |
ELF_M_INFO(ndx, imvp->m_info); |
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
3147 |
|
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
3148 |
if (ELF_ST_TYPE(sym->st_info) != |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
3149 |
STT_SECTION) { |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3150 |
omvp->m_poffset = |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3151 |
sym->st_value - |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3152 |
osp->os_shdr->sh_addr + |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3153 |
imvp->m_poffset; |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
3154 |
} |
0 | 3155 |
} else { |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3156 |
omvp->m_info = |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
3157 |
/* LINTED */ |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
3158 |
ELF_M_INFO(sdp->sd_symndx, |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3159 |
imvp->m_info); |
0 | 3160 |
} |
3161 |
} else { |
|
3162 |
Boolean isredloc = FALSE; |
|
3163 |
||
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
3164 |
if ((ELF_ST_BIND(sym->st_info) == STB_LOCAL) && |
6614
144184774564
6699594 The ld command has a problem handling 'protected' mapfile keyword.
rie
parents:
6299
diff
changeset
|
3165 |
(ofl->ofl_flags & FLG_OF_REDLSYM)) |
0 | 3166 |
isredloc = TRUE; |
3167 |
||
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3168 |
if (isredloc && !(sdp->sd_move)) { |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3169 |
Os_desc *osp = sdp->sd_isc->is_osdesc; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3170 |
Word ndx = osp->os_identndx; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3171 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3172 |
omvp->m_info = |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
3173 |
/* LINTED */ |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3174 |
ELF_M_INFO(ndx, imvp->m_info); |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3175 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3176 |
omvp->m_poffset += sym->st_value; |
0 | 3177 |
} else { |
3178 |
if (isredloc) |
|
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
3179 |
DBG_CALL(Dbg_syms_reduce(ofl, |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3180 |
DBG_SYM_REDUCE_RETAIN, |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3181 |
sdp, idx, |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
3182 |
ofl->ofl_osmove->os_name)); |
0 | 3183 |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3184 |
omvp->m_info = |
4716
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
3185 |
/* LINTED */ |
c06a3889ba02
6577462 Additional improvements needed to handling of gcc's symbol versioning
ab196087
parents:
4284
diff
changeset
|
3186 |
ELF_M_INFO(sdp->sd_symndx, |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3187 |
imvp->m_info); |
0 | 3188 |
} |
3189 |
} |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3190 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3191 |
DBG_CALL(Dbg_move_entry1(ofl->ofl_lml, 0, omvp, sdp)); |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3192 |
omvp++; |
0 | 3193 |
idx++; |
3194 |
} |
|
3195 |
} |
|
3196 |
} |
|
3197 |
||
3198 |
/* |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3199 |
* Scan through the SHT_GROUP output sections. Update their sh_link/sh_info |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3200 |
* fields as well as the section contents. |
0 | 3201 |
*/ |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3202 |
static uintptr_t |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
6614
diff
changeset
|
3203 |
update_ogroup(Ofl_desc *ofl) |
0 | 3204 |
{ |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3205 |
Aliste idx; |
0 | 3206 |
Os_desc *osp; |
3207 |
uintptr_t error = 0; |
|
3208 |
||
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3209 |
for (APLIST_TRAVERSE(ofl->ofl_osgroups, idx, osp)) { |
0 | 3210 |
Is_desc *isp; |
3211 |
Ifl_desc *ifl; |
|
3212 |
Shdr *shdr = osp->os_shdr; |
|
3213 |
Sym_desc *sdp; |
|
3214 |
Xword i, grpcnt; |
|
3215 |
Word *gdata; |
|
3216 |
||
3217 |
/* |
|
3218 |
* Since input GROUP sections always create unique |
|
3219 |
* output GROUP sections - we know there is only one |
|
3220 |
* item on the list. |
|
3221 |
*/ |
|
9615
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9313
diff
changeset
|
3222 |
isp = ld_os_first_isdesc(osp); |
0 | 3223 |
|
3224 |
ifl = isp->is_file; |
|
3225 |
sdp = ifl->ifl_oldndx[isp->is_shdr->sh_info]; |
|
3226 |
shdr->sh_link = (Word)elf_ndxscn(ofl->ofl_ossymtab->os_scn); |
|
3227 |
shdr->sh_info = sdp->sd_symndx; |
|
3228 |
||
3229 |
/* |
|
3230 |
* Scan through the group data section and update |
|
3231 |
* all of the links to new values. |
|
3232 |
*/ |
|
3233 |
grpcnt = shdr->sh_size / shdr->sh_entsize; |
|
3234 |
gdata = (Word *)osp->os_outdata->d_buf; |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
6614
diff
changeset
|
3235 |
|
0 | 3236 |
for (i = 1; i < grpcnt; i++) { |
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
6614
diff
changeset
|
3237 |
Os_desc *_osp; |
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
6614
diff
changeset
|
3238 |
Is_desc *_isp = ifl->ifl_isdesc[gdata[i]]; |
0 | 3239 |
|
3240 |
/* |
|
3241 |
* If the referenced section didn't make it to the |
|
3242 |
* output file - just zero out the entry. |
|
3243 |
*/ |
|
7463
c4d92436ec33
6735939 ld(1) discarded symbol relocations errors (Studio and GNU).
Rod Evans <Rod.Evans@Sun.COM>
parents:
6614
diff
changeset
|
3244 |
if ((_osp = _isp->is_osdesc) == NULL) |
0 | 3245 |
gdata[i] = 0; |
3246 |
else |
|
3247 |
gdata[i] = (Word)elf_ndxscn(_osp->os_scn); |
|
3248 |
} |
|
3249 |
} |
|
3250 |
return (error); |
|
3251 |
} |
|
3252 |
||
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3253 |
static void |
3850
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
3254 |
update_ostrtab(Os_desc *osp, Str_tbl *stp, uint_t extra) |
0 | 3255 |
{ |
3256 |
Elf_Data *data; |
|
3850
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
3257 |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3258 |
if (osp == NULL) |
0 | 3259 |
return; |
3260 |
||
3261 |
data = osp->os_outdata; |
|
3850
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
3262 |
assert(data->d_size == (st_getstrtab_sz(stp) + extra)); |
5892
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
3263 |
(void) st_setstrbuf(stp, data->d_buf, data->d_size - extra); |
3850
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
3264 |
/* If leaving an extra hole at the end, zero it */ |
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
3265 |
if (extra > 0) |
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
3266 |
(void) memset((char *)data->d_buf + data->d_size - extra, |
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
3267 |
0x0, extra); |
0 | 3268 |
} |
3269 |
||
3270 |
/* |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3271 |
* Update capabilities information. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3272 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3273 |
* If string table capabilities exist, then the associated string must be |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3274 |
* translated into an offset into the string table. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3275 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3276 |
static void |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3277 |
update_oscap(Ofl_desc *ofl) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3278 |
{ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3279 |
Os_desc *strosp, *cosp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3280 |
Cap *cap; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3281 |
Str_tbl *strtbl; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3282 |
Capstr *capstr; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3283 |
size_t stoff; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3284 |
Aliste idx1; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3285 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3286 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3287 |
* Determine which symbol table or string table is appropriate. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3288 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3289 |
if (OFL_IS_STATIC_OBJ(ofl)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3290 |
strosp = ofl->ofl_osstrtab; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3291 |
strtbl = ofl->ofl_strtab; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3292 |
} else { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3293 |
strosp = ofl->ofl_osdynstr; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3294 |
strtbl = ofl->ofl_dynstrtab; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3295 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3296 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3297 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3298 |
* If symbol capabilities exist, set the sh_link field of the .SUNW_cap |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3299 |
* section to the .SUNW_capinfo section. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3300 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3301 |
if (ofl->ofl_oscapinfo) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3302 |
cosp = ofl->ofl_oscap; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3303 |
cosp->os_shdr->sh_link = |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3304 |
(Word)elf_ndxscn(ofl->ofl_oscapinfo->os_scn); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3305 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3306 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3307 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3308 |
* If there are capability strings to process, set the sh_info |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3309 |
* field of the .SUNW_cap section to the associated string table, and |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3310 |
* proceed to process any CA_SUNW_PLAT entries. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3311 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3312 |
if ((ofl->ofl_flags & FLG_OF_CAPSTRS) == 0) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3313 |
return; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3314 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3315 |
cosp = ofl->ofl_oscap; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3316 |
cosp->os_shdr->sh_info = (Word)elf_ndxscn(strosp->os_scn); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3317 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3318 |
cap = ofl->ofl_oscap->os_outdata->d_buf; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3319 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3320 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3321 |
* Determine whether an object capability identifier, or object |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3322 |
* machine/platform capabilities exists. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3323 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3324 |
capstr = &ofl->ofl_ocapset.oc_id; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3325 |
if (capstr->cs_str) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3326 |
(void) st_setstring(strtbl, capstr->cs_str, &stoff); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3327 |
cap[capstr->cs_ndx].c_un.c_ptr = stoff; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3328 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3329 |
for (ALIST_TRAVERSE(ofl->ofl_ocapset.oc_plat.cl_val, idx1, capstr)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3330 |
(void) st_setstring(strtbl, capstr->cs_str, &stoff); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3331 |
cap[capstr->cs_ndx].c_un.c_ptr = stoff; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3332 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3333 |
for (ALIST_TRAVERSE(ofl->ofl_ocapset.oc_mach.cl_val, idx1, capstr)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3334 |
(void) st_setstring(strtbl, capstr->cs_str, &stoff); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3335 |
cap[capstr->cs_ndx].c_un.c_ptr = stoff; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3336 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3337 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3338 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3339 |
* Determine any symbol capability identifiers, or machine/platform |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3340 |
* capabilities. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3341 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3342 |
if (ofl->ofl_capgroups) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3343 |
Cap_group *cgp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3344 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3345 |
for (APLIST_TRAVERSE(ofl->ofl_capgroups, idx1, cgp)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3346 |
Objcapset *ocapset = &cgp->cg_set; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3347 |
Aliste idx2; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3348 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3349 |
capstr = &ocapset->oc_id; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3350 |
if (capstr->cs_str) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3351 |
(void) st_setstring(strtbl, capstr->cs_str, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3352 |
&stoff); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3353 |
cap[capstr->cs_ndx].c_un.c_ptr = stoff; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3354 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3355 |
for (ALIST_TRAVERSE(ocapset->oc_plat.cl_val, idx2, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3356 |
capstr)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3357 |
(void) st_setstring(strtbl, capstr->cs_str, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3358 |
&stoff); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3359 |
cap[capstr->cs_ndx].c_un.c_ptr = stoff; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3360 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3361 |
for (ALIST_TRAVERSE(ocapset->oc_mach.cl_val, idx2, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3362 |
capstr)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3363 |
(void) st_setstring(strtbl, capstr->cs_str, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3364 |
&stoff); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3365 |
cap[capstr->cs_ndx].c_un.c_ptr = stoff; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3366 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3367 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3368 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3369 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3370 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3371 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3372 |
* Update the .SUNW_capinfo, and possibly the .SUNW_capchain sections. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3373 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3374 |
static void |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3375 |
update_oscapinfo(Ofl_desc *ofl) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3376 |
{ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3377 |
Os_desc *symosp, *ciosp, *ccosp = NULL; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3378 |
Capinfo *ocapinfo; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3379 |
Capchain *ocapchain; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3380 |
Cap_avlnode *cav; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3381 |
Word chainndx = 0; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3382 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3383 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3384 |
* Determine which symbol table is appropriate. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3385 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3386 |
if (OFL_IS_STATIC_OBJ(ofl)) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3387 |
symosp = ofl->ofl_ossymtab; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3388 |
else |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3389 |
symosp = ofl->ofl_osdynsym; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3390 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3391 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3392 |
* Update the .SUNW_capinfo sh_link to point to the appropriate symbol |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3393 |
* table section. If we're creating a dynamic object, the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3394 |
* .SUNW_capinfo sh_info is updated to point to the .SUNW_capchain |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3395 |
* section. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3396 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3397 |
ciosp = ofl->ofl_oscapinfo; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3398 |
ciosp->os_shdr->sh_link = (Word)elf_ndxscn(symosp->os_scn); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3399 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3400 |
if (OFL_IS_STATIC_OBJ(ofl) == 0) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3401 |
ccosp = ofl->ofl_oscapchain; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3402 |
ciosp->os_shdr->sh_info = (Word)elf_ndxscn(ccosp->os_scn); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3403 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3404 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3405 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3406 |
* Establish the data for each section. The first element of each |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3407 |
* section defines the section's version number. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3408 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3409 |
ocapinfo = ciosp->os_outdata->d_buf; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3410 |
ocapinfo[0] = CAPINFO_CURRENT; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3411 |
if (ccosp) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3412 |
ocapchain = ccosp->os_outdata->d_buf; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3413 |
ocapchain[chainndx++] = CAPCHAIN_CURRENT; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3414 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3415 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3416 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3417 |
* Traverse all capabilities families. Each member has a .SUNW_capinfo |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3418 |
* assignment. The .SUNW_capinfo entry differs for relocatable objects |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3419 |
* and dynamic objects. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3420 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3421 |
* Relocatable objects: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3422 |
* ELF_C_GROUP ELF_C_SYM |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3423 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3424 |
* Family lead: CAPINFO_SUNW_GLOB lead symbol index |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3425 |
* Family lead alias: CAPINFO_SUNW_GLOB lead symbol index |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3426 |
* Family member: .SUNW_cap index lead symbol index |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3427 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3428 |
* Dynamic objects: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3429 |
* ELF_C_GROUP ELF_C_SYM |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3430 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3431 |
* Family lead: CAPINFO_SUNW_GLOB .SUNW_capchain index |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3432 |
* Family lead alias: CAPINFO_SUNW_GLOB .SUNW_capchain index |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3433 |
* Family member: .SUNW_cap index lead symbol index |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3434 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3435 |
* The ELF_C_GROUP field identifies a capabilities symbol. Lead |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3436 |
* capability symbols, and lead capability aliases are identified by |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3437 |
* a CAPINFO_SUNW_GLOB group identifier. For family members, the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3438 |
* ELF_C_GROUP provides an index to the associate capabilities group |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3439 |
* (i.e, an index into the SUNW_cap section that defines a group). |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3440 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3441 |
* For relocatable objects, the ELF_C_SYM field identifies the lead |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3442 |
* capability symbol. For the lead symbol itself, the .SUNW_capinfo |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3443 |
* index is the same as the ELF_C_SYM value. For lead alias symbols, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3444 |
* the .SUNW_capinfo index differs from the ELF_C_SYM value. This |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3445 |
* differentiation of CAPINFO_SUNW_GLOB symbols allows ld(1) to |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3446 |
* identify, and propagate lead alias symbols. For example, the lead |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3447 |
* capability symbol memcpy() would have the ELF_C_SYM for memcpy(), |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3448 |
* and the lead alias _memcpy() would also have the ELF_C_SYM for |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3449 |
* memcpy(). |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3450 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3451 |
* For dynamic objects, both a lead capability symbol, and alias symbol |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3452 |
* would have a ELF_C_SYM value that represents the same capability |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3453 |
* chain index. The capability chain allows ld.so.1 to traverse a |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3454 |
* family chain for a given lead symbol, and select the most appropriate |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3455 |
* family member. The .SUNW_capchain array contains a series of symbol |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3456 |
* indexes for each family member: |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3457 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3458 |
* chaincap[n] chaincap[n + 1] chaincap[n + 2] chaincap[n + x] |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3459 |
* foo() ndx foo%x() ndx foo%y() ndx 0 |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3460 |
* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3461 |
* For family members, the ELF_C_SYM value associates the capability |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3462 |
* members with their family lead symbol. This association, although |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3463 |
* unused within a dynamic object, allows ld(1) to identify, and |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3464 |
* propagate family members when processing relocatable objects. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3465 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3466 |
for (cav = avl_first(ofl->ofl_capfamilies); cav; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3467 |
cav = AVL_NEXT(ofl->ofl_capfamilies, cav)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3468 |
Cap_sym *csp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3469 |
Aliste idx; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3470 |
Sym_desc *asdp, *lsdp = cav->cn_symavlnode.sav_sdp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3471 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3472 |
if (ccosp) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3473 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3474 |
* For a dynamic object, identify this lead symbol, and |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3475 |
* point it to the head of a capability chain. Set the |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3476 |
* head of the capability chain to the same lead symbol. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3477 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3478 |
ocapinfo[lsdp->sd_symndx] = |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3479 |
ELF_C_INFO(chainndx, CAPINFO_SUNW_GLOB); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3480 |
ocapchain[chainndx] = lsdp->sd_symndx; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3481 |
} else { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3482 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3483 |
* For a relocatable object, identify this lead symbol, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3484 |
* and set the lead symbol index to itself. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3485 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3486 |
ocapinfo[lsdp->sd_symndx] = |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3487 |
ELF_C_INFO(lsdp->sd_symndx, CAPINFO_SUNW_GLOB); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3488 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3489 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3490 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3491 |
* Gather any lead symbol aliases. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3492 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3493 |
for (APLIST_TRAVERSE(cav->cn_aliases, idx, asdp)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3494 |
if (ccosp) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3495 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3496 |
* For a dynamic object, identify this lead |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3497 |
* alias symbol, and point it to the same |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3498 |
* capability chain index as the lead symbol. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3499 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3500 |
ocapinfo[asdp->sd_symndx] = |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3501 |
ELF_C_INFO(chainndx, CAPINFO_SUNW_GLOB); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3502 |
} else { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3503 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3504 |
* For a relocatable object, identify this lead |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3505 |
* alias symbol, and set the lead symbol index |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3506 |
* to the lead symbol. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3507 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3508 |
ocapinfo[asdp->sd_symndx] = |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3509 |
ELF_C_INFO(lsdp->sd_symndx, |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3510 |
CAPINFO_SUNW_GLOB); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3511 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3512 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3513 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3514 |
chainndx++; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3515 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3516 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3517 |
* Gather the family members. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3518 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3519 |
for (APLIST_TRAVERSE(cav->cn_members, idx, csp)) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3520 |
Sym_desc *msdp = csp->cs_sdp; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3521 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3522 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3523 |
* Identify the members capability group, and the lead |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3524 |
* symbol of the family this symbol is a member of. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3525 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3526 |
ocapinfo[msdp->sd_symndx] = |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3527 |
ELF_C_INFO(lsdp->sd_symndx, csp->cs_group->cg_ndx); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3528 |
if (ccosp) { |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3529 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3530 |
* For a dynamic object, set the next capability |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3531 |
* chain to point to this family member. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3532 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3533 |
ocapchain[chainndx++] = msdp->sd_symndx; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3534 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3535 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3536 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3537 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3538 |
* Any chain of family members is terminated with a 0 element. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3539 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3540 |
if (ccosp) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3541 |
ocapchain[chainndx++] = 0; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3542 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3543 |
} |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3544 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3545 |
/* |
0 | 3546 |
* Translate the shdr->sh_{link, info} from its input section value to that |
3547 |
* of the corresponding shdr->sh_{link, info} output section value. |
|
3548 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3549 |
static Word |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3550 |
translate_link(Ofl_desc *ofl, Os_desc *osp, Word link, const char *msg) |
0 | 3551 |
{ |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3552 |
Is_desc *isp; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3553 |
Ifl_desc *ifl; |
0 | 3554 |
|
3555 |
/* |
|
3556 |
* Don't translate the special section numbers. |
|
3557 |
*/ |
|
3558 |
if (link >= SHN_LORESERVE) |
|
3559 |
return (link); |
|
3560 |
||
3561 |
/* |
|
3562 |
* Does this output section translate back to an input file. If not |
|
3563 |
* then there is no translation to do. In this case we will assume that |
|
3564 |
* if sh_link has a value, it's the right value. |
|
3565 |
*/ |
|
9615
56391369c440
6837777 ld ordered section code uses too much memory and works too hard
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9313
diff
changeset
|
3566 |
isp = ld_os_first_isdesc(osp); |
0 | 3567 |
if ((ifl = isp->is_file) == NULL) |
3568 |
return (link); |
|
3569 |
||
3570 |
/* |
|
3571 |
* Sanity check to make sure that the sh_{link, info} value |
|
3572 |
* is within range for the input file. |
|
3573 |
*/ |
|
3574 |
if (link >= ifl->ifl_shnum) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3575 |
eprintf(ofl->ofl_lml, ERR_WARNING, msg, ifl->ifl_name, |
9878
ffd737a1c183
6849998 remove undocumented mapfile $SPECVERS and $NEED options
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
9615
diff
changeset
|
3576 |
EC_WORD(isp->is_scnndx), isp->is_name, EC_XWORD(link)); |
0 | 3577 |
return (link); |
3578 |
} |
|
3579 |
||
3580 |
/* |
|
3581 |
* Follow the link to the input section. |
|
3582 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3583 |
if ((isp = ifl->ifl_isdesc[link]) == NULL) |
0 | 3584 |
return (0); |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3585 |
if ((osp = isp->is_osdesc) == NULL) |
0 | 3586 |
return (0); |
3587 |
||
3588 |
/* LINTED */ |
|
3589 |
return ((Word)elf_ndxscn(osp->os_scn)); |
|
3590 |
} |
|
3591 |
||
3592 |
/* |
|
3593 |
* Having created all of the necessary sections, segments, and associated |
|
3594 |
* headers, fill in the program headers and update any other data in the |
|
3595 |
* output image. Some general rules: |
|
3596 |
* |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3597 |
* - If an interpreter is required always generate a PT_PHDR entry as |
0 | 3598 |
* well. It is this entry that triggers the kernel into passing the |
2648
6c17d29a3f67
6465623 need a way of building unix without an interpreter
rie
parents:
2347
diff
changeset
|
3599 |
* interpreter an aux vector instead of just a file descriptor. |
0 | 3600 |
* |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3601 |
* - When generating an image that will be interpreted (ie. a dynamic |
0 | 3602 |
* executable, a shared object, or a static executable that has been |
2648
6c17d29a3f67
6465623 need a way of building unix without an interpreter
rie
parents:
2347
diff
changeset
|
3603 |
* provided with an interpreter - weird, but possible), make the initial |
0 | 3604 |
* loadable segment include both the ehdr and phdr[]. Both of these |
2648
6c17d29a3f67
6465623 need a way of building unix without an interpreter
rie
parents:
2347
diff
changeset
|
3605 |
* tables are used by the interpreter therefore it seems more intuitive |
0 | 3606 |
* to explicitly defined them as part of the mapped image rather than |
2648
6c17d29a3f67
6465623 need a way of building unix without an interpreter
rie
parents:
2347
diff
changeset
|
3607 |
* relying on page rounding by the interpreter to allow their access. |
0 | 3608 |
* |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3609 |
* - When generating a static image that does not require an interpreter |
0 | 3610 |
* have the first loadable segment indicate the address of the first |
3611 |
* .section as the start address (things like /kernel/unix and ufsboot |
|
3612 |
* expect this behavior). |
|
3613 |
*/ |
|
3614 |
uintptr_t |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3615 |
ld_update_outfile(Ofl_desc *ofl) |
0 | 3616 |
{ |
8501
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3617 |
Addr size, etext, vaddr; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3618 |
Sg_desc *sgp; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3619 |
Sg_desc *dtracesgp = NULL, *capsgp = NULL, *intpsgp = NULL; |
5892
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
3620 |
Os_desc *osp; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3621 |
int phdrndx = 0, segndx = -1, secndx, intppndx, intpsndx; |
4284 | 3622 |
int dtracepndx, dtracesndx, cappndx, capsndx; |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3623 |
Ehdr *ehdr = ofl->ofl_nehdr; |
0 | 3624 |
Shdr *hshdr; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3625 |
Phdr *_phdr = NULL; |
4284 | 3626 |
Word phdrsz = (ehdr->e_phnum * ehdr->e_phentsize), shscnndx; |
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
3627 |
ofl_flag_t flags = ofl->ofl_flags; |
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
3628 |
Word ehdrsz = ehdr->e_ehsize; |
0 | 3629 |
Boolean nobits; |
3630 |
Off offset; |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3631 |
Aliste idx1; |
0 | 3632 |
|
3633 |
/* |
|
8501
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3634 |
* Initialize the starting address for the first segment. Executables |
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3635 |
* have different starting addresses depending upon the target ABI, |
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3636 |
* where as shared objects have a starting address of 0. If this is |
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3637 |
* a 64-bit executable that is being constructed to run in a restricted |
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3638 |
* address space, use an alternative origin that will provide more free |
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3639 |
* address space for the the eventual process. |
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3640 |
*/ |
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3641 |
if (ofl->ofl_flags & FLG_OF_EXEC) { |
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3642 |
#if defined(_ELF64) |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3643 |
if (ofl->ofl_ocapset.oc_sf_1.cm_val & SF1_SUNW_ADDR32) |
8501
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3644 |
vaddr = ld_targ.t_m.m_segm_aorigin; |
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3645 |
else |
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3646 |
#endif |
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3647 |
vaddr = ld_targ.t_m.m_segm_origin; |
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3648 |
} else |
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3649 |
vaddr = 0; |
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3650 |
|
e544a13d2b41
6789925 64-bit applications with SF1_SUNW_ADDR32 require non-default starting address
Rod Evans <Rod.Evans@Sun.COM>
parents:
8369
diff
changeset
|
3651 |
/* |
0 | 3652 |
* Loop through the segment descriptors and pick out what we need. |
3653 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3654 |
DBG_CALL(Dbg_seg_title(ofl->ofl_lml)); |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3655 |
for (APLIST_TRAVERSE(ofl->ofl_segs, idx1, sgp)) { |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3656 |
Phdr *phdr = &(sgp->sg_phdr); |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3657 |
Xword p_align; |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3658 |
Aliste idx2; |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3659 |
Sym_desc *sdp; |
0 | 3660 |
|
3661 |
segndx++; |
|
3662 |
||
3663 |
/* |
|
3664 |
* If an interpreter is required generate a PT_INTERP and |
|
3665 |
* PT_PHDR program header entry. The PT_PHDR entry describes |
|
3666 |
* the program header table itself. This information will be |
|
3667 |
* passed via the aux vector to the interpreter (ld.so.1). |
|
3668 |
* The program header array is actually part of the first |
|
3669 |
* loadable segment (and the PT_PHDR entry is the first entry), |
|
3670 |
* therefore its virtual address isn't known until the first |
|
3671 |
* loadable segment is processed. |
|
3672 |
*/ |
|
3673 |
if (phdr->p_type == PT_PHDR) { |
|
3674 |
if (ofl->ofl_osinterp) { |
|
3675 |
phdr->p_offset = ehdr->e_phoff; |
|
3676 |
phdr->p_filesz = phdr->p_memsz = phdrsz; |
|
4284 | 3677 |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3678 |
DBG_CALL(Dbg_seg_entry(ofl, segndx, sgp)); |
0 | 3679 |
ofl->ofl_phdr[phdrndx++] = *phdr; |
3680 |
} |
|
3681 |
continue; |
|
3682 |
} |
|
3683 |
if (phdr->p_type == PT_INTERP) { |
|
3684 |
if (ofl->ofl_osinterp) { |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3685 |
intpsgp = sgp; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3686 |
intpsndx = segndx; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3687 |
intppndx = phdrndx++; |
0 | 3688 |
} |
3689 |
continue; |
|
3690 |
} |
|
3691 |
||
3692 |
/* |
|
4284 | 3693 |
* If we are creating a PT_SUNWDTRACE segment, remember where |
3694 |
* the program header is. The header values are assigned after |
|
3695 |
* update_osym() has completed and the symbol table addresses |
|
10167
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
3696 |
* have been updated. |
0 | 3697 |
*/ |
3698 |
if (phdr->p_type == PT_SUNWDTRACE) { |
|
10167
4c8fee5f1d6a
6862967 rd_loadobj_iter() failing for core files
Rod Evans <Rod.Evans@Sun.COM>
parents:
9878
diff
changeset
|
3699 |
if (ofl->ofl_dtracesym && |
0 | 3700 |
((flags & FLG_OF_RELOBJ) == 0)) { |
4284 | 3701 |
dtracesgp = sgp; |
3702 |
dtracesndx = segndx; |
|
3703 |
dtracepndx = phdrndx++; |
|
0 | 3704 |
} |
3705 |
continue; |
|
3706 |
} |
|
3707 |
||
3708 |
/* |
|
3709 |
* If a hardware/software capabilities section is required, |
|
3710 |
* generate the PT_SUNWCAP header. Note, as this comes before |
|
3711 |
* the first loadable segment, we don't yet know its real |
|
3712 |
* virtual address. This is updated later. |
|
3713 |
*/ |
|
3714 |
if (phdr->p_type == PT_SUNWCAP) { |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3715 |
if (ofl->ofl_oscap && (ofl->ofl_flags & FLG_OF_PTCAP) && |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3716 |
((flags & FLG_OF_RELOBJ) == 0)) { |
4284 | 3717 |
capsgp = sgp; |
3718 |
capsndx = segndx; |
|
3719 |
cappndx = phdrndx++; |
|
0 | 3720 |
} |
3721 |
continue; |
|
3722 |
} |
|
3723 |
||
3724 |
/* |
|
3725 |
* As the dynamic program header occurs after the loadable |
|
3726 |
* headers in the segment descriptor table, all the address |
|
3727 |
* information for the .dynamic output section will have been |
|
3728 |
* figured out by now. |
|
3729 |
*/ |
|
3730 |
if (phdr->p_type == PT_DYNAMIC) { |
|
2766
897bcb036a29
PSARC 2006/526 SHT_SUNW_LDYNSYM - default local symbol addition
ab196087
parents:
2648
diff
changeset
|
3731 |
if (OFL_ALLOW_DYNSYM(ofl)) { |
4284 | 3732 |
Shdr *shdr = ofl->ofl_osdynamic->os_shdr; |
0 | 3733 |
|
3734 |
phdr->p_vaddr = shdr->sh_addr; |
|
3735 |
phdr->p_offset = shdr->sh_offset; |
|
3736 |
phdr->p_filesz = shdr->sh_size; |
|
6206 | 3737 |
phdr->p_flags = ld_targ.t_m.m_dataseg_perm; |
4284 | 3738 |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3739 |
DBG_CALL(Dbg_seg_entry(ofl, segndx, sgp)); |
0 | 3740 |
ofl->ofl_phdr[phdrndx++] = *phdr; |
3741 |
} |
|
3742 |
continue; |
|
3743 |
} |
|
4284 | 3744 |
|
3745 |
/* |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8747
diff
changeset
|
3746 |
* As the unwind (.eh_frame_hdr) program header occurs after |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8747
diff
changeset
|
3747 |
* the loadable headers in the segment descriptor table, all |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8747
diff
changeset
|
3748 |
* the address information for the .eh_frame output section |
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8747
diff
changeset
|
3749 |
* will have been figured out by now. |
4284 | 3750 |
*/ |
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8747
diff
changeset
|
3751 |
if (phdr->p_type == PT_SUNW_UNWIND) { |
0 | 3752 |
Shdr *shdr; |
4284 | 3753 |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8747
diff
changeset
|
3754 |
if (ofl->ofl_unwindhdr == NULL) |
0 | 3755 |
continue; |
4284 | 3756 |
|
0 | 3757 |
shdr = ofl->ofl_unwindhdr->os_shdr; |
3758 |
||
3759 |
phdr->p_flags = PF_R; |
|
3760 |
phdr->p_vaddr = shdr->sh_addr; |
|
3761 |
phdr->p_memsz = shdr->sh_size; |
|
3762 |
phdr->p_filesz = shdr->sh_size; |
|
3763 |
phdr->p_offset = shdr->sh_offset; |
|
3764 |
phdr->p_align = shdr->sh_addralign; |
|
3765 |
phdr->p_paddr = 0; |
|
3766 |
ofl->ofl_phdr[phdrndx++] = *phdr; |
|
3767 |
continue; |
|
3768 |
} |
|
9085
ff7eb0bace56
6813909 generalize eh_frame support to non-amd64 platforms
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8747
diff
changeset
|
3769 |
|
4284 | 3770 |
/* |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3771 |
* The sunwstack program is used to convey non-default |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3772 |
* flags for the process stack. Only emit it if it would |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3773 |
* change the default. |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3774 |
*/ |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3775 |
if (phdr->p_type == PT_SUNWSTACK) { |
11828
90325c8c5951
6916788 ld version 2 mapfile syntax (fix relobj)
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
3776 |
if (((flags & FLG_OF_RELOBJ) == 0) && |
90325c8c5951
6916788 ld version 2 mapfile syntax (fix relobj)
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11827
diff
changeset
|
3777 |
((sgp->sg_flags & FLG_SG_DISABLED) == 0)) |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3778 |
ofl->ofl_phdr[phdrndx++] = *phdr; |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3779 |
continue; |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3780 |
} |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3781 |
|
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3782 |
/* |
4284 | 3783 |
* As the TLS program header occurs after the loadable |
3784 |
* headers in the segment descriptor table, all the address |
|
3785 |
* information for the .tls output section will have been |
|
3786 |
* figured out by now. |
|
3787 |
*/ |
|
0 | 3788 |
if (phdr->p_type == PT_TLS) { |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3789 |
Os_desc *tlsosp; |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3790 |
Shdr *lastfileshdr = NULL; |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3791 |
Shdr *firstshdr = NULL, *lastshdr; |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3792 |
Aliste idx; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3793 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3794 |
if (ofl->ofl_ostlsseg == NULL) |
0 | 3795 |
continue; |
542 | 3796 |
|
4234
9d2660d116eb
6551627 OGL: SIGSEGV when trying to use OpenGL pipeline with splash screen, Solaris/Nvidia only
rie
parents:
3850
diff
changeset
|
3797 |
/* |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3798 |
* Scan the output sections that have contributed TLS. |
4234
9d2660d116eb
6551627 OGL: SIGSEGV when trying to use OpenGL pipeline with splash screen, Solaris/Nvidia only
rie
parents:
3850
diff
changeset
|
3799 |
* Remember the first and last so as to determine the |
9d2660d116eb
6551627 OGL: SIGSEGV when trying to use OpenGL pipeline with splash screen, Solaris/Nvidia only
rie
parents:
3850
diff
changeset
|
3800 |
* TLS memory size requirement. Remember the last |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3801 |
* progbits section to determine the TLS data |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3802 |
* contribution, which determines the TLS program |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3803 |
* header filesz. |
4234
9d2660d116eb
6551627 OGL: SIGSEGV when trying to use OpenGL pipeline with splash screen, Solaris/Nvidia only
rie
parents:
3850
diff
changeset
|
3804 |
*/ |
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3805 |
for (APLIST_TRAVERSE(ofl->ofl_ostlsseg, idx, tlsosp)) { |
542 | 3806 |
Shdr *tlsshdr = tlsosp->os_shdr; |
3807 |
||
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3808 |
if (firstshdr == NULL) |
4234
9d2660d116eb
6551627 OGL: SIGSEGV when trying to use OpenGL pipeline with splash screen, Solaris/Nvidia only
rie
parents:
3850
diff
changeset
|
3809 |
firstshdr = tlsshdr; |
9d2660d116eb
6551627 OGL: SIGSEGV when trying to use OpenGL pipeline with splash screen, Solaris/Nvidia only
rie
parents:
3850
diff
changeset
|
3810 |
if (tlsshdr->sh_type != SHT_NOBITS) |
9d2660d116eb
6551627 OGL: SIGSEGV when trying to use OpenGL pipeline with splash screen, Solaris/Nvidia only
rie
parents:
3850
diff
changeset
|
3811 |
lastfileshdr = tlsshdr; |
9d2660d116eb
6551627 OGL: SIGSEGV when trying to use OpenGL pipeline with splash screen, Solaris/Nvidia only
rie
parents:
3850
diff
changeset
|
3812 |
lastshdr = tlsshdr; |
542 | 3813 |
} |
3814 |
||
0 | 3815 |
phdr->p_flags = PF_R | PF_W; |
3816 |
phdr->p_vaddr = firstshdr->sh_addr; |
|
3817 |
phdr->p_offset = firstshdr->sh_offset; |
|
542 | 3818 |
phdr->p_align = firstshdr->sh_addralign; |
4234
9d2660d116eb
6551627 OGL: SIGSEGV when trying to use OpenGL pipeline with splash screen, Solaris/Nvidia only
rie
parents:
3850
diff
changeset
|
3819 |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3820 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3821 |
* Determine the initialized TLS data size. This |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3822 |
* address range is from the start of the TLS segment |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3823 |
* to the end of the last piece of initialized data. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3824 |
*/ |
4234
9d2660d116eb
6551627 OGL: SIGSEGV when trying to use OpenGL pipeline with splash screen, Solaris/Nvidia only
rie
parents:
3850
diff
changeset
|
3825 |
if (lastfileshdr) |
9d2660d116eb
6551627 OGL: SIGSEGV when trying to use OpenGL pipeline with splash screen, Solaris/Nvidia only
rie
parents:
3850
diff
changeset
|
3826 |
phdr->p_filesz = lastfileshdr->sh_offset + |
9d2660d116eb
6551627 OGL: SIGSEGV when trying to use OpenGL pipeline with splash screen, Solaris/Nvidia only
rie
parents:
3850
diff
changeset
|
3827 |
lastfileshdr->sh_size - phdr->p_offset; |
9d2660d116eb
6551627 OGL: SIGSEGV when trying to use OpenGL pipeline with splash screen, Solaris/Nvidia only
rie
parents:
3850
diff
changeset
|
3828 |
else |
9d2660d116eb
6551627 OGL: SIGSEGV when trying to use OpenGL pipeline with splash screen, Solaris/Nvidia only
rie
parents:
3850
diff
changeset
|
3829 |
phdr->p_filesz = 0; |
9d2660d116eb
6551627 OGL: SIGSEGV when trying to use OpenGL pipeline with splash screen, Solaris/Nvidia only
rie
parents:
3850
diff
changeset
|
3830 |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3831 |
/* |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3832 |
* Determine the total TLS memory size. This includes |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3833 |
* all TLS data and TLS uninitialized data. This |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3834 |
* address range is from the start of the TLS segment |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3835 |
* to the memory address of the last piece of |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3836 |
* uninitialized data. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3837 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3838 |
phdr->p_memsz = lastshdr->sh_addr + |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3839 |
lastshdr->sh_size - phdr->p_vaddr; |
542 | 3840 |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3841 |
DBG_CALL(Dbg_seg_entry(ofl, segndx, sgp)); |
4284 | 3842 |
ofl->ofl_phdr[phdrndx] = *phdr; |
3843 |
ofl->ofl_tlsphdr = &ofl->ofl_phdr[phdrndx++]; |
|
0 | 3844 |
continue; |
3845 |
} |
|
3846 |
||
3847 |
/* |
|
3848 |
* If this is an empty segment declaration, it will occur after |
|
4284 | 3849 |
* all other loadable segments. As empty segments can be |
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
3850 |
* defined with fixed addresses, make sure that no loadable |
4284 | 3851 |
* segments overlap. This might occur as the object evolves |
3852 |
* and the loadable segments grow, thus encroaching upon an |
|
3853 |
* existing segment reservation. |
|
3854 |
* |
|
3855 |
* Segments are only created for dynamic objects, thus this |
|
3856 |
* checking can be skipped when building a relocatable object. |
|
0 | 3857 |
*/ |
6299
35d40fdc268c
6678244 elfdump dymamic section sanity checking needs refinement
ab196087
parents:
6206
diff
changeset
|
3858 |
if (!(flags & FLG_OF_RELOBJ) && |
0 | 3859 |
(sgp->sg_flags & FLG_SG_EMPTY)) { |
4284 | 3860 |
int i; |
0 | 3861 |
Addr v_e; |
3862 |
||
3863 |
vaddr = phdr->p_vaddr; |
|
3864 |
phdr->p_memsz = sgp->sg_length; |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3865 |
DBG_CALL(Dbg_seg_entry(ofl, segndx, sgp)); |
0 | 3866 |
ofl->ofl_phdr[phdrndx++] = *phdr; |
3867 |
||
3868 |
if (phdr->p_type != PT_LOAD) |
|
3869 |
continue; |
|
3870 |
||
3871 |
v_e = vaddr + phdr->p_memsz; |
|
4284 | 3872 |
|
0 | 3873 |
/* |
3874 |
* Check overlaps |
|
3875 |
*/ |
|
3876 |
for (i = 0; i < phdrndx - 1; i++) { |
|
3877 |
Addr p_s = (ofl->ofl_phdr[i]).p_vaddr; |
|
3878 |
Addr p_e; |
|
3879 |
||
3880 |
if ((ofl->ofl_phdr[i]).p_type != PT_LOAD) |
|
3881 |
continue; |
|
3882 |
||
3883 |
p_e = p_s + (ofl->ofl_phdr[i]).p_memsz; |
|
3884 |
if (((p_s <= vaddr) && (p_e > vaddr)) || |
|
3885 |
((vaddr <= p_s) && (v_e > p_s))) |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3886 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
0 | 3887 |
MSG_INTL(MSG_UPD_SEGOVERLAP), |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3888 |
ofl->ofl_name, EC_ADDR(p_e), |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3889 |
sgp->sg_name, EC_ADDR(vaddr)); |
0 | 3890 |
} |
3891 |
continue; |
|
3892 |
} |
|
3893 |
||
3894 |
/* |
|
3895 |
* Having processed any of the special program headers any |
|
3896 |
* remaining headers will be built to express individual |
|
3897 |
* segments. Segments are only built if they have output |
|
3898 |
* section descriptors associated with them (ie. some form of |
|
3899 |
* input section has been matched to this segment). |
|
3900 |
*/ |
|
1682 | 3901 |
if (sgp->sg_osdescs == NULL) |
0 | 3902 |
continue; |
3903 |
||
3904 |
/* |
|
3905 |
* Determine the segments offset and size from the section |
|
3906 |
* information provided from elf_update(). |
|
3907 |
* Allow for multiple NOBITS sections. |
|
3908 |
*/ |
|
5892
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
3909 |
osp = sgp->sg_osdescs->apl_data[0]; |
574 | 3910 |
hshdr = osp->os_shdr; |
0 | 3911 |
|
3912 |
phdr->p_filesz = 0; |
|
3913 |
phdr->p_memsz = 0; |
|
3914 |
phdr->p_offset = offset = hshdr->sh_offset; |
|
1682 | 3915 |
|
574 | 3916 |
nobits = ((hshdr->sh_type == SHT_NOBITS) && |
1682 | 3917 |
((sgp->sg_flags & FLG_SG_PHREQ) == 0)); |
3918 |
||
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3919 |
for (APLIST_TRAVERSE(sgp->sg_osdescs, idx2, osp)) { |
5892
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
3920 |
Shdr *shdr = osp->os_shdr; |
0 | 3921 |
|
3922 |
p_align = 0; |
|
3923 |
if (shdr->sh_addralign > p_align) |
|
3924 |
p_align = shdr->sh_addralign; |
|
1682 | 3925 |
|
0 | 3926 |
offset = (Off)S_ROUND(offset, shdr->sh_addralign); |
3927 |
offset += shdr->sh_size; |
|
1682 | 3928 |
|
0 | 3929 |
if (shdr->sh_type != SHT_NOBITS) { |
3930 |
if (nobits) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3931 |
eprintf(ofl->ofl_lml, ERR_FATAL, |
0 | 3932 |
MSG_INTL(MSG_UPD_NOBITS)); |
3933 |
return (S_ERROR); |
|
3934 |
} |
|
3935 |
phdr->p_filesz = offset - phdr->p_offset; |
|
574 | 3936 |
} else if ((sgp->sg_flags & FLG_SG_PHREQ) == 0) |
0 | 3937 |
nobits = TRUE; |
3938 |
} |
|
3939 |
phdr->p_memsz = offset - hshdr->sh_offset; |
|
3940 |
||
3941 |
/* |
|
3942 |
* If this is the first loadable segment of a dynamic object, |
|
2648
6c17d29a3f67
6465623 need a way of building unix without an interpreter
rie
parents:
2347
diff
changeset
|
3943 |
* or an interpreter has been specified (a static object built |
6c17d29a3f67
6465623 need a way of building unix without an interpreter
rie
parents:
2347
diff
changeset
|
3944 |
* with an interpreter will still be given a PT_HDR entry), then |
0 | 3945 |
* compensate for the elf header and program header array. Both |
3946 |
* of these are actually part of the loadable segment as they |
|
2648
6c17d29a3f67
6465623 need a way of building unix without an interpreter
rie
parents:
2347
diff
changeset
|
3947 |
* may be inspected by the interpreter. Adjust the segments |
0 | 3948 |
* size and offset accordingly. |
3949 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
3950 |
if ((_phdr == NULL) && (phdr->p_type == PT_LOAD) && |
0 | 3951 |
((ofl->ofl_osinterp) || (flags & FLG_OF_DYNAMIC)) && |
1698 | 3952 |
(!(ofl->ofl_dtflags_1 & DF_1_NOHDR))) { |
0 | 3953 |
size = (Addr)S_ROUND((phdrsz + ehdrsz), |
3954 |
hshdr->sh_addralign); |
|
3955 |
phdr->p_offset -= size; |
|
3956 |
phdr->p_filesz += size; |
|
3957 |
phdr->p_memsz += size; |
|
3958 |
} |
|
3959 |
||
3960 |
/* |
|
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3961 |
* If segment size symbols are required (specified via a |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3962 |
* mapfile) update their value. |
0 | 3963 |
*/ |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3964 |
for (APLIST_TRAVERSE(sgp->sg_sizesym, idx2, sdp)) |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3965 |
sdp->sd_sym->st_value = phdr->p_memsz; |
0 | 3966 |
|
3967 |
/* |
|
3968 |
* If no file content has been assigned to this segment (it |
|
3969 |
* only contains no-bits sections), then reset the offset for |
|
3970 |
* consistency. |
|
3971 |
*/ |
|
3972 |
if (phdr->p_filesz == 0) |
|
3973 |
phdr->p_offset = 0; |
|
3974 |
||
3975 |
/* |
|
3976 |
* If a virtual address has been specified for this segment |
|
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3977 |
* from a mapfile use it and make sure the previous segment |
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3978 |
* does not run into this segment. |
0 | 3979 |
*/ |
8159
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
3980 |
if (phdr->p_type == PT_LOAD) { |
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
3981 |
if ((sgp->sg_flags & FLG_SG_P_VADDR)) { |
0 | 3982 |
if (_phdr && (vaddr > phdr->p_vaddr) && |
3983 |
(phdr->p_type == PT_LOAD)) |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
3984 |
eprintf(ofl->ofl_lml, ERR_WARNING, |
0 | 3985 |
MSG_INTL(MSG_UPD_SEGOVERLAP), |
3986 |
ofl->ofl_name, EC_ADDR(vaddr), |
|
3987 |
sgp->sg_name, |
|
3988 |
EC_ADDR(phdr->p_vaddr)); |
|
3989 |
vaddr = phdr->p_vaddr; |
|
3990 |
phdr->p_align = 0; |
|
3991 |
} else { |
|
3992 |
vaddr = phdr->p_vaddr = |
|
3993 |
(Addr)S_ROUND(vaddr, phdr->p_align); |
|
3994 |
} |
|
3995 |
} |
|
3996 |
||
3997 |
/* |
|
3998 |
* Adjust the address offset and p_align if needed. |
|
3999 |
*/ |
|
11734
d29dc9c2b6c5
6916788 ld version 2 mapfile syntax
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
11227
diff
changeset
|
4000 |
if (((sgp->sg_flags & FLG_SG_P_VADDR) == 0) && |
2978
a77a2fdc9d9e
PSARC 2006/595 link-editor support library interface - ld_open()
rie
parents:
2766
diff
changeset
|
4001 |
((ofl->ofl_dtflags_1 & DF_1_NOHDR) == 0)) { |
0 | 4002 |
if (phdr->p_align != 0) |
4003 |
vaddr += phdr->p_offset % phdr->p_align; |
|
4004 |
else |
|
4005 |
vaddr += phdr->p_offset; |
|
4006 |
phdr->p_vaddr = vaddr; |
|
4007 |
} |
|
4008 |
||
4009 |
/* |
|
4010 |
* If an interpreter is required set the virtual address of the |
|
4011 |
* PT_PHDR program header now that we know the virtual address |
|
4012 |
* of the loadable segment that contains it. Update the |
|
4013 |
* PT_SUNWCAP header similarly. |
|
4014 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4015 |
if ((_phdr == NULL) && (phdr->p_type == PT_LOAD)) { |
0 | 4016 |
_phdr = phdr; |
4017 |
||
4284 | 4018 |
if ((ofl->ofl_dtflags_1 & DF_1_NOHDR) == 0) { |
0 | 4019 |
if (ofl->ofl_osinterp) |
4020 |
ofl->ofl_phdr[0].p_vaddr = |
|
4021 |
vaddr + ehdrsz; |
|
4022 |
||
4023 |
/* |
|
4024 |
* Finally, if we're creating a dynamic object |
|
2648
6c17d29a3f67
6465623 need a way of building unix without an interpreter
rie
parents:
2347
diff
changeset
|
4025 |
* (or a static object in which an interpreter |
0 | 4026 |
* is specified) update the vaddr to reflect |
4027 |
* the address of the first section within this |
|
4028 |
* segment. |
|
4029 |
*/ |
|
4030 |
if ((ofl->ofl_osinterp) || |
|
4031 |
(flags & FLG_OF_DYNAMIC)) |
|
4032 |
vaddr += size; |
|
4033 |
} else { |
|
4034 |
/* |
|
4284 | 4035 |
* If the DF_1_NOHDR flag was set, and an |
4036 |
* interpreter is being generated, the PT_PHDR |
|
0 | 4037 |
* will not be part of any loadable segment. |
4038 |
*/ |
|
4284 | 4039 |
if (ofl->ofl_osinterp) { |
4040 |
ofl->ofl_phdr[0].p_vaddr = 0; |
|
4041 |
ofl->ofl_phdr[0].p_memsz = 0; |
|
4042 |
ofl->ofl_phdr[0].p_flags = 0; |
|
4043 |
} |
|
0 | 4044 |
} |
4045 |
} |
|
4046 |
||
4047 |
/* |
|
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
4048 |
* Ensure the ELF entry point defaults to zero. Typically, this |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
4049 |
* value is overridden in update_oehdr() to one of the standard |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
4050 |
* entry points. Historically, this default was set to the |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
4051 |
* address of first executable section, but this has since been |
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
4052 |
* found to be more confusing than it is helpful. |
0 | 4053 |
*/ |
2347
4893f6c77768
6388946 attempting to dlopen a .o file mislabeled as .so fails
rie
parents:
2145
diff
changeset
|
4054 |
ehdr->e_entry = 0; |
0 | 4055 |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4056 |
DBG_CALL(Dbg_seg_entry(ofl, segndx, sgp)); |
0 | 4057 |
|
4058 |
/* |
|
4059 |
* Traverse the output section descriptors for this segment so |
|
4060 |
* that we can update the section headers addresses. We've |
|
4061 |
* calculated the virtual address of the initial section within |
|
4062 |
* this segment, so each successive section can be calculated |
|
4063 |
* based on their offsets from each other. |
|
4064 |
*/ |
|
4065 |
secndx = 0; |
|
4066 |
hshdr = 0; |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4067 |
for (APLIST_TRAVERSE(sgp->sg_osdescs, idx2, osp)) { |
5892
b863dde33f1b
6492726 Merge SHF_MERGE|SHF_STRINGS input sections
ab196087
parents:
5801
diff
changeset
|
4068 |
Shdr *shdr = osp->os_shdr; |
0 | 4069 |
|
4070 |
if (shdr->sh_link) |
|
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
4071 |
shdr->sh_link = translate_link(ofl, osp, |
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
4072 |
shdr->sh_link, MSG_INTL(MSG_FIL_INVSHLINK)); |
0 | 4073 |
|
4074 |
if (shdr->sh_info && (shdr->sh_flags & SHF_INFO_LINK)) |
|
5220
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
4075 |
shdr->sh_info = translate_link(ofl, osp, |
caa2c0074088
PSARC/2007/559 new symbol visibilities - EXPORTED, SINGLETON, and ELIMINATE
rie
parents:
4716
diff
changeset
|
4076 |
shdr->sh_info, MSG_INTL(MSG_FIL_INVSHINFO)); |
0 | 4077 |
|
4078 |
if (!(flags & FLG_OF_RELOBJ) && |
|
8159
89ffa23f2543
6736890 PT_SUNWBSS should be disabled
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8140
diff
changeset
|
4079 |
(phdr->p_type == PT_LOAD)) { |
0 | 4080 |
if (hshdr) |
4081 |
vaddr += (shdr->sh_offset - |
|
4082 |
hshdr->sh_offset); |
|
4083 |
||
4084 |
shdr->sh_addr = vaddr; |
|
4085 |
hshdr = shdr; |
|
4086 |
} |
|
4087 |
||
4088 |
DBG_CALL(Dbg_seg_os(ofl, osp, secndx)); |
|
4089 |
secndx++; |
|
4090 |
} |
|
4091 |
||
4092 |
/* |
|
4093 |
* Establish the virtual address of the end of the last section |
|
4094 |
* in this segment so that the next segments offset can be |
|
4095 |
* calculated from this. |
|
4096 |
*/ |
|
4097 |
if (hshdr) |
|
4098 |
vaddr += hshdr->sh_size; |
|
4099 |
||
4100 |
/* |
|
4101 |
* Output sections for this segment complete. Adjust the |
|
4102 |
* virtual offset for the last sections size, and make sure we |
|
4103 |
* haven't exceeded any maximum segment length specification. |
|
4104 |
*/ |
|
4105 |
if ((sgp->sg_length != 0) && (sgp->sg_length < phdr->p_memsz)) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4106 |
eprintf(ofl->ofl_lml, ERR_FATAL, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4107 |
MSG_INTL(MSG_UPD_LARGSIZE), ofl->ofl_name, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4108 |
sgp->sg_name, EC_XWORD(phdr->p_memsz), |
0 | 4109 |
EC_XWORD(sgp->sg_length)); |
4110 |
return (S_ERROR); |
|
4111 |
} |
|
4112 |
||
4113 |
if (phdr->p_type == PT_NOTE) { |
|
4114 |
phdr->p_vaddr = 0; |
|
4115 |
phdr->p_paddr = 0; |
|
4116 |
phdr->p_align = 0; |
|
4117 |
phdr->p_memsz = 0; |
|
4118 |
} |
|
4284 | 4119 |
|
0 | 4120 |
if ((phdr->p_type != PT_NULL) && !(flags & FLG_OF_RELOBJ)) |
4121 |
ofl->ofl_phdr[phdrndx++] = *phdr; |
|
4122 |
} |
|
4123 |
||
4124 |
/* |
|
4125 |
* Update any new output sections. When building the initial output |
|
4126 |
* image, a number of sections were created but left uninitialized (eg. |
|
4127 |
* .dynsym, .dynstr, .symtab, .symtab, etc.). Here we update these |
|
4128 |
* sections with the appropriate data. Other sections may still be |
|
4129 |
* modified via reloc_process(). |
|
4130 |
* |
|
2648
6c17d29a3f67
6465623 need a way of building unix without an interpreter
rie
parents:
2347
diff
changeset
|
4131 |
* Copy the interpreter name into the .interp section. |
0 | 4132 |
*/ |
4133 |
if (ofl->ofl_interp) |
|
4134 |
(void) strcpy((char *)ofl->ofl_osinterp->os_outdata->d_buf, |
|
4135 |
ofl->ofl_interp); |
|
4136 |
||
4137 |
/* |
|
4138 |
* Update the .shstrtab, .strtab and .dynstr sections. |
|
4139 |
*/ |
|
3850
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
4140 |
update_ostrtab(ofl->ofl_osshstrtab, ofl->ofl_shdrsttab, 0); |
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
4141 |
update_ostrtab(ofl->ofl_osstrtab, ofl->ofl_strtab, 0); |
71162a8a771b
PSARC 2007/127 Reserved space for editing ELF dynamic sections
ab196087
parents:
3788
diff
changeset
|
4142 |
update_ostrtab(ofl->ofl_osdynstr, ofl->ofl_dynstrtab, DYNSTR_EXTRA_PAD); |
0 | 4143 |
|
4144 |
/* |
|
4145 |
* Build any output symbol tables, the symbols information is copied |
|
4146 |
* and updated into the new output image. |
|
4147 |
*/ |
|
4148 |
if ((etext = update_osym(ofl)) == (Addr)S_ERROR) |
|
4149 |
return (S_ERROR); |
|
4150 |
||
4151 |
/* |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4152 |
* If we have an PT_INTERP phdr, update it now from the associated |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4153 |
* section information. |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4154 |
*/ |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4155 |
if (intpsgp) { |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4156 |
Phdr *phdr = &(intpsgp->sg_phdr); |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4157 |
Shdr *shdr = ofl->ofl_osinterp->os_shdr; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4158 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4159 |
phdr->p_vaddr = shdr->sh_addr; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4160 |
phdr->p_offset = shdr->sh_offset; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4161 |
phdr->p_memsz = phdr->p_filesz = shdr->sh_size; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4162 |
phdr->p_flags = PF_R; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4163 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4164 |
DBG_CALL(Dbg_seg_entry(ofl, intpsndx, intpsgp)); |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4165 |
ofl->ofl_phdr[intppndx] = *phdr; |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4166 |
} |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4167 |
|
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4168 |
/* |
0 | 4169 |
* If we have a PT_SUNWDTRACE phdr, update it now with the address of |
4170 |
* the symbol. It's only now been updated via update_sym(). |
|
4171 |
*/ |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
4172 |
if (dtracesgp) { |
4284 | 4173 |
Phdr *aphdr, *phdr = &(dtracesgp->sg_phdr); |
0 | 4174 |
Sym_desc *sdp = ofl->ofl_dtracesym; |
4175 |
||
4284 | 4176 |
phdr->p_vaddr = sdp->sd_sym->st_value; |
4177 |
phdr->p_memsz = sdp->sd_sym->st_size; |
|
0 | 4178 |
|
4179 |
/* |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
4180 |
* Take permissions from the segment that the symbol is |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
4181 |
* associated with. |
0 | 4182 |
*/ |
4284 | 4183 |
aphdr = &sdp->sd_isc->is_osdesc->os_sgdesc->sg_phdr; |
4184 |
assert(aphdr); |
|
4185 |
phdr->p_flags = aphdr->p_flags; |
|
4186 |
||
4187 |
DBG_CALL(Dbg_seg_entry(ofl, dtracesndx, dtracesgp)); |
|
4188 |
ofl->ofl_phdr[dtracepndx] = *phdr; |
|
4189 |
} |
|
4190 |
||
4191 |
/* |
|
4192 |
* If we have a PT_SUNWCAP phdr, update it now from the associated |
|
4193 |
* section information. |
|
4194 |
*/ |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
4195 |
if (capsgp) { |
4284 | 4196 |
Phdr *phdr = &(capsgp->sg_phdr); |
4197 |
Shdr *shdr = ofl->ofl_oscap->os_shdr; |
|
4198 |
||
4199 |
phdr->p_vaddr = shdr->sh_addr; |
|
4200 |
phdr->p_offset = shdr->sh_offset; |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4201 |
phdr->p_memsz = phdr->p_filesz = shdr->sh_size; |
4284 | 4202 |
phdr->p_flags = PF_R; |
4203 |
||
4204 |
DBG_CALL(Dbg_seg_entry(ofl, capsndx, capsgp)); |
|
4205 |
ofl->ofl_phdr[cappndx] = *phdr; |
|
0 | 4206 |
} |
4207 |
||
4208 |
/* |
|
4209 |
* Update the GROUP sections. |
|
4210 |
*/ |
|
4211 |
if (update_ogroup(ofl) == S_ERROR) |
|
4212 |
return (S_ERROR); |
|
4213 |
||
4214 |
/* |
|
4215 |
* Update Move Table. |
|
4216 |
*/ |
|
9131
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4217 |
if (ofl->ofl_osmove || ofl->ofl_isparexpn) |
d7741cc87056
6801536 ld: mapfile processing oddities unveiled through mmapobj(2) observations
Rod Evans <Rod.Evans@Sun.COM>
parents:
9085
diff
changeset
|
4218 |
update_move(ofl); |
0 | 4219 |
|
4220 |
/* |
|
4221 |
* Build any output headers, version information, dynamic structure and |
|
4222 |
* syminfo structure. |
|
4223 |
*/ |
|
4224 |
if (update_oehdr(ofl) == S_ERROR) |
|
4225 |
return (S_ERROR); |
|
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
4226 |
if (!(flags & FLG_OF_NOVERSEC)) { |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
4227 |
if ((flags & FLG_OF_VERDEF) && |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
4228 |
(update_overdef(ofl) == S_ERROR)) |
0 | 4229 |
return (S_ERROR); |
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
4230 |
if ((flags & FLG_OF_VERNEED) && |
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
4231 |
(update_overneed(ofl) == S_ERROR)) |
0 | 4232 |
return (S_ERROR); |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
4233 |
if (flags & (FLG_OF_VERNEED | FLG_OF_VERDEF)) |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
4234 |
update_oversym(ofl); |
7682
b04d06fd448f
6749055 ld should generate GNU style VERSYM indexes for VERNEED records
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
7463
diff
changeset
|
4235 |
} |
0 | 4236 |
if (flags & FLG_OF_DYNAMIC) { |
4237 |
if (update_odynamic(ofl) == S_ERROR) |
|
4238 |
return (S_ERROR); |
|
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
4239 |
} |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
4240 |
if (ofl->ofl_ossyminfo) { |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
4241 |
if (update_osyminfo(ofl) == S_ERROR) |
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
4242 |
return (S_ERROR); |
0 | 4243 |
} |
4244 |
||
4245 |
/* |
|
11827
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
4246 |
* Update capabilities information if required. |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
4247 |
*/ |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
4248 |
if (ofl->ofl_oscap) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
4249 |
update_oscap(ofl); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
4250 |
if (ofl->ofl_oscapinfo) |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
4251 |
update_oscapinfo(ofl); |
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
4252 |
|
d7ef53deac3f
6918143 symbol capabilities
Rod Evans <Rod.Evans@Sun.COM>
parents:
11734
diff
changeset
|
4253 |
/* |
10792
809cb9af791e
6888489 Null environment variables are not overriding crle(1) replaceable environment variables.
Rod Evans <Rod.Evans@Sun.COM>
parents:
10167
diff
changeset
|
4254 |
* Sanity test: the first and last data byte of a string table |
8747
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4255 |
* must be NULL. |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4256 |
*/ |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4257 |
assert((ofl->ofl_osshstrtab == NULL) || |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4258 |
(*((char *)ofl->ofl_osshstrtab->os_outdata->d_buf) == '\0')); |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4259 |
assert((ofl->ofl_osshstrtab == NULL) || |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4260 |
(*(((char *)ofl->ofl_osshstrtab->os_outdata->d_buf) + |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4261 |
ofl->ofl_osshstrtab->os_outdata->d_size - 1) == '\0')); |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4262 |
|
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4263 |
assert((ofl->ofl_osstrtab == NULL) || |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4264 |
(*((char *)ofl->ofl_osstrtab->os_outdata->d_buf) == '\0')); |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4265 |
assert((ofl->ofl_osstrtab == NULL) || |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4266 |
(*(((char *)ofl->ofl_osstrtab->os_outdata->d_buf) + |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4267 |
ofl->ofl_osstrtab->os_outdata->d_size - 1) == '\0')); |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4268 |
|
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4269 |
assert((ofl->ofl_osdynstr == NULL) || |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4270 |
(*((char *)ofl->ofl_osdynstr->os_outdata->d_buf) == '\0')); |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4271 |
assert((ofl->ofl_osdynstr == NULL) || |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4272 |
(*(((char *)ofl->ofl_osdynstr->os_outdata->d_buf) + |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4273 |
ofl->ofl_osdynstr->os_outdata->d_size - DYNSTR_EXTRA_PAD - 1) == |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4274 |
'\0')); |
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4275 |
|
73be8d78d904
6800388 shstrtab can be sized incorrectly when -z ignore is used
Ali Bahrami <Ali.Bahrami@Sun.COM>
parents:
8501
diff
changeset
|
4276 |
/* |
0 | 4277 |
* Emit Strtab diagnostics. |
4278 |
*/ |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4279 |
DBG_CALL(Dbg_sec_strtab(ofl->ofl_lml, ofl->ofl_osshstrtab, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4280 |
ofl->ofl_shdrsttab)); |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4281 |
DBG_CALL(Dbg_sec_strtab(ofl->ofl_lml, ofl->ofl_osstrtab, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4282 |
ofl->ofl_strtab)); |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4283 |
DBG_CALL(Dbg_sec_strtab(ofl->ofl_lml, ofl->ofl_osdynstr, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4284 |
ofl->ofl_dynstrtab)); |
0 | 4285 |
|
4286 |
/* |
|
4287 |
* Initialize the section headers string table index within the elf |
|
4288 |
* header. |
|
4289 |
*/ |
|
4290 |
/* LINTED */ |
|
4291 |
if ((shscnndx = elf_ndxscn(ofl->ofl_osshstrtab->os_scn)) < |
|
4292 |
SHN_LORESERVE) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4293 |
ofl->ofl_nehdr->e_shstrndx = |
0 | 4294 |
/* LINTED */ |
4295 |
(Half)shscnndx; |
|
4296 |
} else { |
|
4297 |
/* |
|
4298 |
* If the STRTAB section index doesn't fit into |
|
4299 |
* e_shstrndx, then we store it in 'shdr[0].st_link'. |
|
4300 |
*/ |
|
4301 |
Elf_Scn *scn; |
|
4302 |
Shdr *shdr0; |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4303 |
|
0 | 4304 |
if ((scn = elf_getscn(ofl->ofl_elf, 0)) == NULL) { |
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4305 |
eprintf(ofl->ofl_lml, ERR_ELF, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4306 |
MSG_INTL(MSG_ELF_GETSCN), ofl->ofl_name); |
0 | 4307 |
return (S_ERROR); |
4308 |
} |
|
4309 |
if ((shdr0 = elf_getshdr(scn)) == NULL) { |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4310 |
eprintf(ofl->ofl_lml, ERR_ELF, |
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4311 |
MSG_INTL(MSG_ELF_GETSHDR), ofl->ofl_name); |
0 | 4312 |
return (S_ERROR); |
4313 |
} |
|
1618
8c9a4f31d225
6316708 LD_DEBUG should provide a means of identifying/isolating individual
rie
parents:
574
diff
changeset
|
4314 |
ofl->ofl_nehdr->e_shstrndx = SHN_XINDEX; |
0 | 4315 |
shdr0->sh_link = shscnndx; |
4316 |
} |
|
4317 |
||
4318 |
return ((uintptr_t)etext); |
|
4319 |
} |