2003-02-28 05:55:04 +01:00
|
|
|
/* Machine-dependent ELF dynamic relocation inline functions.
|
2002-09-18 01:50:03 +02:00
|
|
|
PowerPC64 version.
|
2016-01-04 17:05:18 +01:00
|
|
|
Copyright 1995-2016 Free Software Foundation, Inc.
|
2002-09-18 01:50:03 +02:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 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
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
2012-02-10 00:18:22 +01:00
|
|
|
License along with the GNU C Library; see the file COPYING.LIB. If
|
|
|
|
not, see <http://www.gnu.org/licenses/>. */
|
2002-09-18 01:50:03 +02:00
|
|
|
|
|
|
|
#ifndef dl_machine_h
|
|
|
|
#define dl_machine_h
|
|
|
|
|
|
|
|
#define ELF_MACHINE_NAME "powerpc64"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <sys/param.h>
|
2003-03-05 04:27:24 +01:00
|
|
|
#include <dl-tls.h>
|
Update.
2004-09-07 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc64/configure.in: New file.
* config.h.in (USE_PPC64_OVERLAPPING_OPD): Add.
* configure.in (HAVE_ASM_GLOBAL_DOT_NAME): Remove.
* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(OPD_ENT, BODY_LABEL, ENTRY_1, ENTRY_2, END_2, DOT_PREFIX,
BODY_PREFIX): Define.
(ENTRY, DOT_LABEL, END, TRACEBACK, END_GEN_TB, EALIGN): Support
HAVE_ASM_GLOBAL_DOT_NAME or no dot symbols,
USE_PPC64_OVERLAPPING_OPD or never overlapping .opd entries.
* sysdeps/powerpc/powerpc64/dl-machine.h: Include sysdep.h.
(TRAMPOLINE_TEMPLATE, RTLD_START): Use the new sysdep.h macros.
2004-09-08 09:02:28 +02:00
|
|
|
#include <sysdep.h>
|
2015-10-23 02:26:58 +02:00
|
|
|
#include <hwcapinfo.h>
|
2002-09-18 01:50:03 +02:00
|
|
|
|
|
|
|
/* Translate a processor specific dynamic tag to the index
|
|
|
|
in l_info array. */
|
|
|
|
#define DT_PPC64(x) (DT_PPC64_##x - DT_LOPROC + DT_NUM)
|
|
|
|
|
2013-12-04 13:51:11 +01:00
|
|
|
#if _CALL_ELF != 2
|
2002-09-18 01:50:03 +02:00
|
|
|
/* A PowerPC64 function descriptor. The .plt (procedure linkage
|
|
|
|
table) and .opd (official procedure descriptor) sections are
|
|
|
|
arrays of these. */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
Elf64_Addr fd_func;
|
|
|
|
Elf64_Addr fd_toc;
|
|
|
|
Elf64_Addr fd_aux;
|
|
|
|
} Elf64_FuncDesc;
|
2013-12-04 13:51:11 +01:00
|
|
|
#endif
|
2002-09-18 01:50:03 +02:00
|
|
|
|
|
|
|
#define ELF_MULT_MACHINES_SUPPORTED
|
|
|
|
|
|
|
|
/* Return nonzero iff ELF header is compatible with the running host. */
|
|
|
|
static inline int
|
|
|
|
elf_machine_matches_host (const Elf64_Ehdr *ehdr)
|
|
|
|
{
|
2013-12-04 13:51:11 +01:00
|
|
|
/* Verify that the binary matches our ABI version. */
|
|
|
|
if ((ehdr->e_flags & EF_PPC64_ABI) != 0)
|
|
|
|
{
|
|
|
|
#if _CALL_ELF != 2
|
|
|
|
if ((ehdr->e_flags & EF_PPC64_ABI) != 1)
|
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
if ((ehdr->e_flags & EF_PPC64_ABI) != 2)
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2002-09-18 01:50:03 +02:00
|
|
|
return ehdr->e_machine == EM_PPC64;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return nonzero iff ELF header is compatible with the running host,
|
|
|
|
but not this loader. */
|
|
|
|
static inline int
|
|
|
|
elf_host_tolerates_machine (const Elf64_Ehdr *ehdr)
|
|
|
|
{
|
|
|
|
return ehdr->e_machine == EM_PPC;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return nonzero iff ELF header is compatible with the running host,
|
|
|
|
but not this loader. */
|
|
|
|
static inline int
|
|
|
|
elf_host_tolerates_class (const Elf64_Ehdr *ehdr)
|
|
|
|
{
|
|
|
|
return ehdr->e_ident[EI_CLASS] == ELFCLASS32;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Return the run-time load address of the shared object, assuming it
|
|
|
|
was originally linked at zero. */
|
|
|
|
static inline Elf64_Addr
|
|
|
|
elf_machine_load_address (void) __attribute__ ((const));
|
|
|
|
|
|
|
|
static inline Elf64_Addr
|
|
|
|
elf_machine_load_address (void)
|
|
|
|
{
|
|
|
|
Elf64_Addr ret;
|
|
|
|
|
|
|
|
/* The first entry in .got (and thus the first entry in .toc) is the
|
|
|
|
link-time TOC_base, ie. r2. So the difference between that and
|
|
|
|
the current r2 set by the kernel is how far the shared lib has
|
|
|
|
moved. */
|
|
|
|
asm ( " ld %0,-32768(2)\n"
|
|
|
|
" subf %0,%0,2\n"
|
|
|
|
: "=r" (ret));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the link-time address of _DYNAMIC. */
|
|
|
|
static inline Elf64_Addr
|
|
|
|
elf_machine_dynamic (void)
|
|
|
|
{
|
|
|
|
Elf64_Addr runtime_dynamic;
|
|
|
|
/* It's easier to get the run-time address. */
|
|
|
|
asm ( " addis %0,2,_DYNAMIC@toc@ha\n"
|
|
|
|
" addi %0,%0,_DYNAMIC@toc@l\n"
|
|
|
|
: "=b" (runtime_dynamic));
|
|
|
|
/* Then subtract off the load address offset. */
|
|
|
|
return runtime_dynamic - elf_machine_load_address() ;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info) /* nothing */
|
|
|
|
|
|
|
|
/* The PLT uses Elf64_Rela relocs. */
|
|
|
|
#define elf_machine_relplt elf_machine_rela
|
|
|
|
|
|
|
|
|
2004-07-06 06:26:42 +02:00
|
|
|
#ifdef HAVE_INLINED_SYSCALLS
|
|
|
|
/* We do not need _dl_starting_up. */
|
|
|
|
# define DL_STARTING_UP_DEF
|
|
|
|
#else
|
|
|
|
# define DL_STARTING_UP_DEF \
|
|
|
|
".LC__dl_starting_up:\n" \
|
2014-11-06 00:35:36 +01:00
|
|
|
" .tc __GI__dl_starting_up[TC],__GI__dl_starting_up\n"
|
2004-07-06 06:26:42 +02:00
|
|
|
#endif
|
|
|
|
|
2002-09-18 01:50:03 +02:00
|
|
|
|
|
|
|
/* 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 \
|
2005-05-09 10:53:13 +02:00
|
|
|
asm (".pushsection \".text\"\n" \
|
2002-09-18 01:50:03 +02:00
|
|
|
" .align 2\n" \
|
Update.
2004-09-07 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc64/configure.in: New file.
* config.h.in (USE_PPC64_OVERLAPPING_OPD): Add.
* configure.in (HAVE_ASM_GLOBAL_DOT_NAME): Remove.
* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(OPD_ENT, BODY_LABEL, ENTRY_1, ENTRY_2, END_2, DOT_PREFIX,
BODY_PREFIX): Define.
(ENTRY, DOT_LABEL, END, TRACEBACK, END_GEN_TB, EALIGN): Support
HAVE_ASM_GLOBAL_DOT_NAME or no dot symbols,
USE_PPC64_OVERLAPPING_OPD or never overlapping .opd entries.
* sysdeps/powerpc/powerpc64/dl-machine.h: Include sysdep.h.
(TRAMPOLINE_TEMPLATE, RTLD_START): Use the new sysdep.h macros.
2004-09-08 09:02:28 +02:00
|
|
|
" " ENTRY_2(_start) "\n" \
|
|
|
|
BODY_PREFIX "_start:\n" \
|
2013-12-04 13:51:11 +01:00
|
|
|
" " LOCALENTRY(_start) "\n" \
|
2002-09-18 01:50:03 +02:00
|
|
|
/* We start with the following on the stack, from top: \
|
|
|
|
argc (4 bytes); \
|
|
|
|
arguments for program (terminated by NULL); \
|
|
|
|
environment variables (terminated by NULL); \
|
|
|
|
arguments for the program loader. */ \
|
|
|
|
" mr 3,1\n" \
|
|
|
|
" li 4,0\n" \
|
|
|
|
" stdu 4,-128(1)\n" \
|
|
|
|
/* Call _dl_start with one parameter pointing at argc. */ \
|
Update.
2004-09-07 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc64/configure.in: New file.
* config.h.in (USE_PPC64_OVERLAPPING_OPD): Add.
* configure.in (HAVE_ASM_GLOBAL_DOT_NAME): Remove.
* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(OPD_ENT, BODY_LABEL, ENTRY_1, ENTRY_2, END_2, DOT_PREFIX,
BODY_PREFIX): Define.
(ENTRY, DOT_LABEL, END, TRACEBACK, END_GEN_TB, EALIGN): Support
HAVE_ASM_GLOBAL_DOT_NAME or no dot symbols,
USE_PPC64_OVERLAPPING_OPD or never overlapping .opd entries.
* sysdeps/powerpc/powerpc64/dl-machine.h: Include sysdep.h.
(TRAMPOLINE_TEMPLATE, RTLD_START): Use the new sysdep.h macros.
2004-09-08 09:02:28 +02:00
|
|
|
" bl " DOT_PREFIX "_dl_start\n" \
|
2002-09-18 01:50:03 +02:00
|
|
|
" nop\n" \
|
|
|
|
/* Transfer control to _dl_start_user! */ \
|
Update.
2004-09-07 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc64/configure.in: New file.
* config.h.in (USE_PPC64_OVERLAPPING_OPD): Add.
* configure.in (HAVE_ASM_GLOBAL_DOT_NAME): Remove.
* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(OPD_ENT, BODY_LABEL, ENTRY_1, ENTRY_2, END_2, DOT_PREFIX,
BODY_PREFIX): Define.
(ENTRY, DOT_LABEL, END, TRACEBACK, END_GEN_TB, EALIGN): Support
HAVE_ASM_GLOBAL_DOT_NAME or no dot symbols,
USE_PPC64_OVERLAPPING_OPD or never overlapping .opd entries.
* sysdeps/powerpc/powerpc64/dl-machine.h: Include sysdep.h.
(TRAMPOLINE_TEMPLATE, RTLD_START): Use the new sysdep.h macros.
2004-09-08 09:02:28 +02:00
|
|
|
" b " DOT_PREFIX "_dl_start_user\n" \
|
|
|
|
".LT__start:\n" \
|
|
|
|
" .long 0\n" \
|
2002-09-18 01:50:03 +02:00
|
|
|
" .byte 0x00,0x0c,0x24,0x40,0x00,0x00,0x00,0x00\n" \
|
Update.
2004-09-07 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc64/configure.in: New file.
* config.h.in (USE_PPC64_OVERLAPPING_OPD): Add.
* configure.in (HAVE_ASM_GLOBAL_DOT_NAME): Remove.
* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(OPD_ENT, BODY_LABEL, ENTRY_1, ENTRY_2, END_2, DOT_PREFIX,
BODY_PREFIX): Define.
(ENTRY, DOT_LABEL, END, TRACEBACK, END_GEN_TB, EALIGN): Support
HAVE_ASM_GLOBAL_DOT_NAME or no dot symbols,
USE_PPC64_OVERLAPPING_OPD or never overlapping .opd entries.
* sysdeps/powerpc/powerpc64/dl-machine.h: Include sysdep.h.
(TRAMPOLINE_TEMPLATE, RTLD_START): Use the new sysdep.h macros.
2004-09-08 09:02:28 +02:00
|
|
|
" .long .LT__start-" BODY_PREFIX "_start\n" \
|
2002-09-18 01:50:03 +02:00
|
|
|
" .short .LT__start_name_end-.LT__start_name_start\n" \
|
|
|
|
".LT__start_name_start:\n" \
|
|
|
|
" .ascii \"_start\"\n" \
|
|
|
|
".LT__start_name_end:\n" \
|
|
|
|
" .align 2\n" \
|
Update.
2004-09-07 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc64/configure.in: New file.
* config.h.in (USE_PPC64_OVERLAPPING_OPD): Add.
* configure.in (HAVE_ASM_GLOBAL_DOT_NAME): Remove.
* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(OPD_ENT, BODY_LABEL, ENTRY_1, ENTRY_2, END_2, DOT_PREFIX,
BODY_PREFIX): Define.
(ENTRY, DOT_LABEL, END, TRACEBACK, END_GEN_TB, EALIGN): Support
HAVE_ASM_GLOBAL_DOT_NAME or no dot symbols,
USE_PPC64_OVERLAPPING_OPD or never overlapping .opd entries.
* sysdeps/powerpc/powerpc64/dl-machine.h: Include sysdep.h.
(TRAMPOLINE_TEMPLATE, RTLD_START): Use the new sysdep.h macros.
2004-09-08 09:02:28 +02:00
|
|
|
" " END_2(_start) "\n" \
|
2005-05-09 10:53:13 +02:00
|
|
|
" .pushsection \".toc\",\"aw\"\n" \
|
2004-07-06 06:26:42 +02:00
|
|
|
DL_STARTING_UP_DEF \
|
2012-05-16 22:40:23 +02:00
|
|
|
".LC__rtld_local:\n" \
|
|
|
|
" .tc _rtld_local[TC],_rtld_local\n" \
|
2004-07-06 06:26:42 +02:00
|
|
|
".LC__dl_argc:\n" \
|
|
|
|
" .tc _dl_argc[TC],_dl_argc\n" \
|
|
|
|
".LC__dl_argv:\n" \
|
2014-11-04 18:39:39 +01:00
|
|
|
" .tc __GI__dl_argv[TC],__GI__dl_argv\n" \
|
2004-07-06 06:26:42 +02:00
|
|
|
".LC__dl_fini:\n" \
|
|
|
|
" .tc _dl_fini[TC],_dl_fini\n" \
|
2005-05-09 10:53:13 +02:00
|
|
|
" .popsection\n" \
|
Update.
2004-09-07 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc64/configure.in: New file.
* config.h.in (USE_PPC64_OVERLAPPING_OPD): Add.
* configure.in (HAVE_ASM_GLOBAL_DOT_NAME): Remove.
* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(OPD_ENT, BODY_LABEL, ENTRY_1, ENTRY_2, END_2, DOT_PREFIX,
BODY_PREFIX): Define.
(ENTRY, DOT_LABEL, END, TRACEBACK, END_GEN_TB, EALIGN): Support
HAVE_ASM_GLOBAL_DOT_NAME or no dot symbols,
USE_PPC64_OVERLAPPING_OPD or never overlapping .opd entries.
* sysdeps/powerpc/powerpc64/dl-machine.h: Include sysdep.h.
(TRAMPOLINE_TEMPLATE, RTLD_START): Use the new sysdep.h macros.
2004-09-08 09:02:28 +02:00
|
|
|
" " ENTRY_2(_dl_start_user) "\n" \
|
|
|
|
/* Now, we do our main work of calling initialisation procedures. \
|
|
|
|
The ELF ABI doesn't say anything about parameters for these, \
|
|
|
|
so we just pass argc, argv, and the environment. \
|
|
|
|
Changing these is strongly discouraged (not least because argc is \
|
|
|
|
passed by value!). */ \
|
|
|
|
BODY_PREFIX "_dl_start_user:\n" \
|
2013-12-04 13:51:11 +01:00
|
|
|
" " LOCALENTRY(_dl_start_user) "\n" \
|
2002-09-18 01:50:03 +02:00
|
|
|
/* the address of _start in r30. */ \
|
|
|
|
" mr 30,3\n" \
|
|
|
|
/* &_dl_argc in 29, &_dl_argv in 27, and _dl_loaded in 28. */ \
|
2012-05-16 22:40:23 +02:00
|
|
|
" ld 28,.LC__rtld_local@toc(2)\n" \
|
Update.
2004-09-07 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc64/configure.in: New file.
* config.h.in (USE_PPC64_OVERLAPPING_OPD): Add.
* configure.in (HAVE_ASM_GLOBAL_DOT_NAME): Remove.
* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(OPD_ENT, BODY_LABEL, ENTRY_1, ENTRY_2, END_2, DOT_PREFIX,
BODY_PREFIX): Define.
(ENTRY, DOT_LABEL, END, TRACEBACK, END_GEN_TB, EALIGN): Support
HAVE_ASM_GLOBAL_DOT_NAME or no dot symbols,
USE_PPC64_OVERLAPPING_OPD or never overlapping .opd entries.
* sysdeps/powerpc/powerpc64/dl-machine.h: Include sysdep.h.
(TRAMPOLINE_TEMPLATE, RTLD_START): Use the new sysdep.h macros.
2004-09-08 09:02:28 +02:00
|
|
|
" ld 29,.LC__dl_argc@toc(2)\n" \
|
|
|
|
" ld 27,.LC__dl_argv@toc(2)\n" \
|
2002-09-18 01:50:03 +02:00
|
|
|
/* _dl_init (_dl_loaded, _dl_argc, _dl_argv, _dl_argv+_dl_argc+1). */ \
|
|
|
|
" ld 3,0(28)\n" \
|
|
|
|
" lwa 4,0(29)\n" \
|
|
|
|
" ld 5,0(27)\n" \
|
|
|
|
" sldi 6,4,3\n" \
|
|
|
|
" add 6,5,6\n" \
|
|
|
|
" addi 6,6,8\n" \
|
Update.
2004-09-07 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc64/configure.in: New file.
* config.h.in (USE_PPC64_OVERLAPPING_OPD): Add.
* configure.in (HAVE_ASM_GLOBAL_DOT_NAME): Remove.
* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(OPD_ENT, BODY_LABEL, ENTRY_1, ENTRY_2, END_2, DOT_PREFIX,
BODY_PREFIX): Define.
(ENTRY, DOT_LABEL, END, TRACEBACK, END_GEN_TB, EALIGN): Support
HAVE_ASM_GLOBAL_DOT_NAME or no dot symbols,
USE_PPC64_OVERLAPPING_OPD or never overlapping .opd entries.
* sysdeps/powerpc/powerpc64/dl-machine.h: Include sysdep.h.
(TRAMPOLINE_TEMPLATE, RTLD_START): Use the new sysdep.h macros.
2004-09-08 09:02:28 +02:00
|
|
|
" bl " DOT_PREFIX "_dl_init\n" \
|
2002-09-18 01:50:03 +02:00
|
|
|
" nop\n" \
|
|
|
|
/* Now, to conform to the ELF ABI, we have to: \
|
|
|
|
Pass argc (actually _dl_argc) in r3; */ \
|
|
|
|
" lwa 3,0(29)\n" \
|
|
|
|
/* Pass argv (actually _dl_argv) in r4; */ \
|
|
|
|
" ld 4,0(27)\n" \
|
|
|
|
/* Pass argv+argc+1 in r5; */ \
|
|
|
|
" sldi 5,3,3\n" \
|
|
|
|
" add 6,4,5\n" \
|
|
|
|
" addi 5,6,8\n" \
|
2013-01-07 18:20:53 +01:00
|
|
|
/* Pass the auxiliary vector in r6. This is passed to us just after \
|
2002-09-18 01:50:03 +02:00
|
|
|
_envp. */ \
|
|
|
|
"2: ldu 0,8(6)\n" \
|
|
|
|
" cmpdi 0,0\n" \
|
|
|
|
" bne 2b\n" \
|
|
|
|
" addi 6,6,8\n" \
|
|
|
|
/* Pass a termination function pointer (in this case _dl_fini) in \
|
|
|
|
r7. */ \
|
2004-07-06 06:26:42 +02:00
|
|
|
" ld 7,.LC__dl_fini@toc(2)\n" \
|
2002-09-18 01:50:03 +02:00
|
|
|
/* Pass the stack pointer in r1 (so far so good), pointing to a NULL \
|
|
|
|
value. This lets our startup code distinguish between a program \
|
|
|
|
linked statically, which linux will call with argc on top of the \
|
|
|
|
stack which will hopefully never be zero, and a dynamically linked \
|
|
|
|
program which will always have a NULL on the top of the stack. \
|
Update.
2004-09-07 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc64/configure.in: New file.
* config.h.in (USE_PPC64_OVERLAPPING_OPD): Add.
* configure.in (HAVE_ASM_GLOBAL_DOT_NAME): Remove.
* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(OPD_ENT, BODY_LABEL, ENTRY_1, ENTRY_2, END_2, DOT_PREFIX,
BODY_PREFIX): Define.
(ENTRY, DOT_LABEL, END, TRACEBACK, END_GEN_TB, EALIGN): Support
HAVE_ASM_GLOBAL_DOT_NAME or no dot symbols,
USE_PPC64_OVERLAPPING_OPD or never overlapping .opd entries.
* sysdeps/powerpc/powerpc64/dl-machine.h: Include sysdep.h.
(TRAMPOLINE_TEMPLATE, RTLD_START): Use the new sysdep.h macros.
2004-09-08 09:02:28 +02:00
|
|
|
Take the opportunity to clear LR, so anyone who accidentally \
|
2002-09-18 01:50:03 +02:00
|
|
|
returns from _start gets SEGV. Also clear the next few words of \
|
|
|
|
the stack. */ \
|
|
|
|
" li 31,0\n" \
|
|
|
|
" std 31,0(1)\n" \
|
|
|
|
" mtlr 31\n" \
|
|
|
|
" std 31,8(1)\n" \
|
|
|
|
" std 31,16(1)\n" \
|
|
|
|
" std 31,24(1)\n" \
|
|
|
|
/* Now, call the start function descriptor at r30... */ \
|
Update.
2004-09-07 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc64/configure.in: New file.
* config.h.in (USE_PPC64_OVERLAPPING_OPD): Add.
* configure.in (HAVE_ASM_GLOBAL_DOT_NAME): Remove.
* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(OPD_ENT, BODY_LABEL, ENTRY_1, ENTRY_2, END_2, DOT_PREFIX,
BODY_PREFIX): Define.
(ENTRY, DOT_LABEL, END, TRACEBACK, END_GEN_TB, EALIGN): Support
HAVE_ASM_GLOBAL_DOT_NAME or no dot symbols,
USE_PPC64_OVERLAPPING_OPD or never overlapping .opd entries.
* sysdeps/powerpc/powerpc64/dl-machine.h: Include sysdep.h.
(TRAMPOLINE_TEMPLATE, RTLD_START): Use the new sysdep.h macros.
2004-09-08 09:02:28 +02:00
|
|
|
" .globl ._dl_main_dispatch\n" \
|
|
|
|
"._dl_main_dispatch:\n" \
|
2013-12-04 13:49:15 +01:00
|
|
|
" " PPC64_LOAD_FUNCPTR(30) "\n" \
|
2002-09-18 01:50:03 +02:00
|
|
|
" bctr\n" \
|
Update.
2004-09-07 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc64/configure.in: New file.
* config.h.in (USE_PPC64_OVERLAPPING_OPD): Add.
* configure.in (HAVE_ASM_GLOBAL_DOT_NAME): Remove.
* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(OPD_ENT, BODY_LABEL, ENTRY_1, ENTRY_2, END_2, DOT_PREFIX,
BODY_PREFIX): Define.
(ENTRY, DOT_LABEL, END, TRACEBACK, END_GEN_TB, EALIGN): Support
HAVE_ASM_GLOBAL_DOT_NAME or no dot symbols,
USE_PPC64_OVERLAPPING_OPD or never overlapping .opd entries.
* sysdeps/powerpc/powerpc64/dl-machine.h: Include sysdep.h.
(TRAMPOLINE_TEMPLATE, RTLD_START): Use the new sysdep.h macros.
2004-09-08 09:02:28 +02:00
|
|
|
".LT__dl_start_user:\n" \
|
2002-09-18 01:50:03 +02:00
|
|
|
" .long 0\n" \
|
|
|
|
" .byte 0x00,0x0c,0x24,0x40,0x00,0x00,0x00,0x00\n" \
|
Update.
2004-09-07 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc64/configure.in: New file.
* config.h.in (USE_PPC64_OVERLAPPING_OPD): Add.
* configure.in (HAVE_ASM_GLOBAL_DOT_NAME): Remove.
* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(OPD_ENT, BODY_LABEL, ENTRY_1, ENTRY_2, END_2, DOT_PREFIX,
BODY_PREFIX): Define.
(ENTRY, DOT_LABEL, END, TRACEBACK, END_GEN_TB, EALIGN): Support
HAVE_ASM_GLOBAL_DOT_NAME or no dot symbols,
USE_PPC64_OVERLAPPING_OPD or never overlapping .opd entries.
* sysdeps/powerpc/powerpc64/dl-machine.h: Include sysdep.h.
(TRAMPOLINE_TEMPLATE, RTLD_START): Use the new sysdep.h macros.
2004-09-08 09:02:28 +02:00
|
|
|
" .long .LT__dl_start_user-" BODY_PREFIX "_dl_start_user\n" \
|
2002-09-18 01:50:03 +02:00
|
|
|
" .short .LT__dl_start_user_name_end-.LT__dl_start_user_name_start\n" \
|
|
|
|
".LT__dl_start_user_name_start:\n" \
|
|
|
|
" .ascii \"_dl_start_user\"\n" \
|
|
|
|
".LT__dl_start_user_name_end:\n" \
|
|
|
|
" .align 2\n" \
|
Update.
2004-09-07 Jakub Jelinek <jakub@redhat.com>
* sysdeps/powerpc/powerpc64/configure.in: New file.
* config.h.in (USE_PPC64_OVERLAPPING_OPD): Add.
* configure.in (HAVE_ASM_GLOBAL_DOT_NAME): Remove.
* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(OPD_ENT, BODY_LABEL, ENTRY_1, ENTRY_2, END_2, DOT_PREFIX,
BODY_PREFIX): Define.
(ENTRY, DOT_LABEL, END, TRACEBACK, END_GEN_TB, EALIGN): Support
HAVE_ASM_GLOBAL_DOT_NAME or no dot symbols,
USE_PPC64_OVERLAPPING_OPD or never overlapping .opd entries.
* sysdeps/powerpc/powerpc64/dl-machine.h: Include sysdep.h.
(TRAMPOLINE_TEMPLATE, RTLD_START): Use the new sysdep.h macros.
2004-09-08 09:02:28 +02:00
|
|
|
" " END_2(_dl_start_user) "\n" \
|
2005-05-09 10:53:13 +02:00
|
|
|
" .popsection");
|
2002-09-18 01:50:03 +02:00
|
|
|
|
2015-03-05 17:26:21 +01:00
|
|
|
/* ELF_RTYPE_CLASS_COPY iff TYPE should not be allowed to resolve to
|
2008-04-10 20:26:16 +02:00
|
|
|
one of the main executable's symbols, as for a COPY reloc.
|
2002-09-18 01:50:03 +02:00
|
|
|
|
2008-04-10 20:26:16 +02:00
|
|
|
To make function pointer comparisons work on most targets, the
|
|
|
|
relevant ABI states that the address of a non-local function in a
|
|
|
|
dynamically linked executable is the address of the PLT entry for
|
|
|
|
that function. This is quite reasonable since using the real
|
|
|
|
function address in a non-PIC executable would typically require
|
|
|
|
dynamic relocations in .text, something to be avoided. For such
|
|
|
|
functions, the linker emits a SHN_UNDEF symbol in the executable
|
|
|
|
with value equal to the PLT entry address. Normally, SHN_UNDEF
|
|
|
|
symbols have a value of zero, so this is a clue to ld.so that it
|
|
|
|
should treat these symbols specially. For relocations not in
|
|
|
|
ELF_RTYPE_CLASS_PLT (eg. those on function pointers), ld.so should
|
|
|
|
use the value of the executable SHN_UNDEF symbol, ie. the PLT entry
|
|
|
|
address. For relocations in ELF_RTYPE_CLASS_PLT (eg. the relocs in
|
|
|
|
the PLT itself), ld.so should use the value of the corresponding
|
|
|
|
defined symbol in the object that defines the function, ie. the
|
|
|
|
real function address. This complicates ld.so in that there are
|
|
|
|
now two possible values for a given symbol, and it gets even worse
|
|
|
|
because protected symbols need yet another set of rules.
|
2002-09-18 01:50:03 +02:00
|
|
|
|
2008-04-10 20:26:16 +02:00
|
|
|
On PowerPC64 we don't need any of this. The linker won't emit
|
|
|
|
SHN_UNDEF symbols with non-zero values. ld.so can make all
|
|
|
|
relocations behave "normally", ie. always use the real address
|
|
|
|
like PLT relocations. So always set ELF_RTYPE_CLASS_PLT. */
|
2003-02-26 01:34:09 +01:00
|
|
|
|
2013-12-04 13:51:11 +01:00
|
|
|
#if _CALL_ELF != 2
|
2002-09-18 01:50:03 +02:00
|
|
|
#define elf_machine_type_class(type) \
|
2008-04-10 20:26:16 +02:00
|
|
|
(ELF_RTYPE_CLASS_PLT | (((type) == R_PPC64_COPY) * ELF_RTYPE_CLASS_COPY))
|
2013-12-04 13:51:11 +01:00
|
|
|
#else
|
|
|
|
/* And now that you have read that large comment, you can disregard it
|
|
|
|
all for ELFv2. ELFv2 does need the special SHN_UNDEF treatment. */
|
|
|
|
#define IS_PPC64_TLS_RELOC(R) \
|
|
|
|
(((R) >= R_PPC64_TLS && (R) <= R_PPC64_DTPREL16_HIGHESTA) \
|
|
|
|
|| ((R) >= R_PPC64_TPREL16_HIGH && (R) <= R_PPC64_DTPREL16_HIGHA))
|
|
|
|
|
|
|
|
#define elf_machine_type_class(type) \
|
|
|
|
((((type) == R_PPC64_JMP_SLOT \
|
|
|
|
|| (type) == R_PPC64_ADDR24 \
|
|
|
|
|| IS_PPC64_TLS_RELOC (type)) * ELF_RTYPE_CLASS_PLT) \
|
|
|
|
| (((type) == R_PPC64_COPY) * ELF_RTYPE_CLASS_COPY))
|
|
|
|
#endif
|
2002-09-18 01:50:03 +02:00
|
|
|
|
|
|
|
/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries. */
|
|
|
|
#define ELF_MACHINE_JMP_SLOT R_PPC64_JMP_SLOT
|
|
|
|
|
|
|
|
/* The PowerPC never uses REL relocations. */
|
|
|
|
#define ELF_MACHINE_NO_REL 1
|
2014-06-26 11:47:40 +02:00
|
|
|
#define ELF_MACHINE_NO_RELA 0
|
2002-09-18 01:50:03 +02:00
|
|
|
|
2015-10-23 02:26:58 +02:00
|
|
|
/* We define an initialization function to initialize HWCAP/HWCAP2 and
|
|
|
|
platform data so it can be copied into the TCB later. This is called
|
|
|
|
very early in _dl_sysdep_start for dynamically linked binaries. */
|
|
|
|
#ifdef SHARED
|
|
|
|
# define DL_PLATFORM_INIT dl_platform_init ()
|
|
|
|
|
|
|
|
static inline void __attribute__ ((unused))
|
|
|
|
dl_platform_init (void)
|
|
|
|
{
|
|
|
|
__tcb_parse_hwcap_and_convert_at_platform ();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-09-18 01:50:03 +02:00
|
|
|
/* Stuff for the PLT. */
|
2013-12-04 13:51:11 +01:00
|
|
|
#if _CALL_ELF != 2
|
2002-09-18 01:50:03 +02:00
|
|
|
#define PLT_INITIAL_ENTRY_WORDS 3
|
2013-12-04 13:51:11 +01:00
|
|
|
#define PLT_ENTRY_WORDS 3
|
2002-09-18 01:50:03 +02:00
|
|
|
#define GLINK_INITIAL_ENTRY_WORDS 8
|
2013-12-04 13:51:11 +01:00
|
|
|
/* The first 32k entries of glink can set an index and branch using two
|
|
|
|
instructions; past that point, glink uses three instructions. */
|
|
|
|
#define GLINK_ENTRY_WORDS(I) (((I) < 0x8000)? 2 : 3)
|
|
|
|
#else
|
|
|
|
#define PLT_INITIAL_ENTRY_WORDS 2
|
|
|
|
#define PLT_ENTRY_WORDS 1
|
|
|
|
#define GLINK_INITIAL_ENTRY_WORDS 8
|
|
|
|
#define GLINK_ENTRY_WORDS(I) 1
|
|
|
|
#endif
|
2002-09-18 01:50:03 +02:00
|
|
|
|
|
|
|
#define PPC_DCBST(where) asm volatile ("dcbst 0,%0" : : "r"(where) : "memory")
|
2008-04-11 02:02:52 +02:00
|
|
|
#define PPC_DCBT(where) asm volatile ("dcbt 0,%0" : : "r"(where) : "memory")
|
|
|
|
#define PPC_DCBF(where) asm volatile ("dcbf 0,%0" : : "r"(where) : "memory")
|
2002-09-18 01:50:03 +02:00
|
|
|
#define PPC_SYNC asm volatile ("sync" : : : "memory")
|
|
|
|
#define PPC_ISYNC asm volatile ("sync; isync" : : : "memory")
|
|
|
|
#define PPC_ICBI(where) asm volatile ("icbi 0,%0" : : "r"(where) : "memory")
|
|
|
|
#define PPC_DIE asm volatile ("tweq 0,0")
|
|
|
|
/* Use this when you've modified some code, but it won't be in the
|
|
|
|
instruction fetch queue (or when it doesn't matter if it is). */
|
|
|
|
#define MODIFIED_CODE_NOQUEUE(where) \
|
|
|
|
do { PPC_DCBST(where); PPC_SYNC; PPC_ICBI(where); } while (0)
|
|
|
|
/* Use this when it might be in the instruction queue. */
|
|
|
|
#define MODIFIED_CODE(where) \
|
|
|
|
do { PPC_DCBST(where); PPC_SYNC; PPC_ICBI(where); PPC_ISYNC; } while (0)
|
|
|
|
|
|
|
|
/* Set up the loaded object described by MAP so its unrelocated PLT
|
|
|
|
entries will jump to the on-demand fixup code in dl-runtime.c. */
|
2004-08-06 20:32:16 +02:00
|
|
|
static inline int __attribute__ ((always_inline))
|
2002-09-18 01:50:03 +02:00
|
|
|
elf_machine_runtime_setup (struct link_map *map, int lazy, int profile)
|
|
|
|
{
|
|
|
|
if (map->l_info[DT_JMPREL])
|
|
|
|
{
|
|
|
|
Elf64_Word i;
|
|
|
|
Elf64_Word *glink = NULL;
|
|
|
|
Elf64_Xword *plt = (Elf64_Xword *) D_PTR (map, l_info[DT_PLTGOT]);
|
|
|
|
Elf64_Word num_plt_entries = (map->l_info[DT_PLTRELSZ]->d_un.d_val
|
|
|
|
/ sizeof (Elf64_Rela));
|
|
|
|
Elf64_Addr l_addr = map->l_addr;
|
|
|
|
Elf64_Dyn **info = map->l_info;
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
extern void _dl_runtime_resolve (void);
|
|
|
|
extern void _dl_profile_resolve (void);
|
|
|
|
|
|
|
|
/* Relocate the DT_PPC64_GLINK entry in the _DYNAMIC section.
|
|
|
|
elf_get_dynamic_info takes care of the standard entries but
|
2003-02-28 05:55:04 +01:00
|
|
|
doesn't know exactly what to do with processor specific
|
2013-01-07 18:20:53 +01:00
|
|
|
entries. */
|
2002-09-18 01:50:03 +02:00
|
|
|
if (info[DT_PPC64(GLINK)] != NULL)
|
|
|
|
info[DT_PPC64(GLINK)]->d_un.d_ptr += l_addr;
|
|
|
|
|
|
|
|
if (lazy)
|
|
|
|
{
|
|
|
|
Elf64_Word glink_offset;
|
|
|
|
Elf64_Word offset;
|
2013-12-04 13:51:11 +01:00
|
|
|
Elf64_Addr dlrr;
|
2002-09-18 01:50:03 +02:00
|
|
|
|
2013-12-04 13:51:11 +01:00
|
|
|
dlrr = (Elf64_Addr) (profile ? _dl_profile_resolve
|
|
|
|
: _dl_runtime_resolve);
|
2005-01-08 08:10:00 +01:00
|
|
|
if (profile && GLRO(dl_profile) != NULL
|
|
|
|
&& _dl_name_match_p (GLRO(dl_profile), map))
|
2002-09-18 01:50:03 +02:00
|
|
|
/* This is the object we are looking for. Say that we really
|
|
|
|
want profiling and the timers are started. */
|
|
|
|
GL(dl_profile_map) = map;
|
|
|
|
|
2013-12-04 13:51:11 +01:00
|
|
|
#if _CALL_ELF != 2
|
2002-09-18 01:50:03 +02:00
|
|
|
/* We need to stuff the address/TOC of _dl_runtime_resolve
|
|
|
|
into doublewords 0 and 1 of plt_reserve. Then we need to
|
|
|
|
stuff the map address into doubleword 2 of plt_reserve.
|
|
|
|
This allows the GLINK0 code to transfer control to the
|
|
|
|
correct trampoline which will transfer control to fixup
|
|
|
|
in dl-machine.c. */
|
2013-12-04 13:51:11 +01:00
|
|
|
{
|
|
|
|
/* The plt_reserve area is the 1st 3 doublewords of the PLT. */
|
|
|
|
Elf64_FuncDesc *plt_reserve = (Elf64_FuncDesc *) plt;
|
|
|
|
Elf64_FuncDesc *resolve_fd = (Elf64_FuncDesc *) dlrr;
|
|
|
|
plt_reserve->fd_func = resolve_fd->fd_func;
|
|
|
|
plt_reserve->fd_toc = resolve_fd->fd_toc;
|
|
|
|
plt_reserve->fd_aux = (Elf64_Addr) map;
|
2002-09-18 01:50:03 +02:00
|
|
|
#ifdef RTLD_BOOTSTRAP
|
2013-12-04 13:51:11 +01:00
|
|
|
/* When we're bootstrapping, the opd entry will not have
|
|
|
|
been relocated yet. */
|
|
|
|
plt_reserve->fd_func += l_addr;
|
|
|
|
plt_reserve->fd_toc += l_addr;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
/* When we don't have function descriptors, the first doubleword
|
|
|
|
of the PLT holds the address of _dl_runtime_resolve, and the
|
|
|
|
second doubleword holds the map address. */
|
|
|
|
plt[0] = dlrr;
|
|
|
|
plt[1] = (Elf64_Addr) map;
|
2002-09-18 01:50:03 +02:00
|
|
|
#endif
|
2003-02-28 05:55:04 +01:00
|
|
|
|
2002-09-18 01:50:03 +02:00
|
|
|
/* Set up the lazy PLT entries. */
|
|
|
|
glink = (Elf64_Word *) D_PTR (map, l_info[DT_PPC64(GLINK)]);
|
|
|
|
offset = PLT_INITIAL_ENTRY_WORDS;
|
|
|
|
glink_offset = GLINK_INITIAL_ENTRY_WORDS;
|
|
|
|
for (i = 0; i < num_plt_entries; i++)
|
|
|
|
{
|
|
|
|
|
|
|
|
plt[offset] = (Elf64_Xword) &glink[glink_offset];
|
2013-12-04 13:51:11 +01:00
|
|
|
offset += PLT_ENTRY_WORDS;
|
|
|
|
glink_offset += GLINK_ENTRY_WORDS (i);
|
2002-09-18 01:50:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Now, we've modified data. We need to write the changes from
|
|
|
|
the data cache to a second-level unified cache, then make
|
|
|
|
sure that stale data in the instruction cache is removed.
|
|
|
|
(In a multiprocessor system, the effect is more complex.)
|
|
|
|
Most of the PLT shouldn't be in the instruction cache, but
|
|
|
|
there may be a little overlap at the start and the end.
|
|
|
|
|
|
|
|
Assumes that dcbst and icbi apply to lines of 16 bytes or
|
|
|
|
more. Current known line sizes are 16, 32, and 128 bytes. */
|
|
|
|
|
|
|
|
for (p = (char *) plt; p < (char *) &plt[offset]; p += 16)
|
|
|
|
PPC_DCBST (p);
|
|
|
|
PPC_SYNC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return lazy;
|
|
|
|
}
|
|
|
|
|
PowerPC64 ELFv2 ABI 3/6: PLT local entry point optimization
This is a follow-on to the previous patch to support the ELFv2 ABI in the
dynamic loader, split off into its own patch since it is just an optional
optimization.
In the ELFv2 ABI, most functions define both a global and a local entry
point; the local entry requires r2 to be already set up by the caller
to point to the callee's TOC; while the global entry does not require
the caller to know about the callee's TOC, but it needs to set up r12
to the callee's entry point address.
Now, when setting up a PLT slot, the dynamic linker will usually need
to enter the target function's global entry point. However, if the
linker can prove that the target function is in the same DSO as the
PLT slot itself, and the whole DSO only uses a single TOC (which the
linker will let ld.so know via a DT_PPC64_OPT entry), then it is
possible to actually enter the local entry point address into the
PLT slot, for a slight improvement in performance.
Note that this uncovered a problem on the first call via _dl_runtime_resolve,
because that routine neglected to restore the caller's TOC before calling
the target function for the first time, since it assumed that function
would always reload its own TOC anyway ...
2013-12-04 13:52:40 +01:00
|
|
|
#if _CALL_ELF == 2
|
|
|
|
/* If the PLT entry whose reloc is 'reloc' resolves to a function in
|
|
|
|
the same object, return the target function's local entry point
|
|
|
|
offset if usable. */
|
|
|
|
static inline Elf64_Addr __attribute__ ((always_inline))
|
|
|
|
ppc64_local_entry_offset (struct link_map *map, lookup_t sym_map,
|
|
|
|
const Elf64_Rela *reloc)
|
|
|
|
{
|
|
|
|
const Elf64_Sym *symtab;
|
|
|
|
const Elf64_Sym *sym;
|
|
|
|
|
|
|
|
/* If the target function is in a different object, we cannot
|
|
|
|
use the local entry point. */
|
|
|
|
if (sym_map != map)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* If the linker inserted multiple TOCs, we cannot use the
|
|
|
|
local entry point. */
|
|
|
|
if (map->l_info[DT_PPC64(OPT)]
|
|
|
|
&& (map->l_info[DT_PPC64(OPT)]->d_un.d_val & PPC64_OPT_MULTI_TOC))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Otherwise, we can use the local entry point. Retrieve its offset
|
|
|
|
from the symbol's ELF st_other field. */
|
|
|
|
symtab = (const void *) D_PTR (map, l_info[DT_SYMTAB]);
|
|
|
|
sym = &symtab[ELFW(R_SYM) (reloc->r_info)];
|
|
|
|
|
|
|
|
/* If the target function is an ifunc then the local entry offset is
|
|
|
|
for the resolver, not the final destination. */
|
|
|
|
if (__builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return PPC64_LOCAL_ENTRY_OFFSET (sym->st_other);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-09-18 01:50:03 +02:00
|
|
|
/* Change the PLT entry whose reloc is 'reloc' to call the actual
|
|
|
|
routine. */
|
2004-08-06 20:32:16 +02:00
|
|
|
static inline Elf64_Addr __attribute__ ((always_inline))
|
2002-09-18 01:50:03 +02:00
|
|
|
elf_machine_fixup_plt (struct link_map *map, lookup_t sym_map,
|
|
|
|
const Elf64_Rela *reloc,
|
|
|
|
Elf64_Addr *reloc_addr, Elf64_Addr finaladdr)
|
|
|
|
{
|
2013-12-04 13:51:11 +01:00
|
|
|
#if _CALL_ELF != 2
|
2002-09-18 01:50:03 +02:00
|
|
|
Elf64_FuncDesc *plt = (Elf64_FuncDesc *) reloc_addr;
|
|
|
|
Elf64_FuncDesc *rel = (Elf64_FuncDesc *) finaladdr;
|
|
|
|
Elf64_Addr offset = 0;
|
2015-03-26 03:00:45 +01:00
|
|
|
Elf64_FuncDesc zero_fd = {0, 0, 0};
|
2002-09-18 01:50:03 +02:00
|
|
|
|
2008-04-11 02:02:52 +02:00
|
|
|
PPC_DCBT (&plt->fd_aux);
|
|
|
|
PPC_DCBT (&plt->fd_func);
|
|
|
|
|
2015-03-26 03:00:45 +01:00
|
|
|
/* If sym_map is NULL, it's a weak undefined sym; Set the plt to
|
|
|
|
zero. finaladdr should be zero already in this case, but guard
|
|
|
|
against invalid plt relocations with non-zero addends. */
|
2002-09-18 01:50:03 +02:00
|
|
|
if (sym_map == NULL)
|
2015-03-26 03:00:45 +01:00
|
|
|
finaladdr = 0;
|
|
|
|
|
|
|
|
/* Don't die here if finaladdr is zero, die if this plt entry is
|
|
|
|
actually called. Makes a difference when LD_BIND_NOW=1.
|
|
|
|
finaladdr may be zero for a weak undefined symbol, or when an
|
|
|
|
ifunc resolver returns zero. */
|
|
|
|
if (finaladdr == 0)
|
|
|
|
rel = &zero_fd;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PPC_DCBT (&rel->fd_aux);
|
|
|
|
PPC_DCBT (&rel->fd_func);
|
|
|
|
}
|
2002-09-18 01:50:03 +02:00
|
|
|
|
|
|
|
/* If the opd entry is not yet relocated (because it's from a shared
|
|
|
|
object that hasn't been processed yet), then manually reloc it. */
|
2015-03-26 03:00:45 +01:00
|
|
|
if (finaladdr != 0 && map != sym_map && !sym_map->l_relocated
|
2003-03-02 12:45:12 +01:00
|
|
|
#if !defined RTLD_BOOTSTRAP && defined SHARED
|
2002-09-18 01:50:03 +02:00
|
|
|
/* Bootstrap map doesn't have l_relocated set for it. */
|
|
|
|
&& sym_map != &GL(dl_rtld_map)
|
|
|
|
#endif
|
|
|
|
)
|
|
|
|
offset = sym_map->l_addr;
|
|
|
|
|
|
|
|
/* For PPC64, fixup_plt copies the function descriptor from opd
|
|
|
|
over the corresponding PLT entry.
|
|
|
|
Initially, PLT Entry[i] is set up for lazy linking, or is zero.
|
|
|
|
For lazy linking, the fd_toc and fd_aux entries are irrelevant,
|
|
|
|
so for thread safety we write them before changing fd_func. */
|
|
|
|
|
|
|
|
plt->fd_aux = rel->fd_aux + offset;
|
|
|
|
plt->fd_toc = rel->fd_toc + offset;
|
2008-04-11 02:02:52 +02:00
|
|
|
PPC_DCBF (&plt->fd_toc);
|
|
|
|
PPC_ISYNC;
|
2002-09-18 01:50:03 +02:00
|
|
|
|
|
|
|
plt->fd_func = rel->fd_func + offset;
|
|
|
|
PPC_DCBST (&plt->fd_func);
|
2008-04-11 02:02:52 +02:00
|
|
|
PPC_ISYNC;
|
2013-12-04 13:51:11 +01:00
|
|
|
#else
|
PowerPC64 ELFv2 ABI 3/6: PLT local entry point optimization
This is a follow-on to the previous patch to support the ELFv2 ABI in the
dynamic loader, split off into its own patch since it is just an optional
optimization.
In the ELFv2 ABI, most functions define both a global and a local entry
point; the local entry requires r2 to be already set up by the caller
to point to the callee's TOC; while the global entry does not require
the caller to know about the callee's TOC, but it needs to set up r12
to the callee's entry point address.
Now, when setting up a PLT slot, the dynamic linker will usually need
to enter the target function's global entry point. However, if the
linker can prove that the target function is in the same DSO as the
PLT slot itself, and the whole DSO only uses a single TOC (which the
linker will let ld.so know via a DT_PPC64_OPT entry), then it is
possible to actually enter the local entry point address into the
PLT slot, for a slight improvement in performance.
Note that this uncovered a problem on the first call via _dl_runtime_resolve,
because that routine neglected to restore the caller's TOC before calling
the target function for the first time, since it assumed that function
would always reload its own TOC anyway ...
2013-12-04 13:52:40 +01:00
|
|
|
finaladdr += ppc64_local_entry_offset (map, sym_map, reloc);
|
2013-12-04 13:51:11 +01:00
|
|
|
*reloc_addr = finaladdr;
|
|
|
|
#endif
|
2002-09-18 01:50:03 +02:00
|
|
|
|
|
|
|
return finaladdr;
|
|
|
|
}
|
|
|
|
|
2004-08-06 20:32:16 +02:00
|
|
|
static inline void __attribute__ ((always_inline))
|
PowerPC64 ELFv2 ABI 3/6: PLT local entry point optimization
This is a follow-on to the previous patch to support the ELFv2 ABI in the
dynamic loader, split off into its own patch since it is just an optional
optimization.
In the ELFv2 ABI, most functions define both a global and a local entry
point; the local entry requires r2 to be already set up by the caller
to point to the callee's TOC; while the global entry does not require
the caller to know about the callee's TOC, but it needs to set up r12
to the callee's entry point address.
Now, when setting up a PLT slot, the dynamic linker will usually need
to enter the target function's global entry point. However, if the
linker can prove that the target function is in the same DSO as the
PLT slot itself, and the whole DSO only uses a single TOC (which the
linker will let ld.so know via a DT_PPC64_OPT entry), then it is
possible to actually enter the local entry point address into the
PLT slot, for a slight improvement in performance.
Note that this uncovered a problem on the first call via _dl_runtime_resolve,
because that routine neglected to restore the caller's TOC before calling
the target function for the first time, since it assumed that function
would always reload its own TOC anyway ...
2013-12-04 13:52:40 +01:00
|
|
|
elf_machine_plt_conflict (struct link_map *map, lookup_t sym_map,
|
|
|
|
const Elf64_Rela *reloc,
|
|
|
|
Elf64_Addr *reloc_addr, Elf64_Addr finaladdr)
|
2003-06-01 03:32:04 +02:00
|
|
|
{
|
2013-12-04 13:51:11 +01:00
|
|
|
#if _CALL_ELF != 2
|
2003-06-01 03:32:04 +02:00
|
|
|
Elf64_FuncDesc *plt = (Elf64_FuncDesc *) reloc_addr;
|
|
|
|
Elf64_FuncDesc *rel = (Elf64_FuncDesc *) finaladdr;
|
2015-03-26 03:00:45 +01:00
|
|
|
Elf64_FuncDesc zero_fd = {0, 0, 0};
|
|
|
|
|
|
|
|
if (sym_map == NULL)
|
|
|
|
finaladdr = 0;
|
|
|
|
|
|
|
|
if (finaladdr == 0)
|
|
|
|
rel = &zero_fd;
|
2003-06-01 03:32:04 +02:00
|
|
|
|
|
|
|
plt->fd_func = rel->fd_func;
|
|
|
|
plt->fd_aux = rel->fd_aux;
|
|
|
|
plt->fd_toc = rel->fd_toc;
|
|
|
|
PPC_DCBST (&plt->fd_func);
|
|
|
|
PPC_DCBST (&plt->fd_aux);
|
|
|
|
PPC_DCBST (&plt->fd_toc);
|
|
|
|
PPC_SYNC;
|
2013-12-04 13:51:11 +01:00
|
|
|
#else
|
PowerPC64 ELFv2 ABI 3/6: PLT local entry point optimization
This is a follow-on to the previous patch to support the ELFv2 ABI in the
dynamic loader, split off into its own patch since it is just an optional
optimization.
In the ELFv2 ABI, most functions define both a global and a local entry
point; the local entry requires r2 to be already set up by the caller
to point to the callee's TOC; while the global entry does not require
the caller to know about the callee's TOC, but it needs to set up r12
to the callee's entry point address.
Now, when setting up a PLT slot, the dynamic linker will usually need
to enter the target function's global entry point. However, if the
linker can prove that the target function is in the same DSO as the
PLT slot itself, and the whole DSO only uses a single TOC (which the
linker will let ld.so know via a DT_PPC64_OPT entry), then it is
possible to actually enter the local entry point address into the
PLT slot, for a slight improvement in performance.
Note that this uncovered a problem on the first call via _dl_runtime_resolve,
because that routine neglected to restore the caller's TOC before calling
the target function for the first time, since it assumed that function
would always reload its own TOC anyway ...
2013-12-04 13:52:40 +01:00
|
|
|
finaladdr += ppc64_local_entry_offset (map, sym_map, reloc);
|
2013-12-04 13:51:11 +01:00
|
|
|
*reloc_addr = finaladdr;
|
|
|
|
#endif
|
2003-06-01 03:32:04 +02:00
|
|
|
}
|
|
|
|
|
2002-09-18 01:50:03 +02:00
|
|
|
/* Return the final value of a plt relocation. */
|
|
|
|
static inline Elf64_Addr
|
|
|
|
elf_machine_plt_value (struct link_map *map, const Elf64_Rela *reloc,
|
|
|
|
Elf64_Addr value)
|
|
|
|
{
|
|
|
|
return value + reloc->r_addend;
|
|
|
|
}
|
2003-02-28 05:55:04 +01:00
|
|
|
|
2005-01-07 12:36:07 +01:00
|
|
|
|
|
|
|
/* Names of the architecture-specific auditing callback functions. */
|
2013-12-04 13:59:37 +01:00
|
|
|
#if _CALL_ELF != 2
|
2005-01-07 12:36:07 +01:00
|
|
|
#define ARCH_LA_PLTENTER ppc64_gnu_pltenter
|
|
|
|
#define ARCH_LA_PLTEXIT ppc64_gnu_pltexit
|
2013-12-04 13:59:37 +01:00
|
|
|
#else
|
|
|
|
#define ARCH_LA_PLTENTER ppc64v2_gnu_pltenter
|
|
|
|
#define ARCH_LA_PLTEXIT ppc64v2_gnu_pltexit
|
|
|
|
#endif
|
2005-01-07 12:36:07 +01:00
|
|
|
|
2002-09-18 01:50:03 +02:00
|
|
|
#endif /* dl_machine_h */
|
|
|
|
|
|
|
|
#ifdef RESOLVE_MAP
|
|
|
|
|
|
|
|
#define PPC_LO(v) ((v) & 0xffff)
|
|
|
|
#define PPC_HI(v) (((v) >> 16) & 0xffff)
|
|
|
|
#define PPC_HA(v) PPC_HI ((v) + 0x8000)
|
|
|
|
#define PPC_HIGHER(v) (((v) >> 32) & 0xffff)
|
|
|
|
#define PPC_HIGHERA(v) PPC_HIGHER ((v) + 0x8000)
|
|
|
|
#define PPC_HIGHEST(v) (((v) >> 48) & 0xffff)
|
|
|
|
#define PPC_HIGHESTA(v) PPC_HIGHEST ((v) + 0x8000)
|
2003-03-02 12:45:12 +01:00
|
|
|
#define BIT_INSERT(var, val, mask) \
|
2003-03-05 04:27:24 +01:00
|
|
|
((var) = ((var) & ~(Elf64_Addr) (mask)) | ((val) & (mask)))
|
2002-09-18 01:50:03 +02:00
|
|
|
|
|
|
|
#define dont_expect(X) __builtin_expect ((X), 0)
|
|
|
|
|
|
|
|
extern void _dl_reloc_overflow (struct link_map *map,
|
2011-09-10 22:50:28 +02:00
|
|
|
const char *name,
|
|
|
|
Elf64_Addr *const reloc_addr,
|
|
|
|
const Elf64_Sym *refsym)
|
|
|
|
attribute_hidden;
|
2002-09-18 01:50:03 +02:00
|
|
|
|
2005-02-14 23:44:25 +01:00
|
|
|
auto inline void __attribute__ ((always_inline))
|
2002-09-18 01:50:03 +02:00
|
|
|
elf_machine_rela_relative (Elf64_Addr l_addr, const Elf64_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)
|
2002-09-18 01:50:03 +02:00
|
|
|
{
|
* 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
|
|
|
Elf64_Addr *const reloc_addr = reloc_addr_arg;
|
2002-09-18 01:50:03 +02:00
|
|
|
*reloc_addr = l_addr + reloc->r_addend;
|
2003-02-26 01:34:09 +01:00
|
|
|
}
|
2002-09-18 01:50:03 +02:00
|
|
|
|
2003-03-12 08:45:07 +01:00
|
|
|
/* This computes the value used by TPREL* relocs. */
|
2005-02-14 23:44:25 +01:00
|
|
|
auto inline Elf64_Addr __attribute__ ((always_inline, const))
|
2003-03-12 08:45:07 +01:00
|
|
|
elf_machine_tprel (struct link_map *map,
|
|
|
|
struct link_map *sym_map,
|
|
|
|
const Elf64_Sym *sym,
|
|
|
|
const Elf64_Rela *reloc)
|
|
|
|
{
|
2011-09-10 22:50:28 +02:00
|
|
|
#ifndef RTLD_BOOTSTRAP
|
2003-03-12 08:45:07 +01:00
|
|
|
if (sym_map)
|
|
|
|
{
|
|
|
|
CHECK_STATIC_TLS (map, sym_map);
|
2011-09-10 22:50:28 +02:00
|
|
|
#endif
|
2003-03-12 08:45:07 +01:00
|
|
|
return TLS_TPREL_VALUE (sym_map, sym, reloc);
|
2011-09-10 22:50:28 +02:00
|
|
|
#ifndef RTLD_BOOTSTRAP
|
2003-03-12 08:45:07 +01:00
|
|
|
}
|
2011-09-10 22:50:28 +02:00
|
|
|
#endif
|
2003-03-12 08:45:07 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-30 08:39:38 +01:00
|
|
|
/* Call function at address VALUE (an OPD entry) to resolve ifunc relocs. */
|
|
|
|
auto inline Elf64_Addr __attribute__ ((always_inline))
|
|
|
|
resolve_ifunc (Elf64_Addr value,
|
|
|
|
const struct link_map *map, const struct link_map *sym_map)
|
|
|
|
{
|
2013-12-04 13:51:11 +01:00
|
|
|
#if _CALL_ELF != 2
|
2009-11-06 18:27:41 +01:00
|
|
|
#ifndef RESOLVE_CONFLICT_FIND_MAP
|
2009-10-30 08:39:38 +01:00
|
|
|
/* The function we are calling may not yet have its opd entry relocated. */
|
|
|
|
Elf64_FuncDesc opd;
|
|
|
|
if (map != sym_map
|
2009-11-06 18:27:41 +01:00
|
|
|
# if !defined RTLD_BOOTSTRAP && defined SHARED
|
2009-10-30 08:39:38 +01:00
|
|
|
/* Bootstrap map doesn't have l_relocated set for it. */
|
|
|
|
&& sym_map != &GL(dl_rtld_map)
|
2009-11-06 18:27:41 +01:00
|
|
|
# endif
|
2009-10-30 08:39:38 +01:00
|
|
|
&& !sym_map->l_relocated)
|
|
|
|
{
|
|
|
|
Elf64_FuncDesc *func = (Elf64_FuncDesc *) value;
|
|
|
|
opd.fd_func = func->fd_func + sym_map->l_addr;
|
|
|
|
opd.fd_toc = func->fd_toc + sym_map->l_addr;
|
|
|
|
opd.fd_aux = func->fd_aux;
|
2015-01-23 17:16:49 +01:00
|
|
|
/* GCC 4.9+ eliminates the branch as dead code, force the odp set
|
|
|
|
dependency. */
|
|
|
|
asm ("" : "=r" (value) : "0" (&opd), "X" (opd));
|
2009-10-30 08:39:38 +01:00
|
|
|
}
|
2013-12-04 13:51:11 +01:00
|
|
|
#endif
|
2009-11-06 18:27:41 +01:00
|
|
|
#endif
|
2012-05-25 19:30:42 +02:00
|
|
|
return ((Elf64_Addr (*) (unsigned long int)) value) (GLRO(dl_hwcap));
|
2009-10-30 08:39:38 +01:00
|
|
|
}
|
|
|
|
|
2002-09-18 01:50:03 +02:00
|
|
|
/* Perform the relocation specified by RELOC and SYM (which is fully
|
|
|
|
resolved). MAP is the object containing the reloc. */
|
2005-02-14 23:44:25 +01:00
|
|
|
auto inline void __attribute__ ((always_inline))
|
2002-09-18 01:50:03 +02:00
|
|
|
elf_machine_rela (struct link_map *map,
|
|
|
|
const Elf64_Rela *reloc,
|
|
|
|
const Elf64_Sym *sym,
|
|
|
|
const struct r_found_version *version,
|
2011-10-04 16:10:16 +02:00
|
|
|
void *const reloc_addr_arg,
|
|
|
|
int skip_ifunc)
|
2002-09-18 01:50:03 +02:00
|
|
|
{
|
* 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
|
|
|
Elf64_Addr *const reloc_addr = reloc_addr_arg;
|
2003-03-02 12:45:12 +01:00
|
|
|
const int r_type = ELF64_R_TYPE (reloc->r_info);
|
2002-09-18 01:50:03 +02:00
|
|
|
const Elf64_Sym *const refsym = sym;
|
2013-10-03 06:21:52 +02:00
|
|
|
union unaligned
|
|
|
|
{
|
2013-10-04 05:18:51 +02:00
|
|
|
uint16_t u2;
|
|
|
|
uint32_t u4;
|
|
|
|
uint64_t u8;
|
|
|
|
} __attribute__ ((__packed__));
|
2002-09-18 01:50:03 +02:00
|
|
|
|
|
|
|
if (r_type == R_PPC64_RELATIVE)
|
|
|
|
{
|
2003-02-26 01:34:09 +01:00
|
|
|
*reloc_addr = map->l_addr + reloc->r_addend;
|
2002-09-18 01:50:03 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-10 14:45:42 +01:00
|
|
|
if (__glibc_unlikely (r_type == R_PPC64_NONE))
|
2002-09-18 01:50:03 +02:00
|
|
|
return;
|
|
|
|
|
2009-10-30 08:39:38 +01:00
|
|
|
/* We need SYM_MAP even in the absence of TLS, for elf_machine_fixup_plt
|
|
|
|
and STT_GNU_IFUNC. */
|
2003-03-02 12:45:12 +01:00
|
|
|
struct link_map *sym_map = RESOLVE_MAP (&sym, version, r_type);
|
2003-03-12 08:45:07 +01:00
|
|
|
Elf64_Addr value = ((sym_map == NULL ? 0 : sym_map->l_addr + sym->st_value)
|
2003-03-05 04:27:24 +01:00
|
|
|
+ reloc->r_addend);
|
2002-09-18 01:50:03 +02:00
|
|
|
|
2009-10-30 08:39:38 +01:00
|
|
|
if (sym != NULL
|
|
|
|
&& __builtin_expect (ELFW(ST_TYPE) (sym->st_info) == STT_GNU_IFUNC, 0)
|
2011-10-04 16:10:16 +02:00
|
|
|
&& __builtin_expect (sym->st_shndx != SHN_UNDEF, 1)
|
|
|
|
&& __builtin_expect (!skip_ifunc, 1))
|
2009-10-30 08:39:38 +01:00
|
|
|
value = resolve_ifunc (value, map, sym_map);
|
|
|
|
|
2003-03-02 12:45:12 +01:00
|
|
|
/* For relocs that don't edit code, return.
|
|
|
|
For relocs that might edit instructions, break from the switch. */
|
2002-09-18 01:50:03 +02:00
|
|
|
switch (r_type)
|
|
|
|
{
|
|
|
|
case R_PPC64_ADDR64:
|
|
|
|
case R_PPC64_GLOB_DAT:
|
2003-02-28 05:55:04 +01:00
|
|
|
*reloc_addr = value;
|
2002-09-18 01:50:03 +02:00
|
|
|
return;
|
2003-02-28 05:55:04 +01:00
|
|
|
|
2009-10-30 08:39:38 +01:00
|
|
|
case R_PPC64_IRELATIVE:
|
2014-02-10 14:45:42 +01:00
|
|
|
if (__glibc_likely (!skip_ifunc))
|
2011-10-04 16:10:16 +02:00
|
|
|
value = resolve_ifunc (value, map, sym_map);
|
2009-10-30 08:39:38 +01:00
|
|
|
*reloc_addr = value;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case R_PPC64_JMP_IREL:
|
2014-02-10 14:45:42 +01:00
|
|
|
if (__glibc_likely (!skip_ifunc))
|
2011-10-04 16:10:16 +02:00
|
|
|
value = resolve_ifunc (value, map, sym_map);
|
2009-10-30 08:39:38 +01:00
|
|
|
/* Fall thru */
|
2003-03-02 12:45:12 +01:00
|
|
|
case R_PPC64_JMP_SLOT:
|
|
|
|
#ifdef RESOLVE_CONFLICT_FIND_MAP
|
PowerPC64 ELFv2 ABI 3/6: PLT local entry point optimization
This is a follow-on to the previous patch to support the ELFv2 ABI in the
dynamic loader, split off into its own patch since it is just an optional
optimization.
In the ELFv2 ABI, most functions define both a global and a local entry
point; the local entry requires r2 to be already set up by the caller
to point to the callee's TOC; while the global entry does not require
the caller to know about the callee's TOC, but it needs to set up r12
to the callee's entry point address.
Now, when setting up a PLT slot, the dynamic linker will usually need
to enter the target function's global entry point. However, if the
linker can prove that the target function is in the same DSO as the
PLT slot itself, and the whole DSO only uses a single TOC (which the
linker will let ld.so know via a DT_PPC64_OPT entry), then it is
possible to actually enter the local entry point address into the
PLT slot, for a slight improvement in performance.
Note that this uncovered a problem on the first call via _dl_runtime_resolve,
because that routine neglected to restore the caller's TOC before calling
the target function for the first time, since it assumed that function
would always reload its own TOC anyway ...
2013-12-04 13:52:40 +01:00
|
|
|
elf_machine_plt_conflict (map, sym_map, reloc, reloc_addr, value);
|
2003-06-01 03:32:04 +02:00
|
|
|
#else
|
2003-03-02 12:45:12 +01:00
|
|
|
elf_machine_fixup_plt (map, sym_map, reloc, reloc_addr, value);
|
2003-06-01 03:32:04 +02:00
|
|
|
#endif
|
2003-03-02 12:45:12 +01:00
|
|
|
return;
|
2003-02-26 01:34:09 +01:00
|
|
|
|
|
|
|
case R_PPC64_DTPMOD64:
|
2015-03-25 06:23:47 +01:00
|
|
|
if (map->l_info[DT_PPC64(OPT)]
|
|
|
|
&& (map->l_info[DT_PPC64(OPT)]->d_un.d_val & PPC64_OPT_TLS))
|
|
|
|
{
|
|
|
|
#ifdef RTLD_BOOTSTRAP
|
|
|
|
reloc_addr[0] = 0;
|
|
|
|
reloc_addr[1] = (sym_map->l_tls_offset - TLS_TP_OFFSET
|
|
|
|
+ TLS_DTV_OFFSET);
|
|
|
|
return;
|
|
|
|
#else
|
|
|
|
if (sym_map != NULL)
|
|
|
|
{
|
|
|
|
# ifndef SHARED
|
|
|
|
CHECK_STATIC_TLS (map, sym_map);
|
|
|
|
# else
|
|
|
|
if (TRY_STATIC_TLS (map, sym_map))
|
|
|
|
# endif
|
|
|
|
{
|
|
|
|
reloc_addr[0] = 0;
|
|
|
|
/* Set up for local dynamic. */
|
|
|
|
reloc_addr[1] = (sym_map->l_tls_offset - TLS_TP_OFFSET
|
|
|
|
+ TLS_DTV_OFFSET);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2011-09-10 22:50:28 +02:00
|
|
|
#ifdef RTLD_BOOTSTRAP
|
2003-03-12 08:45:07 +01:00
|
|
|
/* During startup the dynamic linker is always index 1. */
|
2003-02-26 01:34:09 +01:00
|
|
|
*reloc_addr = 1;
|
2011-09-10 22:50:28 +02:00
|
|
|
#else
|
2003-03-12 08:45:07 +01:00
|
|
|
/* Get the information from the link map returned by the
|
|
|
|
resolve function. */
|
2003-02-26 01:34:09 +01:00
|
|
|
if (sym_map != NULL)
|
2011-09-10 22:50:28 +02:00
|
|
|
*reloc_addr = sym_map->l_tls_modid;
|
|
|
|
#endif
|
2003-02-26 01:34:09 +01:00
|
|
|
return;
|
2003-02-28 05:55:04 +01:00
|
|
|
|
2003-03-03 01:20:51 +01:00
|
|
|
case R_PPC64_DTPREL64:
|
2015-03-25 06:23:47 +01:00
|
|
|
if (map->l_info[DT_PPC64(OPT)]
|
|
|
|
&& (map->l_info[DT_PPC64(OPT)]->d_un.d_val & PPC64_OPT_TLS))
|
|
|
|
{
|
|
|
|
#ifdef RTLD_BOOTSTRAP
|
|
|
|
*reloc_addr = TLS_TPREL_VALUE (sym_map, sym, reloc);
|
|
|
|
return;
|
|
|
|
#else
|
|
|
|
if (sym_map != NULL)
|
|
|
|
{
|
|
|
|
/* This reloc is always preceded by R_PPC64_DTPMOD64. */
|
|
|
|
# ifndef SHARED
|
|
|
|
assert (HAVE_STATIC_TLS (map, sym_map));
|
|
|
|
# else
|
|
|
|
if (HAVE_STATIC_TLS (map, sym_map))
|
|
|
|
# endif
|
|
|
|
{
|
|
|
|
*reloc_addr = TLS_TPREL_VALUE (sym_map, sym, reloc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2003-03-02 12:45:12 +01:00
|
|
|
/* During relocation all TLS symbols are defined and used.
|
2011-09-10 22:50:28 +02:00
|
|
|
Therefore the offset is already correct. */
|
|
|
|
#ifndef RTLD_BOOTSTRAP
|
2003-06-18 08:49:48 +02:00
|
|
|
if (sym_map != NULL)
|
|
|
|
*reloc_addr = TLS_DTPREL_VALUE (sym, reloc);
|
2011-09-10 22:50:28 +02:00
|
|
|
#endif
|
2003-03-12 08:45:07 +01:00
|
|
|
return;
|
|
|
|
|
2003-03-03 01:20:51 +01:00
|
|
|
case R_PPC64_TPREL64:
|
2003-03-12 08:45:07 +01:00
|
|
|
*reloc_addr = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
|
return;
|
|
|
|
|
|
|
|
case R_PPC64_TPREL16_LO_DS:
|
|
|
|
value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
|
if (dont_expect ((value & 3) != 0))
|
2011-09-10 22:50:28 +02:00
|
|
|
_dl_reloc_overflow (map, "R_PPC64_TPREL16_LO_DS", reloc_addr, refsym);
|
2010-07-18 14:51:45 +02:00
|
|
|
BIT_INSERT (*(Elf64_Half *) reloc_addr, value, 0xfffc);
|
2003-03-12 08:45:07 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_TPREL16_DS:
|
|
|
|
value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
|
if (dont_expect ((value + 0x8000) >= 0x10000 || (value & 3) != 0))
|
2011-09-10 22:50:28 +02:00
|
|
|
_dl_reloc_overflow (map, "R_PPC64_TPREL16_DS", reloc_addr, refsym);
|
2010-07-18 14:51:45 +02:00
|
|
|
BIT_INSERT (*(Elf64_Half *) reloc_addr, value, 0xfffc);
|
2003-03-12 08:45:07 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_TPREL16:
|
|
|
|
value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
|
if (dont_expect ((value + 0x8000) >= 0x10000))
|
2011-09-10 22:50:28 +02:00
|
|
|
_dl_reloc_overflow (map, "R_PPC64_TPREL16", reloc_addr, refsym);
|
2003-03-12 08:45:07 +01:00
|
|
|
*(Elf64_Half *) reloc_addr = PPC_LO (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_TPREL16_LO:
|
|
|
|
value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
|
*(Elf64_Half *) reloc_addr = PPC_LO (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_TPREL16_HI:
|
2013-12-04 13:44:06 +01:00
|
|
|
value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
|
if (dont_expect (value + 0x80000000 >= 0x100000000LL))
|
|
|
|
_dl_reloc_overflow (map, "R_PPC64_TPREL16_HI", reloc_addr, refsym);
|
|
|
|
*(Elf64_Half *) reloc_addr = PPC_HI (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_TPREL16_HIGH:
|
2003-03-12 08:45:07 +01:00
|
|
|
value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
|
*(Elf64_Half *) reloc_addr = PPC_HI (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_TPREL16_HA:
|
2013-12-04 13:44:06 +01:00
|
|
|
value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
|
if (dont_expect (value + 0x80008000 >= 0x100000000LL))
|
|
|
|
_dl_reloc_overflow (map, "R_PPC64_TPREL16_HA", reloc_addr, refsym);
|
|
|
|
*(Elf64_Half *) reloc_addr = PPC_HA (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_TPREL16_HIGHA:
|
2003-03-12 08:45:07 +01:00
|
|
|
value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
|
*(Elf64_Half *) reloc_addr = PPC_HA (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_TPREL16_HIGHER:
|
|
|
|
value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
|
*(Elf64_Half *) reloc_addr = PPC_HIGHER (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_TPREL16_HIGHEST:
|
|
|
|
value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
|
*(Elf64_Half *) reloc_addr = PPC_HIGHEST (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_TPREL16_HIGHERA:
|
|
|
|
value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
|
*(Elf64_Half *) reloc_addr = PPC_HIGHERA (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_TPREL16_HIGHESTA:
|
|
|
|
value = elf_machine_tprel (map, sym_map, sym, reloc);
|
|
|
|
*(Elf64_Half *) reloc_addr = PPC_HIGHESTA (value);
|
2003-03-02 12:45:12 +01:00
|
|
|
break;
|
2002-09-18 01:50:03 +02:00
|
|
|
|
|
|
|
#ifndef RTLD_BOOTSTRAP /* None of the following appear in ld.so */
|
|
|
|
case R_PPC64_ADDR16_LO_DS:
|
|
|
|
if (dont_expect ((value & 3) != 0))
|
2011-09-10 22:50:28 +02:00
|
|
|
_dl_reloc_overflow (map, "R_PPC64_ADDR16_LO_DS", reloc_addr, refsym);
|
2003-03-02 12:45:12 +01:00
|
|
|
BIT_INSERT (*(Elf64_Half *) reloc_addr, value, 0xfffc);
|
2003-02-26 01:34:09 +01:00
|
|
|
break;
|
|
|
|
|
2002-09-18 01:50:03 +02:00
|
|
|
case R_PPC64_ADDR16_LO:
|
|
|
|
*(Elf64_Half *) reloc_addr = PPC_LO (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_ADDR16_HI:
|
2013-12-04 13:44:06 +01:00
|
|
|
if (dont_expect (value + 0x80000000 >= 0x100000000LL))
|
|
|
|
_dl_reloc_overflow (map, "R_PPC64_ADDR16_HI", reloc_addr, refsym);
|
|
|
|
case R_PPC64_ADDR16_HIGH:
|
2002-09-18 01:50:03 +02:00
|
|
|
*(Elf64_Half *) reloc_addr = PPC_HI (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_ADDR16_HA:
|
2013-12-04 13:44:06 +01:00
|
|
|
if (dont_expect (value + 0x80008000 >= 0x100000000LL))
|
|
|
|
_dl_reloc_overflow (map, "R_PPC64_ADDR16_HA", reloc_addr, refsym);
|
|
|
|
case R_PPC64_ADDR16_HIGHA:
|
2002-09-18 01:50:03 +02:00
|
|
|
*(Elf64_Half *) reloc_addr = PPC_HA (value);
|
|
|
|
break;
|
|
|
|
|
2003-03-12 08:45:07 +01:00
|
|
|
case R_PPC64_ADDR30:
|
2002-09-18 01:50:03 +02:00
|
|
|
{
|
2011-09-10 22:50:28 +02:00
|
|
|
Elf64_Addr delta = value - (Elf64_Xword) reloc_addr;
|
2013-12-04 13:44:06 +01:00
|
|
|
if (dont_expect ((delta + 0x80000000) >= 0x100000000LL
|
2003-03-12 08:45:07 +01:00
|
|
|
|| (delta & 3) != 0))
|
2011-09-10 22:50:28 +02:00
|
|
|
_dl_reloc_overflow (map, "R_PPC64_ADDR30", reloc_addr, refsym);
|
|
|
|
BIT_INSERT (*(Elf64_Word *) reloc_addr, delta, 0xfffffffc);
|
2002-09-18 01:50:03 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_COPY:
|
|
|
|
if (dont_expect (sym == NULL))
|
2003-03-12 08:45:07 +01:00
|
|
|
/* This can happen in trace mode when an object could not be found. */
|
2011-09-10 22:50:28 +02:00
|
|
|
return;
|
2002-09-18 01:50:03 +02:00
|
|
|
if (dont_expect (sym->st_size > refsym->st_size
|
2004-03-05 11:29:47 +01:00
|
|
|
|| (GLRO(dl_verbose)
|
|
|
|
&& sym->st_size < refsym->st_size)))
|
2003-03-12 08:45:07 +01:00
|
|
|
{
|
2011-09-10 22:50:28 +02:00
|
|
|
const char *strtab;
|
2002-09-18 01:50:03 +02:00
|
|
|
|
2011-09-10 22:50:28 +02:00
|
|
|
strtab = (const void *) D_PTR (map, l_info[DT_STRTAB]);
|
|
|
|
_dl_error_printf ("%s: Symbol `%s' has different size" \
|
|
|
|
" in shared object," \
|
|
|
|
" consider re-linking\n",
|
2013-05-29 18:00:20 +02:00
|
|
|
RTLD_PROGNAME, strtab + refsym->st_name);
|
2003-03-12 08:45:07 +01:00
|
|
|
}
|
* 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
|
|
|
memcpy (reloc_addr_arg, (char *) value,
|
|
|
|
MIN (sym->st_size, refsym->st_size));
|
2002-09-18 01:50:03 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
case R_PPC64_UADDR64:
|
2013-10-03 06:21:52 +02:00
|
|
|
((union unaligned *) reloc_addr)->u8 = value;
|
2002-09-18 01:50:03 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
case R_PPC64_UADDR32:
|
2013-10-03 06:21:52 +02:00
|
|
|
((union unaligned *) reloc_addr)->u4 = value;
|
2002-09-18 01:50:03 +02:00
|
|
|
return;
|
|
|
|
|
2003-03-12 08:45:07 +01:00
|
|
|
case R_PPC64_ADDR32:
|
2013-12-04 13:44:06 +01:00
|
|
|
if (dont_expect ((value + 0x80000000) >= 0x100000000LL))
|
2011-09-10 22:50:28 +02:00
|
|
|
_dl_reloc_overflow (map, "R_PPC64_ADDR32", reloc_addr, refsym);
|
2003-03-12 08:45:07 +01:00
|
|
|
*(Elf64_Word *) reloc_addr = value;
|
|
|
|
return;
|
|
|
|
|
2002-09-18 01:50:03 +02:00
|
|
|
case R_PPC64_ADDR24:
|
|
|
|
if (dont_expect ((value + 0x2000000) >= 0x4000000 || (value & 3) != 0))
|
2011-09-10 22:50:28 +02:00
|
|
|
_dl_reloc_overflow (map, "R_PPC64_ADDR24", reloc_addr, refsym);
|
2003-03-02 12:45:12 +01:00
|
|
|
BIT_INSERT (*(Elf64_Word *) reloc_addr, value, 0x3fffffc);
|
2002-09-18 01:50:03 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_ADDR16:
|
|
|
|
if (dont_expect ((value + 0x8000) >= 0x10000))
|
2011-09-10 22:50:28 +02:00
|
|
|
_dl_reloc_overflow (map, "R_PPC64_ADDR16", reloc_addr, refsym);
|
2002-09-18 01:50:03 +02:00
|
|
|
*(Elf64_Half *) reloc_addr = value;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_UADDR16:
|
|
|
|
if (dont_expect ((value + 0x8000) >= 0x10000))
|
2011-09-10 22:50:28 +02:00
|
|
|
_dl_reloc_overflow (map, "R_PPC64_UADDR16", reloc_addr, refsym);
|
2013-10-03 06:21:52 +02:00
|
|
|
((union unaligned *) reloc_addr)->u2 = value;
|
|
|
|
return;
|
2002-09-18 01:50:03 +02:00
|
|
|
|
|
|
|
case R_PPC64_ADDR16_DS:
|
|
|
|
if (dont_expect ((value + 0x8000) >= 0x10000 || (value & 3) != 0))
|
2011-09-10 22:50:28 +02:00
|
|
|
_dl_reloc_overflow (map, "R_PPC64_ADDR16_DS", reloc_addr, refsym);
|
2003-03-02 12:45:12 +01:00
|
|
|
BIT_INSERT (*(Elf64_Half *) reloc_addr, value, 0xfffc);
|
2003-02-26 01:34:09 +01:00
|
|
|
break;
|
|
|
|
|
2002-09-18 01:50:03 +02:00
|
|
|
case R_PPC64_ADDR16_HIGHER:
|
|
|
|
*(Elf64_Half *) reloc_addr = PPC_HIGHER (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_ADDR16_HIGHEST:
|
|
|
|
*(Elf64_Half *) reloc_addr = PPC_HIGHEST (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_ADDR16_HIGHERA:
|
|
|
|
*(Elf64_Half *) reloc_addr = PPC_HIGHERA (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_ADDR16_HIGHESTA:
|
|
|
|
*(Elf64_Half *) reloc_addr = PPC_HIGHESTA (value);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_ADDR14:
|
|
|
|
case R_PPC64_ADDR14_BRTAKEN:
|
|
|
|
case R_PPC64_ADDR14_BRNTAKEN:
|
|
|
|
{
|
2011-09-10 22:50:28 +02:00
|
|
|
if (dont_expect ((value + 0x8000) >= 0x10000 || (value & 3) != 0))
|
2003-05-16 06:22:23 +02:00
|
|
|
_dl_reloc_overflow (map, "R_PPC64_ADDR14", reloc_addr, refsym);
|
2011-09-10 22:50:28 +02:00
|
|
|
Elf64_Word insn = *(Elf64_Word *) reloc_addr;
|
|
|
|
BIT_INSERT (insn, value, 0xfffc);
|
|
|
|
if (r_type != R_PPC64_ADDR14)
|
2003-03-02 12:45:12 +01:00
|
|
|
{
|
|
|
|
insn &= ~(1 << 21);
|
|
|
|
if (r_type == R_PPC64_ADDR14_BRTAKEN)
|
|
|
|
insn |= 1 << 21;
|
|
|
|
if ((insn & (0x14 << 21)) == (0x04 << 21))
|
|
|
|
insn |= 0x02 << 21;
|
|
|
|
else if ((insn & (0x14 << 21)) == (0x10 << 21))
|
|
|
|
insn |= 0x08 << 21;
|
|
|
|
}
|
2011-09-10 22:50:28 +02:00
|
|
|
*(Elf64_Word *) reloc_addr = insn;
|
2002-09-18 01:50:03 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case R_PPC64_REL32:
|
2003-03-12 08:45:07 +01:00
|
|
|
*(Elf64_Word *) reloc_addr = value - (Elf64_Addr) reloc_addr;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case R_PPC64_REL64:
|
|
|
|
*reloc_addr = value - (Elf64_Addr) reloc_addr;
|
2002-09-18 01:50:03 +02:00
|
|
|
return;
|
|
|
|
#endif /* !RTLD_BOOTSTRAP */
|
|
|
|
|
|
|
|
default:
|
|
|
|
_dl_reloc_bad_type (map, r_type, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MODIFIED_CODE_NOQUEUE (reloc_addr);
|
|
|
|
}
|
|
|
|
|
2005-02-14 23:44:25 +01:00
|
|
|
auto inline void __attribute__ ((always_inline))
|
2003-01-30 21:26:38 +01:00
|
|
|
elf_machine_lazy_rel (struct link_map *map,
|
2011-10-04 16:10:16 +02:00
|
|
|
Elf64_Addr l_addr, const Elf64_Rela *reloc,
|
|
|
|
int skip_ifunc)
|
2003-01-30 21:26:38 +01:00
|
|
|
{
|
|
|
|
/* elf_machine_runtime_setup handles this. */
|
|
|
|
}
|
|
|
|
|
2005-02-14 23:44:25 +01:00
|
|
|
|
2002-09-18 01:50:03 +02:00
|
|
|
#endif /* RESOLVE */
|