.
[glibc-ports.git] / sysdeps / mips / elf / ldsodefs.h
blob3868b50ff69f129bb5fe04dc7958c78851cbedd9
1 /* Run-time dynamic linker data structures for loaded ELF shared objects.
2 Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #ifndef _MIPS_LDSODEFS_H
21 #define _MIPS_LDSODEFS_H
23 /* The MIPS ABI specifies that the dynamic section has to be read-only. */
25 #define DL_RO_DYN_SECTION 1
27 #include_next <ldsodefs.h>
29 /* The 64-bit MIPS ELF ABI uses an unusual reloc format. Each
30 relocation entry specifies up to three actual relocations, all at
31 the same address. The first relocation which required a symbol
32 uses the symbol in the r_sym field. The second relocation which
33 requires a symbol uses the symbol in the r_ssym field. If all
34 three relocations require a symbol, the third one uses a zero
35 value.
37 We define these structures in internal headers because we're not
38 sure we want to make them part of the ABI yet. Eventually, some of
39 this may move into elf/elf.h. */
41 /* An entry in a 64 bit SHT_REL section. */
43 typedef struct
45 Elf32_Word r_sym; /* Symbol index */
46 unsigned char r_ssym; /* Special symbol for 2nd relocation */
47 unsigned char r_type3; /* 3rd relocation type */
48 unsigned char r_type2; /* 2nd relocation type */
49 unsigned char r_type1; /* 1st relocation type */
50 } _Elf64_Mips_R_Info;
52 typedef union
54 Elf64_Xword r_info_number;
55 _Elf64_Mips_R_Info r_info_fields;
56 } _Elf64_Mips_R_Info_union;
58 typedef struct
60 Elf64_Addr r_offset; /* Address */
61 _Elf64_Mips_R_Info_union r_info; /* Relocation type and symbol index */
62 } Elf64_Mips_Rel;
64 typedef struct
66 Elf64_Addr r_offset; /* Address */
67 _Elf64_Mips_R_Info_union r_info; /* Relocation type and symbol index */
68 Elf64_Sxword r_addend; /* Addend */
69 } Elf64_Mips_Rela;
71 #define ELF64_MIPS_R_SYM(i) \
72 ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym)
73 #define ELF64_MIPS_R_TYPE(i) \
74 (((_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1 \
75 | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
76 ).r_info_fields.r_type2 << 8) \
77 | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
78 ).r_info_fields.r_type3 << 16) \
79 | ((Elf32_Word)(__extension__ (_Elf64_Mips_R_Info_union)(i) \
80 ).r_info_fields.r_ssym << 24))
81 #define ELF64_MIPS_R_INFO(sym, type) \
82 (__extension__ (_Elf64_Mips_R_Info_union) \
83 (__extension__ (_Elf64_Mips_R_Info) \
84 { (sym), ELF64_MIPS_R_SSYM (type), \
85 ELF64_MIPS_R_TYPE3 (type), \
86 ELF64_MIPS_R_TYPE2 (type), \
87 ELF64_MIPS_R_TYPE1 (type) \
88 }).r_info_number)
89 /* These macros decompose the value returned by ELF64_MIPS_R_TYPE, and
90 compose it back into a value that it can be used as an argument to
91 ELF64_MIPS_R_INFO. */
92 #define ELF64_MIPS_R_SSYM(i) (((i) >> 24) & 0xff)
93 #define ELF64_MIPS_R_TYPE3(i) (((i) >> 16) & 0xff)
94 #define ELF64_MIPS_R_TYPE2(i) (((i) >> 8) & 0xff)
95 #define ELF64_MIPS_R_TYPE1(i) ((i) & 0xff)
96 #define ELF64_MIPS_R_TYPEENC(type1, type2, type3, ssym) \
97 ((type1) \
98 | ((Elf32_Word)(type2) << 8) \
99 | ((Elf32_Word)(type3) << 16) \
100 | ((Elf32_Word)(ssym) << 24))
102 #undef ELF64_R_SYM
103 #define ELF64_R_SYM(i) ELF64_MIPS_R_SYM (i)
104 #undef ELF64_R_TYPE
105 #define ELF64_R_TYPE(i) ELF64_MIPS_R_TYPE (i)
106 #undef ELF64_R_INFO
107 #define ELF64_R_INFO(sym, type) ELF64_MIPS_R_INFO ((sym), (type))
109 #endif