1 /* SPARC-specific support for 64-bit ELF
2 Copyright (C) 1993, 1995, 1996, 1997 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 /* This is defined if one wants to build upward compatible binaries
26 with the original sparc64-elf toolchain. The support is kept in for
27 now but is turned off by default. dje 970930 */
28 /*#define SPARC64_OLD_RELOCS*/
30 #include "elf/sparc.h"
32 /* In case we're on a 32-bit machine, construct a 64-bit "-1" value. */
33 #define MINUS_ONE (~ (bfd_vma) 0)
35 static reloc_howto_type *sparc64_elf_reloc_type_lookup
36 PARAMS ((bfd *, bfd_reloc_code_real_type));
37 static void sparc64_elf_info_to_howto
38 PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
40 static boolean sparc64_elf_check_relocs
41 PARAMS((bfd *, struct bfd_link_info *, asection *sec,
42 const Elf_Internal_Rela *));
43 static boolean sparc64_elf_adjust_dynamic_symbol
44 PARAMS((struct bfd_link_info *, struct elf_link_hash_entry *));
45 static boolean sparc64_elf_size_dynamic_sections
46 PARAMS((bfd *, struct bfd_link_info *));
47 static boolean sparc64_elf_adjust_dynindx
48 PARAMS((struct elf_link_hash_entry *, PTR));
50 static boolean sparc64_elf_merge_private_bfd_data
51 PARAMS ((bfd *, bfd *));
53 static boolean sparc64_elf_relocate_section
54 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
55 Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
56 static boolean sparc64_elf_object_p PARAMS ((bfd *));
58 /* The relocation "howto" table. */
60 static bfd_reloc_status_type sparc_elf_notsup_reloc
61 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
62 static bfd_reloc_status_type sparc_elf_wdisp16_reloc
63 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
64 static bfd_reloc_status_type sparc_elf_hix22_reloc
65 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
66 static bfd_reloc_status_type sparc_elf_lox10_reloc
67 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
69 static reloc_howto_type sparc64_elf_howto_table[] =
71 HOWTO(R_SPARC_NONE, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_NONE", false,0,0x00000000,true),
72 HOWTO(R_SPARC_8, 0,0, 8,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_8", false,0,0x000000ff,true),
73 HOWTO(R_SPARC_16, 0,1,16,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_16", false,0,0x0000ffff,true),
74 HOWTO(R_SPARC_32, 0,2,32,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_32", false,0,0xffffffff,true),
75 HOWTO(R_SPARC_DISP8, 0,0, 8,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP8", false,0,0x000000ff,true),
76 HOWTO(R_SPARC_DISP16, 0,1,16,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP16", false,0,0x0000ffff,true),
77 HOWTO(R_SPARC_DISP32, 0,2,32,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP32", false,0,0x00ffffff,true),
78 HOWTO(R_SPARC_WDISP30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP30", false,0,0x3fffffff,true),
79 HOWTO(R_SPARC_WDISP22, 2,2,22,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP22", false,0,0x003fffff,true),
80 HOWTO(R_SPARC_HI22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HI22", false,0,0x003fffff,true),
81 HOWTO(R_SPARC_22, 0,2,22,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_22", false,0,0x003fffff,true),
82 HOWTO(R_SPARC_13, 0,2,13,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_13", false,0,0x00001fff,true),
83 HOWTO(R_SPARC_LO10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LO10", false,0,0x000003ff,true),
84 HOWTO(R_SPARC_GOT10, 0,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT10", false,0,0x000003ff,true),
85 HOWTO(R_SPARC_GOT13, 0,2,13,false,0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_GOT13", false,0,0x00001fff,true),
86 HOWTO(R_SPARC_GOT22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GOT22", false,0,0x003fffff,true),
87 HOWTO(R_SPARC_PC10, 0,2,10,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_PC10", false,0,0x000003ff,true),
88 HOWTO(R_SPARC_PC22, 10,2,22,true, 0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_PC22", false,0,0x003fffff,true),
89 HOWTO(R_SPARC_WPLT30, 2,2,30,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WPLT30", false,0,0x3fffffff,true),
90 HOWTO(R_SPARC_COPY, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_COPY", false,0,0x00000000,true),
91 HOWTO(R_SPARC_GLOB_DAT, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_GLOB_DAT",false,0,0x00000000,true),
92 HOWTO(R_SPARC_JMP_SLOT, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_JMP_SLOT",false,0,0x00000000,true),
93 HOWTO(R_SPARC_RELATIVE, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_RELATIVE",false,0,0x00000000,true),
94 HOWTO(R_SPARC_UA32, 0,0,00,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_UA32", false,0,0x00000000,true),
95 #ifndef SPARC64_OLD_RELOCS
96 /* These aren't implemented yet. */
97 HOWTO(R_SPARC_PLT32, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsup_reloc, "R_SPARC_PLT32", false,0,0x00000000,true),
98 HOWTO(R_SPARC_HIPLT22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsup_reloc, "R_SPARC_HIPLT22", false,0,0x00000000,true),
99 HOWTO(R_SPARC_LOPLT10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsup_reloc, "R_SPARC_LOPLT10", false,0,0x00000000,true),
100 HOWTO(R_SPARC_PCPLT32, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsup_reloc, "R_SPARC_PCPLT32", false,0,0x00000000,true),
101 HOWTO(R_SPARC_PCPLT22, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsup_reloc, "R_SPARC_PCPLT22", false,0,0x00000000,true),
102 HOWTO(R_SPARC_PCPLT10, 0,0,00,false,0,complain_overflow_dont, sparc_elf_notsup_reloc, "R_SPARC_PCPLT10", false,0,0x00000000,true),
104 HOWTO(R_SPARC_10, 0,2,10,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_10", false,0,0x000003ff,true),
105 HOWTO(R_SPARC_11, 0,2,11,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_11", false,0,0x000007ff,true),
106 HOWTO(R_SPARC_64, 0,4,64,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_64", false,0,MINUS_ONE, true),
107 HOWTO(R_SPARC_OLO10, 0,2,13,false,0,complain_overflow_signed, sparc_elf_notsup_reloc, "R_SPARC_OLO10", false,0,0x00001fff,true),
108 HOWTO(R_SPARC_HH22, 42,2,22,false,0,complain_overflow_unsigned,bfd_elf_generic_reloc, "R_SPARC_HH22", false,0,0x003fffff,true),
109 HOWTO(R_SPARC_HM10, 32,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_HM10", false,0,0x000003ff,true),
110 HOWTO(R_SPARC_LM22, 10,2,22,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_LM22", false,0,0x003fffff,true),
111 HOWTO(R_SPARC_PC_HH22, 42,2,22,true, 0,complain_overflow_unsigned,bfd_elf_generic_reloc, "R_SPARC_PC_HH22", false,0,0x003fffff,true),
112 HOWTO(R_SPARC_PC_HM10, 32,2,10,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_PC_HM10", false,0,0x000003ff,true),
113 HOWTO(R_SPARC_PC_LM22, 10,2,22,true, 0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_PC_LM22", false,0,0x003fffff,true),
114 HOWTO(R_SPARC_WDISP16, 2,2,16,true, 0,complain_overflow_signed, sparc_elf_wdisp16_reloc,"R_SPARC_WDISP16", false,0,0x00000000,true),
115 HOWTO(R_SPARC_WDISP19, 2,2,19,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_WDISP19", false,0,0x0007ffff,true),
116 HOWTO(R_SPARC_UNUSED_42, 0,0, 0,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_UNUSED_42",false,0,0x00000000,true),
117 HOWTO(R_SPARC_7, 0,2, 7,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_7", false,0,0x0000007f,true),
118 HOWTO(R_SPARC_5, 0,2, 5,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_5", false,0,0x0000001f,true),
119 HOWTO(R_SPARC_6, 0,2, 6,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_6", false,0,0x0000003f,true),
120 HOWTO(R_SPARC_DISP64, 0,4,64,true, 0,complain_overflow_signed, bfd_elf_generic_reloc, "R_SPARC_DISP64", false,0,MINUS_ONE, true),
121 HOWTO(R_SPARC_PLT64, 0,4,64,false,0,complain_overflow_bitfield,sparc_elf_notsup_reloc, "R_SPARC_PLT64", false,0,MINUS_ONE, false),
122 HOWTO(R_SPARC_HIX22, 0,4, 0,false,0,complain_overflow_bitfield,sparc_elf_hix22_reloc, "R_SPARC_HIX22", false,0,MINUS_ONE, false),
123 HOWTO(R_SPARC_LOX10, 0,4, 0,false,0,complain_overflow_dont, sparc_elf_lox10_reloc, "R_SPARC_LOX10", false,0,MINUS_ONE, false),
124 HOWTO(R_SPARC_H44, 22,2,22,false,0,complain_overflow_unsigned,bfd_elf_generic_reloc, "R_SPARC_H44", false,0,0x003fffff,false),
125 HOWTO(R_SPARC_M44, 12,2,10,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_M44", false,0,0x000003ff,false),
126 HOWTO(R_SPARC_L44, 0,2,13,false,0,complain_overflow_dont, bfd_elf_generic_reloc, "R_SPARC_L44", false,0,0x00000fff,false),
127 HOWTO(R_SPARC_REGISTER, 0,4, 0,false,0,complain_overflow_bitfield,sparc_elf_notsup_reloc, "R_SPARC_REGISTER",false,0,MINUS_ONE, false),
128 HOWTO(R_SPARC_UA64, 0,4,64,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_UA64", false,0,MINUS_ONE, true),
129 HOWTO(R_SPARC_UA16, 0,1,16,false,0,complain_overflow_bitfield,bfd_elf_generic_reloc, "R_SPARC_UA16", false,0,0x0000ffff,true)
132 struct elf_reloc_map {
133 unsigned char bfd_reloc_val;
134 unsigned char elf_reloc_val;
137 static CONST struct elf_reloc_map sparc_reloc_map[] =
139 { BFD_RELOC_NONE, R_SPARC_NONE, },
140 { BFD_RELOC_16, R_SPARC_16, },
141 { BFD_RELOC_8, R_SPARC_8 },
142 { BFD_RELOC_8_PCREL, R_SPARC_DISP8 },
143 { BFD_RELOC_CTOR, R_SPARC_64 },
144 { BFD_RELOC_32, R_SPARC_32 },
145 { BFD_RELOC_32_PCREL, R_SPARC_DISP32 },
146 { BFD_RELOC_HI22, R_SPARC_HI22 },
147 { BFD_RELOC_LO10, R_SPARC_LO10, },
148 { BFD_RELOC_32_PCREL_S2, R_SPARC_WDISP30 },
149 { BFD_RELOC_SPARC22, R_SPARC_22 },
150 { BFD_RELOC_SPARC13, R_SPARC_13 },
151 { BFD_RELOC_SPARC_GOT10, R_SPARC_GOT10 },
152 { BFD_RELOC_SPARC_GOT13, R_SPARC_GOT13 },
153 { BFD_RELOC_SPARC_GOT22, R_SPARC_GOT22 },
154 { BFD_RELOC_SPARC_PC10, R_SPARC_PC10 },
155 { BFD_RELOC_SPARC_PC22, R_SPARC_PC22 },
156 { BFD_RELOC_SPARC_WPLT30, R_SPARC_WPLT30 },
157 { BFD_RELOC_SPARC_COPY, R_SPARC_COPY },
158 { BFD_RELOC_SPARC_GLOB_DAT, R_SPARC_GLOB_DAT },
159 { BFD_RELOC_SPARC_JMP_SLOT, R_SPARC_JMP_SLOT },
160 { BFD_RELOC_SPARC_RELATIVE, R_SPARC_RELATIVE },
161 { BFD_RELOC_SPARC_WDISP22, R_SPARC_WDISP22 },
162 /* ??? Doesn't dwarf use this? */
163 /*{ BFD_RELOC_SPARC_UA32, R_SPARC_UA32 }, not used?? */
164 {BFD_RELOC_SPARC_10, R_SPARC_10},
165 {BFD_RELOC_SPARC_11, R_SPARC_11},
166 {BFD_RELOC_SPARC_64, R_SPARC_64},
167 {BFD_RELOC_SPARC_OLO10, R_SPARC_OLO10},
168 {BFD_RELOC_SPARC_HH22, R_SPARC_HH22},
169 {BFD_RELOC_SPARC_HM10, R_SPARC_HM10},
170 {BFD_RELOC_SPARC_LM22, R_SPARC_LM22},
171 {BFD_RELOC_SPARC_PC_HH22, R_SPARC_PC_HH22},
172 {BFD_RELOC_SPARC_PC_HM10, R_SPARC_PC_HM10},
173 {BFD_RELOC_SPARC_PC_LM22, R_SPARC_PC_LM22},
174 {BFD_RELOC_SPARC_WDISP16, R_SPARC_WDISP16},
175 {BFD_RELOC_SPARC_WDISP19, R_SPARC_WDISP19},
176 {BFD_RELOC_SPARC_7, R_SPARC_7},
177 {BFD_RELOC_SPARC_5, R_SPARC_5},
178 {BFD_RELOC_SPARC_6, R_SPARC_6},
179 {BFD_RELOC_SPARC_DISP64, R_SPARC_DISP64},
180 {BFD_RELOC_SPARC_PLT64, R_SPARC_PLT64},
181 {BFD_RELOC_SPARC_HIX22, R_SPARC_HIX22},
182 {BFD_RELOC_SPARC_LOX10, R_SPARC_LOX10},
183 {BFD_RELOC_SPARC_H44, R_SPARC_H44},
184 {BFD_RELOC_SPARC_M44, R_SPARC_M44},
185 {BFD_RELOC_SPARC_L44, R_SPARC_L44},
186 {BFD_RELOC_SPARC_REGISTER, R_SPARC_REGISTER}
189 static reloc_howto_type *
190 sparc64_elf_reloc_type_lookup (abfd, code)
192 bfd_reloc_code_real_type code;
195 for (i = 0; i < sizeof (sparc_reloc_map) / sizeof (struct elf_reloc_map); i++)
197 if (sparc_reloc_map[i].bfd_reloc_val == code)
198 return &sparc64_elf_howto_table[(int) sparc_reloc_map[i].elf_reloc_val];
204 sparc64_elf_info_to_howto (abfd, cache_ptr, dst)
207 Elf64_Internal_Rela *dst;
209 BFD_ASSERT (ELF64_R_TYPE (dst->r_info) < (unsigned int) R_SPARC_max);
210 cache_ptr->howto = &sparc64_elf_howto_table[ELF64_R_TYPE (dst->r_info)];
213 /* Utility for performing the standard initial work of an instruction
215 *PRELOCATION will contain the relocated item.
216 *PINSN will contain the instruction from the input stream.
217 If the result is `bfd_reloc_other' the caller can continue with
218 performing the relocation. Otherwise it must stop and return the
219 value to its caller. */
221 static bfd_reloc_status_type
222 init_insn_reloc (abfd,
231 arelent *reloc_entry;
234 asection *input_section;
236 bfd_vma *prelocation;
240 reloc_howto_type *howto = reloc_entry->howto;
242 if (output_bfd != (bfd *) NULL
243 && (symbol->flags & BSF_SECTION_SYM) == 0
244 && (! howto->partial_inplace
245 || reloc_entry->addend == 0))
247 reloc_entry->address += input_section->output_offset;
251 /* This works because partial_inplace == false. */
252 if (output_bfd != NULL)
253 return bfd_reloc_continue;
255 if (reloc_entry->address > input_section->_cooked_size)
256 return bfd_reloc_outofrange;
258 relocation = (symbol->value
259 + symbol->section->output_section->vma
260 + symbol->section->output_offset);
261 relocation += reloc_entry->addend;
262 if (howto->pc_relative)
264 relocation -= (input_section->output_section->vma
265 + input_section->output_offset);
266 relocation -= reloc_entry->address;
269 *prelocation = relocation;
270 *pinsn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
271 return bfd_reloc_other;
274 /* For unsupported relocs. */
276 static bfd_reloc_status_type
277 sparc_elf_notsup_reloc (abfd,
285 arelent *reloc_entry;
288 asection *input_section;
290 char **error_message;
292 return bfd_reloc_notsupported;
295 /* Handle the WDISP16 reloc. */
297 static bfd_reloc_status_type
298 sparc_elf_wdisp16_reloc (abfd, reloc_entry, symbol, data, input_section,
299 output_bfd, error_message)
301 arelent *reloc_entry;
304 asection *input_section;
306 char **error_message;
310 bfd_reloc_status_type status;
312 status = init_insn_reloc (abfd, reloc_entry, symbol, data,
313 input_section, output_bfd, &relocation, &insn);
314 if (status != bfd_reloc_other)
317 insn = (insn & ~0x303fff) | ((((relocation >> 2) & 0xc000) << 6)
318 | ((relocation >> 2) & 0x3fff));
319 bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
321 if ((bfd_signed_vma) relocation < - 0x40000
322 || (bfd_signed_vma) relocation > 0x3ffff)
323 return bfd_reloc_overflow;
328 /* Handle the HIX22 reloc. */
330 static bfd_reloc_status_type
331 sparc_elf_hix22_reloc (abfd,
339 arelent *reloc_entry;
342 asection *input_section;
344 char **error_message;
348 bfd_reloc_status_type status;
350 status = init_insn_reloc (abfd, reloc_entry, symbol, data,
351 input_section, output_bfd, &relocation, &insn);
352 if (status != bfd_reloc_other)
355 relocation ^= MINUS_ONE;
356 insn = (insn & ~0x3fffff) | ((relocation >> 10) & 0x3fffff);
357 bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
359 if ((relocation & ~ (bfd_vma) 0xffffffff) != 0)
360 return bfd_reloc_overflow;
365 /* Handle the LOX10 reloc. */
367 static bfd_reloc_status_type
368 sparc_elf_lox10_reloc (abfd,
376 arelent *reloc_entry;
379 asection *input_section;
381 char **error_message;
385 bfd_reloc_status_type status;
387 status = init_insn_reloc (abfd, reloc_entry, symbol, data,
388 input_section, output_bfd, &relocation, &insn);
389 if (status != bfd_reloc_other)
392 insn = (insn & ~0x1fff) | 0x1c00 | (relocation & 0x3ff);
393 bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
400 /* FIXME: Do Delta Doc PLT entries. */
402 /* We use five different formats, chosing an optimal form for the
403 code model used by the application/library. All of which provide
404 the exact same interface to ld.so.
405 FIXME, well, only three actually used right now -- fix up medlow
406 and fullany later. */
408 /* Both the headers and the entries are icache aligned. */
409 #define PLT_HEADER_SIZE 32
410 #define PLT_ENTRY_SIZE 32
411 #define GOT_RESERVED_ENTRIES 3
413 #define ELF_DYNAMIC_INTERPRETER "/usr/lib/sparcv9/ld.so.1"
415 /* Values for fixups:
426 unsigned int insns[8];
434 static const struct plt_template plt_medlow_header =
437 0x07000000, /* sethi %hi(got0),%g3 */
438 0x8610E000, /* or %g3,%lo(got0),%g3 */
439 0xC258E008, /* ldx [%g3+8],%g1 */
440 0x81C04000, /* jmp %g1 */
441 0xC258E010, /* ldx [%g3+16],%g1 */
442 0x01000000, /* nop */
443 0x01000000, /* nop */
453 static const struct plt_template plt_medlow_entry =
456 0x03000000, /* sethi %hi(gotN),%g1 */
457 0x05000000, /* sethi %hi(relN),%g2 */
458 0xC2586000, /* ldx [%g1+%lo(gotN)],%g1 */
459 0x8410A000, /* or %g2,%lo(relN),%g2 */
460 0x81C04000, /* jmp %g1 */
461 0x01000000, /* nop */
462 0x01000000, /* nop */
473 static const struct plt_template plt_medany_header =
476 0x07000000, /* sethi %hi(got0),%g3 */
477 0x8610E000, /* or %g3,%lo(got0),%g3 */
478 0x8600C004, /* add %g3,%g4,%g3 */
479 0xC258E008, /* ldx [%g3+8],%g1 */
480 0x81C04000, /* jmp %g1 */
481 0xC258E010, /* ldx [%g3+16],%g1 */
482 0x01000000, /* nop */
483 0x01000000, /* nop */
491 static const struct plt_template plt_medany_entry =
494 0x03000000, /* sethi %hi(gotN),%g1 */
495 0x82106000, /* or %g1,%lo(gotN),%g1 */
496 0xC2584004, /* ldx [%g1+%g4],%g1 */
497 0x05000000, /* sethi %hi(relN),%g2 */
498 0x81C04000, /* jmp %g1 */
499 0x8410A000, /* or %g2,%lo(relN),%g2 */
500 0x01000000, /* nop */
513 static const struct plt_template plt_fullany_header =
516 0x07000000, /* sethi %hi(got0-plt0),%g3 */
517 0x8610E000, /* or %g3,%lo(got0-plt0),%g3 */
518 0x86004003, /* add %g1,%g3,%g3 */
519 0xC258C008, /* ldx [%g3+8],%g1 */
520 0x81C04000, /* jmp %g1 */
521 0xC258E010, /* ldx [%g3+16],%g1 */
522 0x01000000, /* nop */
531 static const struct plt_template plt_fullany_entry =
534 0x83414000, /* rd %pc,%g1 */
535 0x07000000, /* sethi %hi(gotN-pltN),%g3 */
536 0x05000000, /* sethi %hi(relN),%g2 */
537 0x8610E000, /* or %g3,%lo(gotN-pltN),%g3 */
538 0xC2584003, /* ldx [%g1+%g3],%g1 */
539 0x81C04000, /* jmp %g1 */
540 0x8410A000, /* or %g2,%lo(relN),%g2 */
554 static const struct plt_template plt_pic_header =
557 0xC25DE008, /* ldx [%l7+8],%g1 */
558 0x81C04000, /* jmp %g1 */
559 0xC25DE010, /* ldx [%l7+16],%g1 */
560 0x01000000, /* nop */
561 0x01000000, /* nop */
562 0x01000000, /* nop */
563 0x01000000, /* nop */
569 static const struct plt_template plt_pic_small_entry =
572 0xC25DE000, /* ldx [%l7+gotN@got],%g1 */
573 0x05000000, /* sethi %hi(relN),%g2 */
574 0x81C04017, /* jmp %g1+%l7 */
575 0x8410A000, /* or %g2,%lo(relN),%g2 */
576 0x01000000, /* nop */
577 0x01000000, /* nop */
578 0x01000000, /* nop */
582 { R_SPARC_13, 5 }, /* R_SPARC_GOT13 */
589 static const struct plt_template plt_pic_large_entry =
592 0x03000000, /* sethi %hi(gotN@got),%g1 */
593 0x82106000, /* or %g1,%lo(gotN@got),%g1 */
594 0xC2584017, /* ldx [%g1+%l7],%g1 */
595 0x05000000, /* sethi %hi(relN),%g2 */
596 0x81C04000, /* jmp %g1 */
597 0x8410A000, /* or %g2,%lo(relN),%g2 */
598 0x01000000, /* nop */
602 { R_SPARC_HI22, 5 }, /* R_SPARC_GOT22 */
603 { R_SPARC_LO10, 5 }, /* R_SPARC_GOT10 */
611 /* Build a plt entry given a template and values. */
613 static boolean sparc64_elf_build_plt_entry(output_bfd, loc, tmpl, values)
616 const struct plt_template *tmpl;
620 for (i = 0; i < 8; ++i)
622 unsigned int insn = tmpl->insns[i];
623 bfd_vma value = values[tmpl->fixup[i].value];
626 switch (tmpl->fixup[i].reloc)
631 insn |= (value >> 10) & 0x3fffff;
634 insn |= value & 0x3ff;
637 if ((bfd_signed_vma)value > 0xfff
638 || (bfd_signed_vma)value < -0x1000)
640 insn |= value & 0x1fff;
646 /* FIXME -- possibly use _bfd_final_link_relocate? */
648 howto = sparc64_elf_howto_table + tmpl->fixups[i].reloc;
649 r = _bfd_final_link_relocate (howto, input_bfd, input_section,
651 if (r != bfd_reloc_ok)
655 bfd_put_32(output_bfd, insn, loc);
662 /* Look through the relocs for a section during the first phase, and
663 allocate space in the global offset table or procedure linkage
667 sparc64_elf_check_relocs (abfd, info, sec, relocs)
669 struct bfd_link_info *info;
671 const Elf_Internal_Rela *relocs;
674 Elf_Internal_Shdr *symtab_hdr;
675 struct elf_link_hash_entry **sym_hashes;
676 bfd_vma *local_got_offsets;
677 const Elf_Internal_Rela *rel;
678 const Elf_Internal_Rela *rel_end;
683 if (info->relocateable || (sec->flags & SEC_DEBUGGING))
686 dynobj = elf_hash_table (info)->dynobj;
687 symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
688 sym_hashes = elf_sym_hashes (abfd);
689 local_got_offsets = elf_local_got_offsets (abfd);
695 rel_end = relocs + sec->reloc_count;
696 for (rel = relocs; rel < rel_end; rel++)
698 unsigned long r_symndx;
699 struct elf_link_hash_entry *h;
701 r_symndx = ELF64_R_SYM (rel->r_info);
702 if (r_symndx < symtab_hdr->sh_info)
705 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
707 switch (ELF64_R_TYPE (rel->r_info))
712 /* This symbol requires a global offset table entry. */
716 /* Create the .got section. */
717 elf_hash_table (info)->dynobj = dynobj = abfd;
718 if (! _bfd_elf_create_got_section (dynobj, info))
724 sgot = bfd_get_section_by_name (dynobj, ".got");
725 BFD_ASSERT (sgot != NULL);
728 if (srelgot == NULL && (h != NULL || info->shared))
730 srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
733 srelgot = bfd_make_section (dynobj, ".rela.got");
735 || ! bfd_set_section_flags (dynobj, srelgot,
742 || ! bfd_set_section_alignment (dynobj, srelgot, 3))
749 if (h->got_offset != (bfd_vma) -1)
751 /* We have already allocated space in the .got. */
754 h->got_offset = sgot->_raw_size;
756 /* Make sure this symbol is output as a dynamic symbol. */
757 if (h->dynindx == -1)
759 if (! bfd_elf64_link_record_dynamic_symbol (info, h))
763 srelgot->_raw_size += sizeof (Elf64_External_Rela);
767 /* This is a global offset table entry for a local
769 if (local_got_offsets == NULL)
772 register unsigned int i;
774 size = symtab_hdr->sh_info * sizeof (bfd_vma);
775 local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
776 if (local_got_offsets == NULL)
778 elf_local_got_offsets (abfd) = local_got_offsets;
779 for (i = 0; i < symtab_hdr->sh_info; i++)
780 local_got_offsets[i] = (bfd_vma) -1;
782 if (local_got_offsets[r_symndx] != (bfd_vma) -1)
784 /* We have already allocated space in the .got. */
787 local_got_offsets[r_symndx] = sgot->_raw_size;
791 /* If we are generating a shared object, we need to
792 output a R_SPARC_RELATIVE reloc so that the
793 dynamic linker can adjust this GOT entry. */
794 srelgot->_raw_size += sizeof (Elf64_External_Rela);
798 sgot->_raw_size += 8;
801 /* Doesn't work for 64-bit -fPIC, since sethi/or builds
802 unsigned numbers. If we permit ourselves to modify
803 code so we get sethi/xor, this could work.
804 Question: do we consider conditionally re-enabling
805 this for -fpic, once we know about object code models? */
806 /* If the .got section is more than 0x1000 bytes, we add
807 0x1000 to the value of _GLOBAL_OFFSET_TABLE_, so that 13
808 bit relocations have a greater chance of working. */
809 if (sgot->_raw_size >= 0x1000
810 && elf_hash_table (info)->hgot->root.u.def.value == 0)
811 elf_hash_table (info)->hgot->root.u.def.value = 0x1000;
818 case R_SPARC_HIPLT22:
819 case R_SPARC_LOPLT10:
820 case R_SPARC_PCPLT32:
821 case R_SPARC_PCPLT22:
822 case R_SPARC_PCPLT10:
824 /* This symbol requires a procedure linkage table entry. We
825 actually build the entry in adjust_dynamic_symbol,
826 because this might be a case of linking PIC code without
827 linking in any dynamic objects, in which case we don't
828 need to generate a procedure linkage table after all. */
832 /* It does not make sense to have a procedure linkage
833 table entry for a local symbol. */
834 bfd_set_error (bfd_error_bad_value);
838 /* Make sure this symbol is output as a dynamic symbol. */
839 if (h->dynindx == -1)
841 if (! bfd_elf64_link_record_dynamic_symbol (info, h))
845 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
850 case R_SPARC_PC_HH22:
851 case R_SPARC_PC_HM10:
852 case R_SPARC_PC_LM22:
854 && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
861 case R_SPARC_WDISP30:
862 case R_SPARC_WDISP22:
863 case R_SPARC_WDISP19:
864 case R_SPARC_WDISP16:
893 /* When creating a shared object, we must copy these relocs
894 into the output file. We create a reloc section in
895 dynobj and make room for the reloc.
897 But don't do this for debugging sections -- this shows up
898 with DWARF2 -- first because they are not loaded, and
899 second because DWARF sez the debug info is not to be
900 biased by the load address. */
901 if (info->shared && !(sec->flags & SEC_DEBUGGING))
907 name = (bfd_elf_string_from_elf_section
909 elf_elfheader (abfd)->e_shstrndx,
910 elf_section_data (sec)->rel_hdr.sh_name));
914 BFD_ASSERT (strncmp (name, ".rela", 5) == 0
915 && strcmp (bfd_get_section_name (abfd, sec),
918 sreloc = bfd_get_section_by_name (dynobj, name);
923 sreloc = bfd_make_section (dynobj, name);
924 flags = (SEC_HAS_CONTENTS | SEC_READONLY
925 | SEC_IN_MEMORY | SEC_LINKER_CREATED);
926 if ((sec->flags & SEC_ALLOC) != 0)
927 flags |= SEC_ALLOC | SEC_LOAD;
929 || ! bfd_set_section_flags (dynobj, sreloc, flags)
930 || ! bfd_set_section_alignment (dynobj, sreloc, 3))
935 sreloc->_raw_size += sizeof (Elf64_External_Rela);
939 case R_SPARC_REGISTER:
944 (*_bfd_error_handler)("%s: check_relocs: unhandled reloc type %d",
945 bfd_get_filename(abfd),
946 ELF64_R_TYPE (rel->r_info));
954 /* Adjust a symbol defined by a dynamic object and referenced by a
955 regular object. The current definition is in some section of the
956 dynamic object, but we're not including those sections. We have to
957 change the definition to something the rest of the link can
961 sparc64_elf_adjust_dynamic_symbol (info, h)
962 struct bfd_link_info *info;
963 struct elf_link_hash_entry *h;
967 unsigned int power_of_two;
969 dynobj = elf_hash_table (info)->dynobj;
971 /* Make sure we know what is going on here. */
972 BFD_ASSERT (dynobj != NULL
973 && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
974 || h->weakdef != NULL
975 || ((h->elf_link_hash_flags
976 & ELF_LINK_HASH_DEF_DYNAMIC) != 0
977 && (h->elf_link_hash_flags
978 & ELF_LINK_HASH_REF_REGULAR) != 0
979 && (h->elf_link_hash_flags
980 & ELF_LINK_HASH_DEF_REGULAR) == 0)));
982 /* If this is a function, put it in the procedure linkage table. We
983 will fill in the contents of the procedure linkage table later
984 (although we could actually do it here). The STT_NOTYPE
985 condition is a hack specifically for the Oracle libraries
986 delivered for Solaris; for some inexplicable reason, they define
987 some of their functions as STT_NOTYPE when they really should be
989 if (h->type == STT_FUNC
990 || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0
991 || (h->type == STT_NOTYPE
992 && (h->root.type == bfd_link_hash_defined
993 || h->root.type == bfd_link_hash_defweak)
994 && (h->root.u.def.section->flags & SEC_CODE) != 0))
996 if (! elf_hash_table (info)->dynamic_sections_created)
998 /* This case can occur if we saw a WPLT30 reloc in an input
999 file, but none of the input files were dynamic objects.
1000 In such a case, we don't actually need to build a
1001 procedure linkage table, and we can just do a WDISP30
1003 BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
1007 s = bfd_get_section_by_name (dynobj, ".plt");
1008 BFD_ASSERT (s != NULL);
1010 /* The first four bit in .plt is reserved. */
1011 if (s->_raw_size == 0)
1012 s->_raw_size = PLT_HEADER_SIZE;
1014 /* If this symbol is not defined in a regular file, and we are
1015 not generating a shared library, then set the symbol to this
1016 location in the .plt. This is required to make function
1017 pointers compare as equal between the normal executable and
1018 the shared library. */
1020 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
1022 h->root.u.def.section = s;
1023 h->root.u.def.value = s->_raw_size;
1026 h->plt_offset = s->_raw_size;
1028 /* Make room for this entry. */
1029 s->_raw_size += PLT_ENTRY_SIZE;
1031 /* We also need to make an entry in the .got.plt section, which
1032 will be placed in the .got section by the linker script. */
1034 s = bfd_get_section_by_name (dynobj, ".got.plt");
1035 BFD_ASSERT (s != NULL);
1038 /* We also need to make an entry in the .rela.plt section. */
1040 s = bfd_get_section_by_name (dynobj, ".rela.plt");
1041 BFD_ASSERT (s != NULL);
1042 s->_raw_size += sizeof (Elf64_External_Rela);
1044 /* The procedure linkage table size is bounded by the magnitude
1045 of the offset we can describe in the entry. */
1046 if (s->_raw_size >= (bfd_vma)1 << 32)
1048 bfd_set_error (bfd_error_bad_value);
1055 /* If this is a weak symbol, and there is a real definition, the
1056 processor independent code will have arranged for us to see the
1057 real definition first, and we can just use the same value. */
1058 if (h->weakdef != NULL)
1060 BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
1061 || h->weakdef->root.type == bfd_link_hash_defweak);
1062 h->root.u.def.section = h->weakdef->root.u.def.section;
1063 h->root.u.def.value = h->weakdef->root.u.def.value;
1067 /* This is a reference to a symbol defined by a dynamic object which
1068 is not a function. */
1070 /* If we are creating a shared library, we must presume that the
1071 only references to the symbol are via the global offset table.
1072 For such cases we need not do anything here; the relocations will
1073 be handled correctly by relocate_section. */
1077 /* We must allocate the symbol in our .dynbss section, which will
1078 become part of the .bss section of the executable. There will be
1079 an entry for this symbol in the .dynsym section. The dynamic
1080 object will contain position independent code, so all references
1081 from the dynamic object to this symbol will go through the global
1082 offset table. The dynamic linker will use the .dynsym entry to
1083 determine the address it must put in the global offset table, so
1084 both the dynamic object and the regular object will refer to the
1085 same memory location for the variable. */
1087 s = bfd_get_section_by_name (dynobj, ".dynbss");
1088 BFD_ASSERT (s != NULL);
1090 /* We must generate a R_SPARC_COPY reloc to tell the dynamic linker
1091 to copy the initial value out of the dynamic object and into the
1092 runtime process image. We need to remember the offset into the
1093 .rel.bss section we are going to use. */
1094 if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
1098 srel = bfd_get_section_by_name (dynobj, ".rela.bss");
1099 BFD_ASSERT (srel != NULL);
1100 srel->_raw_size += sizeof (Elf64_External_Rela);
1101 h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
1104 /* We need to figure out the alignment required for this symbol. I
1105 have no idea how ELF linkers handle this. 16-bytes is the size
1106 of the largest type that requires hard alignment -- long double. */
1107 power_of_two = bfd_log2 (h->size);
1108 if (power_of_two > 4)
1111 /* Apply the required alignment. */
1112 s->_raw_size = BFD_ALIGN (s->_raw_size,
1113 (bfd_size_type) (1 << power_of_two));
1114 if (power_of_two > bfd_get_section_alignment (dynobj, s))
1116 if (! bfd_set_section_alignment (dynobj, s, power_of_two))
1120 /* Define the symbol as being at this point in the section. */
1121 h->root.u.def.section = s;
1122 h->root.u.def.value = s->_raw_size;
1124 /* Increment the section size to make room for the symbol. */
1125 s->_raw_size += h->size;
1130 /* Set the sizes of the dynamic sections. */
1133 sparc64_elf_size_dynamic_sections (output_bfd, info)
1135 struct bfd_link_info *info;
1142 dynobj = elf_hash_table (info)->dynobj;
1143 BFD_ASSERT (dynobj != NULL);
1145 if (elf_hash_table (info)->dynamic_sections_created)
1147 /* Set the contents of the .interp section to the interpreter. */
1150 s = bfd_get_section_by_name (dynobj, ".interp");
1151 BFD_ASSERT (s != NULL);
1152 s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
1153 s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
1158 /* We may have created entries in the .rela.got section.
1159 However, if we are not creating the dynamic sections, we will
1160 not actually use these entries. Reset the size of .rela.got,
1161 which will cause it to get stripped from the output file
1163 s = bfd_get_section_by_name (dynobj, ".rela.got");
1168 /* The check_relocs and adjust_dynamic_symbol entry points have
1169 determined the sizes of the various dynamic sections. Allocate
1173 for (s = dynobj->sections; s != NULL; s = s->next)
1178 if ((s->flags & SEC_LINKER_CREATED) == 0)
1181 /* It's OK to base decisions on the section name, because none
1182 of the dynobj section names depend upon the input files. */
1183 name = bfd_get_section_name (dynobj, s);
1187 if (strncmp (name, ".rela", 5) == 0)
1189 if (s->_raw_size == 0)
1191 /* If we don't need this section, strip it from the
1192 output file. This is to handle .rela.bss and
1193 .rel.plt. We must create it in
1194 create_dynamic_sections, because it must be created
1195 before the linker maps input sections to output
1196 sections. The linker does that before
1197 adjust_dynamic_symbol is called, and it is that
1198 function which decides whether anything needs to go
1199 into these sections. */
1204 const char *outname;
1207 /* If this relocation section applies to a read only
1208 section, then we probably need a DT_TEXTREL entry. */
1209 outname = bfd_get_section_name (output_bfd,
1211 target = bfd_get_section_by_name (output_bfd, outname + 5);
1213 && (target->flags & SEC_READONLY) != 0)
1216 if (strcmp (name, ".rela.plt") == 0)
1219 /* We use the reloc_count field as a counter if we need
1220 to copy relocs into the output file. */
1224 else if (strcmp (name, ".plt") != 0
1225 && strncmp (name, ".got", 4) != 0)
1227 /* It's not one of our sections, so don't allocate space. */
1235 for (spp = &s->output_section->owner->sections;
1236 *spp != s->output_section;
1237 spp = &(*spp)->next)
1239 *spp = s->output_section->next;
1240 --s->output_section->owner->section_count;
1245 /* Allocate memory for the section contents. */
1246 s->contents = (bfd_byte *) bfd_alloc (dynobj, s->_raw_size);
1247 if (s->contents == NULL && s->_raw_size != 0)
1251 if (elf_hash_table (info)->dynamic_sections_created)
1253 /* Add some entries to the .dynamic section. We fill in the
1254 values later, in sparc64_elf_finish_dynamic_sections, but we
1255 must add the entries now so that we get the correct size for
1256 the .dynamic section. The DT_DEBUG entry is filled in by the
1257 dynamic linker and used by the debugger. */
1260 if (! bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0))
1266 if (! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0)
1267 || ! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0)
1268 || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
1269 || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0)
1270 || ! bfd_elf64_add_dynamic_entry (info, DT_SPARC_PLTFMT,
1271 (info->shared != 0) + 1))
1275 if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0)
1276 || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0)
1277 || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT,
1278 sizeof (Elf64_External_Rela)))
1283 if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
1288 /* If we are generating a shared library, we generate a section
1289 symbol for each output section for which we might need to copy
1290 relocs. These are local symbols, which means that they must come
1291 first in the dynamic symbol table. That means we must increment
1292 the dynamic symbol index of every other dynamic symbol. */
1298 for (s = output_bfd->sections; s != NULL; s = s->next)
1300 if ((s->flags & SEC_LINKER_CREATED) != 0
1301 || (s->flags & SEC_ALLOC) == 0)
1304 elf_section_data (s)->dynindx = c + 1;
1306 /* These symbols will have no names, so we don't need to
1307 fiddle with dynstr_index. */
1312 elf_link_hash_traverse (elf_hash_table (info),
1313 sparc64_elf_adjust_dynindx,
1315 elf_hash_table (info)->dynsymcount += c;
1321 /* Increment the index of a dynamic symbol by a given amount. Called
1322 via elf_link_hash_traverse. */
1325 sparc64_elf_adjust_dynindx (h, cparg)
1326 struct elf_link_hash_entry *h;
1329 int *cp = (int *) cparg;
1331 if (h->dynindx != -1)
1337 /* Relocate a SPARC64 ELF section. */
1340 sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section,
1341 contents, relocs, local_syms, local_sections)
1343 struct bfd_link_info *info;
1345 asection *input_section;
1347 Elf_Internal_Rela *relocs;
1348 Elf_Internal_Sym *local_syms;
1349 asection **local_sections;
1352 Elf_Internal_Shdr *symtab_hdr;
1353 struct elf_link_hash_entry **sym_hashes;
1354 bfd_vma *local_got_offsets;
1359 Elf_Internal_Rela *rel;
1360 Elf_Internal_Rela *relend;
1362 dynobj = elf_hash_table (info)->dynobj;
1363 symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
1364 sym_hashes = elf_sym_hashes (input_bfd);
1365 local_got_offsets = elf_local_got_offsets (input_bfd);
1367 if (elf_hash_table(info)->hgot == NULL)
1370 got_base = elf_hash_table (info)->hgot->root.u.def.value;
1372 sgot = splt = sreloc = NULL;
1375 relend = relocs + input_section->reloc_count;
1376 for (; rel < relend; rel++)
1379 reloc_howto_type *howto;
1381 struct elf_link_hash_entry *h;
1382 Elf_Internal_Sym *sym;
1385 bfd_reloc_status_type r;
1387 r_type = ELF64_R_TYPE (rel->r_info);
1388 if (r_type < 0 || r_type >= (int) R_SPARC_max)
1390 bfd_set_error (bfd_error_bad_value);
1393 howto = sparc64_elf_howto_table + r_type;
1395 r_symndx = ELF64_R_SYM (rel->r_info);
1397 if (info->relocateable)
1399 /* This is a relocateable link. We don't have to change
1400 anything, unless the reloc is against a section symbol,
1401 in which case we have to adjust according to where the
1402 section symbol winds up in the output section. */
1403 if (r_symndx < symtab_hdr->sh_info)
1405 sym = local_syms + r_symndx;
1406 if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
1408 sec = local_sections[r_symndx];
1409 rel->r_addend += sec->output_offset + sym->st_value;
1416 /* This is a final link. */
1420 if (r_symndx < symtab_hdr->sh_info)
1422 sym = local_syms + r_symndx;
1423 sec = local_sections[r_symndx];
1424 relocation = (sec->output_section->vma
1425 + sec->output_offset
1430 h = sym_hashes[r_symndx - symtab_hdr->sh_info];
1431 while (h->root.type == bfd_link_hash_indirect
1432 || h->root.type == bfd_link_hash_warning)
1433 h = (struct elf_link_hash_entry *) h->root.u.i.link;
1434 if (h->root.type == bfd_link_hash_defined
1435 || h->root.type == bfd_link_hash_defweak)
1437 boolean skip_it = false;
1438 sec = h->root.u.def.section;
1442 case R_SPARC_WPLT30:
1444 case R_SPARC_HIPLT22:
1445 case R_SPARC_LOPLT10:
1446 case R_SPARC_PCPLT32:
1447 case R_SPARC_PCPLT22:
1448 case R_SPARC_PCPLT10:
1450 if (h->plt_offset != (bfd_vma) -1)
1457 if (elf_hash_table(info)->dynamic_sections_created
1459 || (!info->symbolic && h->dynindx != -1)
1460 || !(h->elf_link_hash_flags
1461 & ELF_LINK_HASH_DEF_REGULAR)))
1467 case R_SPARC_PC_HH22:
1468 case R_SPARC_PC_HM10:
1469 case R_SPARC_PC_LM22:
1470 if (!strcmp(h->root.root.string, "_GLOBAL_OFFSET_TABLE_"))
1478 case R_SPARC_DISP16:
1479 case R_SPARC_DISP32:
1480 case R_SPARC_WDISP30:
1481 case R_SPARC_WDISP22:
1494 case R_SPARC_WDISP19:
1495 case R_SPARC_WDISP16:
1499 case R_SPARC_DISP64:
1508 && ((!info->symbolic && h->dynindx != -1)
1509 || !(h->elf_link_hash_flags
1510 & ELF_LINK_HASH_DEF_REGULAR)))
1517 /* In these cases, we don't need the relocation
1518 value. We check specially because in some
1519 obscure cases sec->output_section will be NULL. */
1524 relocation = (h->root.u.def.value
1525 + sec->output_section->vma
1526 + sec->output_offset);
1529 else if (h->root.type == bfd_link_hash_undefweak)
1531 else if (info->shared && !info->symbolic)
1535 if (! ((*info->callbacks->undefined_symbol)
1536 (info, h->root.root.string, input_bfd,
1537 input_section, rel->r_offset)))
1543 /* When generating a shared object, these relocations are copied
1544 into the output file to be resolved at run time. */
1545 if (info->shared && !(input_section->flags & SEC_DEBUGGING))
1551 case R_SPARC_PC_HH22:
1552 case R_SPARC_PC_HM10:
1553 case R_SPARC_PC_LM22:
1555 && !strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_"))
1559 case R_SPARC_DISP16:
1560 case R_SPARC_DISP32:
1561 case R_SPARC_WDISP30:
1562 case R_SPARC_WDISP22:
1563 case R_SPARC_WDISP19:
1564 case R_SPARC_WDISP16:
1565 case R_SPARC_DISP64:
1595 Elf_Internal_Rela outrel;
1601 (bfd_elf_string_from_elf_section
1603 elf_elfheader (input_bfd)->e_shstrndx,
1604 elf_section_data (input_section)->rel_hdr.sh_name));
1609 BFD_ASSERT (strncmp (name, ".rela", 5) == 0
1610 && strcmp (bfd_get_section_name(input_bfd,
1614 sreloc = bfd_get_section_by_name (dynobj, name);
1615 BFD_ASSERT (sreloc != NULL);
1620 if (elf_section_data (input_section)->stab_info == NULL)
1621 outrel.r_offset = rel->r_offset;
1626 off = (_bfd_stab_section_offset
1627 (output_bfd, &elf_hash_table (info)->stab_info,
1629 &elf_section_data (input_section)->stab_info,
1631 if (off == MINUS_ONE)
1633 outrel.r_offset = off;
1636 outrel.r_offset += (input_section->output_section->vma
1637 + input_section->output_offset);
1639 /* Optimize unaligned reloc usage now that we know where
1640 it finally resides. */
1644 if (outrel.r_offset & 1) r_type = R_SPARC_UA16;
1647 if (!(outrel.r_offset & 1)) r_type = R_SPARC_16;
1650 if (outrel.r_offset & 3) r_type = R_SPARC_UA32;
1653 if (!(outrel.r_offset & 3)) r_type = R_SPARC_32;
1656 if (outrel.r_offset & 7) r_type = R_SPARC_UA64;
1659 if (!(outrel.r_offset & 7)) r_type = R_SPARC_64;
1664 memset (&outrel, 0, sizeof outrel);
1665 /* h->dynindx may be -1 if the symbol was marked to
1668 && ((! info->symbolic && h->dynindx != -1)
1669 || (h->elf_link_hash_flags
1670 & ELF_LINK_HASH_DEF_REGULAR) == 0))
1672 BFD_ASSERT (h->dynindx != -1);
1673 outrel.r_info = ELF64_R_INFO (h->dynindx, r_type);
1674 outrel.r_addend = rel->r_addend;
1678 if (r_type == R_SPARC_64)
1680 outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
1681 outrel.r_addend = relocation + rel->r_addend;
1688 sec = local_sections[r_symndx];
1691 BFD_ASSERT (h->root.type == bfd_link_hash_defined
1693 == bfd_link_hash_defweak));
1694 sec = h->root.u.def.section;
1696 if (sec != NULL && bfd_is_abs_section (sec))
1698 else if (sec == NULL || sec->owner == NULL)
1700 bfd_set_error (bfd_error_bad_value);
1707 osec = sec->output_section;
1708 indx = elf_section_data (osec)->dynindx;
1709 BFD_ASSERT (indx > 0);
1712 outrel.r_info = ELF64_R_INFO (indx, r_type);
1713 outrel.r_addend = relocation + rel->r_addend;
1717 bfd_elf64_swap_reloca_out (output_bfd, &outrel,
1718 (((Elf64_External_Rela *)
1720 + sreloc->reloc_count));
1721 ++sreloc->reloc_count;
1723 /* This reloc will be computed at runtime, so there's no
1724 need to do anything now, unless this is a RELATIVE
1725 reloc in an unallocated section. */
1727 || (input_section->flags & SEC_ALLOC) != 0
1728 || ELF64_R_TYPE (outrel.r_info) != R_SPARC_RELATIVE)
1740 /* Relocation is to the entry for this symbol in the global
1744 sgot = bfd_get_section_by_name (dynobj, ".got");
1745 BFD_ASSERT (sgot != NULL);
1750 bfd_vma off = h->got_offset;
1751 BFD_ASSERT (off != (bfd_vma) -1);
1753 if (! elf_hash_table (info)->dynamic_sections_created
1755 && (info->symbolic || h->dynindx == -1)
1756 && (h->elf_link_hash_flags
1757 & ELF_LINK_HASH_DEF_REGULAR)))
1759 /* This is actually a static link, or it is a -Bsymbolic
1760 link and the symbol is defined locally, or the symbol
1761 was forced to be local because of a version file. We
1762 must initialize this entry in the global offset table.
1763 Since the offset must always be a multiple of 8, we
1764 use the least significant bit to record whether we
1765 have initialized it already.
1767 When doing a dynamic link, we create a .rela.got
1768 relocation entry to initialize the value. This is
1769 done in the finish_dynamic_symbol routine. */
1775 bfd_put_64 (output_bfd, relocation,
1776 sgot->contents + off);
1780 relocation = sgot->output_offset + off - got_base;
1786 BFD_ASSERT (local_got_offsets != NULL);
1787 off = local_got_offsets[r_symndx];
1788 BFD_ASSERT (off != (bfd_vma) -1);
1790 /* The offset must always be a multiple of 8. We use
1791 the least significant bit to record whether we have
1792 already processed this entry. */
1797 bfd_put_64 (output_bfd, relocation, sgot->contents + off);
1798 local_got_offsets[r_symndx] |= 1;
1803 Elf_Internal_Rela outrel;
1805 /* We need to generate a R_SPARC_RELATIVE reloc
1806 for the dynamic linker. */
1807 srelgot = bfd_get_section_by_name(dynobj, ".rela.got");
1808 BFD_ASSERT (srelgot != NULL);
1810 outrel.r_offset = (sgot->output_section->vma
1811 + sgot->output_offset
1813 outrel.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
1814 outrel.r_addend = relocation;
1815 bfd_elf64_swap_reloca_out (output_bfd, &outrel,
1816 (((Elf64_External_Rela *)
1818 + srelgot->reloc_count));
1819 ++srelgot->reloc_count;
1822 relocation = sgot->output_offset + off - got_base;
1826 case R_SPARC_WPLT30:
1828 case R_SPARC_HIPLT22:
1829 case R_SPARC_LOPLT10:
1830 case R_SPARC_PCPLT32:
1831 case R_SPARC_PCPLT22:
1832 case R_SPARC_PCPLT10:
1834 /* Relocation is to the entry for this symbol in the
1835 procedure linkage table. */
1836 BFD_ASSERT (h != NULL);
1838 if (h->plt_offset == (bfd_vma) -1)
1840 /* We didn't make a PLT entry for this symbol. This
1841 happens when statically linking PIC code, or when
1842 using -Bsymbolic. */
1848 splt = bfd_get_section_by_name (dynobj, ".plt");
1849 BFD_ASSERT (splt != NULL);
1852 relocation = (splt->output_section->vma
1853 + splt->output_offset
1861 relocation += rel->r_addend;
1862 relocation = (relocation & 0x3ff) + ELF64_R_TYPE_DATA (rel->r_info);
1864 x = bfd_get_32 (input_bfd, contents + rel->r_offset);
1865 x = (x & ~0x1fff) | (relocation & 0x1fff);
1866 bfd_put_32 (input_bfd, x, contents + rel->r_offset);
1868 r = bfd_check_overflow (howto->complain_on_overflow,
1869 howto->bitsize, howto->rightshift,
1874 case R_SPARC_WDISP16:
1878 relocation += rel->r_addend;
1879 /* Adjust for pc-relative-ness. */
1880 relocation -= (input_section->output_section->vma
1881 + input_section->output_offset);
1882 relocation -= rel->r_offset;
1884 x = bfd_get_32 (input_bfd, contents + rel->r_offset);
1885 x = (x & ~0x303fff) | ((((relocation >> 2) & 0xc000) << 6)
1886 | ((relocation >> 2) & 0x3fff));
1887 bfd_put_32 (input_bfd, x, contents + rel->r_offset);
1889 r = bfd_check_overflow (howto->complain_on_overflow,
1890 howto->bitsize, howto->rightshift,
1899 relocation += rel->r_addend;
1900 relocation = relocation ^ MINUS_ONE;
1902 x = bfd_get_32 (input_bfd, contents + rel->r_offset);
1903 x = (x & ~0x3fffff) | ((relocation >> 10) & 0x3fffff);
1904 bfd_put_32 (input_bfd, x, contents + rel->r_offset);
1906 r = bfd_check_overflow (howto->complain_on_overflow,
1907 howto->bitsize, howto->rightshift,
1916 relocation += rel->r_addend;
1917 relocation = (relocation & 0x3ff) | 0x1c00;
1919 x = bfd_get_32 (input_bfd, contents + rel->r_offset);
1920 x = (x & ~0x1fff) | relocation;
1921 bfd_put_32 (input_bfd, x, contents + rel->r_offset);
1929 r = _bfd_final_link_relocate (howto, input_bfd, input_section,
1930 contents, rel->r_offset,
1931 relocation, rel->r_addend);
1941 case bfd_reloc_outofrange:
1944 case bfd_reloc_overflow:
1950 if (h->root.type == bfd_link_hash_undefweak
1951 && howto->pc_relative)
1953 /* Assume this is a call protected by other code that
1954 detect the symbol is undefined. If this is the case,
1955 we can safely ignore the overflow. If not, the
1956 program is hosed anyway, and a little warning isn't
1961 name = h->root.root.string;
1965 name = (bfd_elf_string_from_elf_section
1967 symtab_hdr->sh_link,
1972 name = bfd_section_name (input_bfd, sec);
1974 if (! ((*info->callbacks->reloc_overflow)
1975 (info, name, howto->name, (bfd_vma) 0,
1976 input_bfd, input_section, rel->r_offset)))
1986 /* Finish up dynamic symbol handling. We set the contents of various
1987 dynamic sections here. */
1990 sparc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym)
1992 struct bfd_link_info *info;
1993 struct elf_link_hash_entry *h;
1994 Elf_Internal_Sym *sym;
1998 dynobj = elf_hash_table (info)->dynobj;
2000 if (h->plt_offset != (bfd_vma) -1)
2005 Elf_Internal_Rela rela;
2007 bfd_vma plt0, pltN, got0, gotN, plt_index, got_offset;
2008 const struct plt_template *plt_tmpl;
2010 /* This symbol has an entry in the procedure linkage table. Set
2013 BFD_ASSERT (h->dynindx != -1);
2015 splt = bfd_get_section_by_name (dynobj, ".plt");
2016 sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
2017 srela = bfd_get_section_by_name (dynobj, ".rela.plt");
2018 BFD_ASSERT (splt != NULL && sgotplt != NULL && srela != NULL);
2020 /* Fill in the various values the plt entry might care about,
2021 as detailed above. */
2023 plt0 = splt->output_section->vma + splt->output_offset;
2024 pltN = plt0 + h->plt_offset;
2025 plt_index = h->plt_offset / PLT_ENTRY_SIZE - 1;
2026 got0 = sgotplt->output_section->vma + sgotplt->output_offset;
2027 got_offset = (plt_index + GOT_RESERVED_ENTRIES) * 8;
2028 gotN = got0 + got_offset;
2031 values[1] = got0 - plt0;
2032 values[5] = got_offset;
2034 values[3] = gotN - pltN;
2035 values[4] = plt_index * sizeof(Elf64_External_Rela);
2037 /* Fill in the entry in the procedure linkage table. */
2040 if (got_offset < 0x1000)
2041 plt_tmpl = &plt_pic_small_entry;
2043 plt_tmpl = &plt_pic_large_entry;
2045 /* FIXME -- learn how to select code models here. */
2046 plt_tmpl = &plt_medany_entry;
2048 sparc64_elf_build_plt_entry(output_bfd, splt->contents + h->plt_offset,
2053 /* We also need to fill in the plt header, but we only need to
2054 do it once. Choose to do it while we do the first plt entry. */
2056 sparc64_elf_build_plt_entry(output_bfd, splt->contents,
2059 : &plt_medany_header),
2063 /* Fill in the entry in the .got.plt section. */
2065 bfd_put_64 (output_bfd, (info->shared ? plt0-got0 : plt0),
2066 sgotplt->contents + got_offset);
2068 /* Fill in the entry in the .rela.plt section. */
2070 rela.r_offset = gotN;
2071 rela.r_info = ELF64_R_INFO (h->dynindx, R_SPARC_JMP_SLOT);
2073 bfd_elf64_swap_reloca_out (output_bfd, &rela,
2074 ((Elf64_External_Rela *) srela->contents
2077 if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
2079 /* Mark the symbol as undefined, rather than as defined in
2080 the .plt section. Leave the value alone. */
2081 sym->st_shndx = SHN_UNDEF;
2085 if (h->got_offset != (bfd_vma) -1)
2089 Elf_Internal_Rela rela;
2091 /* This symbol has an entry in the global offset table. Set it
2094 sgot = bfd_get_section_by_name (dynobj, ".got");
2095 srela = bfd_get_section_by_name (dynobj, ".rela.got");
2096 BFD_ASSERT (sgot != NULL && srela != NULL);
2098 rela.r_offset = (sgot->output_section->vma
2099 + sgot->output_offset
2100 + (h->got_offset &~ 1));
2102 /* If this is a -Bsymbolic link, and the symbol is defined
2103 locally, we just want to emit a RELATIVE reloc. Likewise if
2104 the symbol was forced to be local because of a version file.
2105 The entry in the global offset table will already have been
2106 initialized in the relocate_section function. */
2108 && (info->symbolic || h->dynindx == -1)
2109 && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
2111 asection *sec = h->root.u.def.section;
2112 rela.r_info = ELF64_R_INFO (0, R_SPARC_RELATIVE);
2113 rela.r_addend = (h->root.u.def.value
2114 + sec->output_section->vma
2115 + sec->output_offset);
2119 bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents + h->got_offset);
2120 rela.r_info = ELF64_R_INFO (h->dynindx, R_SPARC_GLOB_DAT);
2124 bfd_elf64_swap_reloca_out (output_bfd, &rela,
2125 ((Elf64_External_Rela *) srela->contents
2126 + srela->reloc_count));
2127 ++srela->reloc_count;
2130 if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
2133 Elf_Internal_Rela rela;
2135 /* This symbols needs a copy reloc. Set it up. */
2137 BFD_ASSERT (h->dynindx != -1);
2139 s = bfd_get_section_by_name (h->root.u.def.section->owner,
2141 BFD_ASSERT (s != NULL);
2143 rela.r_offset = (h->root.u.def.value
2144 + h->root.u.def.section->output_section->vma
2145 + h->root.u.def.section->output_offset);
2146 rela.r_info = ELF64_R_INFO (h->dynindx, R_SPARC_COPY);
2148 bfd_elf64_swap_reloca_out (output_bfd, &rela,
2149 ((Elf64_External_Rela *) s->contents
2154 /* Mark some specially defined symbols as absolute. */
2155 if (strcmp (h->root.root.string, "_DYNAMIC") == 0
2156 || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0
2157 || strcmp (h->root.root.string, "_PROCEDURE_LINKAGE_TABLE_") == 0)
2158 sym->st_shndx = SHN_ABS;
2163 /* Finish up the dynamic sections. */
2166 sparc64_elf_finish_dynamic_sections (output_bfd, info)
2168 struct bfd_link_info *info;
2174 dynobj = elf_hash_table (info)->dynobj;
2176 sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
2178 if (elf_hash_table (info)->dynamic_sections_created)
2181 Elf64_External_Dyn *dyncon, *dynconend;
2183 splt = bfd_get_section_by_name (dynobj, ".plt");
2184 BFD_ASSERT (splt != NULL && sdyn != NULL);
2186 dyncon = (Elf64_External_Dyn *) sdyn->contents;
2187 dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
2188 for (; dyncon < dynconend; dyncon++)
2190 Elf_Internal_Dyn dyn;
2194 bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
2198 case DT_PLTGOT: name = ".got"; size = false; break;
2199 case DT_PLTRELSZ: name = ".rela.plt"; size = true; break;
2200 case DT_JMPREL: name = ".rela.plt"; size = false; break;
2201 default: name = NULL; size = false; break;
2208 s = bfd_get_section_by_name (output_bfd, name);
2214 dyn.d_un.d_ptr = s->vma;
2217 if (s->_cooked_size != 0)
2218 dyn.d_un.d_val = s->_cooked_size;
2220 dyn.d_un.d_val = s->_raw_size;
2223 bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
2227 elf_section_data (splt->output_section)->this_hdr.sh_entsize =
2231 /* Set the first entry in the global offset table to the address of
2232 the dynamic section. */
2233 sgot = bfd_get_section_by_name (dynobj, ".got.plt");
2234 BFD_ASSERT (sgot != NULL);
2235 if (sgot->_raw_size > 0)
2238 bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents);
2240 bfd_put_64 (output_bfd,
2241 sdyn->output_section->vma + sdyn->output_offset,
2245 elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 8;
2251 Elf_Internal_Sym sym;
2254 /* Set up the section symbols for the output sections. */
2256 sdynsym = bfd_get_section_by_name (dynobj, ".dynsym");
2257 BFD_ASSERT (sdynsym != NULL);
2261 sym.st_info = ELF_ST_INFO (STB_LOCAL, STT_SECTION);
2265 for (s = output_bfd->sections; s != NULL; s = s->next)
2269 if (elf_section_data (s)->dynindx == 0)
2272 sym.st_value = s->vma;
2274 indx = elf_section_data (s)->this_idx;
2275 BFD_ASSERT (indx > 0);
2276 sym.st_shndx = indx;
2278 bfd_elf64_swap_symbol_out (output_bfd, &sym,
2279 (PTR) (((Elf64_External_Sym *)
2281 + elf_section_data (s)->dynindx));
2286 /* Set the sh_info field of the output .dynsym section to the
2287 index of the first global symbol. */
2288 elf_section_data (sdynsym->output_section)->this_hdr.sh_info = c + 1;
2294 /* Functions for dealing with the e_flags field. */
2296 /* Merge backend specific data from an object file to the output
2297 object file when linking. */
2300 sparc64_elf_merge_private_bfd_data (ibfd, obfd)
2305 flagword new_flags, old_flags;
2308 if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
2309 || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
2312 new_flags = elf_elfheader (ibfd)->e_flags;
2313 old_flags = elf_elfheader (obfd)->e_flags;
2315 if (!elf_flags_init (obfd)) /* First call, no flags set */
2317 elf_flags_init (obfd) = true;
2318 elf_elfheader (obfd)->e_flags = new_flags;
2321 else if (new_flags == old_flags) /* Compatible flags are ok */
2324 else /* Incompatible flags */
2328 old_flags |= (new_flags & (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1));
2329 new_flags |= (old_flags & (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1));
2330 if ((old_flags & (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1)) ==
2331 (EF_SPARC_SUN_US1|EF_SPARC_HAL_R1))
2334 (*_bfd_error_handler)
2335 ("%s: linking UltraSPARC specific with HAL specific code",
2336 bfd_get_filename (ibfd));
2339 /* Choose the most restrictive memory ordering */
2340 old_mm = (old_flags & EF_SPARCV9_MM);
2341 new_mm = (new_flags & EF_SPARCV9_MM);
2342 old_flags &= ~EF_SPARCV9_MM;
2343 new_flags &= ~EF_SPARCV9_MM;
2344 if (new_mm < old_mm) old_mm = new_mm;
2345 old_flags |= old_mm;
2346 new_flags |= old_mm;
2348 /* Warn about any other mismatches */
2349 if (new_flags != old_flags)
2352 (*_bfd_error_handler)
2353 ("%s: uses different e_flags (0x%lx) fields than previous modules (0x%lx)",
2354 bfd_get_filename (ibfd), (long)new_flags, (long)old_flags);
2357 elf_elfheader (obfd)->e_flags = old_flags;
2361 bfd_set_error (bfd_error_bad_value);
2369 /* Set the right machine number for a SPARC64 ELF file. */
2372 sparc64_elf_object_p (abfd)
2375 unsigned long mach = bfd_mach_sparc_v9;
2377 if (elf_elfheader (abfd)->e_flags & EF_SPARC_SUN_US1)
2378 mach = bfd_mach_sparc_v9a;
2379 return bfd_default_set_arch_mach (abfd, bfd_arch_sparc, mach);
2382 #define TARGET_BIG_SYM bfd_elf64_sparc_vec
2383 #define TARGET_BIG_NAME "elf64-sparc"
2384 #define ELF_ARCH bfd_arch_sparc
2385 #define ELF_MACHINE_CODE EM_SPARC64
2386 #define ELF_MAXPAGESIZE 0x100000
2388 #define elf_info_to_howto \
2389 sparc64_elf_info_to_howto
2390 #define bfd_elf64_bfd_reloc_type_lookup \
2391 sparc64_elf_reloc_type_lookup
2393 #define elf_backend_create_dynamic_sections \
2394 _bfd_elf_create_dynamic_sections
2395 #define elf_backend_check_relocs \
2396 sparc64_elf_check_relocs
2397 #define elf_backend_adjust_dynamic_symbol \
2398 sparc64_elf_adjust_dynamic_symbol
2399 #define elf_backend_size_dynamic_sections \
2400 sparc64_elf_size_dynamic_sections
2401 #define elf_backend_relocate_section \
2402 sparc64_elf_relocate_section
2403 #define elf_backend_finish_dynamic_symbol \
2404 sparc64_elf_finish_dynamic_symbol
2405 #define elf_backend_finish_dynamic_sections \
2406 sparc64_elf_finish_dynamic_sections
2408 #define bfd_elf64_bfd_merge_private_bfd_data \
2409 sparc64_elf_merge_private_bfd_data
2411 #define elf_backend_object_p \
2412 sparc64_elf_object_p
2414 #define elf_backend_want_got_plt 1
2415 #define elf_backend_plt_readonly 1
2416 #define elf_backend_want_plt_sym 1
2417 #define elf_backend_plt_alignment 5
2419 #include "elf64-target.h"