is_IS locale: Base collation on iso14651_t1 [BZ #22519]
[glibc.git] / sysdeps / arm / dl-machine.h
blobfb5468a93b5cc56bb02c7667f3f352274abaa2a9
1 /* Machine-dependent ELF dynamic relocation inline functions. ARM version.
2 Copyright (C) 1995-2017 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 Elf32_Addr pcrel_addr;
57 #ifdef SHARED
58 extern Elf32_Addr __dl_start (void *) asm ("_dl_start");
59 Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
60 asm ("adr %0, _dl_start" : "=r" (pcrel_addr));
61 #else
62 extern Elf32_Addr __dl_relocate_static_pie (void *)
63 asm ("_dl_relocate_static_pie") attribute_hidden;
64 Elf32_Addr got_addr = (Elf32_Addr) &__dl_relocate_static_pie;
65 asm ("adr %0, _dl_relocate_static_pie" : "=r" (pcrel_addr));
66 #endif
67 #ifdef __thumb__
68 /* Clear the low bit of the function address.
70 NOTE: got_addr is from GOT table whose lsb is always set by linker if it's
71 Thumb function address. PCREL_ADDR comes from PC-relative calculation
72 which will finish during assembling. GAS assembler before the fix for
73 PR gas/21458 was not setting the lsb but does after that. Always do the
74 strip for both, so the code works with various combinations of glibc and
75 Binutils. */
76 got_addr &= ~(Elf32_Addr) 1;
77 pcrel_addr &= ~(Elf32_Addr) 1;
78 #endif
79 return pcrel_addr - got_addr;
83 /* Set up the loaded object described by L so its unrelocated PLT
84 entries will jump to the on-demand fixup code in dl-runtime.c. */
86 static inline int __attribute__ ((unused))
87 elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
89 Elf32_Addr *got;
90 extern void _dl_runtime_resolve (Elf32_Word);
91 extern void _dl_runtime_profile (Elf32_Word);
93 if (l->l_info[DT_JMPREL] && lazy)
95 /* patb: this is different than i386 */
96 /* The GOT entries for functions in the PLT have not yet been filled
97 in. Their initial contents will arrange when called to push an
98 index into the .got section, load ip with &_GLOBAL_OFFSET_TABLE_[3],
99 and then jump to _GLOBAL_OFFSET_TABLE[2]. */
100 got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]);
101 /* If a library is prelinked but we have to relocate anyway,
102 we have to be able to undo the prelinking of .got.plt.
103 The prelinker saved us here address of .plt. */
104 if (got[1])
105 l->l_mach.plt = got[1] + l->l_addr;
106 got[1] = (Elf32_Addr) l; /* Identify this shared object. */
108 /* The got[2] entry contains the address of a function which gets
109 called to get the address of a so far unresolved function and
110 jump to it. The profiling extension of the dynamic linker allows
111 to intercept the calls to collect information. In this case we
112 don't store the address in the GOT so that all future calls also
113 end in this function. */
114 if (profile)
116 got[2] = (Elf32_Addr) &_dl_runtime_profile;
118 if (GLRO(dl_profile) != NULL
119 && _dl_name_match_p (GLRO(dl_profile), l))
120 /* Say that we really want profiling and the timers are
121 started. */
122 GL(dl_profile_map) = l;
124 else
125 /* This function will get called to fix up the GOT entry indicated by
126 the offset on the stack, and then jump to the resolved address. */
127 got[2] = (Elf32_Addr) &_dl_runtime_resolve;
130 return lazy;
133 #if defined(ARCH_HAS_BX)
134 #define BX(x) "bx\t" #x
135 #else
136 #define BX(x) "mov\tpc, " #x
137 #endif
139 /* Mask identifying addresses reserved for the user program,
140 where the dynamic linker should not map anything. */
141 #define ELF_MACHINE_USER_ADDRESS_MASK 0xf8000000UL
143 /* Initial entry point code for the dynamic linker.
144 The C function `_dl_start' is the real entry point;
145 its return value is the user program's entry point. */
147 #define RTLD_START asm ("\
148 .text\n\
149 .globl _start\n\
150 .type _start, %function\n\
151 .globl _dl_start_user\n\
152 .type _dl_start_user, %function\n\
153 _start:\n\
154 @ we are PIC code, so get global offset table\n\
155 ldr sl, .L_GET_GOT\n\
156 @ See if we were run as a command with the executable file\n\
157 @ name as an extra leading argument.\n\
158 ldr r4, .L_SKIP_ARGS\n\
159 @ at start time, all the args are on the stack\n\
160 mov r0, sp\n\
161 bl _dl_start\n\
162 @ returns user entry point in r0\n\
163 _dl_start_user:\n\
164 adr r6, .L_GET_GOT\n\
165 add sl, sl, r6\n\
166 ldr r4, [sl, r4]\n\
167 @ save the entry point in another register\n\
168 mov r6, r0\n\
169 @ get the original arg count\n\
170 ldr r1, [sp]\n\
171 @ get the argv address\n\
172 add r2, sp, #4\n\
173 @ Fix up the stack if necessary.\n\
174 cmp r4, #0\n\
175 bne .L_fixup_stack\n\
176 .L_done_fixup:\n\
177 @ compute envp\n\
178 add r3, r2, r1, lsl #2\n\
179 add r3, r3, #4\n\
180 @ now we call _dl_init\n\
181 ldr r0, .L_LOADED\n\
182 ldr r0, [sl, r0]\n\
183 @ call _dl_init\n\
184 bl _dl_init(PLT)\n\
185 @ load the finalizer function\n\
186 ldr r0, .L_FINI_PROC\n\
187 add r0, sl, r0\n\
188 @ jump to the user_s entry point\n\
189 " BX(r6) "\n\
191 @ iWMMXt and EABI targets require the stack to be eight byte\n\
192 @ aligned - shuffle arguments etc.\n\
193 .L_fixup_stack:\n\
194 @ subtract _dl_skip_args from original arg count\n\
195 sub r1, r1, r4\n\
196 @ store the new argc in the new stack location\n\
197 str r1, [sp]\n\
198 @ find the first unskipped argument\n\
199 mov r3, r2\n\
200 add r4, r2, r4, lsl #2\n\
201 @ shuffle argv down\n\
202 1: ldr r5, [r4], #4\n\
203 str r5, [r3], #4\n\
204 cmp r5, #0\n\
205 bne 1b\n\
206 @ shuffle envp down\n\
207 1: ldr r5, [r4], #4\n\
208 str r5, [r3], #4\n\
209 cmp r5, #0\n\
210 bne 1b\n\
211 @ shuffle auxv down\n\
212 1: ldmia r4!, {r0, r5}\n\
213 stmia r3!, {r0, r5}\n\
214 cmp r0, #0\n\
215 bne 1b\n\
216 @ Update _dl_argv\n\
217 ldr r3, .L_ARGV\n\
218 str r2, [sl, r3]\n\
219 b .L_done_fixup\n\
221 .L_GET_GOT:\n\
222 .word _GLOBAL_OFFSET_TABLE_ - .L_GET_GOT\n\
223 .L_SKIP_ARGS:\n\
224 .word _dl_skip_args(GOTOFF)\n\
225 .L_FINI_PROC:\n\
226 .word _dl_fini(GOTOFF)\n\
227 .L_ARGV:\n\
228 .word _dl_argv(GOTOFF)\n\
229 .L_LOADED:\n\
230 .word _rtld_local(GOTOFF)\n\
231 .previous\n\
234 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
235 TLS variable, so undefined references should not be allowed to
236 define the value.
237 ELF_RTYPE_CLASS_COPY iff TYPE should not be allowed to resolve to one
238 of the main executable's symbols, as for a COPY reloc.
239 ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA iff TYPE describes relocation against
240 protected data whose address may be external due to copy relocation. */
241 #ifndef RTLD_BOOTSTRAP
242 # define elf_machine_type_class(type) \
243 ((((type) == R_ARM_JUMP_SLOT || (type) == R_ARM_TLS_DTPMOD32 \
244 || (type) == R_ARM_TLS_DTPOFF32 || (type) == R_ARM_TLS_TPOFF32 \
245 || (type) == R_ARM_TLS_DESC) \
246 * ELF_RTYPE_CLASS_PLT) \
247 | (((type) == R_ARM_COPY) * ELF_RTYPE_CLASS_COPY) \
248 | (((type) == R_ARM_GLOB_DAT) * ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA))
249 #else
250 #define elf_machine_type_class(type) \
251 ((((type) == R_ARM_JUMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
252 | (((type) == R_ARM_COPY) * ELF_RTYPE_CLASS_COPY) \
253 | (((type) == R_ARM_GLOB_DAT) * ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA))
254 #endif
256 /* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
257 #define ELF_MACHINE_JMP_SLOT R_ARM_JUMP_SLOT
259 /* ARM never uses Elf32_Rela relocations for the dynamic linker.
260 Prelinked libraries may use Elf32_Rela though. */
261 #define ELF_MACHINE_PLT_REL 1
263 /* We define an initialization functions. This is called very early in
264 _dl_sysdep_start. */
265 #define DL_PLATFORM_INIT dl_platform_init ()
267 static inline void __attribute__ ((unused))
268 dl_platform_init (void)
270 if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0')
271 /* Avoid an empty string which would disturb us. */
272 GLRO(dl_platform) = NULL;
275 static inline Elf32_Addr
276 elf_machine_fixup_plt (struct link_map *map, lookup_t t,
277 const ElfW(Sym) *refsym, const ElfW(Sym) *sym,
278 const Elf32_Rel *reloc,
279 Elf32_Addr *reloc_addr, Elf32_Addr value)
281 return *reloc_addr = value;
284 /* Return the final value of a plt relocation. */
285 static inline Elf32_Addr
286 elf_machine_plt_value (struct link_map *map, const Elf32_Rel *reloc,
287 Elf32_Addr value)
289 return value;
292 #endif /* !dl_machine_h */
295 /* ARM never uses Elf32_Rela relocations for the dynamic linker.
296 Prelinked libraries may use Elf32_Rela though. */
297 #define ELF_MACHINE_NO_RELA defined RTLD_BOOTSTRAP
298 #define ELF_MACHINE_NO_REL 0
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
305 /* Handle a PC24 reloc, including the out-of-range case. */
306 auto void
307 relocate_pc24 (struct link_map *map, Elf32_Addr value,
308 Elf32_Addr *const reloc_addr, Elf32_Sword addend)
310 Elf32_Addr new_value;
312 /* Set NEW_VALUE based on V, and return true iff it overflows 24 bits. */
313 inline bool set_new_value (Elf32_Addr v)
315 new_value = v + addend - (Elf32_Addr) reloc_addr;
316 Elf32_Addr topbits = new_value & 0xfe000000;
317 return topbits != 0xfe000000 && topbits != 0x00000000;
320 if (set_new_value (value))
322 /* The PC-relative address doesn't fit in 24 bits! */
324 static void *fix_page;
325 static size_t fix_offset;
326 if (fix_page == NULL)
328 void *new_page = __mmap (NULL, GLRO(dl_pagesize),
329 PROT_READ | PROT_WRITE | PROT_EXEC,
330 MAP_PRIVATE | MAP_ANON, -1, 0);
331 if (new_page == MAP_FAILED)
332 _dl_signal_error (0, map->l_name, NULL,
333 "could not map page for fixup");
334 fix_page = new_page;
335 assert (fix_offset == 0);
338 Elf32_Word *fix_address = fix_page + fix_offset;
339 fix_address[0] = 0xe51ff004; /* ldr pc, [pc, #-4] */
340 fix_address[1] = value;
342 fix_offset += sizeof fix_address[0] * 2;
343 if (fix_offset >= GLRO(dl_pagesize))
345 fix_page = NULL;
346 fix_offset = 0;
349 if (set_new_value ((Elf32_Addr) fix_address))
350 _dl_signal_error (0, map->l_name, NULL,
351 "R_ARM_PC24 relocation out of range");
354 *reloc_addr = (*reloc_addr & 0xff000000) | ((new_value >> 2) & 0x00ffffff);
357 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
358 MAP is the object containing the reloc. */
360 auto inline void
361 __attribute__ ((always_inline))
362 elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
363 const Elf32_Sym *sym, const struct r_found_version *version,
364 void *const reloc_addr_arg, int skip_ifunc)
366 Elf32_Addr *const reloc_addr = reloc_addr_arg;
367 const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
369 #if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC
370 if (__builtin_expect (r_type == R_ARM_RELATIVE, 0))
372 # if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC
373 /* This is defined in rtld.c, but nowhere in the static libc.a;
374 make the reference weak so static programs can still link.
375 This declaration cannot be done when compiling rtld.c
376 (i.e. #ifdef RTLD_BOOTSTRAP) because rtld.c contains the
377 common defn for _dl_rtld_map, which is incompatible with a
378 weak decl in the same file. */
379 # ifndef SHARED
380 weak_extern (_dl_rtld_map);
381 # endif
382 if (map != &GL(dl_rtld_map)) /* Already done in rtld itself. */
383 # endif
384 *reloc_addr += map->l_addr;
386 # ifndef RTLD_BOOTSTRAP
387 else if (__builtin_expect (r_type == R_ARM_NONE, 0))
388 return;
389 # endif
390 else
391 #endif
393 const Elf32_Sym *const refsym = sym;
394 struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
395 Elf32_Addr value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
397 if (sym != NULL
398 && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
399 && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1)
400 && __builtin_expect (!skip_ifunc, 1))
401 value = elf_ifunc_invoke (value);
403 switch (r_type)
405 case R_ARM_COPY:
406 if (sym == NULL)
407 /* This can happen in trace mode if an object could not be
408 found. */
409 break;
410 if (sym->st_size > refsym->st_size
411 || (GLRO(dl_verbose) && sym->st_size < refsym->st_size))
413 const char *strtab;
415 strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
416 _dl_error_printf ("\
417 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
418 RTLD_PROGNAME, strtab + refsym->st_name);
420 memcpy (reloc_addr_arg, (void *) value,
421 MIN (sym->st_size, refsym->st_size));
422 break;
423 case R_ARM_GLOB_DAT:
424 case R_ARM_JUMP_SLOT:
425 # ifdef RTLD_BOOTSTRAP
426 /* Fix weak undefined references. */
427 if (sym != NULL && sym->st_value == 0)
428 *reloc_addr = 0;
429 else
430 # endif
431 *reloc_addr = value;
432 break;
433 case R_ARM_ABS32:
435 struct unaligned
437 Elf32_Addr x;
438 } __attribute__ ((packed, may_alias));
439 # ifndef RTLD_BOOTSTRAP
440 /* This is defined in rtld.c, but nowhere in the static
441 libc.a; make the reference weak so static programs can
442 still link. This declaration cannot be done when
443 compiling rtld.c (i.e. #ifdef RTLD_BOOTSTRAP) because
444 rtld.c contains the common defn for _dl_rtld_map, which
445 is incompatible with a weak decl in the same file. */
446 # ifndef SHARED
447 weak_extern (_dl_rtld_map);
448 # endif
449 if (map == &GL(dl_rtld_map))
450 /* Undo the relocation done here during bootstrapping.
451 Now we will relocate it anew, possibly using a
452 binding found in the user program or a loaded library
453 rather than the dynamic linker's built-in definitions
454 used while loading those libraries. */
455 value -= map->l_addr + refsym->st_value;
456 # endif
457 /* Support relocations on mis-aligned offsets. */
458 ((struct unaligned *) reloc_addr)->x += value;
459 break;
461 case R_ARM_TLS_DESC:
463 struct tlsdesc *td = (struct tlsdesc *)reloc_addr;
465 # ifndef RTLD_BOOTSTRAP
466 if (! sym)
467 td->entry = _dl_tlsdesc_undefweak;
468 else
469 # endif
471 if (ELF32_R_SYM (reloc->r_info) == STN_UNDEF)
472 value = td->argument.value;
473 else
474 value = sym->st_value;
476 # ifndef RTLD_BOOTSTRAP
477 # ifndef SHARED
478 CHECK_STATIC_TLS (map, sym_map);
479 # else
480 if (!TRY_STATIC_TLS (map, sym_map))
482 td->argument.pointer
483 = _dl_make_tlsdesc_dynamic (sym_map, value);
484 td->entry = _dl_tlsdesc_dynamic;
486 else
487 # endif
488 # endif
490 td->argument.value = value + sym_map->l_tls_offset;
491 td->entry = _dl_tlsdesc_return;
495 break;
496 case R_ARM_PC24:
497 relocate_pc24 (map, value, reloc_addr,
498 /* Sign-extend the 24-bit addend in the
499 instruction (which counts instructions), and
500 then shift it up two so as to count bytes. */
501 (((Elf32_Sword) *reloc_addr << 8) >> 8) << 2);
502 break;
503 #if !defined RTLD_BOOTSTRAP
504 case R_ARM_TLS_DTPMOD32:
505 /* Get the information from the link map returned by the
506 resolv function. */
507 if (sym_map != NULL)
508 *reloc_addr = sym_map->l_tls_modid;
509 break;
511 case R_ARM_TLS_DTPOFF32:
512 if (sym != NULL)
513 *reloc_addr += sym->st_value;
514 break;
516 case R_ARM_TLS_TPOFF32:
517 if (sym != NULL)
519 CHECK_STATIC_TLS (map, sym_map);
520 *reloc_addr += sym->st_value + sym_map->l_tls_offset;
522 break;
523 case R_ARM_IRELATIVE:
524 value = map->l_addr + *reloc_addr;
525 value = ((Elf32_Addr (*) (int)) value) (GLRO(dl_hwcap));
526 *reloc_addr = value;
527 break;
528 #endif
529 default:
530 _dl_reloc_bad_type (map, r_type, 0);
531 break;
536 # ifndef RTLD_BOOTSTRAP
537 auto inline void
538 __attribute__ ((always_inline))
539 elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
540 const Elf32_Sym *sym, const struct r_found_version *version,
541 void *const reloc_addr_arg, int skip_ifunc)
543 Elf32_Addr *const reloc_addr = reloc_addr_arg;
544 const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
546 if (__builtin_expect (r_type == R_ARM_RELATIVE, 0))
547 *reloc_addr = map->l_addr + reloc->r_addend;
548 else if (__builtin_expect (r_type == R_ARM_NONE, 0))
549 return;
550 else
552 # ifndef RESOLVE_CONFLICT_FIND_MAP
553 const Elf32_Sym *const refsym = sym;
554 # endif
555 struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
556 Elf32_Addr value = sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value;
558 if (sym != NULL
559 && __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
560 && __builtin_expect (sym->st_shndx != SHN_UNDEF, 1)
561 && __builtin_expect (!skip_ifunc, 1))
562 value = elf_ifunc_invoke (value);
564 switch (r_type)
566 # ifndef RESOLVE_CONFLICT_FIND_MAP
567 /* Not needed for dl-conflict.c. */
568 case R_ARM_COPY:
569 if (sym == NULL)
570 /* This can happen in trace mode if an object could not be
571 found. */
572 break;
573 if (sym->st_size > refsym->st_size
574 || (GLRO(dl_verbose) && sym->st_size < refsym->st_size))
576 const char *strtab;
578 strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
579 _dl_error_printf ("\
580 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
581 RTLD_PROGNAME, strtab + refsym->st_name);
583 memcpy (reloc_addr_arg, (void *) value,
584 MIN (sym->st_size, refsym->st_size));
585 break;
586 # endif /* !RESOLVE_CONFLICT_FIND_MAP */
587 case R_ARM_GLOB_DAT:
588 case R_ARM_JUMP_SLOT:
589 case R_ARM_ABS32:
590 *reloc_addr = value + reloc->r_addend;
591 break;
592 case R_ARM_PC24:
593 relocate_pc24 (map, value, reloc_addr, reloc->r_addend);
594 break;
595 #if !defined RTLD_BOOTSTRAP
596 case R_ARM_TLS_DTPMOD32:
597 /* Get the information from the link map returned by the
598 resolv function. */
599 if (sym_map != NULL)
600 *reloc_addr = sym_map->l_tls_modid;
601 break;
603 case R_ARM_TLS_DTPOFF32:
604 *reloc_addr = (sym == NULL ? 0 : sym->st_value) + reloc->r_addend;
605 break;
607 case R_ARM_TLS_TPOFF32:
608 if (sym != NULL)
610 CHECK_STATIC_TLS (map, sym_map);
611 *reloc_addr = (sym->st_value + sym_map->l_tls_offset
612 + reloc->r_addend);
614 break;
615 case R_ARM_IRELATIVE:
616 value = map->l_addr + reloc->r_addend;
617 value = ((Elf32_Addr (*) (int)) value) (GLRO(dl_hwcap));
618 *reloc_addr = value;
619 break;
620 #endif
621 default:
622 _dl_reloc_bad_type (map, r_type, 0);
623 break;
627 # endif
629 auto inline void
630 __attribute__ ((always_inline))
631 elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc,
632 void *const reloc_addr_arg)
634 Elf32_Addr *const reloc_addr = reloc_addr_arg;
635 *reloc_addr += l_addr;
638 # ifndef RTLD_BOOTSTRAP
639 auto inline void
640 __attribute__ ((always_inline))
641 elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
642 void *const reloc_addr_arg)
644 Elf32_Addr *const reloc_addr = reloc_addr_arg;
645 *reloc_addr = l_addr + reloc->r_addend;
647 # endif
649 auto inline void
650 __attribute__ ((always_inline))
651 elf_machine_lazy_rel (struct link_map *map,
652 Elf32_Addr l_addr, const Elf32_Rel *reloc,
653 int skip_ifunc)
655 Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
656 const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
657 /* Check for unexpected PLT reloc type. */
658 if (__builtin_expect (r_type == R_ARM_JUMP_SLOT, 1))
660 if (__builtin_expect (map->l_mach.plt, 0) == 0)
661 *reloc_addr += l_addr;
662 else
663 *reloc_addr = map->l_mach.plt;
665 else if (__builtin_expect (r_type == R_ARM_TLS_DESC, 1))
667 const Elf_Symndx symndx = ELFW (R_SYM) (reloc->r_info);
668 const ElfW (Sym) *symtab = (const void *)D_PTR (map, l_info[DT_SYMTAB]);
669 const ElfW (Sym) *sym = &symtab[symndx];
670 const struct r_found_version *version = NULL;
672 if (map->l_info[VERSYMIDX (DT_VERSYM)] != NULL)
674 const ElfW (Half) *vernum =
675 (const void *)D_PTR (map, l_info[VERSYMIDX (DT_VERSYM)]);
676 version = &map->l_versions[vernum[symndx] & 0x7fff];
679 /* Always initialize TLS descriptors completely, because lazy
680 initialization requires synchronization at every TLS access. */
681 elf_machine_rel (map, reloc, sym, version, reloc_addr, skip_ifunc);
683 else
684 _dl_reloc_bad_type (map, r_type, 1);
687 #endif /* RESOLVE_MAP */