/* Machine-dependent ELF dynamic relocation inline functions. MIPS version.
Copyright (C) 1996-2017 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Kazumoto Kojima <kkojima@info.kanagawa-u.ac.jp>.
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/>. */
/* FIXME: Profiling of shared libraries is not implemented yet. */
#ifndef dl_machine_h
#define dl_machine_h
#define ELF_MACHINE_NAME "MIPS"
#include <entry.h>
#ifndef ENTRY_POINT
#error ENTRY_POINT needs to be defined for MIPS.
#endif
#include <sgidefs.h>
#include <sysdep.h>
#include <sys/asm.h>
#include <dl-tls.h>
/* The offset of gp from GOT might be system-dependent. It's set by
ld. The same value is also */
#define OFFSET_GP_GOT 0x7ff0
#ifndef _RTLD_PROLOGUE
# define _RTLD_PROLOGUE(entry) \
".globl\t" __STRING(entry) "\n\t" \
".ent\t" __STRING(entry) "\n\t" \
".type\t" __STRING(entry) ", @function\n" \
__STRING(entry) ":\n\t"
#endif
#ifndef _RTLD_EPILOGUE
# define _RTLD_EPILOGUE(entry) \
".end\t" __STRING(entry) "\n\t" \
".size\t" __STRING(entry) ", . - " __STRING(entry) "\n\t"
#endif
/* A reloc type used for ld.so cmdline arg lookups to reject PLT entries.
This only makes sense on MIPS when using PLTs, so choose the
PLT relocation (not encountered when not using PLTs). */
#define ELF_MACHINE_JMP_SLOT R_MIPS_JUMP_SLOT
#define elf_machine_type_class(type) \
((((type) == ELF_MACHINE_JMP_SLOT) * ELF_RTYPE_CLASS_PLT) \
| (((type) == R_MIPS_COPY) * ELF_RTYPE_CLASS_COPY))
#define ELF_MACHINE_PLT_REL 1
#define ELF_MACHINE_NO_REL 0
#define ELF_MACHINE_NO_RELA 0
/* Translate a processor specific dynamic tag to the index
in l_info array. */
#define DT_MIPS(x) (DT_MIPS_##x - DT_LOPROC + DT_NUM)
/* If there is a DT_MIPS_RLD_MAP_REL or DT_MIPS_RLD_MAP entry in the dynamic
section, fill in the debug map pointer with the run-time address of the
r_debug structure. */
#define ELF_MACHINE_DEBUG_SETUP(l,r) \
do { if ((l)->l_info[DT_MIPS (RLD_MAP_REL)]) \
{ \
char *ptr = (char *)(l)->l_info[DT_MIPS (RLD_MAP_REL)]; \
ptr += (l)->l_info[DT_MIPS (RLD_MAP_REL)]->d_un.d_val; \
*(ElfW(Addr) *)ptr = (ElfW(Addr)) (r); \
} \
else if ((l)->l_info[DT_MIPS (RLD_MAP)]) \
*(ElfW(Addr) *)((l)->l_info[DT_MIPS (RLD_MAP)]->d_un.d_ptr) = \
(ElfW(Addr)) (r); \
} while (0)
#if ((defined __mips_nan2008 && !defined HAVE_MIPS_NAN2008) \
|| (!defined __mips_nan2008 && defined HAVE_MIPS_NAN2008))
# error "Configuration inconsistency: __mips_nan2008 != HAVE_MIPS_NAN2008, overridden CFLAGS?"
#endif
#ifdef __mips_nan2008
# define ELF_MACHINE_NAN2008 EF_MIPS_NAN2008
#else
# define EL