]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/mips/ldsodefs.h
Update copyright dates with scripts/update-copyrights
[thirdparty/glibc.git] / sysdeps / mips / ldsodefs.h
CommitLineData
19723bdd 1/* Run-time dynamic linker data structures for loaded ELF shared objects.
2b778ceb 2 Copyright (C) 2000-2021 Free Software Foundation, Inc.
19723bdd
DJ
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
ab84e3ff 16 License along with the GNU C Library. If not, see
5a82c748 17 <https://www.gnu.org/licenses/>. */
19723bdd 18
2caa93e2 19#ifndef _MIPS_LDSODEFS_H
19723bdd
DJ
20#define _MIPS_LDSODEFS_H 1
21
22#include <elf.h>
23
24struct La_mips_32_regs;
25struct La_mips_32_retval;
26struct La_mips_64_regs;
27struct La_mips_64_retval;
28
23c1c256
MS
29#define ELF_MACHINE_GNU_HASH_ADDRIDX (DT_MIPS_XHASH - DT_LOPROC + DT_NUM)
30
31/* Calculate the index of a symbol in MIPS xhash. */
32#define ELF_MACHINE_HASH_SYMIDX(map, hasharr) \
33 ((map)->l_mach.mips_xlat_zero[(hasharr) - (map)->l_gnu_chain_zero])
34
35/* Setup MIPS xhash. */
36#define ELF_MACHINE_XHASH_SETUP(hash32, symbias, map) \
37 do \
38 { \
39 (hash32) += (map)->l_info[DT_MIPS (SYMTABNO)]->d_un.d_val - (symbias); \
40 (map)->l_mach.mips_xlat_zero = (hash32) - (symbias); \
41 } \
42 while (0)
43
19723bdd
DJ
44#define ARCH_PLTENTER_MEMBERS \
45 Elf32_Addr (*mips_o32_gnu_pltenter) (Elf32_Sym *, unsigned int, \
46 uintptr_t *, uintptr_t *, \
30f69637 47 struct La_mips_32_regs *, \
19723bdd
DJ
48 unsigned int *, const char *name, \
49 long int *framesizep); \
50 Elf32_Addr (*mips_n32_gnu_pltenter) (Elf32_Sym *, unsigned int, \
51 uintptr_t *, uintptr_t *, \
30f69637 52 struct La_mips_64_regs *, \
19723bdd
DJ
53 unsigned int *, const char *name, \
54 long int *framesizep); \
55 Elf64_Addr (*mips_n64_gnu_pltenter) (Elf64_Sym *, unsigned int, \
56 uintptr_t *, uintptr_t *, \
30f69637 57 struct La_mips_64_regs *, \
19723bdd
DJ
58 unsigned int *, const char *name, \
59 long int *framesizep);
60
61#define ARCH_PLTEXIT_MEMBERS \
62 unsigned int (*mips_o32_gnu_pltexit) (Elf32_Sym *, unsigned int, \
63 uintptr_t *, uintptr_t *, \
64 const struct La_mips_32_regs *, \
65 struct La_mips_32_retval *, \
66 const char *); \
67 unsigned int (*mips_n32_gnu_pltexit) (Elf32_Sym *, unsigned int, \
68 uintptr_t *, uintptr_t *, \
69 const struct La_mips_64_regs *, \
70 struct La_mips_64_retval *, \
71 const char *); \
72 unsigned int (*mips_n64_gnu_pltexit) (Elf64_Sym *, unsigned int, \
73 uintptr_t *, uintptr_t *, \
74 const struct La_mips_64_regs *, \
75 struct La_mips_64_retval *, \
76 const char *);
77
2caa93e2
DJ
78/* The MIPS ABI specifies that the dynamic section has to be read-only. */
79
80#define DL_RO_DYN_SECTION 1
81
19723bdd
DJ
82#include_next <ldsodefs.h>
83
2caa93e2
DJ
84/* The 64-bit MIPS ELF ABI uses an unusual reloc format. Each
85 relocation entry specifies up to three actual relocations, all at
86 the same address. The first relocation which required a symbol
87 uses the symbol in the r_sym field. The second relocation which
88 requires a symbol uses the symbol in the r_ssym field. If all
89 three relocations require a symbol, the third one uses a zero
90 value.
91
92 We define these structures in internal headers because we're not
93 sure we want to make them part of the ABI yet. Eventually, some of
94 this may move into elf/elf.h. */
95
96/* An entry in a 64 bit SHT_REL section. */
97
98typedef struct
99{
100 Elf32_Word r_sym; /* Symbol index */
101 unsigned char r_ssym; /* Special symbol for 2nd relocation */
102 unsigned char r_type3; /* 3rd relocation type */
103 unsigned char r_type2; /* 2nd relocation type */
104 unsigned char r_type1; /* 1st relocation type */
105} _Elf64_Mips_R_Info;
106
107typedef union
108{
109 Elf64_Xword r_info_number;
110 _Elf64_Mips_R_Info r_info_fields;
111} _Elf64_Mips_R_Info_union;
112
113typedef struct
114{
115 Elf64_Addr r_offset; /* Address */
116 _Elf64_Mips_R_Info_union r_info; /* Relocation type and symbol index */
117} Elf64_Mips_Rel;
118
119typedef struct
120{
121 Elf64_Addr r_offset; /* Address */
122 _Elf64_Mips_R_Info_union r_info; /* Relocation type and symbol index */
123 Elf64_Sxword r_addend; /* Addend */
124} Elf64_Mips_Rela;
125
126#define ELF64_MIPS_R_SYM(i) \
127 ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym)
128#define ELF64_MIPS_R_TYPE(i) \
129 (((_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1 \
130 | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
131 ).r_info_fields.r_type2 << 8) \
132 | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
133 ).r_info_fields.r_type3 << 16) \
134 | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
135 ).r_info_fields.r_ssym << 24))
136#define ELF64_MIPS_R_INFO(sym, type) \
137 (__extension__ (_Elf64_Mips_R_Info_union) \
138 (__extension__ (_Elf64_Mips_R_Info) \
139 { (sym), ELF64_MIPS_R_SSYM (type), \
140 ELF64_MIPS_R_TYPE3 (type), \
141 ELF64_MIPS_R_TYPE2 (type), \
142 ELF64_MIPS_R_TYPE1 (type) \
143 }).r_info_number)
144/* These macros decompose the value returned by ELF64_MIPS_R_TYPE, and
145 compose it back into a value that it can be used as an argument to
146 ELF64_MIPS_R_INFO. */
147#define ELF64_MIPS_R_SSYM(i) (((i) >> 24) & 0xff)
148#define ELF64_MIPS_R_TYPE3(i) (((i) >> 16) & 0xff)
149#define ELF64_MIPS_R_TYPE2(i) (((i) >> 8) & 0xff)
150#define ELF64_MIPS_R_TYPE1(i) ((i) & 0xff)
151#define ELF64_MIPS_R_TYPEENC(type1, type2, type3, ssym) \
152 ((type1) \
153 | ((Elf32_Word)(type2) << 8) \
154 | ((Elf32_Word)(type3) << 16) \
155 | ((Elf32_Word)(ssym) << 24))
156
157#undef ELF64_R_SYM
158#define ELF64_R_SYM(i) ELF64_MIPS_R_SYM (i)
159#undef ELF64_R_TYPE
160#define ELF64_R_TYPE(i) ELF64_MIPS_R_TYPE (i)
161#undef ELF64_R_INFO
162#define ELF64_R_INFO(sym, type) ELF64_MIPS_R_INFO ((sym), (type))
163
19723bdd 164#endif