mdreloc.c revision 1.11 1 1.11 skrll /* $NetBSD: mdreloc.c,v 1.11 2018/11/23 10:59:20 skrll Exp $ */
2 1.1 matt
3 1.1 matt /*-
4 1.1 matt * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 1.1 matt * All rights reserved.
6 1.1 matt *
7 1.1 matt * This code is derived from software contributed to The NetBSD Foundation
8 1.1 matt * by Matt Thomas of 3am Software Foundry.
9 1.1 matt *
10 1.1 matt * Redistribution and use in source and binary forms, with or without
11 1.1 matt * modification, are permitted provided that the following conditions
12 1.1 matt * are met:
13 1.1 matt * 1. Redistributions of source code must retain the above copyright
14 1.1 matt * notice, this list of conditions and the following disclaimer.
15 1.1 matt * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 matt * notice, this list of conditions and the following disclaimer in the
17 1.1 matt * documentation and/or other materials provided with the distribution.
18 1.1 matt *
19 1.1 matt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.1 matt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1 matt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.1 matt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.1 matt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.1 matt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.1 matt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.1 matt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.1 matt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.1 matt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.1 matt * POSSIBILITY OF SUCH DAMAGE.
30 1.1 matt */
31 1.1 matt
32 1.9 jakllsch /*-
33 1.9 jakllsch * Copyright (c) 2014-2015 The FreeBSD Foundation
34 1.9 jakllsch * All rights reserved.
35 1.9 jakllsch *
36 1.9 jakllsch * Portions of this software were developed by Andrew Turner
37 1.9 jakllsch * under sponsorship from the FreeBSD Foundation.
38 1.9 jakllsch *
39 1.9 jakllsch * Redistribution and use in source and binary forms, with or without
40 1.9 jakllsch * modification, are permitted provided that the following conditions
41 1.9 jakllsch * are met:
42 1.9 jakllsch * 1. Redistributions of source code must retain the above copyright
43 1.9 jakllsch * notice, this list of conditions and the following disclaimer.
44 1.9 jakllsch * 2. Redistributions in binary form must reproduce the above copyright
45 1.9 jakllsch * notice, this list of conditions and the following disclaimer in the
46 1.9 jakllsch * documentation and/or other materials provided with the distribution.
47 1.9 jakllsch *
48 1.9 jakllsch * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
49 1.9 jakllsch * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 1.9 jakllsch * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 1.9 jakllsch * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
52 1.9 jakllsch * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 1.9 jakllsch * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 1.9 jakllsch * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 1.9 jakllsch * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 1.9 jakllsch * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 1.9 jakllsch * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 1.9 jakllsch * SUCH DAMAGE.
59 1.9 jakllsch */
60 1.9 jakllsch
61 1.1 matt #include <sys/cdefs.h>
62 1.1 matt #ifndef lint
63 1.11 skrll __RCSID("$NetBSD: mdreloc.c,v 1.11 2018/11/23 10:59:20 skrll Exp $");
64 1.1 matt #endif /* not lint */
65 1.1 matt
66 1.1 matt #include <sys/types.h>
67 1.1 matt #include <string.h>
68 1.1 matt
69 1.1 matt #include "debug.h"
70 1.1 matt #include "rtld.h"
71 1.1 matt
72 1.9 jakllsch struct tls_data {
73 1.9 jakllsch int64_t index;
74 1.9 jakllsch Obj_Entry *obj;
75 1.9 jakllsch const Elf_Rela *rela;
76 1.9 jakllsch };
77 1.9 jakllsch
78 1.1 matt void _rtld_bind_start(void);
79 1.1 matt void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
80 1.5 nisimura Elf_Addr _rtld_bind(const Obj_Entry *, Elf_Word);
81 1.7 skrll void *_rtld_tlsdesc(void *);
82 1.9 jakllsch void *_rtld_tlsdesc_dynamic(void *);
83 1.9 jakllsch int64_t _rtld_tlsdesc_handle(struct tls_data *, u_int);
84 1.1 matt
85 1.6 nisimura /*
86 1.6 nisimura * AARCH64 PLT looks like this;
87 1.6 nisimura *
88 1.6 nisimura * PLT HEADER <8 instructions>
89 1.6 nisimura * PLT ENTRY #0 <4 instructions>
90 1.6 nisimura * PLT ENTRY #1 <4 instructions>
91 1.6 nisimura * .
92 1.6 nisimura * .
93 1.6 nisimura * PLT ENTRY #n <4 instructions>
94 1.6 nisimura *
95 1.6 nisimura * PLT HEADER
96 1.6 nisimura * stp x16, x30, [sp, #-16]!
97 1.6 nisimura * adrp x16, (GOT+16)
98 1.6 nisimura * ldr x17, [x16, #PLT_GOT+0x10]
99 1.6 nisimura * add x16, x16, #PLT_GOT+0x10
100 1.6 nisimura * br x17
101 1.6 nisimura * nop
102 1.6 nisimura * nop
103 1.6 nisimura * nop
104 1.6 nisimura *
105 1.6 nisimura * PLT ENTRY #n
106 1.6 nisimura * adrp x16, PLTGOT + n * 8
107 1.6 nisimura * ldr x17, [x16, PLTGOT + n * 8]
108 1.6 nisimura * add x16, x16, :lo12:PLTGOT + n * 8
109 1.6 nisimura * br x17
110 1.6 nisimura */
111 1.1 matt void
112 1.1 matt _rtld_setup_pltgot(const Obj_Entry *obj)
113 1.1 matt {
114 1.6 nisimura
115 1.1 matt obj->pltgot[1] = (Elf_Addr) obj;
116 1.1 matt obj->pltgot[2] = (Elf_Addr) &_rtld_bind_start;
117 1.1 matt }
118 1.1 matt
119 1.9 jakllsch static struct tls_data *
120 1.9 jakllsch _rtld_tlsdesc_alloc(Obj_Entry *obj, const Elf_Rela *rela)
121 1.9 jakllsch {
122 1.9 jakllsch struct tls_data *tlsdesc;
123 1.9 jakllsch
124 1.9 jakllsch tlsdesc = xmalloc(sizeof(*tlsdesc));
125 1.9 jakllsch tlsdesc->index = -1;
126 1.9 jakllsch tlsdesc->obj = obj;
127 1.9 jakllsch tlsdesc->rela = rela;
128 1.9 jakllsch
129 1.9 jakllsch return tlsdesc;
130 1.9 jakllsch }
131 1.9 jakllsch
132 1.9 jakllsch static int64_t
133 1.9 jakllsch _rtld_tlsdesc_handle_locked(struct tls_data *tlsdesc, u_int flags)
134 1.9 jakllsch {
135 1.9 jakllsch const Elf_Rela *rela;
136 1.9 jakllsch const Elf_Sym *def;
137 1.9 jakllsch const Obj_Entry *defobj;
138 1.9 jakllsch Obj_Entry *obj;
139 1.9 jakllsch
140 1.9 jakllsch rela = tlsdesc->rela;
141 1.9 jakllsch obj = tlsdesc->obj;
142 1.9 jakllsch
143 1.9 jakllsch def = _rtld_find_symdef(ELF_R_SYM(rela->r_info), obj, &defobj, flags);
144 1.9 jakllsch if (def == NULL)
145 1.9 jakllsch _rtld_die();
146 1.9 jakllsch
147 1.9 jakllsch tlsdesc->index = defobj->tlsoffset + def->st_value + rela->r_addend +
148 1.9 jakllsch sizeof(struct tls_tcb);
149 1.9 jakllsch
150 1.9 jakllsch return tlsdesc->index;
151 1.9 jakllsch }
152 1.9 jakllsch
153 1.9 jakllsch int64_t
154 1.9 jakllsch _rtld_tlsdesc_handle(struct tls_data *tlsdesc, u_int flags)
155 1.9 jakllsch {
156 1.9 jakllsch sigset_t mask;
157 1.9 jakllsch
158 1.9 jakllsch /* We have already found the index, return it */
159 1.9 jakllsch if (tlsdesc->index >= 0)
160 1.9 jakllsch return tlsdesc->index;
161 1.9 jakllsch
162 1.9 jakllsch _rtld_exclusive_enter(&mask);
163 1.9 jakllsch /* tlsdesc->index may have been set by another thread */
164 1.9 jakllsch if (tlsdesc->index == -1)
165 1.9 jakllsch _rtld_tlsdesc_handle_locked(tlsdesc, flags);
166 1.9 jakllsch _rtld_exclusive_exit(&mask);
167 1.9 jakllsch
168 1.9 jakllsch return tlsdesc->index;
169 1.9 jakllsch }
170 1.9 jakllsch
171 1.9 jakllsch static void
172 1.9 jakllsch _rtld_tlsdesc_fill(Obj_Entry *obj, const Elf_Rela *rela, Elf_Addr *where)
173 1.9 jakllsch {
174 1.9 jakllsch if (ELF_R_SYM(rela->r_info) == 0) {
175 1.9 jakllsch where[0] = (Elf_Addr)_rtld_tlsdesc;
176 1.9 jakllsch where[1] = obj->tlsoffset + rela->r_addend +
177 1.9 jakllsch sizeof(struct tls_tcb);
178 1.9 jakllsch } else {
179 1.9 jakllsch where[0] = (Elf_Addr)_rtld_tlsdesc_dynamic;
180 1.9 jakllsch where[1] = (Elf_Addr)_rtld_tlsdesc_alloc(obj, rela);
181 1.9 jakllsch }
182 1.9 jakllsch }
183 1.9 jakllsch
184 1.1 matt void
185 1.1 matt _rtld_relocate_nonplt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
186 1.1 matt {
187 1.7 skrll const Elf_Rela *rela = 0, *relalim;
188 1.7 skrll Elf_Addr relasz = 0;
189 1.1 matt Elf_Addr *where;
190 1.1 matt
191 1.1 matt for (; dynp->d_tag != DT_NULL; dynp++) {
192 1.1 matt switch (dynp->d_tag) {
193 1.7 skrll case DT_RELA:
194 1.7 skrll rela = (const Elf_Rela *)(relocbase + dynp->d_un.d_ptr);
195 1.1 matt break;
196 1.7 skrll case DT_RELASZ:
197 1.7 skrll relasz = dynp->d_un.d_val;
198 1.1 matt break;
199 1.1 matt }
200 1.1 matt }
201 1.7 skrll relalim = (const Elf_Rela *)((const uint8_t *)rela + relasz);
202 1.7 skrll for (; rela < relalim; rela++) {
203 1.7 skrll where = (Elf_Addr *)(relocbase + rela->r_offset);
204 1.1 matt *where += (Elf_Addr)relocbase;
205 1.1 matt }
206 1.1 matt }
207 1.1 matt
208 1.1 matt int
209 1.1 matt _rtld_relocate_nonplt_objects(Obj_Entry *obj)
210 1.1 matt {
211 1.3 joerg const Elf_Sym *def = NULL;
212 1.3 joerg const Obj_Entry *defobj = NULL;
213 1.3 joerg unsigned long last_symnum = ULONG_MAX;
214 1.3 joerg
215 1.1 matt for (const Elf_Rela *rela = obj->rela; rela < obj->relalim; rela++) {
216 1.1 matt Elf_Addr *where;
217 1.5 nisimura Elf_Addr tmp;
218 1.5 nisimura unsigned long symnum;
219 1.1 matt
220 1.1 matt where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
221 1.1 matt
222 1.1 matt switch (ELF_R_TYPE(rela->r_info)) {
223 1.7 skrll case R_TYPE(ABS64): /* word S + A */
224 1.7 skrll case R_TYPE(GLOB_DAT): /* word S + A */
225 1.3 joerg case R_TLS_TYPE(TLS_DTPREL):
226 1.3 joerg case R_TLS_TYPE(TLS_DTPMOD):
227 1.3 joerg case R_TLS_TYPE(TLS_TPREL):
228 1.3 joerg symnum = ELF_R_SYM(rela->r_info);
229 1.3 joerg if (last_symnum != symnum) {
230 1.3 joerg last_symnum = symnum;
231 1.3 joerg def = _rtld_find_symdef(symnum, obj, &defobj,
232 1.3 joerg false);
233 1.3 joerg if (def == NULL)
234 1.3 joerg return -1;
235 1.3 joerg }
236 1.3 joerg
237 1.3 joerg default:
238 1.3 joerg break;
239 1.3 joerg }
240 1.3 joerg
241 1.3 joerg switch (ELF_R_TYPE(rela->r_info)) {
242 1.1 matt case R_TYPE(NONE):
243 1.1 matt break;
244 1.1 matt
245 1.7 skrll case R_TYPE(ABS64): /* word S + A */
246 1.7 skrll case R_TYPE(GLOB_DAT): /* word S + A */
247 1.5 nisimura tmp = (Elf_Addr)defobj->relocbase + def->st_value +
248 1.5 nisimura rela->r_addend;
249 1.5 nisimura if (*where != tmp)
250 1.5 nisimura *where = tmp;
251 1.1 matt rdbg(("ABS64/GLOB_DAT %s in %s --> %p @ %p in %s",
252 1.1 matt obj->strtab + obj->symtab[symnum].st_name,
253 1.1 matt obj->path, (void *)tmp, where, defobj->path));
254 1.1 matt break;
255 1.1 matt
256 1.1 matt case R_TYPE(RELATIVE): /* word B + A */
257 1.5 nisimura *where = (Elf_Addr)(obj->relocbase + rela->r_addend);
258 1.1 matt rdbg(("RELATIVE in %s --> %p", obj->path,
259 1.5 nisimura (void *)*where));
260 1.1 matt break;
261 1.1 matt
262 1.1 matt case R_TYPE(COPY):
263 1.1 matt /*
264 1.1 matt * These are deferred until all other relocations have
265 1.1 matt * been done. All we do here is make sure that the
266 1.1 matt * COPY relocation is not in a shared library. They
267 1.1 matt * are allowed only in executable files.
268 1.1 matt */
269 1.1 matt if (obj->isdynamic) {
270 1.1 matt _rtld_error(
271 1.1 matt "%s: Unexpected R_COPY relocation in shared library",
272 1.1 matt obj->path);
273 1.1 matt return -1;
274 1.1 matt }
275 1.1 matt rdbg(("COPY (avoid in main)"));
276 1.1 matt break;
277 1.1 matt
278 1.9 jakllsch case R_TYPE(TLSDESC):
279 1.9 jakllsch _rtld_tlsdesc_fill(obj, rela, where);
280 1.9 jakllsch break;
281 1.9 jakllsch
282 1.1 matt case R_TLS_TYPE(TLS_DTPREL):
283 1.5 nisimura *where = (Elf_Addr)(def->st_value + rela->r_addend);
284 1.1 matt
285 1.5 nisimura rdbg(("TLS_DTPREL %s in %s --> %p",
286 1.1 matt obj->strtab + obj->symtab[symnum].st_name,
287 1.5 nisimura obj->path, (void *)*where));
288 1.1 matt
289 1.1 matt break;
290 1.1 matt case R_TLS_TYPE(TLS_DTPMOD):
291 1.1 matt *where = (Elf_Addr)(defobj->tlsindex);
292 1.1 matt
293 1.1 matt rdbg(("TLS_DTPMOD %s in %s --> %p",
294 1.1 matt obj->strtab + obj->symtab[symnum].st_name,
295 1.5 nisimura obj->path, (void *)*where));
296 1.1 matt
297 1.1 matt break;
298 1.1 matt
299 1.1 matt case R_TLS_TYPE(TLS_TPREL):
300 1.1 matt if (!defobj->tls_done &&
301 1.1 matt _rtld_tls_offset_allocate(obj))
302 1.1 matt return -1;
303 1.1 matt
304 1.1 matt *where = (Elf_Addr)def->st_value + defobj->tlsoffset +
305 1.1 matt sizeof(struct tls_tcb);
306 1.5 nisimura rdbg(("TLS_TPREL %s in %s --> %p in %s",
307 1.1 matt obj->strtab + obj->symtab[symnum].st_name,
308 1.5 nisimura obj->path, (void *)*where, defobj->path));
309 1.1 matt break;
310 1.1 matt
311 1.1 matt default:
312 1.1 matt rdbg(("sym = %lu, type = %lu, offset = %p, "
313 1.5 nisimura "addend = %p, contents = %p, symbol = %s",
314 1.3 joerg (u_long)ELF_R_SYM(rela->r_info),
315 1.3 joerg (u_long)ELF_R_TYPE(rela->r_info),
316 1.5 nisimura (void *)rela->r_offset, (void *)rela->r_addend,
317 1.5 nisimura (void *)*where,
318 1.1 matt obj->strtab + obj->symtab[symnum].st_name));
319 1.1 matt _rtld_error("%s: Unsupported relocation type %ld "
320 1.1 matt "in non-PLT relocations",
321 1.1 matt obj->path, (u_long) ELF_R_TYPE(rela->r_info));
322 1.1 matt return -1;
323 1.1 matt }
324 1.1 matt }
325 1.1 matt return 0;
326 1.1 matt }
327 1.1 matt
328 1.1 matt int
329 1.4 joerg _rtld_relocate_plt_lazy(Obj_Entry *obj)
330 1.1 matt {
331 1.1 matt
332 1.1 matt if (!obj->relocbase)
333 1.1 matt return 0;
334 1.1 matt
335 1.7 skrll for (const Elf_Rela *rela = obj->pltrela; rela < obj->pltrelalim; rela++) {
336 1.7 skrll Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
337 1.1 matt
338 1.7 skrll assert((ELF_R_TYPE(rela->r_info) == R_TYPE(JUMP_SLOT)) ||
339 1.7 skrll (ELF_R_TYPE(rela->r_info) == R_TYPE(TLSDESC)));
340 1.1 matt
341 1.7 skrll switch (ELF_R_TYPE(rela->r_info)) {
342 1.7 skrll case R_TYPE(JUMP_SLOT):
343 1.7 skrll /* Just relocate the GOT slots pointing into the PLT */
344 1.7 skrll *where += (Elf_Addr)obj->relocbase;
345 1.7 skrll rdbg(("fixup !main in %s --> %p", obj->path, (void *)*where));
346 1.7 skrll break;
347 1.7 skrll case R_TYPE(TLSDESC):
348 1.9 jakllsch _rtld_tlsdesc_fill(obj, rela, where);
349 1.7 skrll break;
350 1.7 skrll }
351 1.1 matt }
352 1.1 matt
353 1.1 matt return 0;
354 1.1 matt }
355 1.1 matt
356 1.7 skrll void
357 1.7 skrll _rtld_call_ifunc(Obj_Entry *obj, sigset_t *mask, u_int cur_objgen)
358 1.7 skrll {
359 1.7 skrll const Elf_Rela *rela;
360 1.7 skrll Elf_Addr *where, target;
361 1.7 skrll
362 1.7 skrll while (obj->ifunc_remaining > 0 && _rtld_objgen == cur_objgen) {
363 1.7 skrll rela = obj->pltrelalim - obj->ifunc_remaining;
364 1.7 skrll --obj->ifunc_remaining;
365 1.7 skrll if (ELF_R_TYPE(rela->r_info) == R_TYPE(IRELATIVE)) {
366 1.7 skrll where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
367 1.7 skrll target = (Elf_Addr)(obj->relocbase + rela->r_addend);
368 1.7 skrll _rtld_exclusive_exit(mask);
369 1.7 skrll target = _rtld_resolve_ifunc2(obj, target);
370 1.7 skrll _rtld_exclusive_enter(mask);
371 1.7 skrll if (*where != target)
372 1.7 skrll *where = target;
373 1.7 skrll }
374 1.7 skrll }
375 1.7 skrll }
376 1.7 skrll
377 1.1 matt static int
378 1.7 skrll _rtld_relocate_plt_object(const Obj_Entry *obj, const Elf_Rela *rela,
379 1.1 matt Elf_Addr *tp)
380 1.1 matt {
381 1.7 skrll Elf_Addr *where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
382 1.1 matt Elf_Addr new_value;
383 1.1 matt const Elf_Sym *def;
384 1.1 matt const Obj_Entry *defobj;
385 1.1 matt
386 1.9 jakllsch switch (ELF_R_TYPE(rela->r_info)) {
387 1.9 jakllsch case R_TYPE(JUMP_SLOT):
388 1.9 jakllsch def = _rtld_find_plt_symdef(ELF_R_SYM(rela->r_info), obj,
389 1.9 jakllsch &defobj, tp != NULL);
390 1.9 jakllsch if (__predict_false(def == NULL))
391 1.9 jakllsch return -1;
392 1.9 jakllsch if (__predict_false(def == &_rtld_sym_zero))
393 1.9 jakllsch return 0;
394 1.1 matt
395 1.9 jakllsch if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) {
396 1.9 jakllsch if (tp == NULL)
397 1.9 jakllsch return 0;
398 1.9 jakllsch new_value = _rtld_resolve_ifunc(defobj, def);
399 1.9 jakllsch } else {
400 1.9 jakllsch new_value = (Elf_Addr)(defobj->relocbase +
401 1.9 jakllsch def->st_value);
402 1.9 jakllsch }
403 1.9 jakllsch rdbg(("bind now/fixup in %s --> old=%p new=%p",
404 1.9 jakllsch defobj->strtab + def->st_name, (void *)*where,
405 1.9 jakllsch (void *)new_value));
406 1.9 jakllsch if (*where != new_value)
407 1.9 jakllsch *where = new_value;
408 1.9 jakllsch if (tp)
409 1.9 jakllsch *tp = new_value;
410 1.9 jakllsch break;
411 1.9 jakllsch case R_TYPE(TLSDESC):
412 1.9 jakllsch if (ELF_R_SYM(rela->r_info) != 0) {
413 1.9 jakllsch struct tls_data *tlsdesc = (struct tls_data *)where[1];
414 1.9 jakllsch if (tlsdesc->index == -1)
415 1.10 jakllsch _rtld_tlsdesc_handle_locked(tlsdesc, SYMLOOK_IN_PLT);
416 1.9 jakllsch }
417 1.9 jakllsch break;
418 1.2 joerg }
419 1.1 matt
420 1.1 matt return 0;
421 1.1 matt }
422 1.1 matt
423 1.5 nisimura Elf_Addr
424 1.7 skrll _rtld_bind(const Obj_Entry *obj, Elf_Word relaidx)
425 1.1 matt {
426 1.7 skrll const Elf_Rela *rela = obj->pltrela + relaidx;
427 1.8 christos Elf_Addr new_value = 0;
428 1.1 matt
429 1.1 matt _rtld_shared_enter();
430 1.7 skrll int err = _rtld_relocate_plt_object(obj, rela, &new_value);
431 1.1 matt if (err)
432 1.1 matt _rtld_die();
433 1.1 matt _rtld_shared_exit();
434 1.1 matt
435 1.5 nisimura return new_value;
436 1.1 matt }
437 1.1 matt int
438 1.1 matt _rtld_relocate_plt_objects(const Obj_Entry *obj)
439 1.1 matt {
440 1.7 skrll const Elf_Rela *rela;
441 1.1 matt int err = 0;
442 1.11 skrll
443 1.7 skrll for (rela = obj->pltrela; rela < obj->pltrelalim; rela++) {
444 1.7 skrll err = _rtld_relocate_plt_object(obj, rela, NULL);
445 1.1 matt if (err)
446 1.1 matt break;
447 1.1 matt }
448 1.1 matt
449 1.1 matt return err;
450 1.1 matt }
451