Move all files into ports/ subdirectory in preparation for merge with glibc
[glibc.git] / ports / sysdeps / arm / dl-machine.h
blob8d905e8ad9e54424b3142feb0c8ec63994039417
1 /* Machine-dependent ELF dynamic relocation inline functions. ARM version.
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,
3 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
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.
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.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library. If not, see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef dl_machine_h
21 #define dl_machine_h
23 #define ELF_MACHINE_NAME "ARM"
25 #include <sys/param.h>
26 #include <tls.h>
27 #include <dl-tlsdesc.h>
28 #include <dl-irel.h>
30 #define CLEAR_CACHE(BEG,END) \
31 INTERNAL_SYSCALL_ARM (cacheflush, , 3, (BEG), (END), 0)
33 /* Return nonzero iff ELF header is compatible with the running host. */
34 static inline int __attribute__ ((unused))
35 elf_machine_matches_host (const Elf32_Ehdr *ehdr)
37 return ehdr->e_machine == EM_ARM;
41 /* Return the link-time address of _DYNAMIC. Conveniently, this is the
42 first element of the GOT. We used to use the PIC register to do this
43 without a constant pool reference, but GCC 4.2 will use a pseudo-register
44 for the PIC base, so it may not be in r10. */
45 static inline Elf32_Addr __attribute__ ((unused))
46 elf_machine_dynamic (void)
48 Elf32_Addr dynamic;
49 #ifdef __thumb2__
50 long tmp;
51 asm ("ldr\t%0, 1f\n\t"
52 "adr\t%1, 1f\n\t"
53 "ldr\t%0, [%0, %1]\n\t"
54 "b 2f\n"
55 ".align 2\n"
56 "1: .word _GLOBAL_OFFSET_TABLE_ - 1b\n"
57 "2:" : "=r" (dynamic), "=r"(tmp));
58 #else
59 asm ("ldr %0, 2f\n"
60 "1: ldr %0, [pc, %0]\n"
61 "b 3f\n"
62 "2: .word _GLOBAL_OFFSET_TABLE_ - (1b+8)\n"
63 "3:" : "=r" (dynamic));
64 #endif
65 return dynamic;
69 /* Return the run-time load address of the shared object. */
70 static inline Elf32_Addr __attribute__ ((unused))
71 elf_machine_load_address (void)
73 extern void __dl_start asm ("_dl_start");
74 Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
75 Elf32_Addr pcrel_addr;
76 #ifdef __thumb__
77 /* Clear the low bit of the funciton address. */
78 got_addr &= ~(Elf32_Addr) 1;
79 #endif
80 asm ("adr %0, _dl_start" : "=r" (pcrel_addr));
81 return pcrel_addr - got_addr;
85 /* Set up the loaded object described by L so its unrelocated PLT
86 entries will jump to the on-demand fixup code in dl-runtime.c. */
88 static inline int __attribute__ ((unused))
89 elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
91 Elf32_Addr *got;
92 extern void _dl_runtime_resolve (Elf32_Word);
93 extern void _dl_runtime_profile (Elf32_Word);
95 if (l->l_info[DT_JMPREL] && lazy)
97 /* patb: this is different than i386 */
98 /* The GOT entries for functions in the PLT have not yet been filled
99 in. Their initial contents will arrange when called to push an
100 index into the .got section, load ip with &_GLOBAL_OFFSET_TABLE_[3],
101 and then jump to _GLOBAL_OFFSET_TABLE[2]. */
102 got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]);
103 /* If a library is prelinked but we have to relocate anyway,
104 we have to be able to undo the prelinking of .got.plt.
105 The prelinker saved us here address of .plt. */
106 if (got[1])
107 l->l_mach.plt = got[1] + l->l_addr;
108 got[1] = (Elf32_Addr) l; /* Identify this shared object. */
110 /* The got[2] entry contains the address of a function which gets
111 called to get the address of a so far unresolved function and
112 jump to it. The profiling extension of the dynamic linker allows
113 to intercept the calls to collect information. In this case we
114 don't store the address in the GOT so that all future calls also
115 end in this function. */
116 if (profile)
118 got[2] = (Elf32_Addr) &_dl_runtime_profile;
120 if (GLRO(dl_profile) != NULL
121 && _dl_name_match_p (GLRO(dl_profile), l))
122 /* Say that we really want profiling and the timers are
123 started. */
124 GL(dl_profile_map) = l;
126 else
127 /* This function will get called to fix up the GOT entry indicated by
128 the offset on the stack, and then jump to the resolved address. */
129 got[2] = (Elf32_Addr) &_dl_runtime_resolve;
132 if (l->l_info[ADDRIDX (DT_TLSDESC_GOT)] && lazy)
133 *(Elf32_Addr*)(D_PTR (l, l_info[ADDRIDX (DT_TLSDESC_GOT)]) + l->l_addr)
134 = (Elf32_Addr) &_dl_tlsdesc_lazy_resolver;
136 return lazy;
139 #if defined(__USE_BX__)
140 #define BX(x) "bx\t" #x
141 #else
142 #define BX(x) "mov\tpc, " #x
143 #endif
145 /* Mask identifying addresses reserved for the user program,
146 where the dynamic linker should not map anything. */
147 #define ELF_MACHINE_USER_ADDRESS_MASK 0xf8000000UL
149 /* Initial entry point code for the dynamic linker.
150 The C function `_dl_start' is the real entry point;
151 its return value is the user program's entry point. */
153 #define RTLD_START asm ("\
154 .text\n\
155 .globl _start\n\
156 .type _start, %function\n\
157 .globl _dl_start_user\n\
158 .type _dl_start_user, %function\n\
159 _start:\n\
160 @ we are PIC code, so get global offset table\n\
161 ldr sl, .L_GET_GOT\n\
162 @ See if we were run as a command with the executable file\n\
163 @ name as an extra leading argument.\n\
164 ldr r4, .L_SKIP_ARGS\n\
165 @ at start time, all the args are on the stack\n\
166 mov r0, sp\n\
167 bl _dl_start\n\
168 @ returns user entry point in r0\n\
169 _dl_start_user:\n\
170 adr r6, .L_GET_GOT\n\
171 add sl, sl, r6\n\
172 ldr r4, [sl, r4]\n\
173 @ save the entry point in another register\n\
174 mov r6, r0\n\
175 @ get the original arg count\n\
176 ldr r1, [sp]\n\
177 @ get the argv address\n\
178 add r2, sp, #4\n\
179 @ Fix up the stack if necessary.\n\
180 cmp r4, #0\n\
181 bne .L_fixup_stack\n\
182 .L_done_fixup:\n\
183 @ compute envp\n\
184 add r3, r2, r1, lsl #2\n\
185 add r3, r3, #4\n\
186 @ now we call _dl_init\n\
187 ldr r0, .L_LOADED\n\
188 ldr r0, [sl, r0]\n\
189 @ call _dl_init\n\
190 bl _dl_init_internal(PLT)\n\
191 @ load the finalizer function\n\
192 ldr r0, .L_FINI_PROC\n\
193 add r0, sl, r0\n\
194 @ jump to the user_s entry point\n\
195 " BX(r6) "\n\
197 @ iWMMXt and EABI targets require the stack to be eight byte\n\
198 @ aligned - shuffle arguments etc.\n\
199 .L_fixup_stack:\n\
200 @ subtract _dl_skip_args from original arg count\n\
201 sub r1, r1, r4\n\
202 @ store the new argc in the new stack location\n\
203 str r1, [sp]\n\
204 @ find the first unskipped argument\n\
205 mov r3, r2\n\
206 add r4, r2, r4, lsl #2\n\
207 @ shuffle argv down\n\
208 1: ldr r5, [r4], #4\n\
209 str r5, [r3], #4\n\
210 cmp r5, #0\n\
211 bne 1b\n\
212 @ shuffle envp down\n\
213 1: ldr r5, [r4], #4\n\
214 str r5, [r3], #4\n\
215 cmp r5, #0\n\
216 bne 1b\n\
217 @ shuffle auxv down\n\
218 1: ldmia r4!, {r0, r5}\n\
219 stmia r3!, {r0, r5}\n\
220 cmp r0, #0\n\
221 bne 1b\n\
222 @ Update _dl_argv\n\
223 ldr r3, .L_ARGV\n\
224 str r2, [sl, r3]\n\
225 b .L_done_fixup\n\
227 .L_GET_GOT:\n\
228 .word _GLOBAL_OFFSET_TABLE_ - .L_GET_GOT\n\
229 .L_SKIP_ARGS:\n\
230 .word _dl_skip_args(GOTOFF)\n\
231 .L_FINI_PROC:\n\
232 .word _dl_fini(GOTOFF)\n\
233 .L_ARGV:\n\
234 .word _dl_argv(GOTOFF)\n\
235 .L_LOADED:\n\
236 .word _rtld_local(GOTOFF)\n\
237 .previous\n\
240 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
241 TLS variable, so undefined references should not be allowed to
242 define the value.
243 ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
244 of the main executable's symbols, as for a COPY reloc. */
245 #ifndef RTLD_BOOTSTRAP
246 # define elf_machine_type_class(type) \
247 ((((type) == R_ARM_JUMP_SLOT || (type) == R_ARM_TLS_DTPMOD32 \
248 || (type) == R_ARM_TLS_DTPOFF32 || (type) == R_ARM_TLS_TPOFF32 \
249 || (type) == R_ARM_TLS_DESC) \
250 * ELF_RTYPE_CLASS_PLT) \
251 | (((type) == R_ARM_COPY) * ELF_RTYPE_CLASS_COPY))
252 #else
253 #define elf_machine_type_class(type) \
254 ((((type) == R_ARM_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
255 | (((type) == R_ARM_COPY) * ELF_RTYPE_CLASS_COPY))
256 #endif
258 /* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
259 #define ELF_MACHINE_JMP_SLOT R_ARM_JUMP_SLOT
261 /* ARM never uses Elf32_Rela relocations for the dynamic linker.
262 Prelinked libraries may use Elf32_Rela though. */
263 #define ELF_MACHINE_PLT_REL 1
265 /* We define an initialization functions. This is called very early in
266 _dl_sysdep_start. */
267 #define DL_PLATFORM_INIT dl_platform_init ()
269 static inline void __attribute__ ((unused))
270 dl_platform_init (void)
272 if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0')
273 /* Avoid an empty string which would disturb us. */
274 GLRO(dl_platform) = NULL;
277 static inline Elf32_Addr
278 elf_machine_fixup_plt (struct link_map *map, lookup_t t,
279 const Elf32_Rel *reloc,
280 Elf32_Addr *reloc_addr, Elf32_Addr value)
282 return *reloc_addr = value;
285 /* Return the final value of a plt relocation. */
286 static inline Elf32_Addr
287 elf_machine_plt_value (struct link_map *map, const Elf32_Rel *reloc,
288 Elf32_Addr value)
290 return value;
293 #endif /* !dl_machine_h */
296 /* ARM never uses Elf32_Rela relocations for the dynamic linker.
297 Prelinked libraries may use Elf32_Rela though. */
298 #define ELF_MACHINE_NO_RELA defined RTLD_BOOTSTRAP
300 /* Names of the architecture-specific auditing callback functions. */
301 #define ARCH_LA_PLTENTER arm_gnu_pltenter
302 #define ARCH_LA_PLTEXIT arm_gnu_pltexit
304 #ifdef RESOLVE_MAP
306 /* Deal with an out-of-range PC24 reloc. */
307 auto Elf32_Addr
308 fix_bad_pc24 (Elf32_Addr *const reloc_addr, Elf32_Addr value)
310 static void *fix_page;
311 static unsigned int fix_offset;
312 static size_t pagesize;
313 Elf32_Word *fix_address;
315 if (! fix_page)
317 if (! pagesize)
318 pagesize = getpagesize ();
319 fix_page = mmap (NULL, pagesize, PROT_READ | PROT_WRITE | PROT_EXEC,
320 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
321 if (! fix_page)
322 assert (! "could not map page for fixup");
323 fix_offset = 0;
326 fix_address = (Elf32_Word *)(fix_page + fix_offset);
327 fix_address[0] = 0xe51ff004; /* ldr pc, [pc, #-4] */
328 fix_address[1] = value;
330 fix_offset += 8;
331 if (fix_offset >= pagesize)
332 fix_page = NULL;
334 return (Elf32_Addr)fix_address;
337 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
338 MAP is the object containing the reloc. */
340 auto inline void
341 __attribute__ ((always_inline))
342 elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
343 const Elf32_Sym *sym, const struct r_found_version *version,
344 void *const reloc_addr_arg, int skip_ifunc)
346 Elf32_Addr *const reloc_addr = reloc_addr_arg;
347 const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
349 #if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC
350 if (__builtin_expect (r_type == R_ARM_RELATIVE, 0))
352 # if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC
353 /* This is defined in rtld.c, but nowhere in the static libc.a;
354 make the reference weak so static programs can still link.
355 This declaration cannot be done when compiling rtld.c
356 (i.e. #ifdef RTLD_BOOTSTRAP) because rtld.c contains the
357 common defn for _dl_rtld_map, which is incompatible with a
358 weak decl in the same file. */
359 # ifndef SHARED
360 weak_extern (_dl_rtld_map);
361 # endif
362 if (map != &GL(dl_rtld_map)) /* Already done in rtld itself. */
363 # endif
364 *reloc_addr += map->l_addr;
366 # ifndef RTLD_BOOTSTRAP
367 else if (__builtin_expect (r_type == R_ARM_NONE, 0))
368 return;
369 # endif
370 else
371 #endif
373 const Elf32_Sym *const refsym = sym;
374 struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
375 Elf32_Addr value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
377 if (sym != NULL
378 && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
379 && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1)
380 && __builtin_expect (!skip_ifunc, 1))
381 value = elf_ifunc_invoke (value);
383 switch (r_type)
385 case R_ARM_COPY:
386 if (sym == NULL)
387 /* This can happen in trace mode if an object could not be
388 found. */
389 break;
390 if (sym->st_size > refsym->st_size
391 || (GLRO(dl_verbose) && sym->st_size < refsym->st_size))
393 const char *strtab;
395 strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
396 _dl_error_printf ("\
397 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
398 rtld_progname ?: "<program name unknown>",
399 strtab + refsym->st_name);
401 memcpy (reloc_addr_arg, (void *) value,
402 MIN (sym->st_size, refsym->st_size));
403 break;
404 case R_ARM_GLOB_DAT:
405 case R_ARM_JUMP_SLOT:
406 # ifdef RTLD_BOOTSTRAP
407 /* Fix weak undefined references. */
408 if (sym != NULL && sym->st_value == 0)
409 *reloc_addr = 0;
410 else
411 # endif
412 *reloc_addr = value;
413 break;
414 case R_ARM_ABS32:
416 # ifndef RTLD_BOOTSTRAP
417 /* This is defined in rtld.c, but nowhere in the static
418 libc.a; make the reference weak so static programs can
419 still link. This declaration cannot be done when
420 compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP) because
421 rtld.c contains the common defn for _dl_rtld_map, which
422 is incompatible with a weak decl in the same file. */
423 # ifndef SHARED
424 weak_extern (_dl_rtld_map);
425 # endif
426 if (map == &GL(dl_rtld_map))
427 /* Undo the relocation done here during bootstrapping.
428 Now we will relocate it anew, possibly using a
429 binding found in the user program or a loaded library
430 rather than the dynamic linker's built-in definitions
431 used while loading those libraries. */
432 value -= map->l_addr + refsym->st_value;
433 # endif
434 *reloc_addr += value;
435 break;
437 case R_ARM_TLS_DESC:
439 struct tlsdesc volatile *td =
440 (struct tlsdesc volatile *)reloc_addr;
442 # ifndef RTLD_BOOTSTRAP
443 if (! sym)
444 td->entry = _dl_tlsdesc_undefweak;
445 else
446 # endif
448 value = sym->st_value + td->argument.value;
450 # ifndef RTLD_BOOTSTRAP
451 # ifndef SHARED
452 CHECK_STATIC_TLS (map, sym_map);
453 # else
454 if (!TRY_STATIC_TLS (map, sym_map))
456 td->argument.pointer
457 = _dl_make_tlsdesc_dynamic (sym_map, value);
458 td->entry = _dl_tlsdesc_dynamic;
460 else
461 # endif
462 # endif
464 td->argument.value = value + sym_map->l_tls_offset;
465 td->entry = _dl_tlsdesc_return;
469 break;
470 case R_ARM_PC24:
472 Elf32_Sword addend;
473 Elf32_Addr newvalue, topbits;
475 addend = *reloc_addr & 0x00ffffff;
476 if (addend & 0x00800000) addend |= 0xff000000;
478 newvalue = value - (Elf32_Addr)reloc_addr + (addend << 2);
479 topbits = newvalue & 0xfe000000;
480 if (topbits != 0xfe000000 && topbits != 0x00000000)
482 newvalue = fix_bad_pc24(reloc_addr, value)
483 - (Elf32_Addr)reloc_addr + (addend << 2);
484 topbits = newvalue & 0xfe000000;
485 if (topbits != 0xfe000000 && topbits != 0x00000000)
487 _dl_signal_error (0, map->l_name, NULL,
488 "R_ARM_PC24 relocation out of range");
491 newvalue >>= 2;
492 value = (*reloc_addr & 0xff000000) | (newvalue & 0x00ffffff);
493 *reloc_addr = value;
495 break;
496 #if !defined RTLD_BOOTSTRAP
497 case R_ARM_TLS_DTPMOD32:
498 /* Get the information from the link map returned by the
499 resolv function. */
500 if (sym_map != NULL)
501 *reloc_addr = sym_map->l_tls_modid;
502 break;
504 case R_ARM_TLS_DTPOFF32:
505 if (sym != NULL)
506 *reloc_addr += sym->st_value;
507 break;
509 case R_ARM_TLS_TPOFF32:
510 if (sym != NULL)
512 CHECK_STATIC_TLS (map, sym_map);
513 *reloc_addr += sym->st_value + sym_map->l_tls_offset;
515 break;
516 case R_ARM_IRELATIVE:
517 value = map->l_addr + *reloc_addr;
518 value = ((Elf32_Addr (*) (void)) value) ();
519 *reloc_addr = value;
520 break;
521 #endif
522 default:
523 _dl_reloc_bad_type (map, r_type, 0);
524 break;
529 # ifndef RTLD_BOOTSTRAP
530 auto inline void
531 __attribute__ ((always_inline))
532 elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
533 const Elf32_Sym *sym, const struct r_found_version *version,
534 void *const reloc_addr_arg, int skip_ifunc)
536 Elf32_Addr *const reloc_addr = reloc_addr_arg;
537 const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
539 if (__builtin_expect (r_type == R_ARM_RELATIVE, 0))
540 *reloc_addr = map->l_addr + reloc->r_addend;
541 else if (__builtin_expect (r_type == R_ARM_NONE, 0))
542 return;
543 else
545 # ifndef RESOLVE_CONFLICT_FIND_MAP
546 const Elf32_Sym *const refsym = sym;
547 # endif
548 struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
549 Elf32_Addr value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
551 if (sym != NULL
552 && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
553 && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1)
554 && __builtin_expect (!skip_ifunc, 1))
555 value = elf_ifunc_invoke (value);
557 switch (r_type)
559 # ifndef RESOLVE_CONFLICT_FIND_MAP
560 /* Not needed for dl-conflict.c. */
561 case R_ARM_COPY:
562 if (sym == NULL)
563 /* This can happen in trace mode if an object could not be
564 found. */
565 break;
566 if (sym->st_size > refsym->st_size
567 || (GLRO(dl_verbose) && sym->st_size < refsym->st_size))
569 const char *strtab;
571 strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
572 _dl_error_printf ("\
573 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
574 rtld_progname ?: "<program name unknown>",
575 strtab + refsym->st_name);
577 memcpy (reloc_addr_arg, (void *) value,
578 MIN (sym->st_size, refsym->st_size));
579 break;
580 # endif /* !RESOLVE_CONFLICT_FIND_MAP */
581 case R_ARM_GLOB_DAT:
582 case R_ARM_JUMP_SLOT:
583 case R_ARM_ABS32:
584 *reloc_addr = value + reloc->r_addend;
585 break;
586 case R_ARM_PC24:
588 Elf32_Addr newvalue, topbits;
590 newvalue = value + reloc->r_addend - (Elf32_Addr)reloc_addr;
591 topbits = newvalue & 0xfe000000;
592 if (topbits != 0xfe000000 && topbits != 0x00000000)
594 newvalue = fix_bad_pc24(reloc_addr, value)
595 - (Elf32_Addr)reloc_addr + (reloc->r_addend << 2);
596 topbits = newvalue & 0xfe000000;
597 if (topbits != 0xfe000000 && topbits != 0x00000000)
599 _dl_signal_error (0, map->l_name, NULL,
600 "R_ARM_PC24 relocation out of range");
603 newvalue >>= 2;
604 value = (*reloc_addr & 0xff000000) | (newvalue & 0x00ffffff);
605 *reloc_addr = value;
607 break;
608 #if !defined RTLD_BOOTSTRAP
609 case R_ARM_TLS_DTPMOD32:
610 /* Get the information from the link map returned by the
611 resolv function. */
612 if (sym_map != NULL)
613 *reloc_addr = sym_map->l_tls_modid;
614 break;
616 case R_ARM_TLS_DTPOFF32:
617 *reloc_addr = (sym == NULL ? 0 : sym->st_value) + reloc->r_addend;
618 break;
620 case R_ARM_TLS_TPOFF32:
621 if (sym != NULL)
623 CHECK_STATIC_TLS (map, sym_map);
624 *reloc_addr = (sym->st_value + sym_map->l_tls_offset
625 + reloc->r_addend);
627 break;
628 case R_ARM_IRELATIVE:
629 value = map->l_addr + *reloc_addr;
630 value = ((Elf32_Addr (*) (void)) value) ();
631 *reloc_addr = value;
632 break;
633 #endif
634 default:
635 _dl_reloc_bad_type (map, r_type, 0);
636 break;
640 # endif
642 auto inline void
643 __attribute__ ((always_inline))
644 elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc,
645 void *const reloc_addr_arg)
647 Elf32_Addr *const reloc_addr = reloc_addr_arg;
648 *reloc_addr += l_addr;
651 # ifndef RTLD_BOOTSTRAP
652 auto inline void
653 __attribute__ ((always_inline))
654 elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
655 void *const reloc_addr_arg)
657 Elf32_Addr *const reloc_addr = reloc_addr_arg;
658 *reloc_addr = l_addr + reloc->r_addend;
660 # endif
662 auto inline void
663 __attribute__ ((always_inline))
664 elf_machine_lazy_rel (struct link_map *map,
665 Elf32_Addr l_addr, const Elf32_Rel *reloc,
666 int skip_ifunc)
668 Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
669 const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
670 /* Check for unexpected PLT reloc type. */
671 if (__builtin_expect (r_type == R_ARM_JUMP_SLOT, 1))
673 if (__builtin_expect (map->l_mach.plt, 0) == 0)
674 *reloc_addr += l_addr;
675 else
676 *reloc_addr = map->l_mach.plt;
678 else if (__builtin_expect (r_type == R_ARM_TLS_DESC, 1))
680 struct tlsdesc volatile *td =
681 (struct tlsdesc volatile *)reloc_addr;
683 /* The linker must have given us the parameter we need in the
684 first GOT entry, and left the second one empty. We fill the
685 last with the resolver address */
686 assert (td->entry == 0);
687 td->entry = (void*)(D_PTR (map, l_info[ADDRIDX (DT_TLSDESC_PLT)])
688 + map->l_addr);
690 else
691 _dl_reloc_bad_type (map, r_type, 1);
694 #endif /* RESOLVE_MAP */