1 /* SPARC-specific support for 32-bit ELF
2 Copyright 1993 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
28 R_SPARC_8
, R_SPARC_16
, R_SPARC_32
,
29 R_SPARC_DISP8
, R_SPARC_DISP16
, R_SPARC_DISP32
,
30 R_SPARC_WDISP30
, R_SPARC_WDISP22
,
31 R_SPARC_HI22
, R_SPARC_22
,
32 R_SPARC_13
, R_SPARC_LO10
,
33 R_SPARC_GOT10
, R_SPARC_GOT13
, R_SPARC_GOT22
,
34 R_SPARC_PC10
, R_SPARC_PC22
,
37 R_SPARC_GLOB_DAT
, R_SPARC_JMP_SLOT
,
42 R_SPARC_10
, R_SPARC_11
, R_SPARC_64
,
43 R_SPARC_OLO10
, R_SPARC_HH22
, R_SPARC_HM10
, R_SPARC_LM22
,
44 R_SPARC_PC_HH22
, R_SPARC_PC_HM10
, R_SPARC_PC_LM22
,
45 R_SPARC_WDISP16
, R_SPARC_WDISP19
,
46 R_SPARC_GLOB_JMP
, R_SPARC_LO7
,
52 static CONST
char *CONST reloc_type_names
[] =
55 "R_SPARC_8", "R_SPARC_16", "R_SPARC_32",
56 "R_SPARC_DISP8", "R_SPARC_DISP16", "R_SPARC_DISP32",
57 "R_SPARC_WDISP30", "R_SPARC_WDISP22",
58 "R_SPARC_HI22", "R_SPARC_22",
59 "R_SPARC_13", "R_SPARC_LO10",
60 "R_SPARC_GOT10", "R_SPARC_GOT13", "R_SPARC_GOT22",
61 "R_SPARC_PC10", "R_SPARC_PC22",
64 "R_SPARC_GLOB_DAT", "R_SPARC_JMP_SLOT",
68 "R_SPARC_10", "R_SPARC_11", "R_SPARC_64",
69 "R_SPARC_OLO10", "R_SPARC_HH22", "R_SPARC_HM10", "R_SPARC_LM22",
70 "R_SPARC_PC_HH22", "R_SPARC_PC_HM10", "R_SPARC_PC_LM22",
71 "R_SPARC_WDISP16", "R_SPARC_WDISP19",
72 "R_SPARC_GLOB_JMP", "R_SPARC_LO7",
77 #define DIE ((bfd_reloc_status_type(*)())abort)
79 static reloc_howto_type elf_sparc_howto_table
[] =
81 HOWTO(R_SPARC_NONE
, 0,0, 0,false,0,false,false, 0,"R_SPARC_NONE", false,0,0x00000000,false),
82 HOWTO(R_SPARC_8
, 0,0, 8,false,0,true, true, 0,"R_SPARC_8", false,0,0x000000ff,false),
83 HOWTO(R_SPARC_16
, 0,1,16,false,0,true, true, 0,"R_SPARC_16", false,0,0x0000ffff,false),
84 HOWTO(R_SPARC_32
, 0,2,32,false,0,true, true, 0,"R_SPARC_32", false,0,0xffffffff,false),
85 HOWTO(R_SPARC_DISP8
, 0,0, 8,true, 0,false, true, 0,"R_SPARC_DISP8", false,0,0x000000ff,false),
86 HOWTO(R_SPARC_DISP16
, 0,1,16,true, 0,false, true, 0,"R_SPARC_DISP16", false,0,0x0000ffff,false),
87 HOWTO(R_SPARC_DISP32
, 0,2,32,true, 0,false, true, 0,"R_SPARC_DISP32", false,0,0x00ffffff,false),
88 HOWTO(R_SPARC_WDISP30
,2,2,30,true, 0,false, true, 0,"R_SPARC_WDISP30",false,0,0x3fffffff,false),
89 HOWTO(R_SPARC_WDISP22
,2,2,22,true, 0,false, true, 0,"R_SPARC_WDISP22",false,0,0x003fffff,false),
90 HOWTO(R_SPARC_HI22
, 10,2,22,false,0,true, false, 0,"R_SPARC_HI22", false,0,0x003fffff,false),
91 HOWTO(R_SPARC_22
, 0,2,22,false,0,true, true, 0,"R_SPARC_22", false,0,0x003fffff,false),
92 HOWTO(R_SPARC_13
, 0,1,13,false,0,true, true, 0,"R_SPARC_13", false,0,0x00001fff,false),
93 HOWTO(R_SPARC_LO10
, 0,1,10,false,0,true, false, 0,"R_SPARC_LO10", false,0,0x000003ff,false),
94 HOWTO(R_SPARC_GOT10
, 0,1,10,false,0,false, true, 0,"R_SPARC_GOT10", false,0,0x000003ff,false),
95 HOWTO(R_SPARC_GOT13
, 0,1,13,false,0,false, true, 0,"R_SPARC_GOT13", false,0,0x00001fff,false),
96 HOWTO(R_SPARC_GOT22
, 10,2,22,false,0,false, true, 0,"R_SPARC_GOT22", false,0,0x003fffff,false),
97 HOWTO(R_SPARC_PC10
, 0,1,10,false,0,true, true, 0,"R_SPARC_PC10", false,0,0x000003ff,false),
98 HOWTO(R_SPARC_PC22
, 0,2,22,false,0,true, true, 0,"R_SPARC_PC22", false,0,0x003fffff,false),
99 HOWTO(R_SPARC_WPLT30
, 0,0,00,false,0,false,false, 0,"R_SPARC_WPLT30", false,0,0x00000000,false),
100 HOWTO(R_SPARC_COPY
, 0,0,00,false,0,false,false, 0,"R_SPARC_COPY", false,0,0x00000000,false),
101 HOWTO(R_SPARC_GLOB_DAT
,0,0,00,false,0,false,false,0,"R_SPARC_GLOB_DAT",false,0,0x00000000,false),
102 HOWTO(R_SPARC_JMP_SLOT
,0,0,00,false,0,false,false,0,"R_SPARC_JMP_SLOT",false,0,0x00000000,false),
103 HOWTO(R_SPARC_RELATIVE
,0,0,00,false,0,false,false,0,"R_SPARC_RELATIVE",false,0,0x00000000,false),
104 HOWTO(R_SPARC_UA32
, 0,0,00,false,0,false,false,0,"R_SPARC_UA32", false,0,0x00000000,false),
105 HOWTO(R_SPARC_10
, 0,1,10,false,0,true, true, 0, "R_SPARC_10", false,0,0x000003ff,false),
106 HOWTO(R_SPARC_11
, 0,1,11,false,0,true, true, 0,"R_SPARC_11", false,0,0x000007ff,false),
107 HOWTO(R_SPARC_64
, 0,4,00,false,0,true, true, 0,"R_SPARC_64", false,0,(((bfd_vma
)0xffffffff)<<32)+0xffffffff,false),
108 HOWTO(R_SPARC_OLO10
, 0,1,10,false,0,true,false, DIE
,"R_SPARC_OLO10",false,0,0x000003ff,false),
109 HOWTO(R_SPARC_HH22
, 42,2,22,false,0,true, false, 0,"R_SPARC_HH22", false,0,0x003fffff,false),
110 HOWTO(R_SPARC_HM10
, 32,1,10,false,0,true,false, 0,"R_SPARC_HM10", false,0,0x000003ff,false),
111 HOWTO(R_SPARC_LM22
, 10,2,22,false,0,true,false, 0,"R_SPARC_LM22", false,0,0x003fffff,false),
112 HOWTO(R_SPARC_PC_HH22
,42,2,22, true,0,true, false, 0,"R_SPARC_HH22", false,0,0x003fffff,false),
113 HOWTO(R_SPARC_PC_HM10
,32,1,10, true,0,true,false, 0,"R_SPARC_HM10", false,0,0x000003ff,false),
114 HOWTO(R_SPARC_PC_LM22
,10,2,22,true, 0,true,false, 0,"R_SPARC_LM22", false,0,0x003fffff,false),
115 HOWTO(R_SPARC_WDISP16
, 2,2,16,true, 0,false, true,DIE
,"R_SPARC_WDISP16",false,0,0,false),
116 HOWTO(R_SPARC_WDISP19
, 2,2,22,true, 0,false, true, 0, "R_SPARC_WDISP19",false,0,0x0007ffff,false),
117 HOWTO(R_SPARC_GLOB_JMP
,0,0,00,false,0,false,false,0,"R_SPARC_GLOB_DAT",false,0,0x00000000,false),
118 HOWTO(R_SPARC_LO7
, 0,1, 7,false,0,false,false,0,"R_SPARC_LO7", false,0,0x0000007f,false),
121 struct elf_reloc_map
{
122 unsigned char bfd_reloc_val
;
123 unsigned char elf_reloc_val
;
126 static CONST
struct elf_reloc_map sparc_reloc_map
[] =
128 { BFD_RELOC_NONE
, R_SPARC_NONE
, },
129 { BFD_RELOC_16
, R_SPARC_16
, },
130 { BFD_RELOC_8
, R_SPARC_8
},
131 { BFD_RELOC_8_PCREL
, R_SPARC_DISP8
},
132 { BFD_RELOC_CTOR
, R_SPARC_32
}, /* @@ Assumes 32 bits. */
133 { BFD_RELOC_32
, R_SPARC_32
},
134 { BFD_RELOC_32_PCREL
, R_SPARC_DISP32
},
135 { BFD_RELOC_HI22
, R_SPARC_HI22
},
136 { BFD_RELOC_LO10
, R_SPARC_LO10
, },
137 { BFD_RELOC_32_PCREL_S2
, R_SPARC_WDISP30
},
138 { BFD_RELOC_SPARC22
, R_SPARC_22
},
139 { BFD_RELOC_SPARC13
, R_SPARC_13
},
140 { BFD_RELOC_SPARC_GOT10
, R_SPARC_GOT10
},
141 { BFD_RELOC_SPARC_GOT13
, R_SPARC_GOT13
},
142 { BFD_RELOC_SPARC_GOT22
, R_SPARC_GOT22
},
143 { BFD_RELOC_SPARC_PC10
, R_SPARC_PC10
},
144 { BFD_RELOC_SPARC_PC22
, R_SPARC_PC22
},
145 { BFD_RELOC_SPARC_WPLT30
, R_SPARC_WPLT30
},
146 { BFD_RELOC_SPARC_COPY
, R_SPARC_COPY
},
147 { BFD_RELOC_SPARC_GLOB_DAT
, R_SPARC_GLOB_DAT
},
148 { BFD_RELOC_SPARC_JMP_SLOT
, R_SPARC_JMP_SLOT
},
149 { BFD_RELOC_SPARC_RELATIVE
, R_SPARC_RELATIVE
},
150 { BFD_RELOC_SPARC_WDISP22
, R_SPARC_WDISP22
},
151 { BFD_RELOC_SPARC_WDISP19
, R_SPARC_WDISP19
},
152 /* { BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
153 { BFD_RELOC_SPARC_10
, R_SPARC_10
},
154 { BFD_RELOC_SPARC_11
, R_SPARC_11
},
155 { BFD_RELOC_SPARC_64
, R_SPARC_64
},
156 { BFD_RELOC_SPARC_OLO10
, R_SPARC_OLO10
},
157 { BFD_RELOC_SPARC_HH22
, R_SPARC_HH22
},
158 { BFD_RELOC_SPARC_HM10
, R_SPARC_HM10
},
159 { BFD_RELOC_SPARC_LM22
, R_SPARC_LM22
},
160 { BFD_RELOC_SPARC_PC_HH22
, R_SPARC_PC_HH22
},
161 { BFD_RELOC_SPARC_PC_HM10
, R_SPARC_PC_HM10
},
162 { BFD_RELOC_SPARC_PC_LM22
, R_SPARC_PC_LM22
},
163 { BFD_RELOC_SPARC_WDISP16
, R_SPARC_WDISP16
},
164 { BFD_RELOC_SPARC_WDISP19
, R_SPARC_WDISP19
},
165 { BFD_RELOC_SPARC_GLOB_JMP
, R_SPARC_GLOB_JMP
},
166 { BFD_RELOC_SPARC_LO7
, R_SPARC_LO7
},
169 static CONST
struct reloc_howto_struct
*
170 DEFUN (bfd_elf64_bfd_reloc_type_lookup
, (abfd
, code
),
172 bfd_reloc_code_real_type code
)
175 for (i
= 0; i
< sizeof (sparc_reloc_map
) / sizeof (struct elf_reloc_map
); i
++)
177 if (sparc_reloc_map
[i
].bfd_reloc_val
== code
)
178 return &elf_sparc_howto_table
[(int) sparc_reloc_map
[i
].elf_reloc_val
];
184 DEFUN (elf_info_to_howto
, (abfd
, cache_ptr
, dst
),
186 arelent
*cache_ptr AND
187 Elf64_Internal_Rela
*dst
)
189 BFD_ASSERT (ELF64_R_TYPE(dst
->r_info
) < (unsigned int) R_SPARC_max
);
190 cache_ptr
->howto
= &elf_sparc_howto_table
[ELF64_R_TYPE(dst
->r_info
)];
193 #define TARGET_BIG_SYM bfd_elf64_sparc_vec
194 #define TARGET_BIG_NAME "elf64-sparc"
195 #define ELF_ARCH bfd_arch_sparc
197 #include "elf64-target.h"