2001-09-19 12:37:31 +02:00
|
|
|
/* Machine-dependent ELF dynamic relocation inline functions. x86-64 version.
|
2012-05-10 19:20:51 +02:00
|
|
|
Copyright (C) 2001-2012 Free Software Foundation, Inc.
|
2001-09-19 12:37:31 +02:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
Contributed by Andreas Jaeger <aj@suse.de>.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-10 00:18:22 +01:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
2001-09-19 12:37:31 +02:00
|
|
|
|
|
|
|
#ifndef dl_machine_h
|
|
|
|
#define dl_machine_h
|
|
|
|
|
|
|
|
#define ELF_MACHINE_NAME "x86_64"
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
2003-05-30 18:12:18 +02:00
|
|
|
#include <sysdep.h>
|
2004-01-14 00:15:57 +01:00
|
|
|
#include <tls.h>
|
Introduce TLS descriptors for i386 and x86_64.
* include/inline-hashtab.h: New file, copied from 2005's
libiberty, with fix for memory leak imported afterwards by
Glauber de Oliveira Costa.
* elf/tlsdeschtab.h: New file.
* elf/dl-reloc.c (_dl_try_allocate_static_tls): Extract from...
(_dl_allocate_static_tls): ... here. Rearrange failure path.
(CHECK_STATIC_TLS): Move to...
* elf/dynamic-link.h: ... this file.
(TRY_STATIC_TLS): New macro.
* elf/dl-conflict.c (CHECK_STATIC_TLS, TRY_STATIC_TLS): Override.
* elf/elf.h (R_386_TLS_GOTDESC, R_386_TLS_DESC_CALL,
R_386_TLS_DESC): Define.
(R_X86_64_PC64, R_X86_GOTOFF64, R_X86_64_GOTPC32): Merge from
binutils.
(R_X86_64_GOTPC32_TLSDESC, R_X86_64_TLSDESC_CALL,
R_X86_64_TLSDESC): Define.
(R_386_NUM, R_X86_64_NUM): Adjust.
* sysdeps/i386/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/i386/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/i386/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_type_class): Mark R_386_TLS_DESC as PLT class.
(elf_machine_rel): Handle R_386_TLS_DESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
(elf_machine_lazy_rela): Likewise.
* sysdeps/i386/dl-tls.h (struct dl_tls_index): Name it.
* sysdeps/i386/dl-tlsdesc.S: New file.
* sysdeps/i386/dl-tlsdesc.h: New file.
* sysdeps/i386/tlsdesc.c: New file.
* sysdeps/i386/tlsdesc.sym: New file.
* sysdeps/i386/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table.
* sysdeps/x86_64/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/x86_64/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/x86_64/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_runtime_setup): Set up lazy TLSDESC GOT entry.
(elf_machine_type_class): Mark R_X86_64_TLSDESC as PLT class.
(elf_machine_rel): Handle R_X86_64_TLSDESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
* sysdeps/x86_64/dl-tls.h (struct dl_tls_index): Name it.
(__tls_get_addr): Do not declare for non-shared compiles.
* sysdeps/x86_64/dl-tlsdesc.S: New file.
* sysdeps/x86_64/dl-tlsdesc.h: New file.
* sysdeps/x86_64/tlsdesc.c: New file.
* sysdeps/x86_64/tlsdesc.sym: New file.
* sysdeps/x86_64/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table for both 32- and 64-bit structs.
2008-05-13 07:41:30 +02:00
|
|
|
#include <dl-tlsdesc.h>
|
2001-09-19 12:37:31 +02:00
|
|
|
|
|
|
|
/* Return nonzero iff ELF header is compatible with the running host. */
|
|
|
|
static inline int __attribute__ ((unused))
|
2012-05-08 18:39:58 +02:00
|
|
|
elf_machine_matches_host (const ElfW(Ehdr) *ehdr)
|
2001-09-19 12:37:31 +02:00
|
|
|
{
|
|
|
|
return ehdr->e_machine == EM_X86_64;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Return the link-time address of _DYNAMIC. Conveniently, this is the
|
|
|
|
first element of the GOT. This must be inlined in a function which
|
|
|
|
uses global data. */
|
2012-05-08 18:39:58 +02:00
|
|
|
static inline ElfW(Addr) __attribute__ ((unused))
|
2001-09-19 12:37:31 +02:00
|
|
|
elf_machine_dynamic (void)
|
|
|
|
{
|
2012-05-08 18:39:58 +02:00
|
|
|
ElfW(Addr) addr;
|
2002-06-25 14:32:52 +02:00
|
|
|
|
|
|
|
/* This works because we have our GOT address available in the small PIC
|
|
|
|
model. */
|
2012-05-08 18:39:58 +02:00
|
|
|
addr = (ElfW(Addr)) &_DYNAMIC;
|
2001-09-19 12:37:31 +02:00
|
|
|
|
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Return the run-time load address of the shared object. */
|
2012-05-08 18:39:58 +02:00
|
|
|
static inline ElfW(Addr) __attribute__ ((unused))
|
2001-09-19 12:37:31 +02:00
|
|
|
elf_machine_load_address (void)
|
|
|
|
{
|
2012-05-08 18:39:58 +02:00
|
|
|
ElfW(Addr) addr;
|
2001-09-19 12:37:31 +02:00
|
|
|
|
2002-06-25 14:32:52 +02:00
|
|
|
/* The easy way is just the same as on x86:
|
|
|
|
leaq _dl_start, %0
|
|
|
|
leaq _dl_start(%%rip), %1
|
|
|
|
subq %0, %1
|
|
|
|
but this does not work with binutils since we then have
|
|
|
|
a R_X86_64_32S relocation in a shared lib.
|
|
|
|
|
|
|
|
Instead we store the address of _dl_start in the data section
|
|
|
|
and compare it with the current value that we can get via
|
2005-07-31 19:50:49 +02:00
|
|
|
an RIP relative addressing mode. Note that this is the address
|
|
|
|
of _dl_start before any relocation performed at runtime. In case
|
|
|
|
the binary is prelinked the resulting "address" is actually a
|
|
|
|
load offset which is zero if the binary was loaded at the address
|
|
|
|
it is prelinked for. */
|
|
|
|
|
2012-05-15 00:17:30 +02:00
|
|
|
asm ("lea _dl_start(%%rip), %0\n\t"
|
|
|
|
"sub 1f(%%rip), %0\n\t"
|
2005-07-31 18:28:55 +02:00
|
|
|
".section\t.data.rel.ro\n"
|
2012-05-15 00:17:30 +02:00
|
|
|
"1:\t" ASM_ADDR " _dl_start\n\t"
|
2002-06-25 14:32:52 +02:00
|
|
|
".previous\n\t"
|
2005-07-31 19:50:49 +02:00
|
|
|
: "=r" (addr) : : "cc");
|
2002-06-25 14:32:52 +02:00
|
|
|
|
2001-09-19 12:37:31 +02:00
|
|
|
return addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set up the loaded object described by L so its unrelocated PLT
|
|
|
|
entries will jump to the on-demand fixup code in dl-runtime.c. */
|
|
|
|
|
2003-06-18 21:34:34 +02:00
|
|
|
static inline int __attribute__ ((unused, always_inline))
|
2001-09-19 12:37:31 +02:00
|
|
|
elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
|
|
|
|
{
|
|
|
|
Elf64_Addr *got;
|
2012-05-08 18:39:58 +02:00
|
|
|
extern void _dl_runtime_resolve (ElfW(Word)) attribute_hidden;
|
|
|
|
extern void _dl_runtime_profile (ElfW(Word)) attribute_hidden;
|
2001-09-19 12:37:31 +02:00
|
|
|
|
|
|
|
if (l->l_info[DT_JMPREL] && lazy)
|
|
|
|
{
|
|
|
|
/* The GOT entries for functions in the PLT have not yet been filled
|
|
|
|
in. Their initial contents will arrange when called to push an
|
|
|
|
offset into the .rel.plt section, push _GLOBAL_OFFSET_TABLE_[1],
|
2011-12-23 19:59:40 +01:00
|
|
|
and then jump to _GLOBAL_OFFSET_TABLE_[2]. */
|
2001-09-19 12:37:31 +02:00
|
|
|
got = (Elf64_Addr *) D_PTR (l, l_info[DT_PLTGOT]);
|
Update.
2001-12-11 Jakub Jelinek <jakub@redhat.com>
* elf/Makefile (dl-routines): Add conflict.
(rtld-ldscript-in, rtld-ldscript, rtld-parms): Remove.
(ld.so): Add _begin local symbol.
* elf/elf.h (DT_VALTAGIDX, DT_VALNUM, DT_ADDRTAGIDX, DT_ADDRNUM):
Define.
* elf/dl-deps.c (_dl_build_local_scope): New.
(_dl_map_object_deps): If LD_TRACE_PRELINKING, compute local scopes
of all libraries.
* elf/do-rel.h (VALIDX): Define.
(elf_dynamic_do_rel): If ELF_MACHINE_PLT_REL is defined, don't do
lazy binding for RELA. If DT_GNU_PRELINKED, DT_RELACOUNT relocations
can be skipped.
* elf/dl-conflict.c: New file.
* elf/dl-lookup.c (_dl_debug_bindings): New.
(_dl_lookup_symbol): Use _dl_debug_bindings. Reference_name is always
non-NULL.
(_dl_lookup_symbol_skip): Likewise.
(_dl_lookup_versioned_symbol): Likewise.
(_dl_lookup_versioned_symbol_skip): Likewise.
* elf/dl-runtime.c (PLTREL): If ELF_MACHINE_PLT_REL is defined,
define to ElfW(Rel).
* elf/dynamic-link.h (elf_get_dynamic_info): Record selected dynamic
tags in the DT_VALRNGLO..DT_VALRNGHI and DT_ADDRRNGLO..DT_ADDRRNGHI
ranges.
Don't adjust address dynamic tags if l_addr is 0.
* elf/rtld.c (_dl_trace_prelink, _dl_trace_prelink_map): New variables.
(_dl_start): Skip ELF_DYNAMIC_RELOCATE if ld.so is prelinked.
(VALIDX, ADDRIDX): Define.
(_dl_start_final): Initialize _dl_rtld_map's l_map_start and l_map_end.
(dl_main): Print library list for LD_TRACE_PRELINKING.
If prelinking information can be used, skip relocating libraries and
call _dl_resolve_conflicts instead.
(process_envvars): Handle LD_TRACE_PRELINKING envvar.
* elf/dl-load.c (_dl_map_object): Don't create fake libs
if LD_TRACE_PRELINKING.
* include/link.h (struct link_map) [l_info]: Add DT_VALNUM
+ DT_ADDRNUM.
* sysdeps/generic/ldsodefs.h (_dl_trace_prelink_map): New declaration.
(DL_DEBUG_PRELINK): Define.
(_dl_resolve_conflicts): Add prototype.
* sysdeps/alpha/dl-machine.h (elf_machine_runtime_setup): Reinitialize
.plt for prelinked libraries where prelinking info cannot be used.
(elf_machine_rela): If relocating R_ALPHA_JMP_SLOT in .gnu.conflict
section, use RESOLVE_CONFLICT_FIND_MAP to find out reloc's link_map.
* sysdeps/arm/bits/link.h: New file.
* sysdeps/arm/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(ELF_MACHINE_NO_RELA): Only define if RTLD_BOOTSTRAP.
(ELF_MACHINE_PLT_REL): Define.
(elf_machine_rela, elf_machine_rela_relative): New.
(elf_machine_lazy_rel): Reinitialize R_ARM_JUMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/i386/bits/link.h: New file.
* sysdeps/i386/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(ELF_MACHINE_NO_RELA): Only define if RTLD_BOOTSTRAP.
(ELF_MACHINE_PLT_REL): Define.
(elf_machine_rela, elf_machine_rela_relative): New.
(elf_machine_lazy_rel): Reinitialize R_386_JUMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/powerpc/dl-machine.h (elf_machine_rela): If relocating
conflicts, skip finaladdr computation. Use RESOLVE_CONFLICT_FIND_MAP
to find out map for R_PPC_JMP_SLOT relocs.
* sysdeps/sparc/sparc32/dl-machine.h (VALIDX): Define.
(OPCODE_BA): Define.
(elf_machine_runtime_setup): Reinitialize .plt for prelinked
libraries where prelinking info cannot be used.
(sparc_fixup_plt): Renamed from elf_machine_fixup_plt.
(elf_machine_fixup_plt): Call sparc_fixup_plt.
(elf_machine_rela): Set value to 0 if relocating conflicts.
Call sparc_fixup_plt for R_SPARC_JMP_SLOT.
* sysdeps/sparc/sparc64/dl-machine.h (VALIDX): Define.
(sparc64_fixup_plt): Fix a typo.
(elf_machine_rela): Set value to 0 if relocating conflicts.
Handle R_SPARC_JMP_SLOT relocs when relocating conflicts.
(elf_machine_runtime_setup): Reinitialize .plt for prelinked
libraries where prelinking info cannot be used.
* sysdeps/sh/bits/link.h: New file.
* sysdeps/sh/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_SH_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/s390/s390-32/bits/link.h: New file.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_390_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/s390/s390-64/bits/link.h: New file.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_390_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/x86_64/bits/link.h: New file.
* sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_X86_64_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
2001-12-12 01:21:26 +01:00
|
|
|
/* If a library is prelinked but we have to relocate anyway,
|
|
|
|
we have to be able to undo the prelinking of .got.plt.
|
|
|
|
The prelinker saved us here address of .plt + 0x16. */
|
|
|
|
if (got[1])
|
|
|
|
{
|
|
|
|
l->l_mach.plt = got[1] + l->l_addr;
|
2012-05-08 18:39:58 +02:00
|
|
|
l->l_mach.gotplt = (ElfW(Addr)) &got[3];
|
Update.
2001-12-11 Jakub Jelinek <jakub@redhat.com>
* elf/Makefile (dl-routines): Add conflict.
(rtld-ldscript-in, rtld-ldscript, rtld-parms): Remove.
(ld.so): Add _begin local symbol.
* elf/elf.h (DT_VALTAGIDX, DT_VALNUM, DT_ADDRTAGIDX, DT_ADDRNUM):
Define.
* elf/dl-deps.c (_dl_build_local_scope): New.
(_dl_map_object_deps): If LD_TRACE_PRELINKING, compute local scopes
of all libraries.
* elf/do-rel.h (VALIDX): Define.
(elf_dynamic_do_rel): If ELF_MACHINE_PLT_REL is defined, don't do
lazy binding for RELA. If DT_GNU_PRELINKED, DT_RELACOUNT relocations
can be skipped.
* elf/dl-conflict.c: New file.
* elf/dl-lookup.c (_dl_debug_bindings): New.
(_dl_lookup_symbol): Use _dl_debug_bindings. Reference_name is always
non-NULL.
(_dl_lookup_symbol_skip): Likewise.
(_dl_lookup_versioned_symbol): Likewise.
(_dl_lookup_versioned_symbol_skip): Likewise.
* elf/dl-runtime.c (PLTREL): If ELF_MACHINE_PLT_REL is defined,
define to ElfW(Rel).
* elf/dynamic-link.h (elf_get_dynamic_info): Record selected dynamic
tags in the DT_VALRNGLO..DT_VALRNGHI and DT_ADDRRNGLO..DT_ADDRRNGHI
ranges.
Don't adjust address dynamic tags if l_addr is 0.
* elf/rtld.c (_dl_trace_prelink, _dl_trace_prelink_map): New variables.
(_dl_start): Skip ELF_DYNAMIC_RELOCATE if ld.so is prelinked.
(VALIDX, ADDRIDX): Define.
(_dl_start_final): Initialize _dl_rtld_map's l_map_start and l_map_end.
(dl_main): Print library list for LD_TRACE_PRELINKING.
If prelinking information can be used, skip relocating libraries and
call _dl_resolve_conflicts instead.
(process_envvars): Handle LD_TRACE_PRELINKING envvar.
* elf/dl-load.c (_dl_map_object): Don't create fake libs
if LD_TRACE_PRELINKING.
* include/link.h (struct link_map) [l_info]: Add DT_VALNUM
+ DT_ADDRNUM.
* sysdeps/generic/ldsodefs.h (_dl_trace_prelink_map): New declaration.
(DL_DEBUG_PRELINK): Define.
(_dl_resolve_conflicts): Add prototype.
* sysdeps/alpha/dl-machine.h (elf_machine_runtime_setup): Reinitialize
.plt for prelinked libraries where prelinking info cannot be used.
(elf_machine_rela): If relocating R_ALPHA_JMP_SLOT in .gnu.conflict
section, use RESOLVE_CONFLICT_FIND_MAP to find out reloc's link_map.
* sysdeps/arm/bits/link.h: New file.
* sysdeps/arm/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(ELF_MACHINE_NO_RELA): Only define if RTLD_BOOTSTRAP.
(ELF_MACHINE_PLT_REL): Define.
(elf_machine_rela, elf_machine_rela_relative): New.
(elf_machine_lazy_rel): Reinitialize R_ARM_JUMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/i386/bits/link.h: New file.
* sysdeps/i386/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(ELF_MACHINE_NO_RELA): Only define if RTLD_BOOTSTRAP.
(ELF_MACHINE_PLT_REL): Define.
(elf_machine_rela, elf_machine_rela_relative): New.
(elf_machine_lazy_rel): Reinitialize R_386_JUMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/powerpc/dl-machine.h (elf_machine_rela): If relocating
conflicts, skip finaladdr computation. Use RESOLVE_CONFLICT_FIND_MAP
to find out map for R_PPC_JMP_SLOT relocs.
* sysdeps/sparc/sparc32/dl-machine.h (VALIDX): Define.
(OPCODE_BA): Define.
(elf_machine_runtime_setup): Reinitialize .plt for prelinked
libraries where prelinking info cannot be used.
(sparc_fixup_plt): Renamed from elf_machine_fixup_plt.
(elf_machine_fixup_plt): Call sparc_fixup_plt.
(elf_machine_rela): Set value to 0 if relocating conflicts.
Call sparc_fixup_plt for R_SPARC_JMP_SLOT.
* sysdeps/sparc/sparc64/dl-machine.h (VALIDX): Define.
(sparc64_fixup_plt): Fix a typo.
(elf_machine_rela): Set value to 0 if relocating conflicts.
Handle R_SPARC_JMP_SLOT relocs when relocating conflicts.
(elf_machine_runtime_setup): Reinitialize .plt for prelinked
libraries where prelinking info cannot be used.
* sysdeps/sh/bits/link.h: New file.
* sysdeps/sh/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_SH_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/s390/s390-32/bits/link.h: New file.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_390_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/s390/s390-64/bits/link.h: New file.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_390_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/x86_64/bits/link.h: New file.
* sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_X86_64_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
2001-12-12 01:21:26 +01:00
|
|
|
}
|
2012-05-08 18:39:58 +02:00
|
|
|
/* Identify this shared object. */
|
|
|
|
*(ElfW(Addr) *) (got + 1) = (ElfW(Addr)) l;
|
2001-09-19 12:37:31 +02:00
|
|
|
|
|
|
|
/* The got[2] entry contains the address of a function which gets
|
|
|
|
called to get the address of a so far unresolved function and
|
|
|
|
jump to it. The profiling extension of the dynamic linker allows
|
|
|
|
to intercept the calls to collect information. In this case we
|
|
|
|
don't store the address in the GOT so that all future calls also
|
|
|
|
end in this function. */
|
|
|
|
if (__builtin_expect (profile, 0))
|
|
|
|
{
|
2012-05-08 18:39:58 +02:00
|
|
|
*(ElfW(Addr) *) (got + 2) = (ElfW(Addr)) &_dl_runtime_profile;
|
2001-09-19 12:37:31 +02:00
|
|
|
|
2005-01-06 23:40:27 +01:00
|
|
|
if (GLRO(dl_profile) != NULL
|
|
|
|
&& _dl_name_match_p (GLRO(dl_profile), l))
|
2001-09-19 12:37:31 +02:00
|
|
|
/* This is the object we are looking for. Say that we really
|
|
|
|
want profiling and the timers are started. */
|
2002-02-01 02:33:04 +01:00
|
|
|
GL(dl_profile_map) = l;
|
2001-09-19 12:37:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
/* This function will get called to fix up the GOT entry indicated by
|
|
|
|
the offset on the stack, and then jump to the resolved address. */
|
2012-05-08 18:39:58 +02:00
|
|
|
*(ElfW(Addr) *) (got + 2) = (ElfW(Addr)) &_dl_runtime_resolve;
|
2001-09-19 12:37:31 +02:00
|
|
|
}
|
|
|
|
|
Introduce TLS descriptors for i386 and x86_64.
* include/inline-hashtab.h: New file, copied from 2005's
libiberty, with fix for memory leak imported afterwards by
Glauber de Oliveira Costa.
* elf/tlsdeschtab.h: New file.
* elf/dl-reloc.c (_dl_try_allocate_static_tls): Extract from...
(_dl_allocate_static_tls): ... here. Rearrange failure path.
(CHECK_STATIC_TLS): Move to...
* elf/dynamic-link.h: ... this file.
(TRY_STATIC_TLS): New macro.
* elf/dl-conflict.c (CHECK_STATIC_TLS, TRY_STATIC_TLS): Override.
* elf/elf.h (R_386_TLS_GOTDESC, R_386_TLS_DESC_CALL,
R_386_TLS_DESC): Define.
(R_X86_64_PC64, R_X86_GOTOFF64, R_X86_64_GOTPC32): Merge from
binutils.
(R_X86_64_GOTPC32_TLSDESC, R_X86_64_TLSDESC_CALL,
R_X86_64_TLSDESC): Define.
(R_386_NUM, R_X86_64_NUM): Adjust.
* sysdeps/i386/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/i386/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/i386/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_type_class): Mark R_386_TLS_DESC as PLT class.
(elf_machine_rel): Handle R_386_TLS_DESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
(elf_machine_lazy_rela): Likewise.
* sysdeps/i386/dl-tls.h (struct dl_tls_index): Name it.
* sysdeps/i386/dl-tlsdesc.S: New file.
* sysdeps/i386/dl-tlsdesc.h: New file.
* sysdeps/i386/tlsdesc.c: New file.
* sysdeps/i386/tlsdesc.sym: New file.
* sysdeps/i386/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table.
* sysdeps/x86_64/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/x86_64/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/x86_64/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_runtime_setup): Set up lazy TLSDESC GOT entry.
(elf_machine_type_class): Mark R_X86_64_TLSDESC as PLT class.
(elf_machine_rel): Handle R_X86_64_TLSDESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
* sysdeps/x86_64/dl-tls.h (struct dl_tls_index): Name it.
(__tls_get_addr): Do not declare for non-shared compiles.
* sysdeps/x86_64/dl-tlsdesc.S: New file.
* sysdeps/x86_64/dl-tlsdesc.h: New file.
* sysdeps/x86_64/tlsdesc.c: New file.
* sysdeps/x86_64/tlsdesc.sym: New file.
* sysdeps/x86_64/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table for both 32- and 64-bit structs.
2008-05-13 07:41:30 +02:00
|
|
|
if (l->l_info[ADDRIDX (DT_TLSDESC_GOT)] && lazy)
|
2012-05-08 18:39:58 +02:00
|
|
|
*(ElfW(Addr)*)(D_PTR (l, l_info[ADDRIDX (DT_TLSDESC_GOT)]) + l->l_addr)
|
|
|
|
= (ElfW(Addr)) &_dl_tlsdesc_resolve_rela;
|
Introduce TLS descriptors for i386 and x86_64.
* include/inline-hashtab.h: New file, copied from 2005's
libiberty, with fix for memory leak imported afterwards by
Glauber de Oliveira Costa.
* elf/tlsdeschtab.h: New file.
* elf/dl-reloc.c (_dl_try_allocate_static_tls): Extract from...
(_dl_allocate_static_tls): ... here. Rearrange failure path.
(CHECK_STATIC_TLS): Move to...
* elf/dynamic-link.h: ... this file.
(TRY_STATIC_TLS): New macro.
* elf/dl-conflict.c (CHECK_STATIC_TLS, TRY_STATIC_TLS): Override.
* elf/elf.h (R_386_TLS_GOTDESC, R_386_TLS_DESC_CALL,
R_386_TLS_DESC): Define.
(R_X86_64_PC64, R_X86_GOTOFF64, R_X86_64_GOTPC32): Merge from
binutils.
(R_X86_64_GOTPC32_TLSDESC, R_X86_64_TLSDESC_CALL,
R_X86_64_TLSDESC): Define.
(R_386_NUM, R_X86_64_NUM): Adjust.
* sysdeps/i386/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/i386/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/i386/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_type_class): Mark R_386_TLS_DESC as PLT class.
(elf_machine_rel): Handle R_386_TLS_DESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
(elf_machine_lazy_rela): Likewise.
* sysdeps/i386/dl-tls.h (struct dl_tls_index): Name it.
* sysdeps/i386/dl-tlsdesc.S: New file.
* sysdeps/i386/dl-tlsdesc.h: New file.
* sysdeps/i386/tlsdesc.c: New file.
* sysdeps/i386/tlsdesc.sym: New file.
* sysdeps/i386/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table.
* sysdeps/x86_64/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/x86_64/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/x86_64/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_runtime_setup): Set up lazy TLSDESC GOT entry.
(elf_machine_type_class): Mark R_X86_64_TLSDESC as PLT class.
(elf_machine_rel): Handle R_X86_64_TLSDESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
* sysdeps/x86_64/dl-tls.h (struct dl_tls_index): Name it.
(__tls_get_addr): Do not declare for non-shared compiles.
* sysdeps/x86_64/dl-tlsdesc.S: New file.
* sysdeps/x86_64/dl-tlsdesc.h: New file.
* sysdeps/x86_64/tlsdesc.c: New file.
* sysdeps/x86_64/tlsdesc.sym: New file.
* sysdeps/x86_64/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table for both 32- and 64-bit structs.
2008-05-13 07:41:30 +02:00
|
|
|
|
2001-09-19 12:37:31 +02:00
|
|
|
return lazy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initial entry point code for the dynamic linker.
|
|
|
|
The C function `_dl_start' is the real entry point;
|
|
|
|
its return value is the user program's entry point. */
|
|
|
|
#define RTLD_START asm ("\n\
|
|
|
|
.text\n\
|
|
|
|
.align 16\n\
|
|
|
|
.globl _start\n\
|
|
|
|
.globl _dl_start_user\n\
|
|
|
|
_start:\n\
|
|
|
|
movq %rsp, %rdi\n\
|
|
|
|
call _dl_start\n\
|
|
|
|
_dl_start_user:\n\
|
|
|
|
# Save the user entry point address in %r12.\n\
|
|
|
|
movq %rax, %r12\n\
|
|
|
|
# See if we were run as a command with the executable file\n\
|
|
|
|
# name as an extra leading argument.\n\
|
2003-09-23 23:31:54 +02:00
|
|
|
movl _dl_skip_args(%rip), %eax\n\
|
2001-09-19 12:37:31 +02:00
|
|
|
# Pop the original argument count.\n\
|
|
|
|
popq %rdx\n\
|
|
|
|
# Adjust the stack pointer to skip _dl_skip_args words.\n\
|
|
|
|
leaq (%rsp,%rax,8), %rsp\n\
|
|
|
|
# Subtract _dl_skip_args from argc.\n\
|
|
|
|
subl %eax, %edx\n\
|
|
|
|
# Push argc back on the stack.\n\
|
|
|
|
pushq %rdx\n\
|
|
|
|
# Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\
|
|
|
|
# argc -> rsi\n\
|
|
|
|
movq %rdx, %rsi\n\
|
2005-01-22 08:55:35 +01:00
|
|
|
# Save %rsp value in %r13.\n\
|
|
|
|
movq %rsp, %r13\n\
|
|
|
|
# And align stack for the _dl_init_internal call. \n\
|
|
|
|
andq $-16, %rsp\n\
|
2001-09-19 12:37:31 +02:00
|
|
|
# _dl_loaded -> rdi\n\
|
2003-09-23 23:31:54 +02:00
|
|
|
movq _rtld_local(%rip), %rdi\n\
|
2001-09-19 12:37:31 +02:00
|
|
|
# env -> rcx\n\
|
2005-01-22 08:55:35 +01:00
|
|
|
leaq 16(%r13,%rdx,8), %rcx\n\
|
2001-09-19 12:37:31 +02:00
|
|
|
# argv -> rdx\n\
|
2005-01-22 08:55:35 +01:00
|
|
|
leaq 8(%r13), %rdx\n\
|
|
|
|
# Clear %rbp to mark outermost frame obviously even for constructors.\n\
|
2005-03-31 12:02:53 +02:00
|
|
|
xorl %ebp, %ebp\n\
|
2001-09-19 12:37:31 +02:00
|
|
|
# Call the function to run the initializers.\n\
|
Update.
Change ld.so to not use functions which are exported. One cannot
interpose them anyway. Use INT() to mark uses, INTDEF() to mark
definitions.
* include/libc-symbols.h: Define INT and INTDEF.
* sysdeps/generic/ldsodefs.h: Declare _dl_debug_printf_internal,
_dl_signal_error_internal, _dl_map_object_internal,
_dl_map_object_deps_internal, _dl_lookup_symbol_internal,
_dl_lookup_versioned_symbol_internal,
_dl_relocate_object_internal, _dl_debug_state_internal,
_dl_start_profile_internal, and _dl_unload_cache_internal.
* include/dlfcn.h: Declare _dl_catch_error_internal.
* elf/rtld.c: Use INT for calls to any of the *_internal functions
above. Add INTDEF to function definitions.
* elf/dl-debug.c: Likewise.
* elf/dl-deps.c: Likewise.
* elf/dl-dst.h: Likewise.
* elf/dl-error.c: Likewise.
* elf/dl-fini.c: Likewise.
* elf/dl-init.c: Likewise.
* elf/dl-load.c: Likewise.
* elf/dl-lookup.c: Likewise.
* elf/dl-misc.c: Likewise.
* elf/dl-open.c: Likewise.
* elf/dl-profile.c: Likewise.
* elf/dl-reloc.c: Likewise.
* elf/dl-runtime.c: Likewise.
* elf/dl-version.c: Likewise.
* elf/do-lookup.h: Likewise.
* sysdeps/generic/dl-cache.c: Likewise.
* sysdeps/generic/dl-sysdep.c: Likewise.
* sysdeps/alpha/dl-machine.h (RTLD_START): Call _dl_init_internal
instead of _dl_init.
* sysdeps/arm/dl-machine.h: Likewise.
* sysdeps/cris/dl-machine.h: Likewise.
* sysdeps/hppa/dl-machine.h: Likewise.
* sysdeps/i386/dl-machine.h: Likewise.
* sysdeps/ia64/dl-machine.h: Likewise.
* sysdeps/m68k/dl-machine.h: Likewise.
* sysdeps/mips/dl-machine.h: Likewise.
* sysdeps/mips/mips64/dl-machine.h: Likewise.
* sysdeps/s390/s390-32/dl-machine.h: Likewise.
* sysdeps/s390/s390-64/dl-machine.h: Likewise.
* sysdeps/sh/dl-machine.h: Likewise.
* sysdeps/sparc/sparc32/dl-machine.h: Likewise.
* sysdeps/sparc/sparc64/dl-machine.h: Likewise.
* sysdeps/x86_64/dl-machine.h: Likewise.
* sysdeps/powerpc/dl-start.S (_dl_start_user): Likewise.
* elf/Versions: Don't export _dl_check_all_versions, _dl_sysdep_start,
and _dl_debug_initialize.
2002-02-03 01:31:37 +01:00
|
|
|
call _dl_init_internal@PLT\n\
|
2001-09-19 12:37:31 +02:00
|
|
|
# Pass our finalizer function to the user in %rdx, as per ELF ABI.\n\
|
2003-09-23 23:31:54 +02:00
|
|
|
leaq _dl_fini(%rip), %rdx\n\
|
2005-01-22 08:55:35 +01:00
|
|
|
# And make sure %rsp points to argc stored on the stack.\n\
|
|
|
|
movq %r13, %rsp\n\
|
2001-09-19 12:37:31 +02:00
|
|
|
# Jump to the user's entry point.\n\
|
|
|
|
jmp *%r12\n\
|
|
|
|
.previous\n\
|
|
|
|
");
|
|
|
|
|
2002-09-27 09:29:51 +02:00
|
|
|
/* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
|
|
|
|
TLS variable, so undefined references should not be allowed to
|
|
|
|
define the value.
|
2001-09-19 12:37:31 +02:00
|
|
|
ELF_RTYPE_CLASS_NOCOPY iff TYPE should not be allowed to resolve to one
|
|
|
|
of the main executable's symbols, as for a COPY reloc. */
|
2011-09-10 22:50:28 +02:00
|
|
|
#define elf_machine_type_class(type) \
|
2002-09-27 10:29:54 +02:00
|
|
|
((((type) == R_X86_64_JUMP_SLOT \
|
|
|
|
|| (type) == R_X86_64_DTPMOD64 \
|
Introduce TLS descriptors for i386 and x86_64.
* include/inline-hashtab.h: New file, copied from 2005's
libiberty, with fix for memory leak imported afterwards by
Glauber de Oliveira Costa.
* elf/tlsdeschtab.h: New file.
* elf/dl-reloc.c (_dl_try_allocate_static_tls): Extract from...
(_dl_allocate_static_tls): ... here. Rearrange failure path.
(CHECK_STATIC_TLS): Move to...
* elf/dynamic-link.h: ... this file.
(TRY_STATIC_TLS): New macro.
* elf/dl-conflict.c (CHECK_STATIC_TLS, TRY_STATIC_TLS): Override.
* elf/elf.h (R_386_TLS_GOTDESC, R_386_TLS_DESC_CALL,
R_386_TLS_DESC): Define.
(R_X86_64_PC64, R_X86_GOTOFF64, R_X86_64_GOTPC32): Merge from
binutils.
(R_X86_64_GOTPC32_TLSDESC, R_X86_64_TLSDESC_CALL,
R_X86_64_TLSDESC): Define.
(R_386_NUM, R_X86_64_NUM): Adjust.
* sysdeps/i386/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/i386/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/i386/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_type_class): Mark R_386_TLS_DESC as PLT class.
(elf_machine_rel): Handle R_386_TLS_DESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
(elf_machine_lazy_rela): Likewise.
* sysdeps/i386/dl-tls.h (struct dl_tls_index): Name it.
* sysdeps/i386/dl-tlsdesc.S: New file.
* sysdeps/i386/dl-tlsdesc.h: New file.
* sysdeps/i386/tlsdesc.c: New file.
* sysdeps/i386/tlsdesc.sym: New file.
* sysdeps/i386/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table.
* sysdeps/x86_64/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/x86_64/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/x86_64/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_runtime_setup): Set up lazy TLSDESC GOT entry.
(elf_machine_type_class): Mark R_X86_64_TLSDESC as PLT class.
(elf_machine_rel): Handle R_X86_64_TLSDESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
* sysdeps/x86_64/dl-tls.h (struct dl_tls_index): Name it.
(__tls_get_addr): Do not declare for non-shared compiles.
* sysdeps/x86_64/dl-tlsdesc.S: New file.
* sysdeps/x86_64/dl-tlsdesc.h: New file.
* sysdeps/x86_64/tlsdesc.c: New file.
* sysdeps/x86_64/tlsdesc.sym: New file.
* sysdeps/x86_64/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table for both 32- and 64-bit structs.
2008-05-13 07:41:30 +02:00
|
|
|
|| (type) == R_X86_64_DTPOFF64 \
|
|
|
|
|| (type) == R_X86_64_TPOFF64 \
|
|
|
|
|| (type) == R_X86_64_TLSDESC) \
|
2002-09-27 10:29:54 +02:00
|
|
|
* ELF_RTYPE_CLASS_PLT) \
|
2001-09-19 12:37:31 +02:00
|
|
|
| (((type) == R_X86_64_COPY) * ELF_RTYPE_CLASS_COPY))
|
|
|
|
|
|
|
|
/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
|
|
|
|
#define ELF_MACHINE_JMP_SLOT R_X86_64_JUMP_SLOT
|
|
|
|
|
2011-10-17 02:58:17 +02:00
|
|
|
/* The relative ifunc relocation. */
|
|
|
|
// XXX This is a work-around for a broken linker. Remove!
|
|
|
|
#define ELF_MACHINE_IRELATIVE R_X86_64_IRELATIVE
|
|
|
|
|
2012-05-08 18:39:58 +02:00
|
|
|
/* The x86-64 never uses Elf64_Rel/Elf32_Rel relocations. */
|
2001-09-19 12:37:31 +02:00
|
|
|
#define ELF_MACHINE_NO_REL 1
|
|
|
|
|
2011-12-23 19:59:40 +01:00
|
|
|
/* We define an initialization function. This is called very early in
|
2001-09-19 12:37:31 +02:00
|
|
|
_dl_sysdep_start. */
|
|
|
|
#define DL_PLATFORM_INIT dl_platform_init ()
|
|
|
|
|
|
|
|
static inline void __attribute__ ((unused))
|
|
|
|
dl_platform_init (void)
|
|
|
|
{
|
2004-03-05 11:29:47 +01:00
|
|
|
if (GLRO(dl_platform) != NULL && *GLRO(dl_platform) == '\0')
|
2001-09-19 12:37:31 +02:00
|
|
|
/* Avoid an empty string which would disturb us. */
|
2004-03-05 11:29:47 +01:00
|
|
|
GLRO(dl_platform) = NULL;
|
2001-09-19 12:37:31 +02:00
|
|
|
}
|
|
|
|
|
2012-05-08 18:39:58 +02:00
|
|
|
static inline ElfW(Addr)
|
2001-09-19 12:37:31 +02:00
|
|
|
elf_machine_fixup_plt (struct link_map *map, lookup_t t,
|
2012-05-08 18:39:58 +02:00
|
|
|
const ElfW(Rela) *reloc,
|
|
|
|
ElfW(Addr) *reloc_addr, ElfW(Addr) value)
|
2001-09-19 12:37:31 +02:00
|
|
|
{
|
|
|
|
return *reloc_addr = value;
|
|
|
|
}
|
|
|
|
|
2011-12-23 19:59:40 +01:00
|
|
|
/* Return the final value of a PLT relocation. On x86-64 the
|
|
|
|
JUMP_SLOT relocation ignores the addend. */
|
2012-05-08 18:39:58 +02:00
|
|
|
static inline ElfW(Addr)
|
|
|
|
elf_machine_plt_value (struct link_map *map, const ElfW(Rela) *reloc,
|
|
|
|
ElfW(Addr) value)
|
2001-09-19 12:37:31 +02:00
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2005-01-06 23:40:27 +01:00
|
|
|
|
|
|
|
/* Names of the architecture-specific auditing callback functions. */
|
|
|
|
#define ARCH_LA_PLTENTER x86_64_gnu_pltenter
|
|
|
|
#define ARCH_LA_PLTEXIT x86_64_gnu_pltexit
|
|
|
|
|
2001-09-19 12:37:31 +02:00
|
|
|
#endif /* !dl_machine_h */
|
|
|
|
|
2005-01-06 23:40:27 +01:00
|
|
|
#ifdef RESOLVE_MAP
|
2001-09-19 12:37:31 +02:00
|
|
|
|
|
|
|
/* Perform the relocation specified by RELOC and SYM (which is fully resolved).
|
|
|
|
MAP is the object containing the reloc. */
|
|
|
|
|
2004-09-24 19:09:04 +02:00
|
|
|
auto inline void
|
|
|
|
__attribute__ ((always_inline))
|
2012-05-08 18:39:58 +02:00
|
|
|
elf_machine_rela (struct link_map *map, const ElfW(Rela) *reloc,
|
|
|
|
const ElfW(Sym) *sym, const struct r_found_version *version,
|
2011-10-04 16:10:16 +02:00
|
|
|
void *const reloc_addr_arg, int skip_ifunc)
|
2001-09-19 12:37:31 +02:00
|
|
|
{
|
2012-05-08 18:39:58 +02:00
|
|
|
ElfW(Addr) *const reloc_addr = reloc_addr_arg;
|
|
|
|
const unsigned long int r_type = ELFW(R_TYPE) (reloc->r_info);
|
2001-09-19 12:37:31 +02:00
|
|
|
|
2009-03-12 07:31:25 +01:00
|
|
|
# if !defined RTLD_BOOTSTRAP || !defined HAVE_Z_COMBRELOC
|
2001-09-19 12:37:31 +02:00
|
|
|
if (__builtin_expect (r_type == R_X86_64_RELATIVE, 0))
|
|
|
|
{
|
2009-03-12 07:31:25 +01:00
|
|
|
# if !defined RTLD_BOOTSTRAP && !defined HAVE_Z_COMBRELOC
|
2001-09-19 12:37:31 +02:00
|
|
|
/* This is defined in rtld.c, but nowhere in the static libc.a;
|
|
|
|
make the reference weak so static programs can still link.
|
|
|
|
This declaration cannot be done when compiling rtld.c
|
|
|
|
(i.e. #ifdef RTLD_BOOTSTRAP) because rtld.c contains the
|
|
|
|
common defn for _dl_rtld_map, which is incompatible with a
|
|
|
|
weak decl in the same file. */
|
2009-03-12 07:31:25 +01:00
|
|
|
# ifndef SHARED
|
2002-02-01 02:33:04 +01:00
|
|
|
weak_extern (GL(dl_rtld_map));
|
2009-03-12 07:31:25 +01:00
|
|
|
# endif
|
2002-02-01 02:33:04 +01:00
|
|
|
if (map != &GL(dl_rtld_map)) /* Already done in rtld itself. */
|
2009-03-12 07:31:25 +01:00
|
|
|
# endif
|
2001-09-19 12:37:31 +02:00
|
|
|
*reloc_addr = map->l_addr + reloc->r_addend;
|
|
|
|
}
|
|
|
|
else
|
2012-05-11 02:05:06 +02:00
|
|
|
# endif
|
|
|
|
# if !defined RTLD_BOOTSTRAP
|
|
|
|
/* l_addr + r_addend may be > 0xffffffff and R_X86_64_RELATIVE64
|
|
|
|
relocation updates the whole 64-bit entry. */
|
|
|
|
if (__builtin_expect (r_type == R_X86_64_RELATIVE64, 0))
|
|
|
|
*(Elf64_Addr *) reloc_addr = (Elf64_Addr) map->l_addr + reloc->r_addend;
|
|
|
|
else
|
2009-03-12 07:31:25 +01:00
|
|
|
# endif
|
2001-09-19 12:37:31 +02:00
|
|
|
if (__builtin_expect (r_type == R_X86_64_NONE, 0))
|
|
|
|
return;
|
|
|
|
else
|
|
|
|
{
|
2009-03-12 07:31:25 +01:00
|
|
|
# ifndef RTLD_BOOTSTRAP
|
2012-05-08 18:39:58 +02:00
|
|
|
const ElfW(Sym) *const refsym = sym;
|
2009-03-12 07:31:25 +01:00
|
|
|
# endif
|
2002-09-27 09:29:51 +02:00
|
|
|
struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
|
2012-05-08 18:39:58 +02:00
|
|
|
ElfW(Addr) value = (sym == NULL ? 0
|
|
|
|
: (ElfW(Addr)) sym_map->l_addr + sym->st_value);
|
2001-09-19 12:37:31 +02:00
|
|
|
|
2009-03-12 07:31:25 +01:00
|
|
|
if (sym != NULL
|
|
|
|
&& __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC,
|
2009-06-01 20:49:05 +02:00
|
|
|
0)
|
2011-10-04 16:10:16 +02:00
|
|
|
&& __builtin_expect (sym->st_shndx != SHN_UNDEF, 1)
|
|
|
|
&& __builtin_expect (!skip_ifunc, 1))
|
2012-05-08 18:39:58 +02:00
|
|
|
value = ((ElfW(Addr) (*) (void)) value) ();
|
2009-03-12 07:31:25 +01:00
|
|
|
|
2001-09-19 12:37:31 +02:00
|
|
|
switch (r_type)
|
|
|
|
{
|
|
|
|
case R_X86_64_GLOB_DAT:
|
|
|
|
case R_X86_64_JUMP_SLOT:
|
|
|
|
*reloc_addr = value + reloc->r_addend;
|
|
|
|
break;
|
2002-09-27 09:29:51 +02:00
|
|
|
|
2009-03-12 07:31:25 +01:00
|
|
|
# ifndef RESOLVE_CONFLICT_FIND_MAP
|
2002-09-27 09:29:51 +02:00
|
|
|
case R_X86_64_DTPMOD64:
|
2009-03-12 07:31:25 +01:00
|
|
|
# ifdef RTLD_BOOTSTRAP
|
2002-09-27 09:29:51 +02:00
|
|
|
/* During startup the dynamic linker is always the module
|
|
|
|
with index 1.
|
|
|
|
XXX If this relocation is necessary move before RESOLVE
|
|
|
|
call. */
|
|
|
|
*reloc_addr = 1;
|
2009-03-12 07:31:25 +01:00
|
|
|
# else
|
2002-09-27 09:29:51 +02:00
|
|
|
/* Get the information from the link map returned by the
|
|
|
|
resolve function. */
|
|
|
|
if (sym_map != NULL)
|
|
|
|
*reloc_addr = sym_map->l_tls_modid;
|
2009-03-12 07:31:25 +01:00
|
|
|
# endif
|
2002-09-27 09:29:51 +02:00
|
|
|
break;
|
|
|
|
case R_X86_64_DTPOFF64:
|
2009-03-12 07:31:25 +01:00
|
|
|
# ifndef RTLD_BOOTSTRAP
|
2002-09-27 09:29:51 +02:00
|
|
|
/* During relocation all TLS symbols are defined and used.
|
|
|
|
Therefore the offset is already correct. */
|
|
|
|
if (sym != NULL)
|
2012-05-10 19:05:40 +02:00
|
|
|
{
|
|
|
|
value = sym->st_value + reloc->r_addend;
|
|
|
|
# ifdef __ILP32__
|
|
|
|
/* This relocation type computes a signed offset that is
|
|
|
|
usually negative. The symbol and addend values are 32
|
|
|
|
bits but the GOT entry is 64 bits wide and the whole
|
|
|
|
64-bit entry is used as a signed quantity, so we need
|
|
|
|
to sign-extend the computed value to 64 bits. */
|
2012-05-10 19:20:51 +02:00
|
|
|
*(Elf64_Sxword *) reloc_addr = (Elf64_Sxword) (Elf32_Sword) value;
|
2012-05-10 19:05:40 +02:00
|
|
|
# else
|
|
|
|
*reloc_addr = value;
|
|
|
|
# endif
|
|
|
|
}
|
2009-03-12 07:31:25 +01:00
|
|
|
# endif
|
2002-09-27 09:29:51 +02:00
|
|
|
break;
|
Introduce TLS descriptors for i386 and x86_64.
* include/inline-hashtab.h: New file, copied from 2005's
libiberty, with fix for memory leak imported afterwards by
Glauber de Oliveira Costa.
* elf/tlsdeschtab.h: New file.
* elf/dl-reloc.c (_dl_try_allocate_static_tls): Extract from...
(_dl_allocate_static_tls): ... here. Rearrange failure path.
(CHECK_STATIC_TLS): Move to...
* elf/dynamic-link.h: ... this file.
(TRY_STATIC_TLS): New macro.
* elf/dl-conflict.c (CHECK_STATIC_TLS, TRY_STATIC_TLS): Override.
* elf/elf.h (R_386_TLS_GOTDESC, R_386_TLS_DESC_CALL,
R_386_TLS_DESC): Define.
(R_X86_64_PC64, R_X86_GOTOFF64, R_X86_64_GOTPC32): Merge from
binutils.
(R_X86_64_GOTPC32_TLSDESC, R_X86_64_TLSDESC_CALL,
R_X86_64_TLSDESC): Define.
(R_386_NUM, R_X86_64_NUM): Adjust.
* sysdeps/i386/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/i386/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/i386/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_type_class): Mark R_386_TLS_DESC as PLT class.
(elf_machine_rel): Handle R_386_TLS_DESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
(elf_machine_lazy_rela): Likewise.
* sysdeps/i386/dl-tls.h (struct dl_tls_index): Name it.
* sysdeps/i386/dl-tlsdesc.S: New file.
* sysdeps/i386/dl-tlsdesc.h: New file.
* sysdeps/i386/tlsdesc.c: New file.
* sysdeps/i386/tlsdesc.sym: New file.
* sysdeps/i386/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table.
* sysdeps/x86_64/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/x86_64/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/x86_64/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_runtime_setup): Set up lazy TLSDESC GOT entry.
(elf_machine_type_class): Mark R_X86_64_TLSDESC as PLT class.
(elf_machine_rel): Handle R_X86_64_TLSDESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
* sysdeps/x86_64/dl-tls.h (struct dl_tls_index): Name it.
(__tls_get_addr): Do not declare for non-shared compiles.
* sysdeps/x86_64/dl-tlsdesc.S: New file.
* sysdeps/x86_64/dl-tlsdesc.h: New file.
* sysdeps/x86_64/tlsdesc.c: New file.
* sysdeps/x86_64/tlsdesc.sym: New file.
* sysdeps/x86_64/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table for both 32- and 64-bit structs.
2008-05-13 07:41:30 +02:00
|
|
|
case R_X86_64_TLSDESC:
|
|
|
|
{
|
|
|
|
struct tlsdesc volatile *td =
|
|
|
|
(struct tlsdesc volatile *)reloc_addr;
|
|
|
|
|
2009-03-12 07:31:25 +01:00
|
|
|
# ifndef RTLD_BOOTSTRAP
|
Introduce TLS descriptors for i386 and x86_64.
* include/inline-hashtab.h: New file, copied from 2005's
libiberty, with fix for memory leak imported afterwards by
Glauber de Oliveira Costa.
* elf/tlsdeschtab.h: New file.
* elf/dl-reloc.c (_dl_try_allocate_static_tls): Extract from...
(_dl_allocate_static_tls): ... here. Rearrange failure path.
(CHECK_STATIC_TLS): Move to...
* elf/dynamic-link.h: ... this file.
(TRY_STATIC_TLS): New macro.
* elf/dl-conflict.c (CHECK_STATIC_TLS, TRY_STATIC_TLS): Override.
* elf/elf.h (R_386_TLS_GOTDESC, R_386_TLS_DESC_CALL,
R_386_TLS_DESC): Define.
(R_X86_64_PC64, R_X86_GOTOFF64, R_X86_64_GOTPC32): Merge from
binutils.
(R_X86_64_GOTPC32_TLSDESC, R_X86_64_TLSDESC_CALL,
R_X86_64_TLSDESC): Define.
(R_386_NUM, R_X86_64_NUM): Adjust.
* sysdeps/i386/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/i386/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/i386/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_type_class): Mark R_386_TLS_DESC as PLT class.
(elf_machine_rel): Handle R_386_TLS_DESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
(elf_machine_lazy_rela): Likewise.
* sysdeps/i386/dl-tls.h (struct dl_tls_index): Name it.
* sysdeps/i386/dl-tlsdesc.S: New file.
* sysdeps/i386/dl-tlsdesc.h: New file.
* sysdeps/i386/tlsdesc.c: New file.
* sysdeps/i386/tlsdesc.sym: New file.
* sysdeps/i386/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table.
* sysdeps/x86_64/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/x86_64/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/x86_64/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_runtime_setup): Set up lazy TLSDESC GOT entry.
(elf_machine_type_class): Mark R_X86_64_TLSDESC as PLT class.
(elf_machine_rel): Handle R_X86_64_TLSDESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
* sysdeps/x86_64/dl-tls.h (struct dl_tls_index): Name it.
(__tls_get_addr): Do not declare for non-shared compiles.
* sysdeps/x86_64/dl-tlsdesc.S: New file.
* sysdeps/x86_64/dl-tlsdesc.h: New file.
* sysdeps/x86_64/tlsdesc.c: New file.
* sysdeps/x86_64/tlsdesc.sym: New file.
* sysdeps/x86_64/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table for both 32- and 64-bit structs.
2008-05-13 07:41:30 +02:00
|
|
|
if (! sym)
|
|
|
|
{
|
|
|
|
td->arg = (void*)reloc->r_addend;
|
|
|
|
td->entry = _dl_tlsdesc_undefweak;
|
|
|
|
}
|
|
|
|
else
|
2009-03-12 07:31:25 +01:00
|
|
|
# endif
|
Introduce TLS descriptors for i386 and x86_64.
* include/inline-hashtab.h: New file, copied from 2005's
libiberty, with fix for memory leak imported afterwards by
Glauber de Oliveira Costa.
* elf/tlsdeschtab.h: New file.
* elf/dl-reloc.c (_dl_try_allocate_static_tls): Extract from...
(_dl_allocate_static_tls): ... here. Rearrange failure path.
(CHECK_STATIC_TLS): Move to...
* elf/dynamic-link.h: ... this file.
(TRY_STATIC_TLS): New macro.
* elf/dl-conflict.c (CHECK_STATIC_TLS, TRY_STATIC_TLS): Override.
* elf/elf.h (R_386_TLS_GOTDESC, R_386_TLS_DESC_CALL,
R_386_TLS_DESC): Define.
(R_X86_64_PC64, R_X86_GOTOFF64, R_X86_64_GOTPC32): Merge from
binutils.
(R_X86_64_GOTPC32_TLSDESC, R_X86_64_TLSDESC_CALL,
R_X86_64_TLSDESC): Define.
(R_386_NUM, R_X86_64_NUM): Adjust.
* sysdeps/i386/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/i386/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/i386/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_type_class): Mark R_386_TLS_DESC as PLT class.
(elf_machine_rel): Handle R_386_TLS_DESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
(elf_machine_lazy_rela): Likewise.
* sysdeps/i386/dl-tls.h (struct dl_tls_index): Name it.
* sysdeps/i386/dl-tlsdesc.S: New file.
* sysdeps/i386/dl-tlsdesc.h: New file.
* sysdeps/i386/tlsdesc.c: New file.
* sysdeps/i386/tlsdesc.sym: New file.
* sysdeps/i386/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table.
* sysdeps/x86_64/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/x86_64/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/x86_64/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_runtime_setup): Set up lazy TLSDESC GOT entry.
(elf_machine_type_class): Mark R_X86_64_TLSDESC as PLT class.
(elf_machine_rel): Handle R_X86_64_TLSDESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
* sysdeps/x86_64/dl-tls.h (struct dl_tls_index): Name it.
(__tls_get_addr): Do not declare for non-shared compiles.
* sysdeps/x86_64/dl-tlsdesc.S: New file.
* sysdeps/x86_64/dl-tlsdesc.h: New file.
* sysdeps/x86_64/tlsdesc.c: New file.
* sysdeps/x86_64/tlsdesc.sym: New file.
* sysdeps/x86_64/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table for both 32- and 64-bit structs.
2008-05-13 07:41:30 +02:00
|
|
|
{
|
2009-03-12 07:31:25 +01:00
|
|
|
# ifndef RTLD_BOOTSTRAP
|
|
|
|
# ifndef SHARED
|
Introduce TLS descriptors for i386 and x86_64.
* include/inline-hashtab.h: New file, copied from 2005's
libiberty, with fix for memory leak imported afterwards by
Glauber de Oliveira Costa.
* elf/tlsdeschtab.h: New file.
* elf/dl-reloc.c (_dl_try_allocate_static_tls): Extract from...
(_dl_allocate_static_tls): ... here. Rearrange failure path.
(CHECK_STATIC_TLS): Move to...
* elf/dynamic-link.h: ... this file.
(TRY_STATIC_TLS): New macro.
* elf/dl-conflict.c (CHECK_STATIC_TLS, TRY_STATIC_TLS): Override.
* elf/elf.h (R_386_TLS_GOTDESC, R_386_TLS_DESC_CALL,
R_386_TLS_DESC): Define.
(R_X86_64_PC64, R_X86_GOTOFF64, R_X86_64_GOTPC32): Merge from
binutils.
(R_X86_64_GOTPC32_TLSDESC, R_X86_64_TLSDESC_CALL,
R_X86_64_TLSDESC): Define.
(R_386_NUM, R_X86_64_NUM): Adjust.
* sysdeps/i386/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/i386/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/i386/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_type_class): Mark R_386_TLS_DESC as PLT class.
(elf_machine_rel): Handle R_386_TLS_DESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
(elf_machine_lazy_rela): Likewise.
* sysdeps/i386/dl-tls.h (struct dl_tls_index): Name it.
* sysdeps/i386/dl-tlsdesc.S: New file.
* sysdeps/i386/dl-tlsdesc.h: New file.
* sysdeps/i386/tlsdesc.c: New file.
* sysdeps/i386/tlsdesc.sym: New file.
* sysdeps/i386/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table.
* sysdeps/x86_64/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/x86_64/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/x86_64/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_runtime_setup): Set up lazy TLSDESC GOT entry.
(elf_machine_type_class): Mark R_X86_64_TLSDESC as PLT class.
(elf_machine_rel): Handle R_X86_64_TLSDESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
* sysdeps/x86_64/dl-tls.h (struct dl_tls_index): Name it.
(__tls_get_addr): Do not declare for non-shared compiles.
* sysdeps/x86_64/dl-tlsdesc.S: New file.
* sysdeps/x86_64/dl-tlsdesc.h: New file.
* sysdeps/x86_64/tlsdesc.c: New file.
* sysdeps/x86_64/tlsdesc.sym: New file.
* sysdeps/x86_64/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table for both 32- and 64-bit structs.
2008-05-13 07:41:30 +02:00
|
|
|
CHECK_STATIC_TLS (map, sym_map);
|
2009-03-12 07:31:25 +01:00
|
|
|
# else
|
Introduce TLS descriptors for i386 and x86_64.
* include/inline-hashtab.h: New file, copied from 2005's
libiberty, with fix for memory leak imported afterwards by
Glauber de Oliveira Costa.
* elf/tlsdeschtab.h: New file.
* elf/dl-reloc.c (_dl_try_allocate_static_tls): Extract from...
(_dl_allocate_static_tls): ... here. Rearrange failure path.
(CHECK_STATIC_TLS): Move to...
* elf/dynamic-link.h: ... this file.
(TRY_STATIC_TLS): New macro.
* elf/dl-conflict.c (CHECK_STATIC_TLS, TRY_STATIC_TLS): Override.
* elf/elf.h (R_386_TLS_GOTDESC, R_386_TLS_DESC_CALL,
R_386_TLS_DESC): Define.
(R_X86_64_PC64, R_X86_GOTOFF64, R_X86_64_GOTPC32): Merge from
binutils.
(R_X86_64_GOTPC32_TLSDESC, R_X86_64_TLSDESC_CALL,
R_X86_64_TLSDESC): Define.
(R_386_NUM, R_X86_64_NUM): Adjust.
* sysdeps/i386/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/i386/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/i386/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_type_class): Mark R_386_TLS_DESC as PLT class.
(elf_machine_rel): Handle R_386_TLS_DESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
(elf_machine_lazy_rela): Likewise.
* sysdeps/i386/dl-tls.h (struct dl_tls_index): Name it.
* sysdeps/i386/dl-tlsdesc.S: New file.
* sysdeps/i386/dl-tlsdesc.h: New file.
* sysdeps/i386/tlsdesc.c: New file.
* sysdeps/i386/tlsdesc.sym: New file.
* sysdeps/i386/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table.
* sysdeps/x86_64/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/x86_64/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/x86_64/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_runtime_setup): Set up lazy TLSDESC GOT entry.
(elf_machine_type_class): Mark R_X86_64_TLSDESC as PLT class.
(elf_machine_rel): Handle R_X86_64_TLSDESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
* sysdeps/x86_64/dl-tls.h (struct dl_tls_index): Name it.
(__tls_get_addr): Do not declare for non-shared compiles.
* sysdeps/x86_64/dl-tlsdesc.S: New file.
* sysdeps/x86_64/dl-tlsdesc.h: New file.
* sysdeps/x86_64/tlsdesc.c: New file.
* sysdeps/x86_64/tlsdesc.sym: New file.
* sysdeps/x86_64/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table for both 32- and 64-bit structs.
2008-05-13 07:41:30 +02:00
|
|
|
if (!TRY_STATIC_TLS (map, sym_map))
|
|
|
|
{
|
|
|
|
td->arg = _dl_make_tlsdesc_dynamic
|
|
|
|
(sym_map, sym->st_value + reloc->r_addend);
|
|
|
|
td->entry = _dl_tlsdesc_dynamic;
|
|
|
|
}
|
|
|
|
else
|
2009-03-12 07:31:25 +01:00
|
|
|
# endif
|
Introduce TLS descriptors for i386 and x86_64.
* include/inline-hashtab.h: New file, copied from 2005's
libiberty, with fix for memory leak imported afterwards by
Glauber de Oliveira Costa.
* elf/tlsdeschtab.h: New file.
* elf/dl-reloc.c (_dl_try_allocate_static_tls): Extract from...
(_dl_allocate_static_tls): ... here. Rearrange failure path.
(CHECK_STATIC_TLS): Move to...
* elf/dynamic-link.h: ... this file.
(TRY_STATIC_TLS): New macro.
* elf/dl-conflict.c (CHECK_STATIC_TLS, TRY_STATIC_TLS): Override.
* elf/elf.h (R_386_TLS_GOTDESC, R_386_TLS_DESC_CALL,
R_386_TLS_DESC): Define.
(R_X86_64_PC64, R_X86_GOTOFF64, R_X86_64_GOTPC32): Merge from
binutils.
(R_X86_64_GOTPC32_TLSDESC, R_X86_64_TLSDESC_CALL,
R_X86_64_TLSDESC): Define.
(R_386_NUM, R_X86_64_NUM): Adjust.
* sysdeps/i386/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/i386/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/i386/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_type_class): Mark R_386_TLS_DESC as PLT class.
(elf_machine_rel): Handle R_386_TLS_DESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
(elf_machine_lazy_rela): Likewise.
* sysdeps/i386/dl-tls.h (struct dl_tls_index): Name it.
* sysdeps/i386/dl-tlsdesc.S: New file.
* sysdeps/i386/dl-tlsdesc.h: New file.
* sysdeps/i386/tlsdesc.c: New file.
* sysdeps/i386/tlsdesc.sym: New file.
* sysdeps/i386/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table.
* sysdeps/x86_64/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/x86_64/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/x86_64/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_runtime_setup): Set up lazy TLSDESC GOT entry.
(elf_machine_type_class): Mark R_X86_64_TLSDESC as PLT class.
(elf_machine_rel): Handle R_X86_64_TLSDESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
* sysdeps/x86_64/dl-tls.h (struct dl_tls_index): Name it.
(__tls_get_addr): Do not declare for non-shared compiles.
* sysdeps/x86_64/dl-tlsdesc.S: New file.
* sysdeps/x86_64/dl-tlsdesc.h: New file.
* sysdeps/x86_64/tlsdesc.c: New file.
* sysdeps/x86_64/tlsdesc.sym: New file.
* sysdeps/x86_64/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table for both 32- and 64-bit structs.
2008-05-13 07:41:30 +02:00
|
|
|
# endif
|
|
|
|
{
|
|
|
|
td->arg = (void*)(sym->st_value - sym_map->l_tls_offset
|
|
|
|
+ reloc->r_addend);
|
|
|
|
td->entry = _dl_tlsdesc_return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2002-09-27 09:29:51 +02:00
|
|
|
case R_X86_64_TPOFF64:
|
|
|
|
/* The offset is negative, forward from the thread pointer. */
|
2009-03-12 07:31:25 +01:00
|
|
|
# ifndef RTLD_BOOTSTRAP
|
2002-09-27 09:29:51 +02:00
|
|
|
if (sym != NULL)
|
2009-03-12 07:31:25 +01:00
|
|
|
# endif
|
2002-10-17 14:10:17 +02:00
|
|
|
{
|
2009-03-12 07:31:25 +01:00
|
|
|
# ifndef RTLD_BOOTSTRAP
|
2002-10-17 21:44:19 +02:00
|
|
|
CHECK_STATIC_TLS (map, sym_map);
|
2009-03-12 07:31:25 +01:00
|
|
|
# endif
|
2002-10-17 14:10:17 +02:00
|
|
|
/* We know the offset of the object the symbol is contained in.
|
|
|
|
It is a negative value which will be added to the
|
|
|
|
thread pointer. */
|
2012-05-10 19:05:40 +02:00
|
|
|
value = (sym->st_value + reloc->r_addend
|
|
|
|
- sym_map->l_tls_offset);
|
|
|
|
# ifdef __ILP32__
|
|
|
|
/* The symbol and addend values are 32 bits but the GOT
|
|
|
|
entry is 64 bits wide and the whole 64-bit entry is used
|
|
|
|
as a signed quantity, so we need to sign-extend the
|
|
|
|
computed value to 64 bits. */
|
|
|
|
*(Elf64_Sxword *) reloc_addr = (Elf64_Sxword) (Elf32_Sword) value;
|
|
|
|
# else
|
|
|
|
*reloc_addr = value;
|
|
|
|
# endif
|
2002-10-17 14:10:17 +02:00
|
|
|
}
|
2002-09-27 09:29:51 +02:00
|
|
|
break;
|
2009-03-12 07:31:25 +01:00
|
|
|
# endif
|
2002-09-27 09:29:51 +02:00
|
|
|
|
2009-03-12 07:31:25 +01:00
|
|
|
# ifndef RTLD_BOOTSTRAP
|
2001-09-19 12:37:31 +02:00
|
|
|
case R_X86_64_64:
|
2012-05-11 02:05:06 +02:00
|
|
|
/* value + r_addend may be > 0xffffffff and R_X86_64_64
|
|
|
|
relocation updates the whole 64-bit entry. */
|
|
|
|
*(Elf64_Addr *) reloc_addr = (Elf64_Addr) value + reloc->r_addend;
|
2001-09-19 12:37:31 +02:00
|
|
|
break;
|
|
|
|
case R_X86_64_32:
|
2009-03-12 07:31:25 +01:00
|
|
|
value += reloc->r_addend;
|
|
|
|
*(unsigned int *) reloc_addr = value;
|
|
|
|
|
|
|
|
const char *fmt;
|
|
|
|
if (__builtin_expect (value > UINT_MAX, 0))
|
2002-06-25 14:32:52 +02:00
|
|
|
{
|
|
|
|
const char *strtab;
|
|
|
|
|
2009-03-12 07:31:25 +01:00
|
|
|
fmt = "\
|
|
|
|
%s: Symbol `%s' causes overflow in R_X86_64_32 relocation\n";
|
2009-04-26 22:12:37 +02:00
|
|
|
# ifndef RESOLVE_CONFLICT_FIND_MAP
|
2009-03-12 07:31:25 +01:00
|
|
|
print_err:
|
2009-04-26 22:12:37 +02:00
|
|
|
# endif
|
2002-06-25 14:32:52 +02:00
|
|
|
strtab = (const char *) D_PTR (map, l_info[DT_STRTAB]);
|
|
|
|
|
2009-03-12 07:31:25 +01:00
|
|
|
_dl_error_printf (fmt,
|
2002-06-25 14:32:52 +02:00
|
|
|
rtld_progname ?: "<program name unknown>",
|
|
|
|
strtab + refsym->st_name);
|
|
|
|
}
|
2001-09-19 12:37:31 +02:00
|
|
|
break;
|
2009-03-12 07:31:25 +01:00
|
|
|
# ifndef RESOLVE_CONFLICT_FIND_MAP
|
2003-04-24 19:11:08 +02:00
|
|
|
/* Not needed for dl-conflict.c. */
|
2001-09-19 12:37:31 +02:00
|
|
|
case R_X86_64_PC32:
|
2012-05-08 18:39:58 +02:00
|
|
|
value += reloc->r_addend - (ElfW(Addr)) reloc_addr;
|
2009-03-12 07:31:25 +01:00
|
|
|
*(unsigned int *) reloc_addr = value;
|
2010-03-05 04:33:41 +01:00
|
|
|
if (__builtin_expect (value != (int) value, 0))
|
2002-06-25 14:32:52 +02:00
|
|
|
{
|
2009-03-12 07:31:25 +01:00
|
|
|
fmt = "\
|
|
|
|
%s: Symbol `%s' causes overflow in R_X86_64_PC32 relocation\n";
|
|
|
|
goto print_err;
|
2002-06-25 14:32:52 +02:00
|
|
|
}
|
2001-09-19 12:37:31 +02:00
|
|
|
break;
|
|
|
|
case R_X86_64_COPY:
|
|
|
|
if (sym == NULL)
|
|
|
|
/* This can happen in trace mode if an object could not be
|
|
|
|
found. */
|
|
|
|
break;
|
2009-03-12 07:31:25 +01:00
|
|
|
memcpy (reloc_addr_arg, (void *) value,
|
|
|
|
MIN (sym->st_size, refsym->st_size));
|
2001-09-19 12:37:31 +02:00
|
|
|
if (__builtin_expect (sym->st_size > refsym->st_size, 0)
|
|
|
|
|| (__builtin_expect (sym->st_size < refsym->st_size, 0)
|
2004-03-05 11:29:47 +01:00
|
|
|
&& GLRO(dl_verbose)))
|
2001-09-19 12:37:31 +02:00
|
|
|
{
|
2009-03-12 07:31:25 +01:00
|
|
|
fmt = "\
|
|
|
|
%s: Symbol `%s' has different size in shared object, consider re-linking\n";
|
|
|
|
goto print_err;
|
2001-09-19 12:37:31 +02:00
|
|
|
}
|
|
|
|
break;
|
2009-03-12 07:31:25 +01:00
|
|
|
# endif
|
2009-06-01 08:45:33 +02:00
|
|
|
case R_X86_64_IRELATIVE:
|
|
|
|
value = map->l_addr + reloc->r_addend;
|
2012-05-08 18:39:58 +02:00
|
|
|
value = ((ElfW(Addr) (*) (void)) value) ();
|
2009-06-01 08:45:33 +02:00
|
|
|
*reloc_addr = value;
|
|
|
|
break;
|
2001-09-19 12:37:31 +02:00
|
|
|
default:
|
|
|
|
_dl_reloc_bad_type (map, r_type, 0);
|
|
|
|
break;
|
2009-03-12 07:31:25 +01:00
|
|
|
# endif
|
2001-09-19 12:37:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-24 19:09:04 +02:00
|
|
|
auto inline void
|
|
|
|
__attribute ((always_inline))
|
2012-05-08 18:39:58 +02:00
|
|
|
elf_machine_rela_relative (ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
|
* elf/dynamic-link.h (elf_machine_rel, elf_machine_rela, elf_machine_rel_relative, elf_machine_rela_relative): Don't assume reloc_addr is aligned. * sysdeps/alpha/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/arm/dl-machine.h (elf_machine_rel, elf_machine_rela, elf_machine_rel_relative, elf_machine_rela_relative): Adjust. * sysdeps/cris/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/hppa/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela, elf_machine_rel_relative, elf_machine_rela_relative): Adjust. * sysdeps/ia64/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/m68k/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/mips/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/powerpc/powerpc64/dl-machine.h (elf_machine_rela_relative, elf_machine_rela): Adjust. * sysdeps/s390/s390-32/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/s390/s390-64/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): * sysdeps/sh/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust. * sysdeps/x86_64/dl-machine.h (elf_machine_rela, elf_machine_rela_relative): Adjust.
2003-07-31 Alexandre Oliva <aoliva@redhat.com>
* elf/dynamic-link.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Don't assume
reloc_addr is aligned.
* sysdeps/alpha/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/arm/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/cris/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/hppa/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/i386/dl-machine.h (elf_machine_rel, elf_machine_rela,
elf_machine_rel_relative, elf_machine_rela_relative): Adjust.
* sysdeps/ia64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/m68k/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/mips/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/powerpc/powerpc64/dl-machine.h
(elf_machine_rela_relative, elf_machine_rela): Adjust.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative):
* sysdeps/sh/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
* sysdeps/x86_64/dl-machine.h (elf_machine_rela,
elf_machine_rela_relative): Adjust.
2003-07-31 08:33:53 +02:00
|
|
|
void *const reloc_addr_arg)
|
2001-09-19 12:37:31 +02:00
|
|
|
{
|
2012-05-08 18:39:58 +02:00
|
|
|
ElfW(Addr) *const reloc_addr = reloc_addr_arg;
|
2012-05-11 04:24:54 +02:00
|
|
|
#if !defined RTLD_BOOTSTRAP
|
2012-05-11 02:05:06 +02:00
|
|
|
/* l_addr + r_addend may be > 0xffffffff and R_X86_64_RELATIVE64
|
|
|
|
relocation updates the whole 64-bit entry. */
|
|
|
|
if (__builtin_expect (ELFW(R_TYPE) (reloc->r_info) == R_X86_64_RELATIVE64, 0))
|
|
|
|
*(Elf64_Addr *) reloc_addr = (Elf64_Addr) l_addr + reloc->r_addend;
|
|
|
|
else
|
2012-05-11 04:24:54 +02:00
|
|
|
#endif
|
2012-05-11 02:05:06 +02:00
|
|
|
{
|
|
|
|
assert (ELFW(R_TYPE) (reloc->r_info) == R_X86_64_RELATIVE);
|
|
|
|
*reloc_addr = l_addr + reloc->r_addend;
|
|
|
|
}
|
2001-09-19 12:37:31 +02:00
|
|
|
}
|
|
|
|
|
2004-09-24 19:09:04 +02:00
|
|
|
auto inline void
|
|
|
|
__attribute ((always_inline))
|
2001-09-19 12:37:31 +02:00
|
|
|
elf_machine_lazy_rel (struct link_map *map,
|
2012-05-08 18:39:58 +02:00
|
|
|
ElfW(Addr) l_addr, const ElfW(Rela) *reloc,
|
2011-10-04 16:10:16 +02:00
|
|
|
int skip_ifunc)
|
2001-09-19 12:37:31 +02:00
|
|
|
{
|
2012-05-08 18:39:58 +02:00
|
|
|
ElfW(Addr) *const reloc_addr = (void *) (l_addr + reloc->r_offset);
|
|
|
|
const unsigned long int r_type = ELFW(R_TYPE) (reloc->r_info);
|
2001-09-19 12:37:31 +02:00
|
|
|
|
|
|
|
/* Check for unexpected PLT reloc type. */
|
|
|
|
if (__builtin_expect (r_type == R_X86_64_JUMP_SLOT, 1))
|
Update.
2001-12-11 Jakub Jelinek <jakub@redhat.com>
* elf/Makefile (dl-routines): Add conflict.
(rtld-ldscript-in, rtld-ldscript, rtld-parms): Remove.
(ld.so): Add _begin local symbol.
* elf/elf.h (DT_VALTAGIDX, DT_VALNUM, DT_ADDRTAGIDX, DT_ADDRNUM):
Define.
* elf/dl-deps.c (_dl_build_local_scope): New.
(_dl_map_object_deps): If LD_TRACE_PRELINKING, compute local scopes
of all libraries.
* elf/do-rel.h (VALIDX): Define.
(elf_dynamic_do_rel): If ELF_MACHINE_PLT_REL is defined, don't do
lazy binding for RELA. If DT_GNU_PRELINKED, DT_RELACOUNT relocations
can be skipped.
* elf/dl-conflict.c: New file.
* elf/dl-lookup.c (_dl_debug_bindings): New.
(_dl_lookup_symbol): Use _dl_debug_bindings. Reference_name is always
non-NULL.
(_dl_lookup_symbol_skip): Likewise.
(_dl_lookup_versioned_symbol): Likewise.
(_dl_lookup_versioned_symbol_skip): Likewise.
* elf/dl-runtime.c (PLTREL): If ELF_MACHINE_PLT_REL is defined,
define to ElfW(Rel).
* elf/dynamic-link.h (elf_get_dynamic_info): Record selected dynamic
tags in the DT_VALRNGLO..DT_VALRNGHI and DT_ADDRRNGLO..DT_ADDRRNGHI
ranges.
Don't adjust address dynamic tags if l_addr is 0.
* elf/rtld.c (_dl_trace_prelink, _dl_trace_prelink_map): New variables.
(_dl_start): Skip ELF_DYNAMIC_RELOCATE if ld.so is prelinked.
(VALIDX, ADDRIDX): Define.
(_dl_start_final): Initialize _dl_rtld_map's l_map_start and l_map_end.
(dl_main): Print library list for LD_TRACE_PRELINKING.
If prelinking information can be used, skip relocating libraries and
call _dl_resolve_conflicts instead.
(process_envvars): Handle LD_TRACE_PRELINKING envvar.
* elf/dl-load.c (_dl_map_object): Don't create fake libs
if LD_TRACE_PRELINKING.
* include/link.h (struct link_map) [l_info]: Add DT_VALNUM
+ DT_ADDRNUM.
* sysdeps/generic/ldsodefs.h (_dl_trace_prelink_map): New declaration.
(DL_DEBUG_PRELINK): Define.
(_dl_resolve_conflicts): Add prototype.
* sysdeps/alpha/dl-machine.h (elf_machine_runtime_setup): Reinitialize
.plt for prelinked libraries where prelinking info cannot be used.
(elf_machine_rela): If relocating R_ALPHA_JMP_SLOT in .gnu.conflict
section, use RESOLVE_CONFLICT_FIND_MAP to find out reloc's link_map.
* sysdeps/arm/bits/link.h: New file.
* sysdeps/arm/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(ELF_MACHINE_NO_RELA): Only define if RTLD_BOOTSTRAP.
(ELF_MACHINE_PLT_REL): Define.
(elf_machine_rela, elf_machine_rela_relative): New.
(elf_machine_lazy_rel): Reinitialize R_ARM_JUMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/i386/bits/link.h: New file.
* sysdeps/i386/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(ELF_MACHINE_NO_RELA): Only define if RTLD_BOOTSTRAP.
(ELF_MACHINE_PLT_REL): Define.
(elf_machine_rela, elf_machine_rela_relative): New.
(elf_machine_lazy_rel): Reinitialize R_386_JUMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/powerpc/dl-machine.h (elf_machine_rela): If relocating
conflicts, skip finaladdr computation. Use RESOLVE_CONFLICT_FIND_MAP
to find out map for R_PPC_JMP_SLOT relocs.
* sysdeps/sparc/sparc32/dl-machine.h (VALIDX): Define.
(OPCODE_BA): Define.
(elf_machine_runtime_setup): Reinitialize .plt for prelinked
libraries where prelinking info cannot be used.
(sparc_fixup_plt): Renamed from elf_machine_fixup_plt.
(elf_machine_fixup_plt): Call sparc_fixup_plt.
(elf_machine_rela): Set value to 0 if relocating conflicts.
Call sparc_fixup_plt for R_SPARC_JMP_SLOT.
* sysdeps/sparc/sparc64/dl-machine.h (VALIDX): Define.
(sparc64_fixup_plt): Fix a typo.
(elf_machine_rela): Set value to 0 if relocating conflicts.
Handle R_SPARC_JMP_SLOT relocs when relocating conflicts.
(elf_machine_runtime_setup): Reinitialize .plt for prelinked
libraries where prelinking info cannot be used.
* sysdeps/sh/bits/link.h: New file.
* sysdeps/sh/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_SH_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/s390/s390-32/bits/link.h: New file.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_390_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/s390/s390-64/bits/link.h: New file.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_390_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/x86_64/bits/link.h: New file.
* sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_X86_64_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
2001-12-12 01:21:26 +01:00
|
|
|
{
|
|
|
|
if (__builtin_expect (map->l_mach.plt, 0) == 0)
|
|
|
|
*reloc_addr += l_addr;
|
|
|
|
else
|
|
|
|
*reloc_addr =
|
|
|
|
map->l_mach.plt
|
2012-05-08 18:39:58 +02:00
|
|
|
+ (((ElfW(Addr)) reloc_addr) - map->l_mach.gotplt) * 2;
|
Update.
2001-12-11 Jakub Jelinek <jakub@redhat.com>
* elf/Makefile (dl-routines): Add conflict.
(rtld-ldscript-in, rtld-ldscript, rtld-parms): Remove.
(ld.so): Add _begin local symbol.
* elf/elf.h (DT_VALTAGIDX, DT_VALNUM, DT_ADDRTAGIDX, DT_ADDRNUM):
Define.
* elf/dl-deps.c (_dl_build_local_scope): New.
(_dl_map_object_deps): If LD_TRACE_PRELINKING, compute local scopes
of all libraries.
* elf/do-rel.h (VALIDX): Define.
(elf_dynamic_do_rel): If ELF_MACHINE_PLT_REL is defined, don't do
lazy binding for RELA. If DT_GNU_PRELINKED, DT_RELACOUNT relocations
can be skipped.
* elf/dl-conflict.c: New file.
* elf/dl-lookup.c (_dl_debug_bindings): New.
(_dl_lookup_symbol): Use _dl_debug_bindings. Reference_name is always
non-NULL.
(_dl_lookup_symbol_skip): Likewise.
(_dl_lookup_versioned_symbol): Likewise.
(_dl_lookup_versioned_symbol_skip): Likewise.
* elf/dl-runtime.c (PLTREL): If ELF_MACHINE_PLT_REL is defined,
define to ElfW(Rel).
* elf/dynamic-link.h (elf_get_dynamic_info): Record selected dynamic
tags in the DT_VALRNGLO..DT_VALRNGHI and DT_ADDRRNGLO..DT_ADDRRNGHI
ranges.
Don't adjust address dynamic tags if l_addr is 0.
* elf/rtld.c (_dl_trace_prelink, _dl_trace_prelink_map): New variables.
(_dl_start): Skip ELF_DYNAMIC_RELOCATE if ld.so is prelinked.
(VALIDX, ADDRIDX): Define.
(_dl_start_final): Initialize _dl_rtld_map's l_map_start and l_map_end.
(dl_main): Print library list for LD_TRACE_PRELINKING.
If prelinking information can be used, skip relocating libraries and
call _dl_resolve_conflicts instead.
(process_envvars): Handle LD_TRACE_PRELINKING envvar.
* elf/dl-load.c (_dl_map_object): Don't create fake libs
if LD_TRACE_PRELINKING.
* include/link.h (struct link_map) [l_info]: Add DT_VALNUM
+ DT_ADDRNUM.
* sysdeps/generic/ldsodefs.h (_dl_trace_prelink_map): New declaration.
(DL_DEBUG_PRELINK): Define.
(_dl_resolve_conflicts): Add prototype.
* sysdeps/alpha/dl-machine.h (elf_machine_runtime_setup): Reinitialize
.plt for prelinked libraries where prelinking info cannot be used.
(elf_machine_rela): If relocating R_ALPHA_JMP_SLOT in .gnu.conflict
section, use RESOLVE_CONFLICT_FIND_MAP to find out reloc's link_map.
* sysdeps/arm/bits/link.h: New file.
* sysdeps/arm/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(ELF_MACHINE_NO_RELA): Only define if RTLD_BOOTSTRAP.
(ELF_MACHINE_PLT_REL): Define.
(elf_machine_rela, elf_machine_rela_relative): New.
(elf_machine_lazy_rel): Reinitialize R_ARM_JUMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/i386/bits/link.h: New file.
* sysdeps/i386/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(ELF_MACHINE_NO_RELA): Only define if RTLD_BOOTSTRAP.
(ELF_MACHINE_PLT_REL): Define.
(elf_machine_rela, elf_machine_rela_relative): New.
(elf_machine_lazy_rel): Reinitialize R_386_JUMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/powerpc/dl-machine.h (elf_machine_rela): If relocating
conflicts, skip finaladdr computation. Use RESOLVE_CONFLICT_FIND_MAP
to find out map for R_PPC_JMP_SLOT relocs.
* sysdeps/sparc/sparc32/dl-machine.h (VALIDX): Define.
(OPCODE_BA): Define.
(elf_machine_runtime_setup): Reinitialize .plt for prelinked
libraries where prelinking info cannot be used.
(sparc_fixup_plt): Renamed from elf_machine_fixup_plt.
(elf_machine_fixup_plt): Call sparc_fixup_plt.
(elf_machine_rela): Set value to 0 if relocating conflicts.
Call sparc_fixup_plt for R_SPARC_JMP_SLOT.
* sysdeps/sparc/sparc64/dl-machine.h (VALIDX): Define.
(sparc64_fixup_plt): Fix a typo.
(elf_machine_rela): Set value to 0 if relocating conflicts.
Handle R_SPARC_JMP_SLOT relocs when relocating conflicts.
(elf_machine_runtime_setup): Reinitialize .plt for prelinked
libraries where prelinking info cannot be used.
* sysdeps/sh/bits/link.h: New file.
* sysdeps/sh/dl-machine.h (elf_machine_runtime_setup): Save original
content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_SH_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/s390/s390-32/bits/link.h: New file.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_390_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/s390/s390-64/bits/link.h: New file.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_390_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
* sysdeps/x86_64/bits/link.h: New file.
* sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup):
Save original content of .got[1].
(elf_machine_lazy_rel): Reinitialize R_X86_64_JMP_SLOT address instead
of adjusting it if prelinked and prelinking cannot be used.
2001-12-12 01:21:26 +01:00
|
|
|
}
|
Introduce TLS descriptors for i386 and x86_64.
* include/inline-hashtab.h: New file, copied from 2005's
libiberty, with fix for memory leak imported afterwards by
Glauber de Oliveira Costa.
* elf/tlsdeschtab.h: New file.
* elf/dl-reloc.c (_dl_try_allocate_static_tls): Extract from...
(_dl_allocate_static_tls): ... here. Rearrange failure path.
(CHECK_STATIC_TLS): Move to...
* elf/dynamic-link.h: ... this file.
(TRY_STATIC_TLS): New macro.
* elf/dl-conflict.c (CHECK_STATIC_TLS, TRY_STATIC_TLS): Override.
* elf/elf.h (R_386_TLS_GOTDESC, R_386_TLS_DESC_CALL,
R_386_TLS_DESC): Define.
(R_X86_64_PC64, R_X86_GOTOFF64, R_X86_64_GOTPC32): Merge from
binutils.
(R_X86_64_GOTPC32_TLSDESC, R_X86_64_TLSDESC_CALL,
R_X86_64_TLSDESC): Define.
(R_386_NUM, R_X86_64_NUM): Adjust.
* sysdeps/i386/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/i386/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/i386/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_type_class): Mark R_386_TLS_DESC as PLT class.
(elf_machine_rel): Handle R_386_TLS_DESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
(elf_machine_lazy_rela): Likewise.
* sysdeps/i386/dl-tls.h (struct dl_tls_index): Name it.
* sysdeps/i386/dl-tlsdesc.S: New file.
* sysdeps/i386/dl-tlsdesc.h: New file.
* sysdeps/i386/tlsdesc.c: New file.
* sysdeps/i386/tlsdesc.sym: New file.
* sysdeps/i386/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table.
* sysdeps/x86_64/Makefile (sysdep-dl-routines, sysdep_routines,
systep-rtld-routines): Add tlsdesc and dl-tlsdesc for elf subdir.
(gen-as-const-headers): Add tlsdesc.sym to csu subdir.
* sysdeps/x86_64/dl-lookupcfg.h: New file. Introduce _dl_unmap to
release tlsdesc_table.
* sysdeps/x86_64/dl-machine.h: Include dl-tlsdesc.h.
(elf_machine_runtime_setup): Set up lazy TLSDESC GOT entry.
(elf_machine_type_class): Mark R_X86_64_TLSDESC as PLT class.
(elf_machine_rel): Handle R_X86_64_TLSDESC.
(elf_machine_rela): Likewise.
(elf_machine_lazy_rel): Likewise.
* sysdeps/x86_64/dl-tls.h (struct dl_tls_index): Name it.
(__tls_get_addr): Do not declare for non-shared compiles.
* sysdeps/x86_64/dl-tlsdesc.S: New file.
* sysdeps/x86_64/dl-tlsdesc.h: New file.
* sysdeps/x86_64/tlsdesc.c: New file.
* sysdeps/x86_64/tlsdesc.sym: New file.
* sysdeps/x86_64/bits/linkmap.h (struct link_map_machine): Add
tlsdesc_table for both 32- and 64-bit structs.
2008-05-13 07:41:30 +02:00
|
|
|
else if (__builtin_expect (r_type == R_X86_64_TLSDESC, 1))
|
|
|
|
{
|
|
|
|
struct tlsdesc volatile * __attribute__((__unused__)) td =
|
|
|
|
(struct tlsdesc volatile *)reloc_addr;
|
|
|
|
|
|
|
|
td->arg = (void*)reloc;
|
|
|
|
td->entry = (void*)(D_PTR (map, l_info[ADDRIDX (DT_TLSDESC_PLT)])
|
|
|
|
+ map->l_addr);
|
|
|
|
}
|
2009-06-01 08:45:33 +02:00
|
|
|
else if (__builtin_expect (r_type == R_X86_64_IRELATIVE, 0))
|
|
|
|
{
|
2012-05-08 18:39:58 +02:00
|
|
|
ElfW(Addr) value = map->l_addr + reloc->r_addend;
|
2011-10-04 16:10:16 +02:00
|
|
|
if (__builtin_expect (!skip_ifunc, 1))
|
2012-05-08 18:39:58 +02:00
|
|
|
value = ((ElfW(Addr) (*) (void)) value) ();
|
2009-06-01 08:45:33 +02:00
|
|
|
*reloc_addr = value;
|
|
|
|
}
|
2001-09-19 12:37:31 +02:00
|
|
|
else
|
|
|
|
_dl_reloc_bad_type (map, r_type, 1);
|
|
|
|
}
|
|
|
|
|
2005-01-06 23:40:27 +01:00
|
|
|
#endif /* RESOLVE_MAP */
|