1 /* Machine-dependent ELF dynamic relocation inline functions. i386 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/>. */
22 #define ELF_MACHINE_NAME "i386"
24 #include <sys/param.h>
27 #include <dl-tlsdesc.h>
28 #include <cpu-features.c>
30 /* Return nonzero iff ELF header is compatible with the running host. */
31 static inline int __attribute__ ((unused
))
32 elf_machine_matches_host (const Elf32_Ehdr
*ehdr
)
34 return ehdr
->e_machine
== EM_386
;
38 /* Return the link-time address of _DYNAMIC. Conveniently, this is the
39 first element of the GOT, a special entry that is never relocated. */
40 static inline Elf32_Addr
__attribute__ ((unused
, const))
41 elf_machine_dynamic (void)
43 /* This produces a GOTOFF reloc that resolves to zero at link time, so in
44 fact just loads from the GOT register directly. By doing it without
45 an asm we can let the compiler choose any register. */
46 extern const Elf32_Addr _GLOBAL_OFFSET_TABLE_
[] attribute_hidden
;
47 return _GLOBAL_OFFSET_TABLE_
[0];
50 /* Return the run-time load address of the shared object. */
51 static inline Elf32_Addr
__attribute__ ((unused
))
52 elf_machine_load_address (void)
54 /* Compute the difference between the runtime address of _DYNAMIC as seen
55 by a GOTOFF reference, and the link-time address found in the special
56 unrelocated first GOT entry. */
57 extern Elf32_Dyn bygotoff
[] asm ("_DYNAMIC") attribute_hidden
;
58 return (Elf32_Addr
) &bygotoff
- elf_machine_dynamic ();
61 /* Set up the loaded object described by L so its unrelocated PLT
62 entries will jump to the on-demand fixup code in dl-runtime.c. */
64 static inline int __attribute__ ((unused
, always_inline
))
65 elf_machine_runtime_setup (struct link_map
*l
, int lazy
, int profile
)
68 extern void _dl_runtime_resolve (Elf32_Word
) attribute_hidden
;
69 extern void _dl_runtime_profile (Elf32_Word
) attribute_hidden
;
71 if (l
->l_info
[DT_JMPREL
] && lazy
)
73 /* The GOT entries for functions in the PLT have not yet been filled
74 in. Their initial contents will arrange when called to push an
75 offset into the .rel.plt section, push _GLOBAL_OFFSET_TABLE_[1],
76 and then jump to _GLOBAL_OFFSET_TABLE[2]. */
77 got
= (Elf32_Addr
*) D_PTR (l
, l_info
[DT_PLTGOT
]);
78 /* If a library is prelinked but we have to relocate anyway,
79 we have to be able to undo the prelinking of .got.plt.
80 The prelinker saved us here address of .plt + 0x16. */
83 l
->l_mach
.plt
= got
[1] + l
->l_addr
;
84 l
->l_mach
.gotplt
= (Elf32_Addr
) &got
[3];
86 got
[1] = (Elf32_Addr
) l
; /* Identify this shared object. */
88 /* The got[2] entry contains the address of a function which gets
89 called to get the address of a so far unresolved function and
90 jump to it. The profiling extension of the dynamic linker allows
91 to intercept the calls to collect information. In this case we
92 don't store the address in the GOT so that all future calls also
93 end in this function. */
94 if (__glibc_unlikely (profile
))
96 got
[2] = (Elf32_Addr
) &_dl_runtime_profile
;
98 if (GLRO(dl_profile
) != NULL
99 && _dl_name_match_p (GLRO(dl_profile
), l
))
100 /* This is the object we are looking for. Say that we really
101 want profiling and the timers are started. */
102 GL(dl_profile_map
) = l
;
105 /* This function will get called to fix up the GOT entry indicated by
106 the offset on the stack, and then jump to the resolved address. */
107 got
[2] = (Elf32_Addr
) &_dl_runtime_resolve
;
116 /* We add a declaration of this function here so that in dl-runtime.c
117 the ELF_MACHINE_RUNTIME_TRAMPOLINE macro really can pass the parameters
120 We cannot use this scheme for profiling because the _mcount call
121 destroys the passed register information. */
122 #define ARCH_FIXUP_ATTRIBUTE __attribute__ ((regparm (3), stdcall, unused))
124 extern ElfW(Addr
) _dl_fixup (struct link_map
*l
,
125 ElfW(Word
) reloc_offset
)
126 ARCH_FIXUP_ATTRIBUTE
;
127 extern ElfW(Addr
) _dl_profile_fixup (struct link_map
*l
,
128 ElfW(Word
) reloc_offset
,
129 ElfW(Addr
) retaddr
, void *regs
,
130 long int *framesizep
)
131 ARCH_FIXUP_ATTRIBUTE
;
136 /* Mask identifying addresses reserved for the user program,
137 where the dynamic linker should not map anything. */
138 #define ELF_MACHINE_USER_ADDRESS_MASK 0xf8000000UL
140 /* Initial entry point code for the dynamic linker.
141 The C function `_dl_start' is the real entry point;
142 its return value is the user program's entry point. */
144 #define RTLD_START asm ("\n\
147 0: movl (%esp), %ebx\n\
151 .globl _dl_start_user\n\
153 # Note that _dl_start gets the parameter in %eax.\n\
157 # Save the user entry point address in %edi.\n\
159 # Point %ebx at the GOT.\n\
161 addl $_GLOBAL_OFFSET_TABLE_, %ebx\n\
162 # See if we were run as a command with the executable file\n\
163 # name as an extra leading argument.\n\
164 movl _dl_skip_args@GOTOFF(%ebx), %eax\n\
165 # Pop the original argument count.\n\
167 # Adjust the stack pointer to skip _dl_skip_args words.\n\
168 leal (%esp,%eax,4), %esp\n\
169 # Subtract _dl_skip_args from argc.\n\
171 # Push argc back on the stack.\n\
173 # The special initializer gets called with the stack just\n\
174 # as the application's entry point will see it; it can\n\
175 # switch stacks if it moves these contents over.\n\
176 " RTLD_START_SPECIAL_INIT "\n\
177 # Load the parameters again.\n\
178 # (eax, edx, ecx, *--esp) = (_dl_loaded, argc, argv, envp)\n\
179 movl _rtld_local@GOTOFF(%ebx), %eax\n\
180 leal 8(%esp,%edx,4), %esi\n\
181 leal 4(%esp), %ecx\n\
183 # Make sure _dl_init is run with 16 byte aligned stack.\n\
189 # Clear %ebp, so that even constructors have terminated backchain.\n\
191 # Call the function to run the initializers.\n\
193 # Pass our finalizer function to the user in %edx, as per ELF ABI.\n\
194 leal _dl_fini@GOTOFF(%ebx), %edx\n\
195 # Restore %esp _start expects.\n\
197 # Jump to the user's entry point.\n\
202 #ifndef RTLD_START_SPECIAL_INIT
203 # define RTLD_START_SPECIAL_INIT /* nothing */
206 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
207 TLS variable, so undefined references should not be allowed to
209 ELF_RTYPE_CLASS_COPY iff TYPE should not be allowed to resolve to one
210 of the main executable's symbols, as for a COPY reloc.
211 ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA iff TYPE describes relocation may
212 against protected data whose address be external due to copy relocation.
214 # define elf_machine_type_class(type) \
215 ((((type) == R_386_JMP_SLOT || (type) == R_386_TLS_DTPMOD32 \
216 || (type) == R_386_TLS_DTPOFF32 || (type) == R_386_TLS_TPOFF32 \
217 || (type) == R_386_TLS_TPOFF || (type) == R_386_TLS_DESC) \
218 * ELF_RTYPE_CLASS_PLT) \
219 | (((type) == R_386_COPY) * ELF_RTYPE_CLASS_COPY) \
220 | (((type) == R_386_GLOB_DAT) * ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA))
222 /* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
223 #define ELF_MACHINE_JMP_SLOT R_386_JMP_SLOT
225 /* The i386 never uses Elf32_Rela relocations for the dynamic linker.
226 Prelinked libraries may use Elf32_Rela though. */
227 #define ELF_MACHINE_PLT_REL 1
229 /* We define an initialization functions. This is called very early in
231 #define DL_PLATFORM_INIT dl_platform_init ()
233 static inline void __attribute__ ((unused
))
234 dl_platform_init (void)
237 /* init_cpu_features has been called early from __libc_start_main in
238 static executable. */
239 init_cpu_features (&GLRO(dl_x86_cpu_features
));
241 if (GLRO(dl_platform
) != NULL
&& *GLRO(dl_platform
) == '\0')
242 /* Avoid an empty string which would disturb us. */
243 GLRO(dl_platform
) = NULL
;
247 static inline Elf32_Addr
248 elf_machine_fixup_plt (struct link_map
*map
, lookup_t t
,
249 const ElfW(Sym
) *refsym
, const ElfW(Sym
) *sym
,
250 const Elf32_Rel
*reloc
,
251 Elf32_Addr
*reloc_addr
, Elf32_Addr value
)
253 return *reloc_addr
= value
;
256 /* Return the final value of a plt relocation. */
257 static inline Elf32_Addr
258 elf_machine_plt_value (struct link_map
*map
, const Elf32_Rel
*reloc
,
265 /* Names of the architecture-specific auditing callback functions. */
266 #define ARCH_LA_PLTENTER i86_gnu_pltenter
267 #define ARCH_LA_PLTEXIT i86_gnu_pltexit
269 #endif /* !dl_machine_h */
271 /* The i386 never uses Elf32_Rela relocations for the dynamic linker.
272 Prelinked libraries may use Elf32_Rela though. */
273 #define ELF_MACHINE_NO_RELA defined RTLD_BOOTSTRAP
274 #define ELF_MACHINE_NO_REL 0
278 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
279 MAP is the object containing the reloc. */
282 __attribute ((always_inline
))
283 elf_machine_rel (struct link_map
*map
, const Elf32_Rel
*reloc
,
284 const Elf32_Sym
*sym
, const struct r_found_version
*version
,
285 void *const reloc_addr_arg
, int skip_ifunc
)
287 Elf32_Addr
*const reloc_addr
= reloc_addr_arg
;
288 const unsigned int r_type
= ELF32_R_TYPE (reloc
->r_info
);
290 # if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC
291 if (__glibc_unlikely (r_type
== R_386_RELATIVE
))
293 # if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC
294 /* This is defined in rtld.c, but nowhere in the static libc.a;
295 make the reference weak so static programs can still link.
296 This declaration cannot be done when compiling rtld.c
297 (i.e. #ifdef RTLD_BOOTSTRAP) because rtld.c contains the
298 common defn for _dl_rtld_map, which is incompatible with a
299 weak decl in the same file. */
301 weak_extern (_dl_rtld_map
);
303 if (map
!= &GL(dl_rtld_map
)) /* Already done in rtld itself. */
305 *reloc_addr
+= map
->l_addr
;
307 # ifndef RTLD_BOOTSTRAP
308 else if (__glibc_unlikely (r_type
== R_386_NONE
))
312 # endif /* !RTLD_BOOTSTRAP and have no -z combreloc */
314 # ifndef RTLD_BOOTSTRAP
315 const Elf32_Sym
*const refsym
= sym
;
317 struct link_map
*sym_map
= RESOLVE_MAP (&sym
, version
, r_type
);
318 Elf32_Addr value
= sym_map
== NULL
? 0 : sym_map
->l_addr
+ sym
->st_value
;
321 && __builtin_expect (ELFW(ST_TYPE
) (sym
->st_info
) == STT_GNU_IFUNC
,
323 && __builtin_expect (sym
->st_shndx
!= SHN_UNDEF
, 1)
324 && __builtin_expect (!skip_ifunc
, 1))
326 # ifndef RTLD_BOOTSTRAP
328 && sym_map
->l_type
!= lt_executable
329 && !sym_map
->l_relocated
)
332 = (const char *) D_PTR (map
, l_info
[DT_STRTAB
]);
334 %s: Relink `%s' with `%s' for IFUNC symbol `%s'\n",
335 RTLD_PROGNAME
, map
->l_name
,
337 strtab
+ refsym
->st_name
);
340 value
= ((Elf32_Addr (*) (void)) value
) ();
345 # ifndef RTLD_BOOTSTRAP
347 /* Set to symbol size plus addend. */
348 *reloc_addr
+= sym
->st_size
;
356 case R_386_TLS_DTPMOD32
:
357 # ifdef RTLD_BOOTSTRAP
358 /* During startup the dynamic linker is always the module
360 XXX If this relocation is necessary move before RESOLVE
364 /* Get the information from the link map returned by the
367 *reloc_addr
= sym_map
->l_tls_modid
;
370 case R_386_TLS_DTPOFF32
:
371 # ifndef RTLD_BOOTSTRAP
372 /* During relocation all TLS symbols are defined and used.
373 Therefore the offset is already correct. */
375 *reloc_addr
= sym
->st_value
;
380 struct tlsdesc
volatile *td
=
381 (struct tlsdesc
volatile *)reloc_addr
;
383 # ifndef RTLD_BOOTSTRAP
385 td
->entry
= _dl_tlsdesc_undefweak
;
389 # ifndef RTLD_BOOTSTRAP
391 CHECK_STATIC_TLS (map
, sym_map
);
393 if (!TRY_STATIC_TLS (map
, sym_map
))
395 td
->arg
= _dl_make_tlsdesc_dynamic
396 (sym_map
, sym
->st_value
+ (ElfW(Word
))td
->arg
);
397 td
->entry
= _dl_tlsdesc_dynamic
;
403 td
->arg
= (void*)(sym
->st_value
- sym_map
->l_tls_offset
404 + (ElfW(Word
))td
->arg
);
405 td
->entry
= _dl_tlsdesc_return
;
410 case R_386_TLS_TPOFF32
:
411 /* The offset is positive, backward from the thread pointer. */
412 # ifdef RTLD_BOOTSTRAP
413 *reloc_addr
+= map
->l_tls_offset
- sym
->st_value
;
415 /* We know the offset of object the symbol is contained in.
416 It is a positive value which will be subtracted from the
417 thread pointer. To get the variable position in the TLS
418 block we subtract the offset from that of the TLS block. */
421 CHECK_STATIC_TLS (map
, sym_map
);
422 *reloc_addr
+= sym_map
->l_tls_offset
- sym
->st_value
;
426 case R_386_TLS_TPOFF
:
427 /* The offset is negative, forward from the thread pointer. */
428 # ifdef RTLD_BOOTSTRAP
429 *reloc_addr
+= sym
->st_value
- map
->l_tls_offset
;
431 /* We know the offset of object the symbol is contained in.
432 It is a negative value which will be added to the
436 CHECK_STATIC_TLS (map
, sym_map
);
437 *reloc_addr
+= sym
->st_value
- sym_map
->l_tls_offset
;
442 # ifndef RTLD_BOOTSTRAP
444 *reloc_addr
+= value
;
447 *reloc_addr
+= (value
- (Elf32_Addr
) reloc_addr
);
451 /* This can happen in trace mode if an object could not be
454 if (__builtin_expect (sym
->st_size
> refsym
->st_size
, 0)
455 || (__builtin_expect (sym
->st_size
< refsym
->st_size
, 0)
456 && GLRO(dl_verbose
)))
460 strtab
= (const char *) D_PTR (map
, l_info
[DT_STRTAB
]);
462 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
463 RTLD_PROGNAME
, strtab
+ refsym
->st_name
);
465 memcpy (reloc_addr_arg
, (void *) value
,
466 MIN (sym
->st_size
, refsym
->st_size
));
468 case R_386_IRELATIVE
:
469 value
= map
->l_addr
+ *reloc_addr
;
470 value
= ((Elf32_Addr (*) (void)) value
) ();
474 _dl_reloc_bad_type (map
, r_type
, 0);
476 # endif /* !RTLD_BOOTSTRAP */
481 # ifndef RTLD_BOOTSTRAP
483 __attribute__ ((always_inline
))
484 elf_machine_rela (struct link_map
*map
, const Elf32_Rela
*reloc
,
485 const Elf32_Sym
*sym
, const struct r_found_version
*version
,
486 void *const reloc_addr_arg
, int skip_ifunc
)
488 Elf32_Addr
*const reloc_addr
= reloc_addr_arg
;
489 const unsigned int r_type
= ELF32_R_TYPE (reloc
->r_info
);
491 if (ELF32_R_TYPE (reloc
->r_info
) == R_386_RELATIVE
)
492 *reloc_addr
= map
->l_addr
+ reloc
->r_addend
;
493 else if (r_type
!= R_386_NONE
)
495 # ifndef RESOLVE_CONFLICT_FIND_MAP
496 const Elf32_Sym
*const refsym
= sym
;
498 struct link_map
*sym_map
= RESOLVE_MAP (&sym
, version
, r_type
);
499 Elf32_Addr value
= sym
== NULL
? 0 : sym_map
->l_addr
+ sym
->st_value
;
502 && __builtin_expect (sym
->st_shndx
!= SHN_UNDEF
, 1)
503 && __builtin_expect (ELFW(ST_TYPE
) (sym
->st_info
) == STT_GNU_IFUNC
, 0)
504 && __builtin_expect (!skip_ifunc
, 1))
505 value
= ((Elf32_Addr (*) (void)) value
) ();
507 switch (ELF32_R_TYPE (reloc
->r_info
))
510 /* Set to symbol size plus addend. */
511 value
= sym
->st_size
;
515 *reloc_addr
= value
+ reloc
->r_addend
;
517 # ifndef RESOLVE_CONFLICT_FIND_MAP
518 /* Not needed for dl-conflict.c. */
520 *reloc_addr
= (value
+ reloc
->r_addend
- (Elf32_Addr
) reloc_addr
);
523 case R_386_TLS_DTPMOD32
:
524 /* Get the information from the link map returned by the
527 *reloc_addr
= sym_map
->l_tls_modid
;
529 case R_386_TLS_DTPOFF32
:
530 /* During relocation all TLS symbols are defined and used.
531 Therefore the offset is already correct. */
532 *reloc_addr
= (sym
== NULL
? 0 : sym
->st_value
) + reloc
->r_addend
;
536 struct tlsdesc
volatile *td
=
537 (struct tlsdesc
volatile *)reloc_addr
;
539 # ifndef RTLD_BOOTSTRAP
542 td
->arg
= (void*)reloc
->r_addend
;
543 td
->entry
= _dl_tlsdesc_undefweak
;
548 # ifndef RTLD_BOOTSTRAP
550 CHECK_STATIC_TLS (map
, sym_map
);
552 if (!TRY_STATIC_TLS (map
, sym_map
))
554 td
->arg
= _dl_make_tlsdesc_dynamic
555 (sym_map
, sym
->st_value
+ reloc
->r_addend
);
556 td
->entry
= _dl_tlsdesc_dynamic
;
562 td
->arg
= (void*)(sym
->st_value
- sym_map
->l_tls_offset
564 td
->entry
= _dl_tlsdesc_return
;
569 case R_386_TLS_TPOFF32
:
570 /* The offset is positive, backward from the thread pointer. */
571 /* We know the offset of object the symbol is contained in.
572 It is a positive value which will be subtracted from the
573 thread pointer. To get the variable position in the TLS
574 block we subtract the offset from that of the TLS block. */
577 CHECK_STATIC_TLS (map
, sym_map
);
578 *reloc_addr
= sym_map
->l_tls_offset
- sym
->st_value
582 case R_386_TLS_TPOFF
:
583 /* The offset is negative, forward from the thread pointer. */
584 /* We know the offset of object the symbol is contained in.
585 It is a negative value which will be added to the
589 CHECK_STATIC_TLS (map
, sym_map
);
590 *reloc_addr
= sym
->st_value
- sym_map
->l_tls_offset
596 /* This can happen in trace mode if an object could not be
599 if (__builtin_expect (sym
->st_size
> refsym
->st_size
, 0)
600 || (__builtin_expect (sym
->st_size
< refsym
->st_size
, 0)
601 && GLRO(dl_verbose
)))
605 strtab
= (const char *) D_PTR (map
, l_info
[DT_STRTAB
]);
607 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
608 RTLD_PROGNAME
, strtab
+ refsym
->st_name
);
610 memcpy (reloc_addr_arg
, (void *) value
,
611 MIN (sym
->st_size
, refsym
->st_size
));
613 # endif /* !RESOLVE_CONFLICT_FIND_MAP */
614 case R_386_IRELATIVE
:
615 value
= map
->l_addr
+ reloc
->r_addend
;
616 value
= ((Elf32_Addr (*) (void)) value
) ();
620 /* We add these checks in the version to relocate ld.so only
621 if we are still debugging. */
622 _dl_reloc_bad_type (map
, r_type
, 0);
627 # endif /* !RTLD_BOOTSTRAP */
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 assert (ELF32_R_TYPE (reloc
->r_info
) == R_386_RELATIVE
);
636 *reloc_addr
+= l_addr
;
639 # ifndef RTLD_BOOTSTRAP
641 __attribute__ ((always_inline
))
642 elf_machine_rela_relative (Elf32_Addr l_addr
, const Elf32_Rela
*reloc
,
643 void *const reloc_addr_arg
)
645 Elf32_Addr
*const reloc_addr
= reloc_addr_arg
;
646 *reloc_addr
= l_addr
+ reloc
->r_addend
;
648 # endif /* !RTLD_BOOTSTRAP */
651 __attribute__ ((always_inline
))
652 elf_machine_lazy_rel (struct link_map
*map
,
653 Elf32_Addr l_addr
, const Elf32_Rel
*reloc
,
656 Elf32_Addr
*const reloc_addr
= (void *) (l_addr
+ reloc
->r_offset
);
657 const unsigned int r_type
= ELF32_R_TYPE (reloc
->r_info
);
658 /* Check for unexpected PLT reloc type. */
659 if (__glibc_likely (r_type
== R_386_JMP_SLOT
))
661 if (__builtin_expect (map
->l_mach
.plt
, 0) == 0)
662 *reloc_addr
+= l_addr
;
664 *reloc_addr
= (map
->l_mach
.plt
665 + (((Elf32_Addr
) reloc_addr
) - map
->l_mach
.gotplt
) * 4);
667 else if (__glibc_likely (r_type
== R_386_TLS_DESC
))
669 struct tlsdesc
volatile * __attribute__((__unused__
)) td
=
670 (struct tlsdesc
volatile *)reloc_addr
;
672 /* Handle relocations that reference the local *ABS* in a simple
673 way, so as to preserve a potential addend. */
674 if (ELF32_R_SYM (reloc
->r_info
) == 0)
675 td
->entry
= _dl_tlsdesc_resolve_abs_plus_addend
;
676 /* Given a known-zero addend, we can store a pointer to the
677 reloc in the arg position. */
678 else if (td
->arg
== 0)
680 td
->arg
= (void*)reloc
;
681 td
->entry
= _dl_tlsdesc_resolve_rel
;
685 /* We could handle non-*ABS* relocations with non-zero addends
686 by allocating dynamically an arg to hold a pointer to the
687 reloc, but that sounds pointless. */
688 const Elf32_Rel
*const r
= reloc
;
689 /* The code below was borrowed from elf_dynamic_do_rel(). */
690 const ElfW(Sym
) *const symtab
=
691 (const void *) D_PTR (map
, l_info
[DT_SYMTAB
]);
693 # ifdef RTLD_BOOTSTRAP
694 /* The dynamic linker always uses versioning. */
695 assert (map
->l_info
[VERSYMIDX (DT_VERSYM
)] != NULL
);
697 if (map
->l_info
[VERSYMIDX (DT_VERSYM
)])
700 const ElfW(Half
) *const version
=
701 (const void *) D_PTR (map
, l_info
[VERSYMIDX (DT_VERSYM
)]);
702 ElfW(Half
) ndx
= version
[ELFW(R_SYM
) (r
->r_info
)] & 0x7fff;
703 elf_machine_rel (map
, r
, &symtab
[ELFW(R_SYM
) (r
->r_info
)],
704 &map
->l_versions
[ndx
],
705 (void *) (l_addr
+ r
->r_offset
), skip_ifunc
);
707 # ifndef RTLD_BOOTSTRAP
709 elf_machine_rel (map
, r
, &symtab
[ELFW(R_SYM
) (r
->r_info
)], NULL
,
710 (void *) (l_addr
+ r
->r_offset
), skip_ifunc
);
714 else if (__glibc_unlikely (r_type
== R_386_IRELATIVE
))
716 Elf32_Addr value
= map
->l_addr
+ *reloc_addr
;
717 if (__glibc_likely (!skip_ifunc
))
718 value
= ((Elf32_Addr (*) (void)) value
) ();
722 _dl_reloc_bad_type (map
, r_type
, 1);
725 # ifndef RTLD_BOOTSTRAP
728 __attribute__ ((always_inline
))
729 elf_machine_lazy_rela (struct link_map
*map
,
730 Elf32_Addr l_addr
, const Elf32_Rela
*reloc
,
733 Elf32_Addr
*const reloc_addr
= (void *) (l_addr
+ reloc
->r_offset
);
734 const unsigned int r_type
= ELF32_R_TYPE (reloc
->r_info
);
735 if (__glibc_likely (r_type
== R_386_JMP_SLOT
))
737 else if (__glibc_likely (r_type
== R_386_TLS_DESC
))
739 struct tlsdesc
volatile * __attribute__((__unused__
)) td
=
740 (struct tlsdesc
volatile *)reloc_addr
;
742 td
->arg
= (void*)reloc
;
743 td
->entry
= _dl_tlsdesc_resolve_rela
;
745 else if (__glibc_unlikely (r_type
== R_386_IRELATIVE
))
747 Elf32_Addr value
= map
->l_addr
+ reloc
->r_addend
;
748 if (__glibc_likely (!skip_ifunc
))
749 value
= ((Elf32_Addr (*) (void)) value
) ();
753 _dl_reloc_bad_type (map
, r_type
, 1);
756 # endif /* !RTLD_BOOTSTRAP */
758 #endif /* RESOLVE_MAP */