conformtest: clean up POSIX expectations for unistd.h.
[glibc.git] / sysdeps / arm / dl-machine.h
blobf9015382554103bce84ea198eb509534eba74d14
1 /* Machine-dependent ELF dynamic relocation inline functions. ARM version.
2 Copyright (C) 1995-2015 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef dl_machine_h
20 #define dl_machine_h
22 #define ELF_MACHINE_NAME "ARM"
24 #include <sys/param.h>
25 #include <tls.h>
26 #include <dl-tlsdesc.h>
27 #include <dl-irel.h>
29 #ifndef CLEAR_CACHE
30 # error CLEAR_CACHE definition required to handle TEXTREL
31 #endif
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. */
43 static inline Elf32_Addr __attribute__ ((unused))
44 elf_machine_dynamic (void)
46 /* Declaring this hidden ensures that a PC-relative reference is used. */
47 extern const Elf32_Addr _GLOBAL_OFFSET_TABLE_[] attribute_hidden;
48 return _GLOBAL_OFFSET_TABLE_[0];
52 /* Return the run-time load address of the shared object. */
53 static inline Elf32_Addr __attribute__ ((unused))
54 elf_machine_load_address (void)
56 extern Elf32_Addr internal_function __dl_start (void *) asm ("_dl_start");
57 Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
58 Elf32_Addr pcrel_addr;
59 #ifdef __thumb__
60 /* Clear the low bit of the funciton address. */
61 got_addr &= ~(Elf32_Addr) 1;
62 #endif
63 asm ("adr %0, _dl_start" : "=r" (pcrel_addr));
64 return pcrel_addr - got_addr;
68 /* Set up the loaded object described by L so its unrelocated PLT
69 entries will jump to the on-demand fixup code in dl-runtime.c. */
71 static inline int __attribute__ ((unused))
72 elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
74 Elf32_Addr *got;
75 extern void _dl_runtime_resolve (Elf32_Word);
76 extern void _dl_runtime_profile (Elf32_Word);
78 if (l->l_info[DT_JMPREL] && lazy)
80 /* patb: this is different than i386 */
81 /* The GOT entries for functions in the PLT have not yet been filled
82 in. Their initial contents will arrange when called to push an
83 index into the .got section, load ip with &_GLOBAL_OFFSET_TABLE_[3],
84 and then jump to _GLOBAL_OFFSET_TABLE[2]. */
85 got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]);
86 /* If a library is prelinked but we have to relocate anyway,
87 we have to be able to undo the prelinking of .got.plt.
88 The prelinker saved us here address of .plt. */
89 if (got[1])
90 l->l_mach.plt = got[1] + l->l_addr;
91 got[1] = (Elf32_Addr) l; /* Identify this shared object. */
93 /* The got[2] entry contains the address of a function which gets
94 called to get the address of a so far unresolved function and
95 jump to it. The profiling extension of the dynamic linker allows
96 to intercept the calls to collect information. In this case we
97 don't store the address in the GOT so that all future calls also
98 end in this function. */
99 if (profile)
101 got[2] = (Elf32_Addr) &_dl_runtime_profile;
103 if (GLRO(dl_profile) != NULL
104 && _dl_name_match_p (GLRO(dl_profile), l))
105 /* Say that we really want profiling and the timers are
106 started. */
107 GL(dl_profile_map) = l;
109 else
110 /* This function will get called to fix up the GOT entry indicated by
111 the offset on the stack, and then jump to the resolved address. */
112 got[2] = (Elf32_Addr) &_dl_runtime_resolve;
115 if (l->l_info[ADDRIDX (DT_TLSDESC_GOT)] && lazy)
116 *(Elf32_Addr*)(D_PTR (l, l_info[ADDRIDX (DT_TLSDESC_GOT)]) + l->l_addr)
117 = (Elf32_Addr) &_dl_tlsdesc_lazy_resolver;
119 return lazy;
122 #if defined(ARCH_HAS_BX)
123 #define BX(x) "bx\t" #x
124 #else
125 #define BX(x) "mov\tpc, " #x
126 #endif
128 /* Mask identifying addresses reserved for the user program,
129 where the dynamic linker should not map anything. */
130 #define ELF_MACHINE_USER_ADDRESS_MASK 0xf8000000UL
132 /* Initial entry point code for the dynamic linker.
133 The C function `_dl_start' is the real entry point;
134 its return value is the user program's entry point. */
136 #define RTLD_START asm ("\
137 .text\n\
138 .globl _start\n\
139 .type _start, %function\n\
140 .globl _dl_start_user\n\
141 .type _dl_start_user, %function\n\
142 _start:\n\
143 @ we are PIC code, so get global offset table\n\
144 ldr sl, .L_GET_GOT\n\
145 @ See if we were run as a command with the executable file\n\
146 @ name as an extra leading argument.\n\
147 ldr r4, .L_SKIP_ARGS\n\
148 @ at start time, all the args are on the stack\n\
149 mov r0, sp\n\
150 bl _dl_start\n\
151 @ returns user entry point in r0\n\
152 _dl_start_user:\n\
153 adr r6, .L_GET_GOT\n\
154 add sl, sl, r6\n\
155 ldr r4, [sl, r4]\n\
156 @ save the entry point in another register\n\
157 mov r6, r0\n\
158 @ get the original arg count\n\
159 ldr r1, [sp]\n\
160 @ get the argv address\n\
161 add r2, sp, #4\n\
162 @ Fix up the stack if necessary.\n\
163 cmp r4, #0\n\
164 bne .L_fixup_stack\n\
165 .L_done_fixup:\n\
166 @ compute envp\n\
167 add r3, r2, r1, lsl #2\n\
168 add r3, r3, #4\n\
169 @ now we call _dl_init\n\
170 ldr r0, .L_LOADED\n\
171 ldr r0, [sl, r0]\n\
172 @ call _dl_init\n\
173 bl _dl_init(PLT)\n\
174 @ load the finalizer function\n\
175 ldr r0, .L_FINI_PROC\n\
176 add r0, sl, r0\n\
177 @ jump to the user_s entry point\n\
178 " BX(r6) "\n\
180 @ iWMMXt and EABI targets require the stack to be eight byte\n\
181 @ aligned - shuffle arguments etc.\n\
182 .L_fixup_stack:\n\
183 @ subtract _dl_skip_args from original arg count\n\
184 sub r1, r1, r4\n\
185 @ store the new argc in the new stack location\n\
186 str r1, [sp]\n\
187 @ find the first unskipped argument\n\
188 mov r3, r2\n\
189 add r4, r2, r4, lsl #2\n\
190 @ shuffle argv down\n\
191 1: ldr r5, [r4], #4\n\
192 str r5, [r3], #4\n\
193 cmp r5, #0\n\
194 bne 1b\n\
195 @ shuffle envp down\n\
196 1: ldr r5, [r4], #4\n\
197 str r5, [r3], #4\n\
198 cmp r5, #0\n\
199 bne 1b\n\
200 @ shuffle auxv down\n\
201 1: ldmia r4!, {r0, r5}\n\
202 stmia r3!, {r0, r5}\n\
203 cmp r0, #0\n\
204 bne 1b\n\
205 @ Update _dl_argv\n\
206 ldr r3, .L_ARGV\n\
207 str r2, [sl, r3]\n\
208 b .L_done_fixup\n\
210 .L_GET_GOT:\n\
211 .word _GLOBAL_OFFSET_TABLE_ - .L_GET_GOT\n\
212 .L_SKIP_ARGS:\n\
213 .word _dl_skip_args(GOTOFF)\n\
214 .L_FINI_PROC:\n\
215 .word _dl_fini(GOTOFF)\n\
216 .L_ARGV:\n\
217 .word _dl_argv(GOTOFF)\n\
218 .L_LOADED:\n\
219 .word _rtld_local(GOTOFF)\n\
220 .previous\n\
223 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
224 TLS variable, so undefined references should not be allowed to
225 define the value.
226 ELF_RTYPE_CLASS_COPY iff TYPE should not be allowed to resolve to one
227 of the main executable's symbols, as for a COPY reloc. */
228 #ifndef RTLD_BOOTSTRAP
229 # define elf_machine_type_class(type) \
230 ((((type) == R_ARM_JUMP_SLOT || (type) == R_ARM_TLS_DTPMOD32 \
231 || (type) == R_ARM_TLS_DTPOFF32 || (type) == R_ARM_TLS_TPOFF32 \
232 || (type) == R_ARM_TLS_DESC) \
233 * ELF_RTYPE_CLASS_PLT) \
234 | (((type) == R_ARM_COPY) * ELF_RTYPE_CLASS_COPY))
235 #else
236 #define elf_machine_type_class(type) \
237 ((((type) == R_ARM_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
238 | (((type) == R_ARM_COPY) * ELF_RTYPE_CLASS_COPY))
239 #endif
241 /* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
242 #define ELF_MACHINE_JMP_SLOT R_ARM_JUMP_SLOT
244 /* ARM never uses Elf32_Rela relocations for the dynamic linker.
245 Prelinked libraries may use Elf32_Rela though. */
246 #define ELF_MACHINE_PLT_REL 1
248 /* We define an initialization functions. This is called very early in
249 _dl_sysdep_start. */
250 #define DL_PLATFORM_INIT dl_platform_init ()
252 static inline void __attribute__ ((unused))
253 dl_platform_init (void)
255 if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0')
256 /* Avoid an empty string which would disturb us. */
257 GLRO(dl_platform) = NULL;
260 static inline Elf32_Addr
261 elf_machine_fixup_plt (struct link_map *map, lookup_t t,
262 const Elf32_Rel *reloc,
263 Elf32_Addr *reloc_addr, Elf32_Addr value)
265 return *reloc_addr = value;
268 /* Return the final value of a plt relocation. */
269 static inline Elf32_Addr
270 elf_machine_plt_value (struct link_map *map, const Elf32_Rel *reloc,
271 Elf32_Addr value)
273 return value;
276 #endif /* !dl_machine_h */
279 /* ARM never uses Elf32_Rela relocations for the dynamic linker.
280 Prelinked libraries may use Elf32_Rela though. */
281 #define ELF_MACHINE_NO_RELA defined RTLD_BOOTSTRAP
282 #define ELF_MACHINE_NO_REL 0
284 /* Names of the architecture-specific auditing callback functions. */
285 #define ARCH_LA_PLTENTER arm_gnu_pltenter
286 #define ARCH_LA_PLTEXIT arm_gnu_pltexit
288 #ifdef RESOLVE_MAP
289 /* Handle a PC24 reloc, including the out-of-range case. */
290 auto void
291 relocate_pc24 (struct link_map *map, Elf32_Addr value,
292 Elf32_Addr *const reloc_addr, Elf32_Sword addend)
294 Elf32_Addr new_value;
296 /* Set NEW_VALUE based on V, and return true iff it overflows 24 bits. */
297 inline bool set_new_value (Elf32_Addr v)
299 new_value = v + addend - (Elf32_Addr) reloc_addr;
300 Elf32_Addr topbits = new_value & 0xfe000000;
301 return topbits != 0xfe000000 && topbits != 0x00000000;
304 if (set_new_value (value))
306 /* The PC-relative address doesn't fit in 24 bits! */
308 static void *fix_page;
309 static size_t fix_offset;
310 if (fix_page == NULL)
312 void *new_page = __mmap (NULL, GLRO(dl_pagesize),
313 PROT_READ | PROT_WRITE | PROT_EXEC,
314 MAP_PRIVATE | MAP_ANON, -1, 0);
315 if (new_page == MAP_FAILED)
316 _dl_signal_error (0, map->l_name, NULL,
317 "could not map page for fixup");
318 fix_page = new_page;
319 assert (fix_offset == 0);
322 Elf32_Word *fix_address = fix_page + fix_offset;
323 fix_address[0] = 0xe51ff004; /* ldr pc, [pc, #-4] */
324 fix_address[1] = value;
326 fix_offset += sizeof fix_address[0] * 2;
327 if (fix_offset >= GLRO(dl_pagesize))
329 fix_page = NULL;
330 fix_offset = 0;
333 if (set_new_value ((Elf32_Addr) fix_address))
334 _dl_signal_error (0, map->l_name, NULL,
335 "R_ARM_PC24 relocation out of range");
338 *reloc_addr = (*reloc_addr & 0xff000000) | ((new_value >> 2) & 0x00ffffff);
341 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
342 MAP is the object containing the reloc. */
344 auto inline void
345 __attribute__ ((always_inline))
346 elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
347 const Elf32_Sym *sym, const struct r_found_version *version,
348 void *const reloc_addr_arg, int skip_ifunc)
350 Elf32_Addr *const reloc_addr = reloc_addr_arg;
351 const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
353 #if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC
354 if (__builtin_expect (r_type == R_ARM_RELATIVE, 0))
356 # if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC
357 /* This is defined in rtld.c, but nowhere in the static libc.a;
358 make the reference weak so static programs can still link.
359 This declaration cannot be done when compiling rtld.c
360 (i.e. #ifdef RTLD_BOOTSTRAP) because rtld.c contains the
361 common defn for _dl_rtld_map, which is incompatible with a
362 weak decl in the same file. */
363 # ifndef SHARED
364 weak_extern (_dl_rtld_map);
365 # endif
366 if (map != &GL(dl_rtld_map)) /* Already done in rtld itself. */
367 # endif
368 *reloc_addr += map->l_addr;
370 # ifndef RTLD_BOOTSTRAP
371 else if (__builtin_expect (r_type == R_ARM_NONE, 0))
372 return;
373 # endif
374 else
375 #endif
377 const Elf32_Sym *const refsym = sym;
378 struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
379 Elf32_Addr value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
381 if (sym != NULL
382 && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
383 && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1)
384 && __builtin_expect (!skip_ifunc, 1))
385 value = elf_ifunc_invoke (value);
387 switch (r_type)
389 case R_ARM_COPY:
390 if (sym == NULL)
391 /* This can happen in trace mode if an object could not be
392 found. */
393 break;
394 if (sym->st_size > refsym->st_size
395 || (GLRO(dl_verbose) && sym->st_size < refsym->st_size))
397 const char *strtab;
399 strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
400 _dl_error_printf ("\
401 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
402 RTLD_PROGNAME, strtab + refsym->st_name);
404 memcpy (reloc_addr_arg, (void *) value,
405 MIN (sym->st_size, refsym->st_size));
406 break;
407 case R_ARM_GLOB_DAT:
408 case R_ARM_JUMP_SLOT:
409 # ifdef RTLD_BOOTSTRAP
410 /* Fix weak undefined references. */
411 if (sym != NULL && sym->st_value == 0)
412 *reloc_addr = 0;
413 else
414 # endif
415 *reloc_addr = value;
416 break;
417 case R_ARM_ABS32:
419 struct unaligned
421 Elf32_Addr x;
422 } __attribute__ ((packed, may_alias));
423 # ifndef RTLD_BOOTSTRAP
424 /* This is defined in rtld.c, but nowhere in the static
425 libc.a; make the reference weak so static programs can
426 still link. This declaration cannot be done when
427 compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP) because
428 rtld.c contains the common defn for _dl_rtld_map, which
429 is incompatible with a weak decl in the same file. */
430 # ifndef SHARED
431 weak_extern (_dl_rtld_map);
432 # endif
433 if (map == &GL(dl_rtld_map))
434 /* Undo the relocation done here during bootstrapping.
435 Now we will relocate it anew, possibly using a
436 binding found in the user program or a loaded library
437 rather than the dynamic linker's built-in definitions
438 used while loading those libraries. */
439 value -= map->l_addr + refsym->st_value;
440 # endif
441 /* Support relocations on mis-aligned offsets. */
442 ((struct unaligned *) reloc_addr)->x += value;
443 break;
445 case R_ARM_TLS_DESC:
447 struct tlsdesc volatile *td =
448 (struct tlsdesc volatile *)reloc_addr;
450 # ifndef RTLD_BOOTSTRAP
451 if (! sym)
452 td->entry = _dl_tlsdesc_undefweak;
453 else
454 # endif
456 if (ELF32_R_SYM (reloc->r_info) == STN_UNDEF)
457 value = td->argument.value;
458 else
459 value = sym->st_value;
461 # ifndef RTLD_BOOTSTRAP
462 # ifndef SHARED
463 CHECK_STATIC_TLS (map, sym_map);
464 # else
465 if (!TRY_STATIC_TLS (map, sym_map))
467 td->argument.pointer
468 = _dl_make_tlsdesc_dynamic (sym_map, value);
469 td->entry = _dl_tlsdesc_dynamic;
471 else
472 # endif
473 # endif
475 td->argument.value = value + sym_map->l_tls_offset;
476 td->entry = _dl_tlsdesc_return;
480 break;
481 case R_ARM_PC24:
482 relocate_pc24 (map, value, reloc_addr,
483 /* Sign-extend the 24-bit addend in the
484 instruction (which counts instructions), and
485 then shift it up two so as to count bytes. */
486 (((Elf32_Sword) *reloc_addr << 8) >> 8) << 2);
487 break;
488 #if !defined RTLD_BOOTSTRAP
489 case R_ARM_TLS_DTPMOD32:
490 /* Get the information from the link map returned by the
491 resolv function. */
492 if (sym_map != NULL)
493 *reloc_addr = sym_map->l_tls_modid;
494 break;
496 case R_ARM_TLS_DTPOFF32:
497 if (sym != NULL)
498 *reloc_addr += sym->st_value;
499 break;
501 case R_ARM_TLS_TPOFF32:
502 if (sym != NULL)
504 CHECK_STATIC_TLS (map, sym_map);
505 *reloc_addr += sym->st_value + sym_map->l_tls_offset;
507 break;
508 case R_ARM_IRELATIVE:
509 value = map->l_addr + *reloc_addr;
510 value = ((Elf32_Addr (*) (int)) value) (GLRO(dl_hwcap));
511 *reloc_addr = value;
512 break;
513 #endif
514 default:
515 _dl_reloc_bad_type (map, r_type, 0);
516 break;
521 # ifndef RTLD_BOOTSTRAP
522 auto inline void
523 __attribute__ ((always_inline))
524 elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
525 const Elf32_Sym *sym, const struct r_found_version *version,
526 void *const reloc_addr_arg, int skip_ifunc)
528 Elf32_Addr *const reloc_addr = reloc_addr_arg;
529 const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
531 if (__builtin_expect (r_type == R_ARM_RELATIVE, 0))
532 *reloc_addr = map->l_addr + reloc->r_addend;
533 else if (__builtin_expect (r_type == R_ARM_NONE, 0))
534 return;
535 else
537 # ifndef RESOLVE_CONFLICT_FIND_MAP
538 const Elf32_Sym *const refsym = sym;
539 # endif
540 struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
541 Elf32_Addr value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
543 if (sym != NULL
544 && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
545 && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1)
546 && __builtin_expect (!skip_ifunc, 1))
547 value = elf_ifunc_invoke (value);
549 switch (r_type)
551 # ifndef RESOLVE_CONFLICT_FIND_MAP
552 /* Not needed for dl-conflict.c. */
553 case R_ARM_COPY:
554 if (sym == NULL)
555 /* This can happen in trace mode if an object could not be
556 found. */
557 break;
558 if (sym->st_size > refsym->st_size
559 || (GLRO(dl_verbose) && sym->st_size < refsym->st_size))
561 const char *strtab;
563 strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
564 _dl_error_printf ("\
565 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
566 RTLD_PROGNAME, strtab + refsym->st_name);
568 memcpy (reloc_addr_arg, (void *) value,
569 MIN (sym->st_size, refsym->st_size));
570 break;
571 # endif /* !RESOLVE_CONFLICT_FIND_MAP */
572 case R_ARM_GLOB_DAT:
573 case R_ARM_JUMP_SLOT:
574 case R_ARM_ABS32:
575 *reloc_addr = value + reloc->r_addend;
576 break;
577 # ifdef RESOLVE_CONFLICT_FIND_MAP
578 case R_ARM_TLS_DESC:
580 struct tlsdesc volatile *td =
581 (struct tlsdesc volatile *) reloc_addr;
583 RESOLVE_CONFLICT_FIND_MAP (map, reloc_addr);
585 /* Make sure we know what's going on. */
586 assert (td->entry
587 == (void *) (D_PTR (map, l_info[ADDRIDX (DT_TLSDESC_PLT)])
588 + map->l_addr));
589 assert (map->l_info[ADDRIDX (DT_TLSDESC_GOT)]);
591 /* Set up the lazy resolver and store the pointer to our link
592 map in _GLOBAL_OFFSET_TABLE[1] now as for a prelinked
593 binary elf_machine_runtime_setup() is not called and hence
594 neither has been initialized. */
595 *(Elf32_Addr *) (D_PTR (map, l_info[ADDRIDX (DT_TLSDESC_GOT)])
596 + map->l_addr)
597 = (Elf32_Addr) &_dl_tlsdesc_lazy_resolver;
598 ((Elf32_Addr *) D_PTR (map, l_info[DT_PLTGOT]))[1]
599 = (Elf32_Addr) map;
601 break;
602 # endif /* RESOLVE_CONFLICT_FIND_MAP */
603 case R_ARM_PC24:
604 relocate_pc24 (map, value, reloc_addr, reloc->r_addend);
605 break;
606 #if !defined RTLD_BOOTSTRAP
607 case R_ARM_TLS_DTPMOD32:
608 /* Get the information from the link map returned by the
609 resolv function. */
610 if (sym_map != NULL)
611 *reloc_addr = sym_map->l_tls_modid;
612 break;
614 case R_ARM_TLS_DTPOFF32:
615 *reloc_addr = (sym == NULL ? 0 : sym->st_value) + reloc->r_addend;
616 break;
618 case R_ARM_TLS_TPOFF32:
619 if (sym != NULL)
621 CHECK_STATIC_TLS (map, sym_map);
622 *reloc_addr = (sym->st_value + sym_map->l_tls_offset
623 + reloc->r_addend);
625 break;
626 case R_ARM_IRELATIVE:
627 value = map->l_addr + reloc->r_addend;
628 value = ((Elf32_Addr (*) (int)) value) (GLRO(dl_hwcap));
629 *reloc_addr = value;
630 break;
631 #endif
632 default:
633 _dl_reloc_bad_type (map, r_type, 0);
634 break;
638 # endif
640 auto inline void
641 __attribute__ ((always_inline))
642 elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc,
643 void *const reloc_addr_arg)
645 Elf32_Addr *const reloc_addr = reloc_addr_arg;
646 *reloc_addr += l_addr;
649 # ifndef RTLD_BOOTSTRAP
650 auto inline void
651 __attribute__ ((always_inline))
652 elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
653 void *const reloc_addr_arg)
655 Elf32_Addr *const reloc_addr = reloc_addr_arg;
656 *reloc_addr = l_addr + reloc->r_addend;
658 # endif
660 auto inline void
661 __attribute__ ((always_inline))
662 elf_machine_lazy_rel (struct link_map *map,
663 Elf32_Addr l_addr, const Elf32_Rel *reloc,
664 int skip_ifunc)
666 Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
667 const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
668 /* Check for unexpected PLT reloc type. */
669 if (__builtin_expect (r_type == R_ARM_JUMP_SLOT, 1))
671 if (__builtin_expect (map->l_mach.plt, 0) == 0)
672 *reloc_addr += l_addr;
673 else
674 *reloc_addr = map->l_mach.plt;
676 else if (__builtin_expect (r_type == R_ARM_TLS_DESC, 1))
678 struct tlsdesc volatile *td =
679 (struct tlsdesc volatile *)reloc_addr;
681 /* The linker must have given us the parameter we need in the
682 first GOT entry, and left the second one empty. The latter
683 will have been preset by the prelinker if used though.
684 We fill it with the resolver address. */
685 assert (td->entry == 0
686 || map->l_info[VALIDX (DT_GNU_PRELINKED)] != NULL);
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 */