| xf.li | bdd93d5 | 2023-05-12 07:10:14 -0700 | [diff] [blame] | 1 | /* Run-time dynamic linker data structures for loaded ELF shared objects. | 
|  | 2 | Copyright (C) 2000-2016 Free Software Foundation, Inc. | 
|  | 3 | This file is part of the GNU C Library. | 
|  | 4 |  | 
|  | 5 | The GNU C Library is free software; you can redistribute it and/or | 
|  | 6 | modify it under the terms of the GNU Lesser General Public | 
|  | 7 | License as published by the Free Software Foundation; either | 
|  | 8 | version 2.1 of the License, or (at your option) any later version. | 
|  | 9 |  | 
|  | 10 | The GNU C Library is distributed in the hope that it will be useful, | 
|  | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|  | 13 | Lesser General Public License for more details. | 
|  | 14 |  | 
|  | 15 | You should have received a copy of the GNU Lesser General Public | 
|  | 16 | License along with the GNU C Library.  If not, see | 
|  | 17 | <http://www.gnu.org/licenses/>.  */ | 
|  | 18 |  | 
|  | 19 | #ifndef _MIPS_LDSODEFS_H | 
|  | 20 | #define _MIPS_LDSODEFS_H 1 | 
|  | 21 |  | 
|  | 22 | #include <elf.h> | 
|  | 23 |  | 
|  | 24 | struct La_mips_32_regs; | 
|  | 25 | struct La_mips_32_retval; | 
|  | 26 | struct La_mips_64_regs; | 
|  | 27 | struct La_mips_64_retval; | 
|  | 28 |  | 
|  | 29 | #define ARCH_PLTENTER_MEMBERS						    \ | 
|  | 30 | Elf32_Addr (*mips_o32_gnu_pltenter) (Elf32_Sym *, unsigned int,	    \ | 
|  | 31 | uintptr_t *, uintptr_t *,	    \ | 
|  | 32 | struct La_mips_32_regs *,	    \ | 
|  | 33 | unsigned int *, const char *name,  \ | 
|  | 34 | long int *framesizep);		    \ | 
|  | 35 | Elf32_Addr (*mips_n32_gnu_pltenter) (Elf32_Sym *, unsigned int,	    \ | 
|  | 36 | uintptr_t *, uintptr_t *,	    \ | 
|  | 37 | struct La_mips_64_regs *,	    \ | 
|  | 38 | unsigned int *, const char *name,  \ | 
|  | 39 | long int *framesizep);		    \ | 
|  | 40 | Elf64_Addr (*mips_n64_gnu_pltenter) (Elf64_Sym *, unsigned int,	    \ | 
|  | 41 | uintptr_t *, uintptr_t *,	    \ | 
|  | 42 | struct La_mips_64_regs *,	    \ | 
|  | 43 | unsigned int *, const char *name,  \ | 
|  | 44 | long int *framesizep); | 
|  | 45 |  | 
|  | 46 | #define ARCH_PLTEXIT_MEMBERS						    \ | 
|  | 47 | unsigned int (*mips_o32_gnu_pltexit) (Elf32_Sym *, unsigned int,	    \ | 
|  | 48 | uintptr_t *, uintptr_t *,	    \ | 
|  | 49 | const struct La_mips_32_regs *,   \ | 
|  | 50 | struct La_mips_32_retval *,	    \ | 
|  | 51 | const char *);		    \ | 
|  | 52 | unsigned int (*mips_n32_gnu_pltexit) (Elf32_Sym *, unsigned int,	    \ | 
|  | 53 | uintptr_t *, uintptr_t *,	    \ | 
|  | 54 | const struct La_mips_64_regs *,   \ | 
|  | 55 | struct La_mips_64_retval *,	    \ | 
|  | 56 | const char *);		    \ | 
|  | 57 | unsigned int (*mips_n64_gnu_pltexit) (Elf64_Sym *, unsigned int,	    \ | 
|  | 58 | uintptr_t *, uintptr_t *,	    \ | 
|  | 59 | const struct La_mips_64_regs *,   \ | 
|  | 60 | struct La_mips_64_retval *,	    \ | 
|  | 61 | const char *); | 
|  | 62 |  | 
|  | 63 | /* The MIPS ABI specifies that the dynamic section has to be read-only.  */ | 
|  | 64 |  | 
|  | 65 | #define DL_RO_DYN_SECTION 1 | 
|  | 66 |  | 
|  | 67 | #include_next <ldsodefs.h> | 
|  | 68 |  | 
|  | 69 | /* The 64-bit MIPS ELF ABI uses an unusual reloc format.  Each | 
|  | 70 | relocation entry specifies up to three actual relocations, all at | 
|  | 71 | the same address.  The first relocation which required a symbol | 
|  | 72 | uses the symbol in the r_sym field.  The second relocation which | 
|  | 73 | requires a symbol uses the symbol in the r_ssym field.  If all | 
|  | 74 | three relocations require a symbol, the third one uses a zero | 
|  | 75 | value. | 
|  | 76 |  | 
|  | 77 | We define these structures in internal headers because we're not | 
|  | 78 | sure we want to make them part of the ABI yet.  Eventually, some of | 
|  | 79 | this may move into elf/elf.h.  */ | 
|  | 80 |  | 
|  | 81 | /* An entry in a 64 bit SHT_REL section.  */ | 
|  | 82 |  | 
|  | 83 | typedef struct | 
|  | 84 | { | 
|  | 85 | Elf32_Word    r_sym;		/* Symbol index */ | 
|  | 86 | unsigned char r_ssym;		/* Special symbol for 2nd relocation */ | 
|  | 87 | unsigned char r_type3;	/* 3rd relocation type */ | 
|  | 88 | unsigned char r_type2;	/* 2nd relocation type */ | 
|  | 89 | unsigned char r_type1;	/* 1st relocation type */ | 
|  | 90 | } _Elf64_Mips_R_Info; | 
|  | 91 |  | 
|  | 92 | typedef union | 
|  | 93 | { | 
|  | 94 | Elf64_Xword	r_info_number; | 
|  | 95 | _Elf64_Mips_R_Info r_info_fields; | 
|  | 96 | } _Elf64_Mips_R_Info_union; | 
|  | 97 |  | 
|  | 98 | typedef struct | 
|  | 99 | { | 
|  | 100 | Elf64_Addr	r_offset;		/* Address */ | 
|  | 101 | _Elf64_Mips_R_Info_union r_info;	/* Relocation type and symbol index */ | 
|  | 102 | } Elf64_Mips_Rel; | 
|  | 103 |  | 
|  | 104 | typedef struct | 
|  | 105 | { | 
|  | 106 | Elf64_Addr	r_offset;		/* Address */ | 
|  | 107 | _Elf64_Mips_R_Info_union r_info;	/* Relocation type and symbol index */ | 
|  | 108 | Elf64_Sxword	r_addend;		/* Addend */ | 
|  | 109 | } Elf64_Mips_Rela; | 
|  | 110 |  | 
|  | 111 | #define ELF64_MIPS_R_SYM(i) \ | 
|  | 112 | ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym) | 
|  | 113 | #define ELF64_MIPS_R_TYPE(i) \ | 
|  | 114 | (((_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1 \ | 
|  | 115 | | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \ | 
|  | 116 | ).r_info_fields.r_type2 << 8) \ | 
|  | 117 | | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \ | 
|  | 118 | ).r_info_fields.r_type3 << 16) \ | 
|  | 119 | | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \ | 
|  | 120 | ).r_info_fields.r_ssym << 24)) | 
|  | 121 | #define ELF64_MIPS_R_INFO(sym, type) \ | 
|  | 122 | (__extension__ (_Elf64_Mips_R_Info_union) \ | 
|  | 123 | (__extension__ (_Elf64_Mips_R_Info) \ | 
|  | 124 | { (sym), ELF64_MIPS_R_SSYM (type), \ | 
|  | 125 | ELF64_MIPS_R_TYPE3 (type), \ | 
|  | 126 | ELF64_MIPS_R_TYPE2 (type), \ | 
|  | 127 | ELF64_MIPS_R_TYPE1 (type) \ | 
|  | 128 | }).r_info_number) | 
|  | 129 | /* These macros decompose the value returned by ELF64_MIPS_R_TYPE, and | 
|  | 130 | compose it back into a value that it can be used as an argument to | 
|  | 131 | ELF64_MIPS_R_INFO.  */ | 
|  | 132 | #define ELF64_MIPS_R_SSYM(i) (((i) >> 24) & 0xff) | 
|  | 133 | #define ELF64_MIPS_R_TYPE3(i) (((i) >> 16) & 0xff) | 
|  | 134 | #define ELF64_MIPS_R_TYPE2(i) (((i) >> 8) & 0xff) | 
|  | 135 | #define ELF64_MIPS_R_TYPE1(i) ((i) & 0xff) | 
|  | 136 | #define ELF64_MIPS_R_TYPEENC(type1, type2, type3, ssym) \ | 
|  | 137 | ((type1) \ | 
|  | 138 | | ((Elf32_Word)(type2) << 8) \ | 
|  | 139 | | ((Elf32_Word)(type3) << 16) \ | 
|  | 140 | | ((Elf32_Word)(ssym) << 24)) | 
|  | 141 |  | 
|  | 142 | #undef ELF64_R_SYM | 
|  | 143 | #define ELF64_R_SYM(i) ELF64_MIPS_R_SYM (i) | 
|  | 144 | #undef ELF64_R_TYPE | 
|  | 145 | #define ELF64_R_TYPE(i) ELF64_MIPS_R_TYPE (i) | 
|  | 146 | #undef ELF64_R_INFO | 
|  | 147 | #define ELF64_R_INFO(sym, type) ELF64_MIPS_R_INFO ((sym), (type)) | 
|  | 148 |  | 
|  | 149 | #endif |