mips_reloc.c revision 1.59 1 1.59 joerg /* $NetBSD: mips_reloc.c,v 1.59 2010/08/06 16:33:18 joerg Exp $ */
2 1.1 mhitch
3 1.1 mhitch /*
4 1.1 mhitch * Copyright 1997 Michael L. Hitch <mhitch (at) montana.edu>
5 1.37 mycroft * Portions copyright 2002 Charles M. Hannum <root (at) ihack.net>
6 1.1 mhitch * All rights reserved.
7 1.1 mhitch *
8 1.1 mhitch * Redistribution and use in source and binary forms, with or without
9 1.1 mhitch * modification, are permitted provided that the following conditions
10 1.1 mhitch * are met:
11 1.1 mhitch * 1. Redistributions of source code must retain the above copyright
12 1.1 mhitch * notice, this list of conditions and the following disclaimer.
13 1.1 mhitch * 2. Redistributions in binary form must reproduce the above copyright
14 1.1 mhitch * notice, this list of conditions and the following disclaimer in the
15 1.1 mhitch * documentation and/or other materials provided with the distribution.
16 1.1 mhitch * 3. The name of the author may not be used to endorse or promote products
17 1.1 mhitch * derived from this software without specific prior written permission.
18 1.1 mhitch *
19 1.1 mhitch * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 1.1 mhitch * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 1.1 mhitch * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 1.1 mhitch * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 1.1 mhitch * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 1.1 mhitch * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 1.1 mhitch * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 1.1 mhitch * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 1.1 mhitch * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 1.1 mhitch * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 1.1 mhitch */
30 1.1 mhitch
31 1.48 skrll #include <sys/cdefs.h>
32 1.48 skrll #ifndef lint
33 1.59 joerg __RCSID("$NetBSD: mips_reloc.c,v 1.59 2010/08/06 16:33:18 joerg Exp $");
34 1.48 skrll #endif /* not lint */
35 1.48 skrll
36 1.1 mhitch #include <sys/types.h>
37 1.56 matt #include <sys/endian.h>
38 1.40 mrg
39 1.40 mrg #include <stdlib.h>
40 1.33 thorpej #include <string.h>
41 1.1 mhitch
42 1.1 mhitch #include "debug.h"
43 1.1 mhitch #include "rtld.h"
44 1.1 mhitch
45 1.56 matt #ifdef __mips_o32
46 1.36 mycroft #define SUPPORT_OLD_BROKEN_LD
47 1.56 matt #endif
48 1.36 mycroft
49 1.22 mycroft void _rtld_bind_start(void);
50 1.17 mycroft void _rtld_relocate_nonplt_self(Elf_Dyn *, Elf_Addr);
51 1.36 mycroft caddr_t _rtld_bind(Elf_Word, Elf_Addr, Elf_Addr, Elf_Addr);
52 1.6 mycroft
53 1.45 simonb /*
54 1.45 simonb * It is possible for the compiler to emit relocations for unaligned data.
55 1.45 simonb * We handle this situation with these inlines.
56 1.45 simonb */
57 1.45 simonb
58 1.56 matt #if ELFSIZE == 64
59 1.56 matt /*
60 1.56 matt * ELF64 MIPS encodes the relocs uniquely. The first 32-bits of info contain
61 1.56 matt * the symbol index. The top 32-bits contain three relocation types encoded
62 1.56 matt * in big-endian integer with first relocation in LSB. This means for little
63 1.56 matt * endian we have to byte swap that interger (r_type).
64 1.56 matt */
65 1.56 matt #define Elf_Sxword Elf64_Sxword
66 1.56 matt #define ELF_R_NXTTYPE_64_P(r_type) ((((r_type) >> 8) & 0xff) == R_TYPE(64))
67 1.56 matt #if BYTE_ORDER == LITTLE_ENDIAN
68 1.56 matt #undef ELF_R_SYM
69 1.56 matt #undef ELF_R_TYPE
70 1.56 matt #define ELF_R_SYM(r_info) ((r_info) & 0xffffffff)
71 1.56 matt #define ELF_R_TYPE(r_info) bswap32((r_info) >> 32)
72 1.56 matt #endif
73 1.56 matt #else
74 1.56 matt #define ELF_R_NXTTYPE_64_P(r_type) (0)
75 1.56 matt #define Elf_Sxword Elf32_Sword
76 1.56 matt #endif
77 1.56 matt
78 1.56 matt static inline Elf_Sxword
79 1.56 matt load_ptr(void *where, size_t len)
80 1.45 simonb {
81 1.56 matt Elf_Sxword val;
82 1.45 simonb
83 1.56 matt if (__predict_true(((uintptr_t)where & (len - 1)) == 0)) {
84 1.56 matt #if ELFSIZE == 64
85 1.56 matt if (len == sizeof(Elf_Sxword))
86 1.56 matt return *(Elf_Sxword *)where;
87 1.56 matt #endif
88 1.56 matt return *(Elf_Sword *)where;
89 1.52 simonb }
90 1.56 matt
91 1.56 matt val = 0;
92 1.56 matt #if BYTE_ORDER == LITTLE_ENDIAN
93 1.56 matt (void)memcpy(&val, where, len);
94 1.56 matt #endif
95 1.56 matt #if BYTE_ORDER == BIG_ENDIAN
96 1.56 matt (void)memcpy((uint8_t *)((&val)+1) - len, where, len);
97 1.56 matt #endif
98 1.56 matt return (len == sizeof(Elf_Sxword)) ? val : (Elf_Sword)val;
99 1.45 simonb }
100 1.45 simonb
101 1.49 perry static inline void
102 1.56 matt store_ptr(void *where, Elf_Sxword val, size_t len)
103 1.45 simonb {
104 1.56 matt if (__predict_true(((uintptr_t)where & (len - 1)) == 0)) {
105 1.56 matt #if ELFSIZE == 64
106 1.56 matt if (len == sizeof(Elf_Sxword)) {
107 1.56 matt *(Elf_Sxword *)where = val;
108 1.56 matt return;
109 1.56 matt }
110 1.56 matt #endif
111 1.56 matt *(Elf_Sword *)where = val;
112 1.56 matt return;
113 1.56 matt }
114 1.56 matt #if BYTE_ORDER == LITTLE_ENDIAN
115 1.56 matt (void)memcpy(where, &val, len);
116 1.56 matt #endif
117 1.56 matt #if BYTE_ORDER == BIG_ENDIAN
118 1.56 matt (void)memcpy(where, (const uint8_t *)((&val)+1) - len, len);
119 1.56 matt #endif
120 1.45 simonb }
121 1.45 simonb
122 1.45 simonb
123 1.1 mhitch void
124 1.39 skrll _rtld_setup_pltgot(const Obj_Entry *obj)
125 1.1 mhitch {
126 1.6 mycroft obj->pltgot[0] = (Elf_Addr) &_rtld_bind_start;
127 1.6 mycroft /* XXX only if obj->pltgot[1] & 0x80000000 ?? */
128 1.6 mycroft obj->pltgot[1] |= (Elf_Addr) obj;
129 1.8 mycroft }
130 1.8 mycroft
131 1.17 mycroft void
132 1.39 skrll _rtld_relocate_nonplt_self(Elf_Dyn *dynp, Elf_Addr relocbase)
133 1.17 mycroft {
134 1.17 mycroft const Elf_Rel *rel = 0, *rellim;
135 1.17 mycroft Elf_Addr relsz = 0;
136 1.52 simonb void *where;
137 1.47 he const Elf_Sym *symtab = NULL, *sym;
138 1.47 he Elf_Addr *got = NULL;
139 1.56 matt Elf_Word local_gotno = 0, symtabno = 0, gotsym = 0;
140 1.56 matt size_t i;
141 1.17 mycroft
142 1.17 mycroft for (; dynp->d_tag != DT_NULL; dynp++) {
143 1.17 mycroft switch (dynp->d_tag) {
144 1.17 mycroft case DT_REL:
145 1.17 mycroft rel = (const Elf_Rel *)(relocbase + dynp->d_un.d_ptr);
146 1.17 mycroft break;
147 1.17 mycroft case DT_RELSZ:
148 1.17 mycroft relsz = dynp->d_un.d_val;
149 1.17 mycroft break;
150 1.17 mycroft case DT_SYMTAB:
151 1.17 mycroft symtab = (const Elf_Sym *)(relocbase + dynp->d_un.d_ptr);
152 1.17 mycroft break;
153 1.18 mycroft case DT_PLTGOT:
154 1.18 mycroft got = (Elf_Addr *)(relocbase + dynp->d_un.d_ptr);
155 1.18 mycroft break;
156 1.18 mycroft case DT_MIPS_LOCAL_GOTNO:
157 1.18 mycroft local_gotno = dynp->d_un.d_val;
158 1.18 mycroft break;
159 1.18 mycroft case DT_MIPS_SYMTABNO:
160 1.18 mycroft symtabno = dynp->d_un.d_val;
161 1.18 mycroft break;
162 1.18 mycroft case DT_MIPS_GOTSYM:
163 1.18 mycroft gotsym = dynp->d_un.d_val;
164 1.18 mycroft break;
165 1.17 mycroft }
166 1.17 mycroft }
167 1.34 mycroft
168 1.34 mycroft i = (got[1] & 0x80000000) ? 2 : 1;
169 1.34 mycroft /* Relocate the local GOT entries */
170 1.34 mycroft got += i;
171 1.34 mycroft for (; i < local_gotno; i++)
172 1.34 mycroft *got++ += relocbase;
173 1.34 mycroft sym = symtab + gotsym;
174 1.34 mycroft /* Now do the global GOT entries */
175 1.34 mycroft for (i = gotsym; i < symtabno; i++) {
176 1.34 mycroft *got = sym->st_value + relocbase;
177 1.34 mycroft ++sym;
178 1.34 mycroft ++got;
179 1.34 mycroft }
180 1.34 mycroft
181 1.56 matt rellim = (const Elf_Rel *)((uintptr_t)rel + relsz);
182 1.17 mycroft for (; rel < rellim; rel++) {
183 1.56 matt Elf_Word r_symndx, r_type;
184 1.56 matt
185 1.52 simonb where = (void *)(relocbase + rel->r_offset);
186 1.17 mycroft
187 1.56 matt r_symndx = ELF_R_SYM(rel->r_info);
188 1.56 matt r_type = ELF_R_TYPE(rel->r_info);
189 1.56 matt
190 1.56 matt switch (r_type & 0xff) {
191 1.56 matt case R_TYPE(REL32): {
192 1.56 matt const size_t rlen =
193 1.56 matt ELF_R_NXTTYPE_64_P(r_type)
194 1.56 matt ? sizeof(Elf_Sxword)
195 1.56 matt : sizeof(Elf_Sword);
196 1.56 matt Elf_Sxword old = load_ptr(where, rlen);
197 1.56 matt Elf_Sxword val = old;
198 1.56 matt #if ELFSIZE == 64
199 1.56 matt assert(r_type == R_TYPE(REL32)
200 1.56 matt || r_type == (R_TYPE(REL32)|(R_TYPE(64) << 8)));
201 1.56 matt #endif
202 1.56 matt assert(r_symndx < gotsym);
203 1.56 matt sym = symtab + r_symndx;
204 1.56 matt assert(ELF_ST_BIND(sym->st_info) == STB_LOCAL);
205 1.56 matt val += relocbase;
206 1.56 matt store_ptr(where, val, sizeof(Elf_Sword));
207 1.56 matt rdbg(("REL32/L(%p) %p -> %p in <self>",
208 1.56 matt where, (void *)old, (void *)val));
209 1.56 matt store_ptr(where, val, rlen);
210 1.56 matt break;
211 1.56 matt }
212 1.56 matt
213 1.56 matt case R_TYPE(GPREL32):
214 1.17 mycroft case R_TYPE(NONE):
215 1.17 mycroft break;
216 1.17 mycroft
217 1.17 mycroft
218 1.17 mycroft default:
219 1.17 mycroft abort();
220 1.17 mycroft }
221 1.17 mycroft }
222 1.17 mycroft }
223 1.17 mycroft
224 1.8 mycroft int
225 1.59 joerg _rtld_relocate_nonplt_objects(Obj_Entry *obj)
226 1.8 mycroft {
227 1.9 mycroft const Elf_Rel *rel;
228 1.18 mycroft Elf_Addr *got = obj->pltgot;
229 1.19 mycroft const Elf_Sym *sym, *def;
230 1.18 mycroft const Obj_Entry *defobj;
231 1.54 christos Elf_Word i;
232 1.36 mycroft #ifdef SUPPORT_OLD_BROKEN_LD
233 1.36 mycroft int broken;
234 1.36 mycroft #endif
235 1.36 mycroft
236 1.36 mycroft #ifdef SUPPORT_OLD_BROKEN_LD
237 1.36 mycroft broken = 0;
238 1.36 mycroft sym = obj->symtab;
239 1.36 mycroft for (i = 1; i < 12; i++)
240 1.36 mycroft if (sym[i].st_info == ELF_ST_INFO(STB_LOCAL, STT_NOTYPE))
241 1.36 mycroft broken = 1;
242 1.36 mycroft dbg(("%s: broken=%d", obj->path, broken));
243 1.36 mycroft #endif
244 1.17 mycroft
245 1.34 mycroft i = (got[1] & 0x80000000) ? 2 : 1;
246 1.34 mycroft /* Relocate the local GOT entries */
247 1.34 mycroft got += i;
248 1.34 mycroft for (; i < obj->local_gotno; i++)
249 1.34 mycroft *got++ += (Elf_Addr)obj->relocbase;
250 1.34 mycroft sym = obj->symtab + obj->gotsym;
251 1.34 mycroft /* Now do the global GOT entries */
252 1.34 mycroft for (i = obj->gotsym; i < obj->symtabno; i++) {
253 1.56 matt rdbg((" doing got %d sym %p (%s, %lx)", i - obj->gotsym, sym,
254 1.56 matt sym->st_name + obj->strtab, (u_long) *got));
255 1.34 mycroft
256 1.36 mycroft #ifdef SUPPORT_OLD_BROKEN_LD
257 1.34 mycroft if (ELF_ST_TYPE(sym->st_info) == STT_FUNC &&
258 1.36 mycroft broken && sym->st_shndx == SHN_UNDEF) {
259 1.34 mycroft /*
260 1.34 mycroft * XXX DANGER WILL ROBINSON!
261 1.34 mycroft * You might think this is stupid, as it intentionally
262 1.34 mycroft * defeats lazy binding -- and you'd be right.
263 1.34 mycroft * Unfortunately, for lazy binding to work right, we
264 1.34 mycroft * need to a way to force the GOT slots used for
265 1.34 mycroft * function pointers to be resolved immediately. This
266 1.34 mycroft * is supposed to be done automatically by the linker,
267 1.34 mycroft * by not outputting a PLT slot and setting st_value
268 1.36 mycroft * to 0 if there are non-PLT references, but older
269 1.36 mycroft * versions of GNU ld do not do this.
270 1.34 mycroft */
271 1.38 skrll def = _rtld_find_symdef(i, obj, &defobj, false);
272 1.34 mycroft if (def == NULL)
273 1.34 mycroft return -1;
274 1.34 mycroft *got = def->st_value + (Elf_Addr)defobj->relocbase;
275 1.36 mycroft } else
276 1.36 mycroft #endif
277 1.36 mycroft if (ELF_ST_TYPE(sym->st_info) == STT_FUNC &&
278 1.41 mycroft sym->st_value != 0 && sym->st_shndx == SHN_UNDEF) {
279 1.34 mycroft /*
280 1.34 mycroft * If there are non-PLT references to the function,
281 1.34 mycroft * st_value should be 0, forcing us to resolve the
282 1.34 mycroft * address immediately.
283 1.41 mycroft *
284 1.41 mycroft * XXX DANGER WILL ROBINSON!
285 1.41 mycroft * The linker is not outputting PLT slots for calls to
286 1.41 mycroft * functions that are defined in the same shared
287 1.42 mycroft * library. This is a bug, because it can screw up
288 1.42 mycroft * link ordering rules if the symbol is defined in
289 1.42 mycroft * more than one module. For now, if there is a
290 1.42 mycroft * definition, we fail the test above and force a full
291 1.44 mycroft * symbol lookup. This means that all intra-module
292 1.44 mycroft * calls are bound immediately. - mycroft, 2003/09/24
293 1.34 mycroft */
294 1.34 mycroft *got = sym->st_value + (Elf_Addr)obj->relocbase;
295 1.34 mycroft } else if (sym->st_info == ELF_ST_INFO(STB_GLOBAL, STT_SECTION)) {
296 1.34 mycroft /* Symbols with index SHN_ABS are not relocated. */
297 1.34 mycroft if (sym->st_shndx != SHN_ABS)
298 1.34 mycroft *got = sym->st_value +
299 1.34 mycroft (Elf_Addr)obj->relocbase;
300 1.34 mycroft } else {
301 1.38 skrll def = _rtld_find_symdef(i, obj, &defobj, false);
302 1.34 mycroft if (def == NULL)
303 1.34 mycroft return -1;
304 1.34 mycroft *got = def->st_value + (Elf_Addr)defobj->relocbase;
305 1.34 mycroft }
306 1.34 mycroft
307 1.56 matt rdbg((" --> now %lx", (u_long) *got));
308 1.34 mycroft ++sym;
309 1.34 mycroft ++got;
310 1.34 mycroft }
311 1.34 mycroft
312 1.34 mycroft got = obj->pltgot;
313 1.9 mycroft for (rel = obj->rel; rel < obj->rellim; rel++) {
314 1.56 matt Elf_Word r_symndx, r_type;
315 1.52 simonb void *where;
316 1.9 mycroft
317 1.52 simonb where = obj->relocbase + rel->r_offset;
318 1.56 matt r_symndx = ELF_R_SYM(rel->r_info);
319 1.56 matt r_type = ELF_R_TYPE(rel->r_info);
320 1.9 mycroft
321 1.56 matt switch (r_type & 0xff) {
322 1.9 mycroft case R_TYPE(NONE):
323 1.9 mycroft break;
324 1.9 mycroft
325 1.56 matt case R_TYPE(REL32): {
326 1.9 mycroft /* 32-bit PC-relative reference */
327 1.56 matt const size_t rlen =
328 1.56 matt ELF_R_NXTTYPE_64_P(r_type)
329 1.56 matt ? sizeof(Elf_Sxword)
330 1.56 matt : sizeof(Elf_Sword);
331 1.56 matt Elf_Sxword old = load_ptr(where, rlen);
332 1.56 matt Elf_Sxword val = old;
333 1.56 matt
334 1.56 matt def = obj->symtab + r_symndx;
335 1.56 matt
336 1.56 matt if (r_symndx >= obj->gotsym) {
337 1.56 matt val += got[obj->local_gotno + r_symndx - obj->gotsym];
338 1.56 matt rdbg(("REL32/G(%p) %p --> %p (%s) in %s",
339 1.56 matt where, (void *)old, (void *)val,
340 1.56 matt obj->strtab + def->st_name,
341 1.56 matt obj->path));
342 1.34 mycroft } else {
343 1.9 mycroft /*
344 1.9 mycroft * XXX: ABI DIFFERENCE!
345 1.9 mycroft *
346 1.9 mycroft * Old NetBSD binutils would generate shared
347 1.9 mycroft * libs with section-relative relocations being
348 1.9 mycroft * already adjusted for the start address of
349 1.9 mycroft * the section.
350 1.9 mycroft *
351 1.9 mycroft * New binutils, OTOH, generate shared libs
352 1.9 mycroft * with the same relocations being based at
353 1.9 mycroft * zero, so we need to add in the start address
354 1.9 mycroft * of the section.
355 1.9 mycroft *
356 1.9 mycroft * --rkb, Oct 6, 2001
357 1.9 mycroft */
358 1.34 mycroft
359 1.35 mycroft if (def->st_info ==
360 1.36 mycroft ELF_ST_INFO(STB_LOCAL, STT_SECTION)
361 1.36 mycroft #ifdef SUPPORT_OLD_BROKEN_LD
362 1.36 mycroft && !broken
363 1.36 mycroft #endif
364 1.36 mycroft )
365 1.56 matt val += (Elf_Addr)def->st_value;
366 1.9 mycroft
367 1.56 matt val += (Elf_Addr)obj->relocbase;
368 1.9 mycroft
369 1.56 matt rdbg(("REL32/L(%p) %p -> %p (%s) in %s",
370 1.56 matt where, (void *)old, (void *)val,
371 1.56 matt obj->strtab + def->st_name, obj->path));
372 1.9 mycroft }
373 1.56 matt store_ptr(where, val, rlen);
374 1.9 mycroft break;
375 1.56 matt }
376 1.9 mycroft
377 1.9 mycroft default:
378 1.23 mycroft rdbg(("sym = %lu, type = %lu, offset = %p, "
379 1.9 mycroft "contents = %p, symbol = %s",
380 1.56 matt (u_long)r_symndx, (u_long)ELF_R_TYPE(rel->r_info),
381 1.56 matt (void *)rel->r_offset,
382 1.56 matt (void *)load_ptr(where, sizeof(Elf_Sword)),
383 1.56 matt obj->strtab + obj->symtab[r_symndx].st_name));
384 1.9 mycroft _rtld_error("%s: Unsupported relocation type %ld "
385 1.55 jmmv "in non-PLT relocations",
386 1.9 mycroft obj->path, (u_long) ELF_R_TYPE(rel->r_info));
387 1.9 mycroft return -1;
388 1.8 mycroft }
389 1.18 mycroft }
390 1.18 mycroft
391 1.8 mycroft return 0;
392 1.8 mycroft }
393 1.8 mycroft
394 1.8 mycroft int
395 1.39 skrll _rtld_relocate_plt_lazy(const Obj_Entry *obj)
396 1.13 mycroft {
397 1.31 mycroft /* PLT fixups were done above in the GOT relocation. */
398 1.28 mycroft return 0;
399 1.36 mycroft }
400 1.36 mycroft
401 1.50 skrll static inline int
402 1.50 skrll _rtld_relocate_plt_object(const Obj_Entry *obj, Elf_Word sym, Elf_Addr *tp)
403 1.36 mycroft {
404 1.50 skrll Elf_Addr *got = obj->pltgot;
405 1.36 mycroft const Elf_Sym *def;
406 1.36 mycroft const Obj_Entry *defobj;
407 1.36 mycroft Elf_Addr new_value;
408 1.36 mycroft
409 1.57 christos def = _rtld_find_plt_symdef(sym, obj, &defobj, tp != NULL);
410 1.57 christos if (__predict_false(def == NULL))
411 1.50 skrll return -1;
412 1.57 christos if (__predict_false(def == &_rtld_sym_zero))
413 1.57 christos return 0;
414 1.36 mycroft
415 1.36 mycroft new_value = (Elf_Addr)(defobj->relocbase + def->st_value);
416 1.36 mycroft rdbg(("bind now/fixup in %s --> new=%p",
417 1.36 mycroft defobj->strtab + def->st_name, (void *)new_value));
418 1.50 skrll got[obj->local_gotno + sym - obj->gotsym] = new_value;
419 1.50 skrll
420 1.50 skrll if (tp)
421 1.50 skrll *tp = new_value;
422 1.50 skrll return 0;
423 1.50 skrll }
424 1.50 skrll
425 1.50 skrll caddr_t
426 1.50 skrll _rtld_bind(Elf_Word a0, Elf_Addr a1, Elf_Addr a2, Elf_Addr a3)
427 1.50 skrll {
428 1.50 skrll Elf_Addr *got = (Elf_Addr *)(a2 - 0x7ff0);
429 1.50 skrll const Obj_Entry *obj = (Obj_Entry *)(got[1] & 0x7fffffff);
430 1.58 skrll Elf_Addr new_value = 0; /* XXX gcc */
431 1.50 skrll int err;
432 1.50 skrll
433 1.50 skrll err = _rtld_relocate_plt_object(obj, a0, &new_value);
434 1.57 christos if (err)
435 1.50 skrll _rtld_die();
436 1.50 skrll
437 1.50 skrll return (caddr_t)new_value;
438 1.50 skrll }
439 1.50 skrll
440 1.50 skrll int
441 1.50 skrll _rtld_relocate_plt_objects(const Obj_Entry *obj)
442 1.50 skrll {
443 1.50 skrll const Elf_Sym *sym = obj->symtab + obj->gotsym;
444 1.54 christos Elf_Word i;
445 1.50 skrll
446 1.50 skrll for (i = obj->gotsym; i < obj->symtabno; i++, sym++) {
447 1.50 skrll if (ELF_ST_TYPE(sym->st_info) == STT_FUNC)
448 1.50 skrll if (_rtld_relocate_plt_object(obj, i, NULL) < 0)
449 1.50 skrll return -1;
450 1.50 skrll }
451 1.50 skrll
452 1.50 skrll return 0;
453 1.1 mhitch }
454