/* Machine-dependent ELF dynamic relocation inline functions. PA-RISC version.
Copyright (C) 1995-2019 Free Software Foundation, Inc.
Contributed by David Huggins-Daines <dhd@debian.org>
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 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
License along with the GNU C Library. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef dl_machine_h
#define dl_machine_h 1
#define ELF_MACHINE_NAME "hppa"
#include <sys/param.h>
#include <assert.h>
#include <string.h>
#include <link.h>
#include <errno.h>
#include <dl-fptr.h>
#include <abort-instr.h>
#include <tls.h>
/* These two definitions must match the definition of the stub in
bfd/elf32-hppa.c (see plt_stub[]).
a. Define the size of the *entire* stub we place at the end of the PLT
table (right up against the GOT).
b. Define the number of bytes back from the GOT to the entry point of
the PLT stub. You see the PLT stub must be entered in the middle
so it can depwi to find it's own address (long jump stub)
c. Define the size of a single PLT entry so we can jump over the
last entry to get the stub address */
#define SIZEOF_PLT_STUB (7*4)
#define GOT_FROM_PLT_STUB (4*4)
#define PLT_ENTRY_SIZE (2*4)
/* Initialize the function descriptor table before relocations */
static inline void
__hppa_init_bootstrap_fdesc_table (struct link_map *map)
{
ElfW(Addr) *boot_table;
/* Careful: this will be called before got has been relocated... */
ELF_MACHINE_LOAD_ADDRESS(boot_table,_dl_boot_fptr_table);
map->l_mach.fptr_table_len = ELF_MACHINE_BOOT_FPTR_TABLE_LEN;
map->l_mach.fptr_table = boot_table;
}
#define ELF_MACHINE_BEFORE_RTLD_RELOC(dynamic_info) \
__hppa_init_bootstrap_fdesc_table (BOOTSTRAP_MAP); \
_dl_fptr_init();
/* Return nonzero iff ELF header is compatible with the running host. */
static inline int
elf_machine_matches_host (const Elf32_Ehdr *ehdr)
{
return ehdr->e_machine == EM_PARISC;
}
/* Return the link-time address of _DYNAMIC. */
static inline Elf32_Addr
elf_machine_dynamic (void) __attribute__ ((const));
static inline Elf32_Addr
elf_machine_dynamic (void)
{
Elf32_Addr dynamic;
asm ("bl 1f,%0\n"
" addil L'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 1),%0\n"
"1: ldw R'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 5)(%%r1),%0\n"
: "=r" (dynamic) : : "r1");
return dynamic;
}
/* Return the run-time load address of the shared object. */
static inline Elf32_Addr
elf_machine_load_address (void) __attribute__ ((const));
static inline Elf32_Addr
elf_machine_load_address (void)
{
Elf32_Addr dynamic;
asm (
" bl 1f,%0\n"
" addil L'_DYNAMIC - ($PIC_pcrel$0 - 1),%0\n"
"1: ldo R'_DYNAMIC - ($PIC_pcrel$0 - 5)(%%r1),%0\n"
: "=r" (dynamic) : : "r1");
return dynamic - elf_machine_dynamic ();
}
/* Fixup a PLT entry to bounce directly to the function at VALUE. */
static inline struct fdesc __attribute__ ((always_inline))
elf_machine_fixup_plt (struct link_map *map, lookup_t