/* Machine-dependent ELF dynamic relocation inline functions. PA-RISC version.
Copyright (C) 1995-2023 Free Software Foundation, Inc.
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
<https://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>
#include <dl-static-tls.h>
#include <dl-machine-rel.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)
/* The gp slot in the function descriptor contains the relocation offset
before resolution. To distinguish between a resolved gp value and an
unresolved relocation offset we set an unused bit in the relocation
offset. This would allow us to do a synchronzied two word update
using this bit (interlocked update), but instead of waiting for the
update we simply recompute the gp value given that we know the ip. */
#define PA_GP_RELOC 1
/* 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(map, dynamic_info) \
__hppa_init_bootstrap_fdesc_table (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"