]> sourceware.org Git - glibc.git/blob - sysdeps/i386/dl-machine.h
fa5076e3e5f351769602a202a7534482c058aca2
[glibc.git] / sysdeps / i386 / dl-machine.h
1 /* Machine-dependent ELF dynamic relocation inline functions. i386 version.
2 Copyright (C) 1995-2002, 2003 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
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.
9
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.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20 #ifndef dl_machine_h
21 #define dl_machine_h
22
23 #define ELF_MACHINE_NAME "i386"
24
25 #include <sys/param.h>
26
27 #include <tls.h>
28
29 /* Return nonzero iff ELF header is compatible with the running host. */
30 static inline int __attribute__ ((unused))
31 elf_machine_matches_host (const Elf32_Ehdr *ehdr)
32 {
33 return ehdr->e_machine == EM_386;
34 }
35
36
37 #if defined PI_STATIC_AND_HIDDEN \
38 && defined HAVE_VISIBILITY_ATTRIBUTE && defined HAVE_HIDDEN \
39 && !defined HAVE_BROKEN_VISIBILITY_ATTRIBUTE
40
41 /* Return the link-time address of _DYNAMIC. Conveniently, this is the
42 first element of the GOT, a special entry that is never relocated. */
43 static inline Elf32_Addr __attribute__ ((unused, const))
44 elf_machine_dynamic (void)
45 {
46 /* This produces a GOTOFF reloc that resolves to zero at link time, so in
47 fact just loads from the GOT register directly. By doing it without
48 an asm we can let the compiler choose any register. */
49 extern const Elf32_Addr _GLOBAL_OFFSET_TABLE_[] attribute_hidden;
50 return _GLOBAL_OFFSET_TABLE_[0];
51 }
52
53 /* Return the run-time load address of the shared object. */
54 static inline Elf32_Addr __attribute__ ((unused))
55 elf_machine_load_address (void)
56 {
57 /* Compute the difference between the runtime address of _DYNAMIC as seen
58 by a GOTOFF reference, and the link-time address found in the special
59 unrelocated first GOT entry. */
60 extern Elf32_Dyn bygotoff[] asm ("_DYNAMIC") attribute_hidden;
61 return (Elf32_Addr) &bygotoff - elf_machine_dynamic ();
62 }
63
64 #else /* Without .hidden support, we can't compile the code above. */
65
66 /* Return the link-time address of _DYNAMIC. Conveniently, this is the
67 first element of the GOT. This must be inlined in a function which
68 uses global data. */
69 static inline Elf32_Addr __attribute__ ((unused))
70 elf_machine_dynamic (void)
71 {
72 register Elf32_Addr *got asm ("%ebx");
73 return *got;
74 }
75
76
77 /* Return the run-time load address of the shared object. */
78 static inline Elf32_Addr __attribute__ ((unused))
79 elf_machine_load_address (void)
80 {
81 /* It doesn't matter what variable this is, the reference never makes
82 it to assembly. We need a dummy reference to some global variable
83 via the GOT to make sure the compiler initialized %ebx in time. */
84 extern int _dl_argc;
85 Elf32_Addr addr;
86 asm ("leal _dl_start@GOTOFF(%%ebx), %0\n"
87 "subl _dl_start@GOT(%%ebx), %0"
88 : "=r" (addr) : "m" (_dl_argc) : "cc");
89 return addr;
90 }
91
92 #endif
93
94
95 /* Set up the loaded object described by L so its unrelocated PLT
96 entries will jump to the on-demand fixup code in dl-runtime.c. */
97
98 static inline int __attribute__ ((unused))
99 elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
100 {
101 Elf32_Addr *got;
102 extern void _dl_runtime_resolve (Elf32_Word) attribute_hidden;
103 extern void _dl_runtime_profile (Elf32_Word) attribute_hidden;
104
105 if (l->l_info[DT_JMPREL] && lazy)
106 {
107 /* The GOT entries for functions in the PLT have not yet been filled
108 in. Their initial contents will arrange when called to push an
109 offset into the .rel.plt section, push _GLOBAL_OFFSET_TABLE_[1],
110 and then jump to _GLOBAL_OFFSET_TABLE[2]. */
111 got = (Elf32_Addr *) D_PTR (l, l_info[DT_PLTGOT]);
112 /* If a library is prelinked but we have to relocate anyway,
113 we have to be able to undo the prelinking of .got.plt.
114 The prelinker saved us here address of .plt + 0x16. */
115 if (got[1])
116 {
117 l->l_mach.plt = got[1] + l->l_addr;
118 l->l_mach.gotplt = (Elf32_Addr) &got[3];
119 }
120 got[1] = (Elf32_Addr) l; /* Identify this shared object. */
121
122 /* The got[2] entry contains the address of a function which gets
123 called to get the address of a so far unresolved function and
124 jump to it. The profiling extension of the dynamic linker allows
125 to intercept the calls to collect information. In this case we
126 don't store the address in the GOT so that all future calls also
127 end in this function. */
128 if (__builtin_expect (profile, 0))
129 {
130 got[2] = (Elf32_Addr) &_dl_runtime_profile;
131
132 if (_dl_name_match_p (GL(dl_profile), l))
133 /* This is the object we are looking for. Say that we really
134 want profiling and the timers are started. */
135 GL(dl_profile_map) = l;
136 }
137 else
138 /* This function will get called to fix up the GOT entry indicated by
139 the offset on the stack, and then jump to the resolved address. */
140 got[2] = (Elf32_Addr) &_dl_runtime_resolve;
141 }
142
143 return lazy;
144 }
145
146 #ifdef IN_DL_RUNTIME
147
148 # if !defined PROF && !__BOUNDED_POINTERS__
149 /* We add a declaration of this function here so that in dl-runtime.c
150 the ELF_MACHINE_RUNTIME_TRAMPOLINE macro really can pass the parameters
151 in registers.
152
153 We cannot use this scheme for profiling because the _mcount call
154 destroys the passed register information. */
155 /* GKM FIXME: Fix trampoline to pass bounds so we can do
156 without the `__unbounded' qualifier. */
157 static ElfW(Addr) fixup (struct link_map *__unbounded l, ElfW(Word) reloc_offset)
158 __attribute__ ((regparm (2), unused));
159 static ElfW(Addr) profile_fixup (struct link_map *l, ElfW(Word) reloc_offset,
160 ElfW(Addr) retaddr)
161 __attribute__ ((regparm (3), unused));
162 # endif
163
164 /* This code is used in dl-runtime.c to call the `fixup' function
165 and then redirect to the address it returns. */
166 # if !defined PROF && !__BOUNDED_POINTERS__
167 # define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\
168 .text\n\
169 .globl _dl_runtime_resolve\n\
170 .type _dl_runtime_resolve, @function\n\
171 .align 16\n\
172 _dl_runtime_resolve:\n\
173 pushl %eax # Preserve registers otherwise clobbered.\n\
174 pushl %ecx\n\
175 pushl %edx\n\
176 movl 16(%esp), %edx # Copy args pushed by PLT in register. Note\n\
177 movl 12(%esp), %eax # that `fixup' takes its parameters in regs.\n\
178 call fixup # Call resolver.\n\
179 popl %edx # Get register content back.\n\
180 popl %ecx\n\
181 xchgl %eax, (%esp) # Get %eax contents end store function address.\n\
182 ret $8 # Jump to function address.\n\
183 .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
184 \n\
185 .globl _dl_runtime_profile\n\
186 .type _dl_runtime_profile, @function\n\
187 .align 16\n\
188 _dl_runtime_profile:\n\
189 pushl %eax # Preserve registers otherwise clobbered.\n\
190 pushl %ecx\n\
191 pushl %edx\n\
192 movl 20(%esp), %ecx # Load return address\n\
193 movl 16(%esp), %edx # Copy args pushed by PLT in register. Note\n\
194 movl 12(%esp), %eax # that `fixup' takes its parameters in regs.\n\
195 call profile_fixup # Call resolver.\n\
196 popl %edx # Get register content back.\n\
197 popl %ecx\n\
198 xchgl %eax, (%esp) # Get %eax contents end store function address.\n\
199 ret $8 # Jump to function address.\n\
200 .size _dl_runtime_profile, .-_dl_runtime_profile\n\
201 .previous\n\
202 ");
203 # else
204 # define ELF_MACHINE_RUNTIME_TRAMPOLINE asm ("\n\
205 .text\n\
206 .globl _dl_runtime_resolve\n\
207 .globl _dl_runtime_profile\n\
208 .type _dl_runtime_resolve, @function\n\
209 .type _dl_runtime_profile, @function\n\
210 .align 16\n\
211 _dl_runtime_resolve:\n\
212 _dl_runtime_profile:\n\
213 pushl %eax # Preserve registers otherwise clobbered.\n\
214 pushl %ecx\n\
215 pushl %edx\n\
216 movl 16(%esp), %edx # Push the arguments for `fixup'\n\
217 movl 12(%esp), %eax\n\
218 pushl %edx\n\
219 pushl %eax\n\
220 call fixup # Call resolver.\n\
221 popl %edx # Pop the parameters\n\
222 popl %ecx\n\
223 popl %edx # Get register content back.\n\
224 popl %ecx\n\
225 xchgl %eax, (%esp) # Get %eax contents end store function address.\n\
226 ret $8 # Jump to function address.\n\
227 .size _dl_runtime_resolve, .-_dl_runtime_resolve\n\
228 .size _dl_runtime_profile, .-_dl_runtime_profile\n\
229 .previous\n\
230 ");
231 # endif
232 #endif
233
234 /* Mask identifying addresses reserved for the user program,
235 where the dynamic linker should not map anything. */
236 #define ELF_MACHINE_USER_ADDRESS_MASK 0xf8000000UL
237
238 /* Initial entry point code for the dynamic linker.
239 The C function `_dl_start' is the real entry point;
240 its return value is the user program's entry point. */
241
242 #define RTLD_START asm ("\n\
243 .text\n\
244 .align 16\n\
245 0: movl (%esp), %ebx\n\
246 ret\n\
247 .align 16\n\
248 .globl _start\n\
249 .globl _dl_start_user\n\
250 _start:\n\
251 # Note that _dl_start gets the parameter in %eax.\n\
252 movl %esp, %eax\n\
253 call _dl_start\n\
254 _dl_start_user:\n\
255 # Save the user entry point address in %edi.\n\
256 movl %eax, %edi\n\
257 # Point %ebx at the GOT.\n\
258 call 0b\n\
259 addl $_GLOBAL_OFFSET_TABLE_, %ebx\n\
260 # Store the highest stack address\n\
261 movl __libc_stack_end@GOT(%ebx), %eax\n\
262 movl %esp, (%eax)\n\
263 # See if we were run as a command with the executable file\n\
264 # name as an extra leading argument.\n\
265 movl _dl_skip_args@GOTOFF(%ebx), %eax\n\
266 # Pop the original argument count.\n\
267 popl %edx\n\
268 # Adjust the stack pointer to skip _dl_skip_args words.\n\
269 leal (%esp,%eax,4), %esp\n\
270 # Subtract _dl_skip_args from argc.\n\
271 subl %eax, %edx\n\
272 # Push argc back on the stack.\n\
273 push %edx\n\
274 # The special initializer gets called with the stack just\n\
275 # as the application's entry point will see it; it can\n\
276 # switch stacks if it moves these contents over.\n\
277 " RTLD_START_SPECIAL_INIT "\n\
278 # Load the parameters again.\n\
279 # (eax, edx, ecx, *--esp) = (_dl_loaded, argc, argv, envp)\n\
280 movl _rtld_local@GOTOFF(%ebx), %eax\n\
281 leal 8(%esp,%edx,4), %esi\n\
282 leal 4(%esp), %ecx\n\
283 pushl %esi\n\
284 # Call the function to run the initializers.\n\
285 call _dl_init_internal@PLT\n\
286 # Pass our finalizer function to the user in %edx, as per ELF ABI.\n\
287 leal _dl_fini@GOTOFF(%ebx), %edx\n\
288 # Jump to the user's entry point.\n\
289 jmp *%edi\n\
290 .previous\n\
291 ");
292
293 #ifndef RTLD_START_SPECIAL_INIT
294 # define RTLD_START_SPECIAL_INIT /* nothing */
295 #endif
296
297 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
298 TLS variable, so undefined references should not be allowed to
299 define the value.
300 ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
301 of the main executable's symbols, as for a COPY reloc. */
302 #if defined USE_TLS && (!defined RTLD_BOOTSTRAP || USE___THREAD)
303 # define elf_machine_type_class(type) \
304 ((((type) == R_386_JMP_SLOT || (type) == R_386_TLS_DTPMOD32 \
305 || (type) == R_386_TLS_DTPOFF32 || (type) == R_386_TLS_TPOFF32 \
306 || (type) == R_386_TLS_TPOFF) \
307 * ELF_RTYPE_CLASS_PLT) \
308 | (((type) == R_386_COPY) * ELF_RTYPE_CLASS_COPY))
309 #else
310 # define elf_machine_type_class(type) \
311 ((((type) == R_386_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
312 | (((type) == R_386_COPY) * ELF_RTYPE_CLASS_COPY))
313 #endif
314
315 /* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
316 #define ELF_MACHINE_JMP_SLOT R_386_JMP_SLOT
317
318 /* The i386 never uses Elf32_Rela relocations for the dynamic linker.
319 Prelinked libraries may use Elf32_Rela though. */
320 #define ELF_MACHINE_PLT_REL 1
321
322 /* We define an initialization functions. This is called very early in
323 _dl_sysdep_start. */
324 #define DL_PLATFORM_INIT dl_platform_init ()
325
326 static inline void __attribute__ ((unused))
327 dl_platform_init (void)
328 {
329 if (GL(dl_platform) != NULL && *GL(dl_platform) == '\0')
330 /* Avoid an empty string which would disturb us. */
331 GL(dl_platform) = NULL;
332 }
333
334 static inline Elf32_Addr
335 elf_machine_fixup_plt (struct link_map *map, lookup_t t,
336 const Elf32_Rel *reloc,
337 Elf32_Addr *reloc_addr, Elf32_Addr value)
338 {
339 return *reloc_addr = value;
340 }
341
342 /* Return the final value of a plt relocation. */
343 static inline Elf32_Addr
344 elf_machine_plt_value (struct link_map *map, const Elf32_Rel *reloc,
345 Elf32_Addr value)
346 {
347 return value;
348 }
349
350 #endif /* !dl_machine_h */
351
352 #ifdef RESOLVE
353
354 /* The i386 never uses Elf32_Rela relocations for the dynamic linker.
355 Prelinked libraries may use Elf32_Rela though. */
356 #ifdef RTLD_BOOTSTRAP
357 # define ELF_MACHINE_NO_RELA 1
358 #endif
359
360 /* Perform the relocation specified by RELOC and SYM (which is fully resolved).
361 MAP is the object containing the reloc. */
362
363 static inline void
364 elf_machine_rel (struct link_map *map, const Elf32_Rel *reloc,
365 const Elf32_Sym *sym, const struct r_found_version *version,
366 Elf32_Addr *const reloc_addr)
367 {
368 const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
369
370 #if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC
371 if (__builtin_expect (r_type == R_386_RELATIVE, 0))
372 {
373 # if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC
374 /* This is defined in rtld.c, but nowhere in the static libc.a;
375 make the reference weak so static programs can still link.
376 This declaration cannot be done when compiling rtld.c
377 (i.e. #ifdef RTLD_BOOTSTRAP) because rtld.c contains the
378 common defn for _dl_rtld_map, which is incompatible with a
379 weak decl in the same file. */
380 # ifndef SHARED
381 weak_extern (_dl_rtld_map);
382 # endif
383 if (map != &GL(dl_rtld_map)) /* Already done in rtld itself. */
384 # endif
385 *reloc_addr += map->l_addr;
386 }
387 # ifndef RTLD_BOOTSTRAP
388 else if (__builtin_expect (r_type == R_386_NONE, 0))
389 return;
390 # endif
391 else
392 #endif /* !RTLD_BOOTSTRAP and have no -z combreloc */
393 {
394 const Elf32_Sym *const refsym = sym;
395 #if defined USE_TLS && !defined RTLD_BOOTSTRAP
396 struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
397 Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value;
398 #else
399 Elf32_Addr value = RESOLVE (&sym, version, r_type);
400
401 # ifndef RTLD_BOOTSTRAP
402 if (sym != NULL)
403 # endif
404 value += sym->st_value;
405 #endif /* use TLS and !RTLD_BOOTSTRAP */
406
407 switch (r_type)
408 {
409 case R_386_GLOB_DAT:
410 case R_386_JMP_SLOT:
411 *reloc_addr = value;
412 break;
413
414 #if defined USE_TLS && (!defined RTLD_BOOTSTRAP || USE___THREAD)
415 case R_386_TLS_DTPMOD32:
416 # ifdef RTLD_BOOTSTRAP
417 /* During startup the dynamic linker is always the module
418 with index 1.
419 XXX If this relocation is necessary move before RESOLVE
420 call. */
421 *reloc_addr = 1;
422 # else
423 /* Get the information from the link map returned by the
424 resolv function. */
425 if (sym_map != NULL)
426 *reloc_addr = sym_map->l_tls_modid;
427 # endif
428 break;
429 case R_386_TLS_DTPOFF32:
430 # ifndef RTLD_BOOTSTRAP
431 /* During relocation all TLS symbols are defined and used.
432 Therefore the offset is already correct. */
433 if (sym != NULL)
434 *reloc_addr = sym->st_value;
435 # endif
436 break;
437 case R_386_TLS_TPOFF32:
438 /* The offset is positive, backward from the thread pointer. */
439 # ifdef RTLD_BOOTSTRAP
440 *reloc_addr += map->l_tls_offset - sym->st_value;
441 # else
442 /* We know the offset of object the symbol is contained in.
443 It is a positive value which will be subtracted from the
444 thread pointer. To get the variable position in the TLS
445 block we subtract the offset from that of the TLS block. */
446 if (sym != NULL)
447 {
448 CHECK_STATIC_TLS (map, sym_map);
449 *reloc_addr += sym_map->l_tls_offset - sym->st_value;
450 }
451 # endif
452 break;
453 case R_386_TLS_TPOFF:
454 /* The offset is negative, forward from the thread pointer. */
455 # ifdef RTLD_BOOTSTRAP
456 *reloc_addr += sym->st_value - map->l_tls_offset;
457 # else
458 /* We know the offset of object the symbol is contained in.
459 It is a negative value which will be added to the
460 thread pointer. */
461 if (sym != NULL)
462 {
463 CHECK_STATIC_TLS (map, sym_map);
464 *reloc_addr += sym->st_value - sym_map->l_tls_offset;
465 }
466 # endif
467 break;
468 #endif /* use TLS */
469
470 #ifndef RTLD_BOOTSTRAP
471 case R_386_32:
472 *reloc_addr += value;
473 break;
474 case R_386_PC32:
475 *reloc_addr += (value - (Elf32_Addr) reloc_addr);
476 break;
477 case R_386_COPY:
478 if (sym == NULL)
479 /* This can happen in trace mode if an object could not be
480 found. */
481 break;
482 if (__builtin_expect (sym->st_size > refsym->st_size, 0)
483 || (__builtin_expect (sym->st_size < refsym->st_size, 0)
484 && GL(dl_verbose)))
485 {
486 const char *strtab;
487
488 strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
489 _dl_error_printf ("\
490 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
491 rtld_progname ?: "<program name unknown>",
492 strtab + refsym->st_name);
493 }
494 memcpy (reloc_addr, (void *) value, MIN (sym->st_size,
495 refsym->st_size));
496 break;
497 default:
498 _dl_reloc_bad_type (map, r_type, 0);
499 break;
500 #endif /* !RTLD_BOOTSTRAP */
501 }
502 }
503 }
504
505 #ifndef RTLD_BOOTSTRAP
506 static inline void
507 elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
508 const Elf32_Sym *sym, const struct r_found_version *version,
509 Elf32_Addr *const reloc_addr)
510 {
511 const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
512
513 if (ELF32_R_TYPE (reloc->r_info) == R_386_RELATIVE)
514 *reloc_addr = map->l_addr + reloc->r_addend;
515 else if (r_type != R_386_NONE)
516 {
517 # ifndef RESOLVE_CONFLICT_FIND_MAP
518 const Elf32_Sym *const refsym = sym;
519 # endif
520 # ifdef USE_TLS
521 struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
522 Elf32_Addr value = sym == NULL ? 0 : sym_map->l_addr + sym->st_value;
523 # else
524 Elf32_Addr value = RESOLVE (&sym, version, ELF32_R_TYPE (reloc->r_info));
525 if (sym != NULL)
526 value += sym->st_value;
527 # endif
528
529 switch (ELF32_R_TYPE (reloc->r_info))
530 {
531 case R_386_GLOB_DAT:
532 case R_386_JMP_SLOT:
533 case R_386_32:
534 *reloc_addr = value + reloc->r_addend;
535 break;
536 case R_386_PC32:
537 *reloc_addr = (value + reloc->r_addend - (Elf32_Addr) reloc_addr);
538 break;
539
540 # ifdef USE_TLS
541 case R_386_TLS_DTPMOD32:
542 /* Get the information from the link map returned by the
543 resolv function. */
544 if (sym_map != NULL)
545 *reloc_addr = sym_map->l_tls_modid;
546 break;
547 case R_386_TLS_DTPOFF32:
548 /* During relocation all TLS symbols are defined and used.
549 Therefore the offset is already correct. */
550 *reloc_addr = (sym == NULL ? 0 : sym->st_value) + reloc->r_addend;
551 break;
552 case R_386_TLS_TPOFF32:
553 /* The offset is positive, backward from the thread pointer. */
554 /* We know the offset of object the symbol is contained in.
555 It is a positive value which will be subtracted from the
556 thread pointer. To get the variable position in the TLS
557 block we subtract the offset from that of the TLS block. */
558 CHECK_STATIC_TLS (map, sym_map);
559 *reloc_addr
560 = (sym == NULL ? 0 : sym_map->l_tls_offset - sym->st_value)
561 + reloc->r_addend;
562 break;
563 case R_386_TLS_TPOFF:
564 /* The offset is negative, forward from the thread pointer. */
565 /* We know the offset of object the symbol is contained in.
566 It is a negative value which will be added to the
567 thread pointer. */
568 CHECK_STATIC_TLS (map, sym_map);
569 *reloc_addr
570 = (sym == NULL ? 0 : sym->st_value - sym_map->l_tls_offset)
571 + reloc->r_addend;
572 break;
573 # endif /* use TLS */
574 # ifndef RESOLVE_CONFLICT_FIND_MAP
575 /* Not needed for dl-conflict.c. */
576 case R_386_COPY:
577 if (sym == NULL)
578 /* This can happen in trace mode if an object could not be
579 found. */
580 break;
581 if (__builtin_expect (sym->st_size > refsym->st_size, 0)
582 || (__builtin_expect (sym->st_size < refsym->st_size, 0)
583 && GL(dl_verbose)))
584 {
585 const char *strtab;
586
587 strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
588 _dl_error_printf ("\
589 %s: Symbol `%s' has different size in shared object, consider re-linking\n",
590 rtld_progname ?: "<program name unknown>",
591 strtab + refsym->st_name);
592 }
593 memcpy (reloc_addr, (void *) value, MIN (sym->st_size,
594 refsym->st_size));
595 break;
596 # endif /* !RESOLVE_CONFLICT_FIND_MAP */
597 default:
598 /* We add these checks in the version to relocate ld.so only
599 if we are still debugging. */
600 _dl_reloc_bad_type (map, r_type, 0);
601 break;
602 }
603 }
604 }
605 #endif /* !RTLD_BOOTSTRAP */
606
607 static inline void
608 elf_machine_rel_relative (Elf32_Addr l_addr, const Elf32_Rel *reloc,
609 Elf32_Addr *const reloc_addr)
610 {
611 assert (ELF32_R_TYPE (reloc->r_info) == R_386_RELATIVE);
612 *reloc_addr += l_addr;
613 }
614
615 #ifndef RTLD_BOOTSTRAP
616 static inline void
617 elf_machine_rela_relative (Elf32_Addr l_addr, const Elf32_Rela *reloc,
618 Elf32_Addr *const reloc_addr)
619 {
620 *reloc_addr = l_addr + reloc->r_addend;
621 }
622 #endif /* !RTLD_BOOTSTRAP */
623
624 static inline void
625 elf_machine_lazy_rel (struct link_map *map,
626 Elf32_Addr l_addr, const Elf32_Rel *reloc)
627 {
628 Elf32_Addr *const reloc_addr = (void *) (l_addr + reloc->r_offset);
629 const unsigned int r_type = ELF32_R_TYPE (reloc->r_info);
630 /* Check for unexpected PLT reloc type. */
631 if (__builtin_expect (r_type == R_386_JMP_SLOT, 1))
632 {
633 if (__builtin_expect (map->l_mach.plt, 0) == 0)
634 *reloc_addr += l_addr;
635 else
636 *reloc_addr = (map->l_mach.plt
637 + (((Elf32_Addr) reloc_addr) - map->l_mach.gotplt) * 4);
638 }
639 else
640 _dl_reloc_bad_type (map, r_type, 1);
641 }
642
643 #ifndef RTLD_BOOTSTRAP
644
645 static inline void
646 elf_machine_lazy_rela (struct link_map *map,
647 Elf32_Addr l_addr, const Elf32_Rela *reloc)
648 {
649 }
650
651 #endif /* !RTLD_BOOTSTRAP */
652
653 #endif /* RESOLVE */
This page took 0.066199 seconds and 5 git commands to generate.