hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame sysdeps/mips/ldsodefs.h

Packit 6c4009
/* Run-time dynamic linker data structures for loaded ELF shared objects.
Packit 6c4009
   Copyright (C) 2000-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library.  If not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef _MIPS_LDSODEFS_H
Packit 6c4009
#define _MIPS_LDSODEFS_H 1
Packit 6c4009
Packit 6c4009
#include <elf.h>
Packit 6c4009
Packit 6c4009
struct La_mips_32_regs;
Packit 6c4009
struct La_mips_32_retval;
Packit 6c4009
struct La_mips_64_regs;
Packit 6c4009
struct La_mips_64_retval;
Packit 6c4009
Packit 6c4009
#define ARCH_PLTENTER_MEMBERS						    \
Packit 6c4009
    Elf32_Addr (*mips_o32_gnu_pltenter) (Elf32_Sym *, unsigned int,	    \
Packit 6c4009
					 uintptr_t *, uintptr_t *,	    \
Packit 6c4009
					 struct La_mips_32_regs *,	    \
Packit 6c4009
					 unsigned int *, const char *name,  \
Packit 6c4009
					 long int *framesizep);		    \
Packit 6c4009
    Elf32_Addr (*mips_n32_gnu_pltenter) (Elf32_Sym *, unsigned int,	    \
Packit 6c4009
					 uintptr_t *, uintptr_t *,	    \
Packit 6c4009
					 struct La_mips_64_regs *,	    \
Packit 6c4009
					 unsigned int *, const char *name,  \
Packit 6c4009
					 long int *framesizep);		    \
Packit 6c4009
    Elf64_Addr (*mips_n64_gnu_pltenter) (Elf64_Sym *, unsigned int,	    \
Packit 6c4009
					 uintptr_t *, uintptr_t *,	    \
Packit 6c4009
					 struct La_mips_64_regs *,	    \
Packit 6c4009
					 unsigned int *, const char *name,  \
Packit 6c4009
					 long int *framesizep);
Packit 6c4009
Packit 6c4009
#define ARCH_PLTEXIT_MEMBERS						    \
Packit 6c4009
    unsigned int (*mips_o32_gnu_pltexit) (Elf32_Sym *, unsigned int,	    \
Packit 6c4009
					  uintptr_t *, uintptr_t *,	    \
Packit 6c4009
					  const struct La_mips_32_regs *,   \
Packit 6c4009
					  struct La_mips_32_retval *,	    \
Packit 6c4009
					  const char *);		    \
Packit 6c4009
    unsigned int (*mips_n32_gnu_pltexit) (Elf32_Sym *, unsigned int,	    \
Packit 6c4009
					  uintptr_t *, uintptr_t *,	    \
Packit 6c4009
					  const struct La_mips_64_regs *,   \
Packit 6c4009
					  struct La_mips_64_retval *,	    \
Packit 6c4009
					  const char *);		    \
Packit 6c4009
    unsigned int (*mips_n64_gnu_pltexit) (Elf64_Sym *, unsigned int,	    \
Packit 6c4009
					  uintptr_t *, uintptr_t *,	    \
Packit 6c4009
					  const struct La_mips_64_regs *,   \
Packit 6c4009
					  struct La_mips_64_retval *,	    \
Packit 6c4009
					  const char *);
Packit 6c4009
Packit 6c4009
/* The MIPS ABI specifies that the dynamic section has to be read-only.  */
Packit 6c4009
Packit 6c4009
#define DL_RO_DYN_SECTION 1
Packit 6c4009
Packit 6c4009
#include_next <ldsodefs.h>
Packit 6c4009
Packit 6c4009
/* The 64-bit MIPS ELF ABI uses an unusual reloc format.  Each
Packit 6c4009
   relocation entry specifies up to three actual relocations, all at
Packit 6c4009
   the same address.  The first relocation which required a symbol
Packit 6c4009
   uses the symbol in the r_sym field.  The second relocation which
Packit 6c4009
   requires a symbol uses the symbol in the r_ssym field.  If all
Packit 6c4009
   three relocations require a symbol, the third one uses a zero
Packit 6c4009
   value.
Packit 6c4009
Packit 6c4009
   We define these structures in internal headers because we're not
Packit 6c4009
   sure we want to make them part of the ABI yet.  Eventually, some of
Packit 6c4009
   this may move into elf/elf.h.  */
Packit 6c4009
Packit 6c4009
/* An entry in a 64 bit SHT_REL section.  */
Packit 6c4009
Packit 6c4009
typedef struct
Packit 6c4009
{
Packit 6c4009
  Elf32_Word    r_sym;		/* Symbol index */
Packit 6c4009
  unsigned char r_ssym;		/* Special symbol for 2nd relocation */
Packit 6c4009
  unsigned char r_type3;	/* 3rd relocation type */
Packit 6c4009
  unsigned char r_type2;	/* 2nd relocation type */
Packit 6c4009
  unsigned char r_type1;	/* 1st relocation type */
Packit 6c4009
} _Elf64_Mips_R_Info;
Packit 6c4009
Packit 6c4009
typedef union
Packit 6c4009
{
Packit 6c4009
  Elf64_Xword	r_info_number;
Packit 6c4009
  _Elf64_Mips_R_Info r_info_fields;
Packit 6c4009
} _Elf64_Mips_R_Info_union;
Packit 6c4009
Packit 6c4009
typedef struct
Packit 6c4009
{
Packit 6c4009
  Elf64_Addr	r_offset;		/* Address */
Packit 6c4009
  _Elf64_Mips_R_Info_union r_info;	/* Relocation type and symbol index */
Packit 6c4009
} Elf64_Mips_Rel;
Packit 6c4009
Packit 6c4009
typedef struct
Packit 6c4009
{
Packit 6c4009
  Elf64_Addr	r_offset;		/* Address */
Packit 6c4009
  _Elf64_Mips_R_Info_union r_info;	/* Relocation type and symbol index */
Packit 6c4009
  Elf64_Sxword	r_addend;		/* Addend */
Packit 6c4009
} Elf64_Mips_Rela;
Packit 6c4009
Packit 6c4009
#define ELF64_MIPS_R_SYM(i) \
Packit 6c4009
  ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym)
Packit 6c4009
#define ELF64_MIPS_R_TYPE(i) \
Packit 6c4009
  (((_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1 \
Packit 6c4009
   | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
Packit 6c4009
		   ).r_info_fields.r_type2 << 8) \
Packit 6c4009
   | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
Packit 6c4009
		   ).r_info_fields.r_type3 << 16) \
Packit 6c4009
   | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
Packit 6c4009
		   ).r_info_fields.r_ssym << 24))
Packit 6c4009
#define ELF64_MIPS_R_INFO(sym, type) \
Packit 6c4009
  (__extension__ (_Elf64_Mips_R_Info_union) \
Packit 6c4009
   (__extension__ (_Elf64_Mips_R_Info) \
Packit 6c4009
   { (sym), ELF64_MIPS_R_SSYM (type), \
Packit 6c4009
       ELF64_MIPS_R_TYPE3 (type), \
Packit 6c4009
       ELF64_MIPS_R_TYPE2 (type), \
Packit 6c4009
       ELF64_MIPS_R_TYPE1 (type) \
Packit 6c4009
   }).r_info_number)
Packit 6c4009
/* These macros decompose the value returned by ELF64_MIPS_R_TYPE, and
Packit 6c4009
   compose it back into a value that it can be used as an argument to
Packit 6c4009
   ELF64_MIPS_R_INFO.  */
Packit 6c4009
#define ELF64_MIPS_R_SSYM(i) (((i) >> 24) & 0xff)
Packit 6c4009
#define ELF64_MIPS_R_TYPE3(i) (((i) >> 16) & 0xff)
Packit 6c4009
#define ELF64_MIPS_R_TYPE2(i) (((i) >> 8) & 0xff)
Packit 6c4009
#define ELF64_MIPS_R_TYPE1(i) ((i) & 0xff)
Packit 6c4009
#define ELF64_MIPS_R_TYPEENC(type1, type2, type3, ssym) \
Packit 6c4009
  ((type1) \
Packit 6c4009
   | ((Elf32_Word)(type2) << 8) \
Packit 6c4009
   | ((Elf32_Word)(type3) << 16) \
Packit 6c4009
   | ((Elf32_Word)(ssym) << 24))
Packit 6c4009
Packit 6c4009
#undef ELF64_R_SYM
Packit 6c4009
#define ELF64_R_SYM(i) ELF64_MIPS_R_SYM (i)
Packit 6c4009
#undef ELF64_R_TYPE
Packit 6c4009
#define ELF64_R_TYPE(i) ELF64_MIPS_R_TYPE (i)
Packit 6c4009
#undef ELF64_R_INFO
Packit 6c4009
#define ELF64_R_INFO(sym, type) ELF64_MIPS_R_INFO ((sym), (type))
Packit 6c4009
Packit 6c4009
#endif