]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/sh/dl-machine.h
[BZ #40]
[thirdparty/glibc.git] / sysdeps / sh / dl-machine.h
1 /* Machine-dependent ELF dynamic relocation inline functions. SH version.
2 Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
3 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
20
21 #ifndef dl_machine_h
22 #define dl_machine_h
23
24 /* Only dummy. This doesn't work. */
25
26 #define ELF_MACHINE_NAME "SH"
27
28 #include <sys/param.h>
29
30 #include <assert.h>
31
32 /* Return nonzero iff ELF header is compatible with the running host. */
33 static inline int __attribute__ ((unused))
34 elf_machine_matches_host (const Elf32_Ehdr *ehdr)
35 {
36 return ehdr->e_machine == EM_SH;
37 }
38
39
40 /* Return the link-time address of _DYNAMIC. Conveniently, this is the
41 first element of the GOT. This must be inlined in a function which
42 uses global data. */
43 static inline Elf32_Addr __attribute__ ((unused))
44 elf_machine_dynamic (void)
45 {
46 register Elf32_Addr *got;
47 asm ("mov r12,%0" :"=r" (got));
48 return *got;
49 }
50
51
52 /* Return the run-time load address of the shared object. */
53 static inline Elf32_Addr __attribute__ ((unused))
54 elf_machine_load_address (void)
55 {
56 Elf32_Addr addr;
57 asm ("mov.l 1f,r0\n\
58 mov.l 3f,r2\n\
59 add r12,r2\n\
60 mov.l @(r0,r12),r0\n\
61 bra 2f\n\
62 sub r0,r2\n\
63 .align 2\n\
64 1: .long _dl_start@GOT\n\
65 3: .long _dl_start@GOTOFF\n\
66 2: mov r2,%0"
67 : "=r" (addr) : : "r0", "r1", "r2");
68 return addr;
69 }
70
71
72 /* Set up the loaded object described by L so its unrelocated PLT
73 entries will jump to the on-demand fixup code in dl-runtime.c. */
74
75 static inline int __attribute__ ((unused))
76 elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
77 {
78 Elf32_Addr *got;
79 extern void _dl_runtime_resolve (Elf32_Word);
80 extern void _dl_runtime_profile (Elf32_Word);
81
82 if (l->l_info[DT_JMPREL] && lazy)
83 {
84 /* The GOT entries for functions in the PLT have not yet been filled
85 in. Their initial contents will arrange when called to load an
86 offset into the .rela.plt section and _GLOBAL_OFFSET_TABLE_[1],
87 and then jump to _GLOBAL_OFFSET_TABLE[2]. */
88 got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]);
89 /* If a library is prelinked but we have to relocate anyway,
90 we have to be able to undo the prelinking of .got.plt.
91 The prelinker saved us here address of .plt + 36. */
92 if (got[1])
93 {
94 l->l_mach.plt = got[1] + l->l_addr;
95 l->l_mach.gotplt = (Elf32_Addr) &got[3];
96 }
97 got[1] = (Elf32_Addr) l; /* Identify this shared object. */
98
99 /* The got[2] entry contains the address of a function which gets
100 called to get the address of a so far unresolved function and
101 jump to it. The profiling extension of the dynamic linker allows
102 to intercept the calls to collect information. In this case we
103 don't store the address in the GOT so that all future calls also
104 end in this function. */
105 if (profile)
106 {
107 got[2] = (Elf32_Addr) &_dl_runtime_profile;
108 /* Say that we really want profiling and the timers are started. */
109 GL(dl_profile_map) = l;
110 }
111 else
112 /* This function will get called to fix up the GOT entry indicated by
113 the offset on the stack, and then jump to the resolved address. */
114 got[2] = (Elf32_Addr) &_dl_runtime_resolve;
115 }
116 return lazy;
117 }
118
119 /* This code is used in dl-runtime.c to call the `fixup' function
120 and then redirect to the address it returns. */
121
122 #define ELF_MACHINE_RUNTIME_FIXUP_ARGS int plt_type
123
124 #ifdef SHARED
125 #define FUN_ADDR "\
126 mov.l 1f,r2\n\
127 mova 1f,r0\n\
128 bra 2f\n\
129 add r0,r2 ! Get GOT address in r2\n\
130 0: .align 2\n\
131 1: .long _GLOBAL_OFFSET_TABLE_\n\
132 2: mov.l 3f,r0\n\
133 add r2,r0"
134 #define GOTJMP(x) #x "@GOTOFF"
135 #else
136 #define FUN_ADDR "\
137 mov.l 3f,r0"
138 #define GOTJMP(x) #x
139 #endif
140
141 #ifdef HAVE_FPU
142 #define FGR_SAVE "\
143 sts.l fpscr, @-r15\n\
144 mov #8,r3\n\
145 swap.w r3, r3\n\
146 lds r3, fpscr\n\
147 fmov.s fr11, @-r15\n\
148 fmov.s fr10, @-r15\n\
149 fmov.s fr9, @-r15\n\
150 fmov.s fr8, @-r15\n\
151 fmov.s fr7, @-r15\n\
152 fmov.s fr6, @-r15\n\
153 fmov.s fr5, @-r15\n\
154 fmov.s fr4, @-r15"
155 #define FGR_LOAD "\
156 fmov.s @r15+, fr4\n\
157 fmov.s @r15+, fr5\n\
158 fmov.s @r15+, fr6\n\
159 fmov.s @r15+, fr7\n\
160 fmov.s @r15+, fr8\n\
161 fmov.s @r15+, fr9\n\
162 fmov.s @r15+, fr10\n\
163 fmov.s @r15+, fr11\n\
164 lds.l @r15+, fpscr"
165 #else
166 #define FGR_SAVE ""
167 #define FGR_LOAD ""
168 #endif
169
170 #ifndef PROF
171 # define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
172 .text\n\
173 .globl _dl_runtime_resolve\n\
174 .type _dl_runtime_resolve, @function\n\
175 .align 5\n\
176 _dl_runtime_resolve:\n\
177 mov.l r2,@-r15\n\
178 mov.l r3,@-r15\n\
179 mov.l r4,@-r15\n\
180 mov.l r5,@-r15\n\
181 mov.l r6,@-r15\n\
182 mov.l r7,@-r15\n\
183 mov.l r12,@-r15\n\
184 movt r3 ! Save T flag.\n\
185 mov.l r3,@-r15\n\
186 " FGR_SAVE "\n\
187 sts.l pr,@-r15\n\
188 tst r0,r0\n\
189 bt 1f\n\
190 mov r0,r2\n\
191 1:\n\
192 mov r0,r4 ! PLT type\n\
193 mov r2,r5 ! link map address\n\
194 " FUN_ADDR "\n\
195 jsr @r0 ! Call resolver.\n\
196 mov r1,r6 ! reloc offset\n\
197 lds.l @r15+,pr ! Get register content back.\n\
198 " FGR_LOAD "\n\
199 mov.l @r15+,r3\n\
200 shal r3 ! Lode T flag.\n\
201 mov.l @r15+,r12\n\
202 mov.l @r15+,r7\n\
203 mov.l @r15+,r6\n\
204 mov.l @r15+,r5\n\
205 mov.l @r15+,r4\n\
206 mov.l @r15+,r3\n\
207 jmp @r0 ! Jump to function address.\n\
208 mov.l @r15+,r2\n\
209 .align 2\n\
210 3:\n\
211 .long " GOTJMP (fixup) "\n\
212 .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
213 \n\
214 .globl _dl_runtime_profile\n\
215 .type _dl_runtime_profile, @function\n\
216 .align 5\n\
217 _dl_runtime_profile:\n\
218 mov.l r2,@-r15\n\
219 mov.l r3,@-r15\n\
220 mov.l r4,@-r15\n\
221 mov.l r5,@-r15\n\
222 mov.l r6,@-r15\n\
223 mov.l r7,@-r15\n\
224 mov.l r12,@-r15\n\
225 movt r3 ! Save T flag.\n\
226 mov.l r3,@-r15\n\
227 " FGR_SAVE "\n\
228 sts.l pr,@-r15\n\
229 tst r0,r0\n\
230 bt 1f\n\
231 mov r0,r2\n\
232 1:\n\
233 mov r0,r4 ! PLT type\n\
234 mov r2,r5 ! link map address\n\
235 sts pr,r7 ! return address\n\
236 " FUN_ADDR "\n\
237 jsr @r0 ! Call resolver.\n\
238 mov r1,r6 ! reloc offset\n\
239 lds.l @r15+,pr ! Get register content back.\n\
240 " FGR_LOAD "\n\
241 mov.l @r15+,r3\n\
242 shal r3 ! Lode T flag.\n\
243 mov.l @r15+,r12\n\
244 mov.l @r15+,r7\n\
245 mov.l @r15+,r6\n\
246 mov.l @r15+,r5\n\
247 mov.l @r15+,r4\n\
248 mov.l @r15+,r3\n\
249 jmp @r0 ! Jump to function address.\n\
250 mov.l @r15+,r2\n\
251 .align 2\n\
252 3:\n\
253 .long " GOTJMP (profile_fixup) "\n\
254 .size _dl_runtime_profile, .-_dl_runtime_profile\n\
255 .previous\n\
256 ");
257 #else
258 # define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
259 .text\n\
260 .globl _dl_runtime_resolve\n\
261 .globl _dl_runtime_profile\n\
262 .type _dl_runtime_resolve, @function\n\
263 .type _dl_runtime_profile, @function\n\
264 .align 5\n\
265 _dl_runtime_resolve:\n\
266 _dl_runtime_profile:\n\
267 mov.l r2,@-r15\n\
268 mov.l r3,@-r15\n\
269 mov.l r4,@-r15\n\
270 mov.l r5,@-r15\n\
271 mov.l r6,@-r15\n\
272 mov.l r7,@-r15\n\
273 mov.l r12,@-r15\n\
274 movt r3 ! Save T flag.\n\
275 mov.l r3,@-r15\n\
276 " FGR_SAVE "\n\
277 sts.l pr,@-r15\n\
278 tst r0,r0\n\
279 bt 1f\n\
280 mov r0,r2\n\
281 1:\n\
282 mov r0,r4 ! PLT type\n\
283 mov r2,r5 ! link map address\n\
284 sts pr,r7 ! return address\n\
285 " FUN_ADDR "\n\
286 jsr @r0 ! Call resolver.\n\
287 mov r1,r6 ! reloc offset\n\
288 lds.l @r15+,pr ! Get register content back.\n\
289 " FGR_LOAD "\n\
290 mov.l @r15+,r3\n\
291 shal r3 ! Lode T flag.\n\
292 mov.l @r15+,r12\n\
293 mov.l @r15+,r7\n\
294 mov.l @r15+,r6\n\
295 mov.l @r15+,r5\n\
296 mov.l @r15+,r4\n\
297 mov.l @r15+,r3\n\
298 jmp @r0 ! Jump to function address.\n\
299 mov.l @r15+,r2\n\
300 .align 2\n\
301 3:\n\
302 .long " GOTJMP (fixup) "\n\
303 .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
304 .size _dl_runtime_profile, .-_dl_runtime_profile\n\
305 .previous\n\
306 ");
307 #endif
308
309 /* Mask identifying addresses reserved for the user program,
310 where the dynamic linker should not map anything. */
311 #define ELF_MACHINE_USER_ADDRESS_MASK 0x80000000UL
312
313 /* Initial entry point code for the dynamic linker.
314 The C function `_dl_start' is the real entry point;
315 its return value is the user program's entry point. */
316
317 #define RTLD_START asm ("\
318 .text\n\
319 .globl _start\n\
320 .globl _dl_start_user\n\
321 _start:\n\
322 mov r15,r4\n\
323 mov.l .L_dl_start,r1\n\
324 mova .L_dl_start,r0\n\
325 add r1,r0\n\
326 jsr @r0\n\
327 nop\n\
328 _dl_start_user:\n\
329 ! Save the user entry point address in r8.\n\
330 mov r0,r8\n\
331 ! Point r12 at the GOT.\n\
332 mov.l 1f,r12\n\
333 mova 1f,r0\n\
334 bra 2f\n\
335 add r0,r12\n\
336 .align 2\n\
337 1: .long _GLOBAL_OFFSET_TABLE_\n\
338 2: ! See if we were run as a command with the executable file\n\
339 ! name as an extra leading argument.\n\
340 mov.l .L_dl_skip_args,r0\n\
341 mov.l @(r0,r12),r0\n\
342 mov.l @r0,r0\n\
343 ! Get the original argument count.\n\
344 mov.l @r15,r5\n\
345 ! Subtract _dl_skip_args from it.\n\
346 sub r0,r5\n\
347 ! Adjust the stack pointer to skip _dl_skip_args words.\n\
348 shll2 r0\n\
349 add r0,r15\n\
350 ! Store back the modified argument count.\n\
351 mov.l r5,@r15\n\
352 ! Compute argv address and envp.\n\
353 mov r15,r6\n\
354 add #4,r6\n\
355 mov r5,r7\n\
356 shll2 r7\n\
357 add r15,r7\n\
358 mov.l .L_dl_loaded,r0\n\
359 mov.l @(r0,r12),r0\n\
360 mov.l @r0,r4\n\
361 ! Call _dl_init.\n\
362 mov.l .L_dl_init,r1\n\
363 mova .L_dl_init,r0\n\
364 add r1,r0\n\
365 jsr @r0\n\
366 nop\n\
367 1: ! Clear the startup flag.\n\
368 mov.l .L_dl_starting_up,r0\n\
369 mov.l @(r0,r12),r0\n\
370 mov #0,r2\n\
371 mov.l r2,@r0\n\
372 ! Pass our finalizer function to the user in r4, as per ELF ABI.\n\
373 mov.l .L_dl_fini,r0\n\
374 mov.l @(r0,r12),r4\n\
375 ! Jump to the user's entry point.\n\
376 jmp @r8\n\
377 nop\n\
378 .align 2\n\
379 .L_dl_start:\n\
380 .long _dl_start@PLT\n\
381 .L_dl_skip_args:\n\
382 .long _dl_skip_args@GOT\n\
383 .L_dl_init:\n\
384 .long _dl_init_internal@PLT\n\
385 .L_dl_loaded:\n\
386 .long _rtld_local@GOT\n\
387 .L_dl_starting_up:\n\
388 .long _dl_starting_up@GOT\n\
389 .L_dl_fini:\n\
390 .long _dl_fini@GOT\n\
391 .previous\n\
392 ");
393
394 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
395 TLS variable, so undefined references should not be allowed to
396 define the value.
397 ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
398 of the main executable's symbols, as for a COPY reloc. */
399 #if defined USE_TLS && (!defined RTLD_BOOTSTRAP || USE___THREAD)
400 # define elf_machine_type_class(type) \
401 ((((type) == R_SH_JMP_SLOT || (type) == R_SH_TLS_DTPMOD32 \
402 || (type) == R_SH_TLS_DTPOFF32 || (type) == R_SH_TLS_TPOFF32) \
403 * ELF_RTYPE_CLASS_PLT) \
404 | (((type) == R_SH_COPY) * ELF_RTYPE_CLASS_COPY))
405 #else
406 #define elf_machine_type_class(type) \
407 ((((type) == R_SH_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
408 | (((type) == R_SH_COPY) * ELF_RTYPE_CLASS_COPY))
409 #endif
410
411 /* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
412 #define ELF_MACHINE_JMP_SLOT R_SH_JMP_SLOT
413
414 /* We define an initialization functions. This is called very early in
415 _dl_sysdep_start. */
416 #define DL_PLATFORM_INIT dl_platform_init ()
417
418 static inline void __attribute__ ((unused))
419 dl_platform_init (void)
420 {
421 if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0')
422 /* Avoid an empty string which would disturb us. */
423 GLRO(dl_platform) = NULL;
424 }
425
426 static inline Elf32_Addr
427 elf_machine_fixup_plt (struct link_map *map, lookup_t t,
428 const Elf32_Rela *reloc,
429 Elf32_Addr *reloc_addr, Elf32_Addr value)
430 {
431 return *reloc_addr = value;
432 }
433
434 /* Return the final value of a plt relocation. */
435 static inline Elf32_Addr
436 elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
437 Elf32_Addr value)
438 {
439 return value + reloc->r_addend;
440 }
441
442 #endif /* !dl_machine_h */
443
444 #ifdef RESOLVE
445
446 /* SH never uses Elf32_Rel relocations. */
447 #define ELF_MACHINE_NO_REL 1
448
449 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
450 MAP is the object containing the reloc. */
451
452 static inline void
453 elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
454 const Elf32_Sym *sym, const struct r_found_version *version,
455 void *const reloc_addr_arg)
456 {
457 Elf32_Addr *const reloc_addr = reloc_addr_arg;
458 const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
459 Elf32_Addr value;
460
461 #define COPY_UNALIGNED_WORD(swp, twp, align) \
462 { \
463 void *__s = (swp), *__t = (twp); \
464 unsigned char *__s1 = __s, *__t1 = __t; \
465 unsigned short *__s2 = __s, *__t2 = __t; \
466 unsigned long *__s4 = __s, *__t4 = __t; \
467 switch ((align)) \
468 { \
469 case 0: \
470 *__t4 = *__s4; \
471 break; \
472 case 2: \
473 *__t2++ = *__s2++; \
474 *__t2 = *__s2; \
475 break; \
476 default: \
477 *__t1++ = *__s1++; \
478 *__t1++ = *__s1++; \
479 *__t1++ = *__s1++; \
480 *__t1 = *__s1; \
481 break; \
482 } \
483 }
484
485 if (__builtin_expect (r_type == R_SH_RELATIVE, 0))
486 {
487 #ifndef RTLD_BOOTSTRAP
488 if (map != &GL(dl_rtld_map)) /* Already done in rtld itself. */
489 #endif
490 {
491 if (reloc->r_addend)
492 value = map->l_addr + reloc->r_addend;
493 else
494 {
495 COPY_UNALIGNED_WORD (reloc_addr_arg, &value,
496 (int) reloc_addr_arg & 3);
497 value += map->l_addr;
498 }
499 COPY_UNALIGNED_WORD (&value, reloc_addr_arg,
500 (int) reloc_addr_arg & 3);
501 }
502 }
503 #ifndef RTLD_BOOTSTRAP
504 else if (__builtin_expect (r_type == R_SH_NONE, 0))
505 return;
506 #endif
507 else
508 {
509 const Elf32_Sym *const refsym = sym;
510 #if defined USE_TLS && !defined RTLD_BOOTSTRAP
511 struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
512
513 value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value;
514 #else
515
516 value = RESOLVE (&sym, version, r_type);
517 # ifndef RTLD_BOOTSTRAP
518 if (sym != NULL)
519 # endif
520 value += sym->st_value;
521 #endif
522 value += reloc->r_addend;
523
524 switch (r_type)
525 {
526 case R_SH_COPY:
527 if (sym == NULL)
528 /* This can happen in trace mode if an object could not be
529 found. */
530 break;
531 if (sym->st_size > refsym->st_size
532 || (sym->st_size < refsym->st_size && GLRO(dl_verbose)))
533 {
534 const char *strtab;
535
536 strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
537 _dl_error_printf ("\
538 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
539 rtld_progname ?: "<program name unknown>",
540 strtab + refsym->st_name);
541 }
542 memcpy (reloc_addr_arg, (void *) value,
543 MIN (sym->st_size, refsym->st_size));
544 break;
545 case R_SH_GLOB_DAT:
546 case R_SH_JMP_SLOT:
547 /* These addresses are always aligned. */
548 *reloc_addr = value;
549 break;
550 #if defined USE_TLS && (!defined RTLD_BOOTSTRAP || USE___THREAD)
551 /* XXX Remove TLS relocations which are not needed. */
552 case R_SH_TLS_DTPMOD32:
553 # ifdef RTLD_BOOTSTRAP
554 /* During startup the dynamic linker is always the module
555 with index 1.
556 XXX If this relocation is necessary move before RESOLVE
557 call. */
558 *reloc_addr = 1;
559 # else
560 /* Get the information from the link map returned by the
561 resolv function. */
562 if (sym_map != NULL)
563 *reloc_addr = sym_map->l_tls_modid;
564 # endif
565 break;
566 case R_SH_TLS_DTPOFF32:
567 # ifndef RTLD_BOOTSTRAP
568 /* During relocation all TLS symbols are defined and used.
569 Therefore the offset is already correct. */
570 if (sym != NULL)
571 *reloc_addr = sym->st_value;
572 # endif
573 break;
574 case R_SH_TLS_TPOFF32:
575 /* The offset is positive, afterward from the thread pointer. */
576 # ifdef RTLD_BOOTSTRAP
577 *reloc_addr = map->l_tls_offset + sym->st_value + reloc->r_addend;
578 # else
579 /* We know the offset of object the symbol is contained in.
580 It is a positive value which will be added to the thread
581 pointer. To get the variable position in the TLS block
582 we add the offset from that of the TLS block. */
583 if (sym != NULL)
584 {
585 CHECK_STATIC_TLS (map, sym_map);
586 *reloc_addr = sym_map->l_tls_offset + sym->st_value
587 + reloc->r_addend;
588 }
589 # endif
590 break;
591 #endif /* use TLS */
592 case R_SH_DIR32:
593 {
594 #ifndef RTLD_BOOTSTRAP
595 /* This is defined in rtld.c, but nowhere in the static
596 libc.a; make the reference weak so static programs can
597 still link. This declaration cannot be done when
598 compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP) because
599 rtld.c contains the common defn for _dl_rtld_map, which
600 is incompatible with a weak decl in the same file. */
601 # ifndef SHARED
602 weak_extern (_dl_rtld_map);
603 # endif
604 if (map == &GL(dl_rtld_map))
605 /* Undo the relocation done here during bootstrapping.
606 Now we will relocate it anew, possibly using a
607 binding found in the user program or a loaded library
608 rather than the dynamic linker's built-in definitions
609 used while loading those libraries. */
610 value -= map->l_addr + refsym->st_value + reloc->r_addend;
611 #endif
612 COPY_UNALIGNED_WORD (&value, reloc_addr_arg,
613 (int) reloc_addr_arg & 3);
614 break;
615 }
616 case R_SH_REL32:
617 value = (value - (Elf32_Addr) reloc_addr);
618 COPY_UNALIGNED_WORD (&value, reloc_addr_arg,
619 (int) reloc_addr_arg & 3);
620 break;
621 default:
622 _dl_reloc_bad_type (map, r_type, 0);
623 break;
624 }
625 }
626 }
627
628 static inline void
629 elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
630 void *const reloc_addr_arg)
631 {
632 Elf32_Addr *const reloc_addr = reloc_addr_arg;
633 Elf32_Addr value;
634
635 if (reloc->r_addend)
636 value = l_addr + reloc->r_addend;
637 else
638 {
639 COPY_UNALIGNED_WORD (reloc_addr_arg, &value, (int) reloc_addr_arg & 3);
640 value += l_addr;
641 }
642 COPY_UNALIGNED_WORD (&value, reloc_addr_arg, (int) reloc_addr_arg & 3);
643
644 #undef COPY_UNALIGNED_WORD
645 }
646
647 static inline void
648 elf_machine_lazy_rel (struct link_map *map,
649 Elf32_Addr l_addr, const Elf32_Rela *reloc)
650 {
651 Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
652 /* Check for unexpected PLT reloc type. */
653 if (ELF32_R_TYPE (reloc->r_info) == R_SH_JMP_SLOT)
654 {
655 if (__builtin_expect (map->l_mach.plt, 0) == 0)
656 *reloc_addr += l_addr;
657 else
658 *reloc_addr =
659 map->l_mach.plt
660 + (((Elf32_Addr) reloc_addr) - map->l_mach.gotplt) * 7;
661 }
662 else
663 _dl_reloc_bad_type (map, ELF32_R_TYPE (reloc->r_info), 1);
664 }
665
666 #endif /* RESOLVE */