1 | /* SuperH SH64-specific support for 64-bit ELF
|
---|
2 | Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
---|
3 |
|
---|
4 | This file is part of BFD, the Binary File Descriptor library.
|
---|
5 |
|
---|
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.
|
---|
10 |
|
---|
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.
|
---|
15 |
|
---|
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. */
|
---|
19 |
|
---|
20 | #define SH64_ELF64
|
---|
21 |
|
---|
22 | #include "bfd.h"
|
---|
23 | #include "sysdep.h"
|
---|
24 | #include "bfdlink.h"
|
---|
25 | #include "libbfd.h"
|
---|
26 | #include "elf-bfd.h"
|
---|
27 | #include "elf/sh.h"
|
---|
28 |
|
---|
29 | /* Add a suffix for datalabel indirection symbols. It must not match any
|
---|
30 | other symbols; user symbols with or without version or other
|
---|
31 | decoration. It must only be used internally and not emitted by any
|
---|
32 | means. */
|
---|
33 | #define DATALABEL_SUFFIX " DL"
|
---|
34 |
|
---|
35 | #define GOT_BIAS (-((long)-32768))
|
---|
36 |
|
---|
37 | #define PLT_ENTRY_SIZE 64
|
---|
38 |
|
---|
39 | /* Return size of a PLT entry. */
|
---|
40 | #define elf_sh64_sizeof_plt(info) PLT_ENTRY_SIZE
|
---|
41 |
|
---|
42 | /* Return offset of the PLT0 address in an absolute PLT entry. */
|
---|
43 | #define elf_sh64_plt_plt0_offset(info) 32
|
---|
44 |
|
---|
45 | /* Return offset of the linker in PLT0 entry. */
|
---|
46 | #define elf_sh64_plt0_gotplt_offset(info) 0
|
---|
47 |
|
---|
48 | /* Return offset of the trampoline in PLT entry */
|
---|
49 | #define elf_sh64_plt_temp_offset(info) 33 /* Add one because it's SHmedia. */
|
---|
50 |
|
---|
51 | /* Return offset of the symbol in PLT entry. */
|
---|
52 | #define elf_sh64_plt_symbol_offset(info) 0
|
---|
53 |
|
---|
54 | /* Return offset of the relocation in PLT entry. */
|
---|
55 | #define elf_sh64_plt_reloc_offset(info) (info->shared ? 52 : 44)
|
---|
56 |
|
---|
57 | #define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"
|
---|
58 |
|
---|
59 | /* The sh linker needs to keep track of the number of relocs that it
|
---|
60 | decides to copy in check_relocs for each symbol. This is so that
|
---|
61 | it can discard PC relative relocs if it doesn't need them when
|
---|
62 | linking with -Bsymbolic. We store the information in a field
|
---|
63 | extending the regular ELF linker hash table. */
|
---|
64 |
|
---|
65 | /* This structure keeps track of the number of PC relative relocs we
|
---|
66 | have copied for a given symbol. */
|
---|
67 |
|
---|
68 | struct elf_sh64_pcrel_relocs_copied
|
---|
69 | {
|
---|
70 | /* Next section. */
|
---|
71 | struct elf_sh64_pcrel_relocs_copied *next;
|
---|
72 | /* A section in dynobj. */
|
---|
73 | asection *section;
|
---|
74 | /* Number of relocs copied in this section. */
|
---|
75 | bfd_size_type count;
|
---|
76 | };
|
---|
77 |
|
---|
78 | /* sh ELF linker hash entry. */
|
---|
79 |
|
---|
80 | struct elf_sh64_link_hash_entry
|
---|
81 | {
|
---|
82 | struct elf_link_hash_entry root;
|
---|
83 |
|
---|
84 | bfd_vma datalabel_got_offset;
|
---|
85 |
|
---|
86 | /* Number of PC relative relocs copied for this symbol. */
|
---|
87 | struct elf_sh64_pcrel_relocs_copied *pcrel_relocs_copied;
|
---|
88 | };
|
---|
89 |
|
---|
90 | /* sh ELF linker hash table. */
|
---|
91 |
|
---|
92 | struct elf_sh64_link_hash_table
|
---|
93 | {
|
---|
94 | struct elf_link_hash_table root;
|
---|
95 | };
|
---|
96 |
|
---|
97 | /* Traverse an sh ELF linker hash table. */
|
---|
98 |
|
---|
99 | #define sh64_elf64_link_hash_traverse(table, func, info) \
|
---|
100 | (elf_link_hash_traverse \
|
---|
101 | (&(table)->root, \
|
---|
102 | (bfd_boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func), \
|
---|
103 | (info)))
|
---|
104 |
|
---|
105 | /* Get the sh ELF linker hash table from a link_info structure. */
|
---|
106 |
|
---|
107 | #define sh64_elf64_hash_table(p) \
|
---|
108 | ((struct elf_sh64_link_hash_table *) ((p)->hash))
|
---|
109 |
|
---|
110 | static bfd_boolean sh_elf64_copy_private_data
|
---|
111 | PARAMS ((bfd *, bfd *));
|
---|
112 | static bfd_boolean sh_elf64_copy_private_data_internal
|
---|
113 | PARAMS ((bfd *, bfd *));
|
---|
114 | static bfd_boolean sh_elf64_merge_private_data
|
---|
115 | PARAMS ((bfd *, bfd *));
|
---|
116 | static bfd_reloc_status_type sh_elf64_ignore_reloc
|
---|
117 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
---|
118 | static bfd_reloc_status_type sh_elf64_reloc
|
---|
119 | PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
|
---|
120 | static reloc_howto_type *sh_elf64_reloc_type_lookup
|
---|
121 | PARAMS ((bfd *, bfd_reloc_code_real_type));
|
---|
122 | static void sh_elf64_info_to_howto
|
---|
123 | PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
|
---|
124 | static bfd_boolean sh_elf64_relocate_section
|
---|
125 | PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
---|
126 | Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
|
---|
127 | static bfd_byte *sh_elf64_get_relocated_section_contents
|
---|
128 | PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
|
---|
129 | bfd_byte *, bfd_boolean, asymbol **));
|
---|
130 | static bfd_boolean sh_elf64_set_mach_from_flags
|
---|
131 | PARAMS ((bfd *));
|
---|
132 | static bfd_boolean sh_elf64_set_private_flags
|
---|
133 | PARAMS ((bfd *, flagword));
|
---|
134 | static asection *sh_elf64_gc_mark_hook
|
---|
135 | PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,
|
---|
136 | struct elf_link_hash_entry *, Elf_Internal_Sym *));
|
---|
137 | static bfd_boolean sh_elf64_gc_sweep_hook
|
---|
138 | PARAMS ((bfd *, struct bfd_link_info *, asection *,
|
---|
139 | const Elf_Internal_Rela *));
|
---|
140 | static bfd_boolean sh_elf64_check_relocs
|
---|
141 | PARAMS ((bfd *, struct bfd_link_info *, asection *,
|
---|
142 | const Elf_Internal_Rela *));
|
---|
143 | static int sh64_elf64_get_symbol_type
|
---|
144 | PARAMS ((Elf_Internal_Sym *, int));
|
---|
145 | static bfd_boolean sh64_elf64_add_symbol_hook
|
---|
146 | PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
|
---|
147 | const char **, flagword *, asection **, bfd_vma *));
|
---|
148 | static bfd_boolean sh64_elf64_link_output_symbol_hook
|
---|
149 | PARAMS ((bfd *, struct bfd_link_info *, const char *, Elf_Internal_Sym *,
|
---|
150 | asection *));
|
---|
151 | static bfd_boolean sh64_elf64_fake_sections
|
---|
152 | PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));
|
---|
153 | static void sh64_elf64_final_write_processing
|
---|
154 | PARAMS ((bfd *, bfd_boolean));
|
---|
155 | static struct bfd_hash_entry *sh64_elf64_link_hash_newfunc
|
---|
156 | PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *));
|
---|
157 | static struct bfd_link_hash_table *sh64_elf64_link_hash_table_create
|
---|
158 | PARAMS ((bfd *));
|
---|
159 | inline static void movi_shori_putval
|
---|
160 | PARAMS ((bfd *, unsigned long, char *));
|
---|
161 | inline static void movi_3shori_putval
|
---|
162 | PARAMS ((bfd *, bfd_vma, char *));
|
---|
163 | static bfd_boolean sh64_elf64_create_dynamic_sections
|
---|
164 | PARAMS ((bfd *, struct bfd_link_info *));
|
---|
165 | static bfd_boolean sh64_elf64_adjust_dynamic_symbol
|
---|
166 | PARAMS ((struct bfd_link_info *info, struct elf_link_hash_entry *));
|
---|
167 | static bfd_boolean sh64_elf64_discard_copies
|
---|
168 | PARAMS ((struct elf_sh64_link_hash_entry *, PTR));
|
---|
169 | static bfd_boolean sh64_elf64_size_dynamic_sections
|
---|
170 | PARAMS ((bfd *, struct bfd_link_info *));
|
---|
171 | static bfd_boolean sh64_elf64_finish_dynamic_symbol
|
---|
172 | PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
|
---|
173 | Elf_Internal_Sym *));
|
---|
174 | static bfd_boolean sh64_elf64_finish_dynamic_sections
|
---|
175 | PARAMS ((bfd *, struct bfd_link_info *));
|
---|
176 |
|
---|
177 | static reloc_howto_type sh_elf64_howto_table[] = {
|
---|
178 | /* No relocation. */
|
---|
179 | HOWTO (R_SH_NONE, /* type */
|
---|
180 | 0, /* rightshift */
|
---|
181 | 0, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
182 | 0, /* bitsize */
|
---|
183 | FALSE, /* pc_relative */
|
---|
184 | 0, /* bitpos */
|
---|
185 | complain_overflow_dont, /* complain_on_overflow */
|
---|
186 | sh_elf64_ignore_reloc, /* special_function */
|
---|
187 | "R_SH_NONE", /* name */
|
---|
188 | FALSE, /* partial_inplace */
|
---|
189 | 0, /* src_mask */
|
---|
190 | 0, /* dst_mask */
|
---|
191 | FALSE), /* pcrel_offset */
|
---|
192 |
|
---|
193 | /* 32 bit absolute relocation. Setting partial_inplace to TRUE and
|
---|
194 | src_mask to a non-zero value is similar to the COFF toolchain. */
|
---|
195 | HOWTO (R_SH_DIR32, /* type */
|
---|
196 | 0, /* rightshift */
|
---|
197 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
198 | 32, /* bitsize */
|
---|
199 | FALSE, /* pc_relative */
|
---|
200 | 0, /* bitpos */
|
---|
201 | complain_overflow_bitfield, /* complain_on_overflow */
|
---|
202 | sh_elf64_reloc, /* special_function */
|
---|
203 | "R_SH_DIR32", /* name */
|
---|
204 | TRUE, /* partial_inplace */
|
---|
205 | 0xffffffff, /* src_mask */
|
---|
206 | 0xffffffff, /* dst_mask */
|
---|
207 | FALSE), /* pcrel_offset */
|
---|
208 |
|
---|
209 | /* 32 bit PC relative relocation. */
|
---|
210 | HOWTO (R_SH_REL32, /* type */
|
---|
211 | 0, /* rightshift */
|
---|
212 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
213 | 32, /* bitsize */
|
---|
214 | TRUE, /* pc_relative */
|
---|
215 | 0, /* bitpos */
|
---|
216 | complain_overflow_signed, /* complain_on_overflow */
|
---|
217 | sh_elf64_ignore_reloc, /* special_function */
|
---|
218 | "R_SH_REL32", /* name */
|
---|
219 | FALSE, /* partial_inplace */
|
---|
220 | 0, /* src_mask */
|
---|
221 | 0xffffffff, /* dst_mask */
|
---|
222 | TRUE), /* pcrel_offset */
|
---|
223 |
|
---|
224 | /* For 32-bit sh, this is R_SH_DIR8WPN. */
|
---|
225 | EMPTY_HOWTO (3),
|
---|
226 |
|
---|
227 | /* For 32-bit sh, this is R_SH_IND12W. */
|
---|
228 | EMPTY_HOWTO (4),
|
---|
229 |
|
---|
230 | /* For 32-bit sh, this is R_SH_DIR8WPL. */
|
---|
231 | EMPTY_HOWTO (5),
|
---|
232 |
|
---|
233 | /* For 32-bit sh, this is R_SH_DIR8WPZ. */
|
---|
234 | EMPTY_HOWTO (6),
|
---|
235 |
|
---|
236 | /* For 32-bit sh, this is R_SH_DIR8BP. */
|
---|
237 | EMPTY_HOWTO (7),
|
---|
238 |
|
---|
239 | /* For 32-bit sh, this is R_SH_DIR8W. */
|
---|
240 | EMPTY_HOWTO (8),
|
---|
241 |
|
---|
242 | /* For 32-bit sh, this is R_SH_DIR8L. */
|
---|
243 | EMPTY_HOWTO (9),
|
---|
244 |
|
---|
245 | EMPTY_HOWTO (10),
|
---|
246 | EMPTY_HOWTO (11),
|
---|
247 | EMPTY_HOWTO (12),
|
---|
248 | EMPTY_HOWTO (13),
|
---|
249 | EMPTY_HOWTO (14),
|
---|
250 | EMPTY_HOWTO (15),
|
---|
251 | EMPTY_HOWTO (16),
|
---|
252 | EMPTY_HOWTO (17),
|
---|
253 | EMPTY_HOWTO (18),
|
---|
254 | EMPTY_HOWTO (19),
|
---|
255 | EMPTY_HOWTO (20),
|
---|
256 | EMPTY_HOWTO (21),
|
---|
257 | EMPTY_HOWTO (22),
|
---|
258 | EMPTY_HOWTO (23),
|
---|
259 | EMPTY_HOWTO (24),
|
---|
260 |
|
---|
261 | /* The remaining relocs are a GNU extension used for relaxing. The
|
---|
262 | final pass of the linker never needs to do anything with any of
|
---|
263 | these relocs. Any required operations are handled by the
|
---|
264 | relaxation code. */
|
---|
265 |
|
---|
266 | /* A 16 bit switch table entry. This is generated for an expression
|
---|
267 | such as ``.word L1 - L2''. The offset holds the difference
|
---|
268 | between the reloc address and L2. */
|
---|
269 | HOWTO (R_SH_SWITCH16, /* type */
|
---|
270 | 0, /* rightshift */
|
---|
271 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
272 | 16, /* bitsize */
|
---|
273 | FALSE, /* pc_relative */
|
---|
274 | 0, /* bitpos */
|
---|
275 | complain_overflow_unsigned, /* complain_on_overflow */
|
---|
276 | sh_elf64_ignore_reloc, /* special_function */
|
---|
277 | "R_SH_SWITCH16", /* name */
|
---|
278 | FALSE, /* partial_inplace */
|
---|
279 | 0, /* src_mask */
|
---|
280 | 0, /* dst_mask */
|
---|
281 | TRUE), /* pcrel_offset */
|
---|
282 |
|
---|
283 | /* A 32 bit switch table entry. This is generated for an expression
|
---|
284 | such as ``.long L1 - L2''. The offset holds the difference
|
---|
285 | between the reloc address and L2. */
|
---|
286 | HOWTO (R_SH_SWITCH32, /* type */
|
---|
287 | 0, /* rightshift */
|
---|
288 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
289 | 32, /* bitsize */
|
---|
290 | FALSE, /* pc_relative */
|
---|
291 | 0, /* bitpos */
|
---|
292 | complain_overflow_unsigned, /* complain_on_overflow */
|
---|
293 | sh_elf64_ignore_reloc, /* special_function */
|
---|
294 | "R_SH_SWITCH32", /* name */
|
---|
295 | FALSE, /* partial_inplace */
|
---|
296 | 0, /* src_mask */
|
---|
297 | 0, /* dst_mask */
|
---|
298 | TRUE), /* pcrel_offset */
|
---|
299 |
|
---|
300 | /* For 32-bit sh, this is R_SH_USES. */
|
---|
301 | EMPTY_HOWTO (27),
|
---|
302 |
|
---|
303 | /* For 32-bit sh, this is R_SH_COUNT. */
|
---|
304 | EMPTY_HOWTO (28),
|
---|
305 |
|
---|
306 | /* For 32-bit sh, this is R_SH_ALIGN. FIXME: For linker relaxation,
|
---|
307 | this might be emitted. When linker relaxation is implemented, we
|
---|
308 | might want to use it. */
|
---|
309 | EMPTY_HOWTO (29),
|
---|
310 |
|
---|
311 | /* For 32-bit sh, this is R_SH_CODE. FIXME: For linker relaxation,
|
---|
312 | this might be emitted. When linker relaxation is implemented, we
|
---|
313 | might want to use it. */
|
---|
314 | EMPTY_HOWTO (30),
|
---|
315 |
|
---|
316 | /* For 32-bit sh, this is R_SH_DATA. FIXME: For linker relaxation,
|
---|
317 | this might be emitted. When linker relaxation is implemented, we
|
---|
318 | might want to use it. */
|
---|
319 | EMPTY_HOWTO (31),
|
---|
320 |
|
---|
321 | /* For 32-bit sh, this is R_SH_LABEL. FIXME: For linker relaxation,
|
---|
322 | this might be emitted. When linker relaxation is implemented, we
|
---|
323 | might want to use it. */
|
---|
324 | EMPTY_HOWTO (32),
|
---|
325 |
|
---|
326 | /* An 8 bit switch table entry. This is generated for an expression
|
---|
327 | such as ``.word L1 - L2''. The offset holds the difference
|
---|
328 | between the reloc address and L2. */
|
---|
329 | HOWTO (R_SH_SWITCH8, /* type */
|
---|
330 | 0, /* rightshift */
|
---|
331 | 0, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
332 | 8, /* bitsize */
|
---|
333 | FALSE, /* pc_relative */
|
---|
334 | 0, /* bitpos */
|
---|
335 | complain_overflow_unsigned, /* complain_on_overflow */
|
---|
336 | sh_elf64_ignore_reloc, /* special_function */
|
---|
337 | "R_SH_SWITCH8", /* name */
|
---|
338 | FALSE, /* partial_inplace */
|
---|
339 | 0, /* src_mask */
|
---|
340 | 0, /* dst_mask */
|
---|
341 | TRUE), /* pcrel_offset */
|
---|
342 |
|
---|
343 | /* GNU extension to record C++ vtable hierarchy */
|
---|
344 | HOWTO (R_SH_GNU_VTINHERIT, /* type */
|
---|
345 | 0, /* rightshift */
|
---|
346 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
347 | 0, /* bitsize */
|
---|
348 | FALSE, /* pc_relative */
|
---|
349 | 0, /* bitpos */
|
---|
350 | complain_overflow_dont, /* complain_on_overflow */
|
---|
351 | NULL, /* special_function */
|
---|
352 | "R_SH_GNU_VTINHERIT", /* name */
|
---|
353 | FALSE, /* partial_inplace */
|
---|
354 | 0, /* src_mask */
|
---|
355 | 0, /* dst_mask */
|
---|
356 | FALSE), /* pcrel_offset */
|
---|
357 |
|
---|
358 | /* GNU extension to record C++ vtable member usage */
|
---|
359 | HOWTO (R_SH_GNU_VTENTRY, /* type */
|
---|
360 | 0, /* rightshift */
|
---|
361 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
362 | 0, /* bitsize */
|
---|
363 | FALSE, /* pc_relative */
|
---|
364 | 0, /* bitpos */
|
---|
365 | complain_overflow_dont, /* complain_on_overflow */
|
---|
366 | _bfd_elf_rel_vtable_reloc_fn, /* special_function */
|
---|
367 | "R_SH_GNU_VTENTRY", /* name */
|
---|
368 | FALSE, /* partial_inplace */
|
---|
369 | 0, /* src_mask */
|
---|
370 | 0, /* dst_mask */
|
---|
371 | FALSE), /* pcrel_offset */
|
---|
372 |
|
---|
373 | /* For 32-bit sh, this is R_SH_LOOP_START. */
|
---|
374 | EMPTY_HOWTO (36),
|
---|
375 |
|
---|
376 | /* For 32-bit sh, this is R_SH_LOOP_END. */
|
---|
377 | EMPTY_HOWTO (37),
|
---|
378 |
|
---|
379 | EMPTY_HOWTO (38),
|
---|
380 | EMPTY_HOWTO (39),
|
---|
381 | EMPTY_HOWTO (40),
|
---|
382 | EMPTY_HOWTO (41),
|
---|
383 | EMPTY_HOWTO (42),
|
---|
384 | EMPTY_HOWTO (43),
|
---|
385 | EMPTY_HOWTO (44),
|
---|
386 |
|
---|
387 | /* Used in SHLLI.L and SHLRI.L. */
|
---|
388 | HOWTO (R_SH_DIR5U, /* type */
|
---|
389 | 0, /* rightshift */
|
---|
390 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
391 | 5, /* bitsize */
|
---|
392 | FALSE, /* pc_relative */
|
---|
393 | 10, /* bitpos */
|
---|
394 | complain_overflow_unsigned, /* complain_on_overflow */
|
---|
395 | bfd_elf_generic_reloc, /* special_function */
|
---|
396 | "R_SH_DIR5U", /* name */
|
---|
397 | FALSE, /* partial_inplace */
|
---|
398 | 0, /* src_mask */
|
---|
399 | 0xfc00, /* dst_mask */
|
---|
400 | FALSE), /* pcrel_offset */
|
---|
401 |
|
---|
402 | /* Used in SHARI, SHLLI et al. */
|
---|
403 | HOWTO (R_SH_DIR6U, /* type */
|
---|
404 | 0, /* rightshift */
|
---|
405 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
406 | 6, /* bitsize */
|
---|
407 | FALSE, /* pc_relative */
|
---|
408 | 10, /* bitpos */
|
---|
409 | complain_overflow_unsigned, /* complain_on_overflow */
|
---|
410 | bfd_elf_generic_reloc, /* special_function */
|
---|
411 | "R_SH_DIR6U", /* name */
|
---|
412 | FALSE, /* partial_inplace */
|
---|
413 | 0, /* src_mask */
|
---|
414 | 0xfc00, /* dst_mask */
|
---|
415 | FALSE), /* pcrel_offset */
|
---|
416 |
|
---|
417 | /* Used in BxxI, LDHI.L et al. */
|
---|
418 | HOWTO (R_SH_DIR6S, /* type */
|
---|
419 | 0, /* rightshift */
|
---|
420 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
421 | 6, /* bitsize */
|
---|
422 | FALSE, /* pc_relative */
|
---|
423 | 10, /* bitpos */
|
---|
424 | complain_overflow_signed, /* complain_on_overflow */
|
---|
425 | bfd_elf_generic_reloc, /* special_function */
|
---|
426 | "R_SH_DIR6S", /* name */
|
---|
427 | FALSE, /* partial_inplace */
|
---|
428 | 0, /* src_mask */
|
---|
429 | 0xfc00, /* dst_mask */
|
---|
430 | FALSE), /* pcrel_offset */
|
---|
431 |
|
---|
432 | /* Used in ADDI, ANDI et al. */
|
---|
433 | HOWTO (R_SH_DIR10S, /* type */
|
---|
434 | 0, /* rightshift */
|
---|
435 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
436 | 10, /* bitsize */
|
---|
437 | FALSE, /* pc_relative */
|
---|
438 | 10, /* bitpos */
|
---|
439 | complain_overflow_signed, /* complain_on_overflow */
|
---|
440 | bfd_elf_generic_reloc, /* special_function */
|
---|
441 | "R_SH_DIR10S", /* name */
|
---|
442 | FALSE, /* partial_inplace */
|
---|
443 | 0, /* src_mask */
|
---|
444 | 0xffc00, /* dst_mask */
|
---|
445 | FALSE), /* pcrel_offset */
|
---|
446 |
|
---|
447 | /* Used in LD.UW, ST.W et al. */
|
---|
448 | HOWTO (R_SH_DIR10SW, /* type */
|
---|
449 | 1, /* rightshift */
|
---|
450 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
451 | 11, /* bitsize */
|
---|
452 | FALSE, /* pc_relative */
|
---|
453 | 10, /* bitpos */
|
---|
454 | complain_overflow_signed, /* complain_on_overflow */
|
---|
455 | bfd_elf_generic_reloc, /* special_function */
|
---|
456 | "R_SH_DIR10SW", /* name */
|
---|
457 | FALSE, /* partial_inplace */
|
---|
458 | 0, /* src_mask */
|
---|
459 | 0xffc00, /* dst_mask */
|
---|
460 | FALSE), /* pcrel_offset */
|
---|
461 |
|
---|
462 | /* Used in LD.L, FLD.S et al. */
|
---|
463 | HOWTO (R_SH_DIR10SL, /* type */
|
---|
464 | 2, /* rightshift */
|
---|
465 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
466 | 12, /* bitsize */
|
---|
467 | FALSE, /* pc_relative */
|
---|
468 | 10, /* bitpos */
|
---|
469 | complain_overflow_signed, /* complain_on_overflow */
|
---|
470 | bfd_elf_generic_reloc, /* special_function */
|
---|
471 | "R_SH_DIR10SL", /* name */
|
---|
472 | FALSE, /* partial_inplace */
|
---|
473 | 0, /* src_mask */
|
---|
474 | 0xffc00, /* dst_mask */
|
---|
475 | FALSE), /* pcrel_offset */
|
---|
476 |
|
---|
477 | /* Used in FLD.D, FST.P et al. */
|
---|
478 | HOWTO (R_SH_DIR10SQ, /* type */
|
---|
479 | 3, /* rightshift */
|
---|
480 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
481 | 13, /* bitsize */
|
---|
482 | FALSE, /* pc_relative */
|
---|
483 | 10, /* bitpos */
|
---|
484 | complain_overflow_signed, /* complain_on_overflow */
|
---|
485 | bfd_elf_generic_reloc, /* special_function */
|
---|
486 | "R_SH_DIR10SQ", /* name */
|
---|
487 | FALSE, /* partial_inplace */
|
---|
488 | 0, /* src_mask */
|
---|
489 | 0xffc00, /* dst_mask */
|
---|
490 | FALSE), /* pcrel_offset */
|
---|
491 |
|
---|
492 | EMPTY_HOWTO (52),
|
---|
493 | EMPTY_HOWTO (53),
|
---|
494 | EMPTY_HOWTO (54),
|
---|
495 | EMPTY_HOWTO (55),
|
---|
496 | EMPTY_HOWTO (56),
|
---|
497 | EMPTY_HOWTO (57),
|
---|
498 | EMPTY_HOWTO (58),
|
---|
499 | EMPTY_HOWTO (59),
|
---|
500 | EMPTY_HOWTO (60),
|
---|
501 | EMPTY_HOWTO (61),
|
---|
502 | EMPTY_HOWTO (62),
|
---|
503 | EMPTY_HOWTO (63),
|
---|
504 | EMPTY_HOWTO (64),
|
---|
505 | EMPTY_HOWTO (65),
|
---|
506 | EMPTY_HOWTO (66),
|
---|
507 | EMPTY_HOWTO (67),
|
---|
508 | EMPTY_HOWTO (68),
|
---|
509 | EMPTY_HOWTO (69),
|
---|
510 | EMPTY_HOWTO (70),
|
---|
511 | EMPTY_HOWTO (71),
|
---|
512 | EMPTY_HOWTO (72),
|
---|
513 | EMPTY_HOWTO (73),
|
---|
514 | EMPTY_HOWTO (74),
|
---|
515 | EMPTY_HOWTO (75),
|
---|
516 | EMPTY_HOWTO (76),
|
---|
517 | EMPTY_HOWTO (77),
|
---|
518 | EMPTY_HOWTO (78),
|
---|
519 | EMPTY_HOWTO (79),
|
---|
520 | EMPTY_HOWTO (80),
|
---|
521 | EMPTY_HOWTO (81),
|
---|
522 | EMPTY_HOWTO (82),
|
---|
523 | EMPTY_HOWTO (83),
|
---|
524 | EMPTY_HOWTO (84),
|
---|
525 | EMPTY_HOWTO (85),
|
---|
526 | EMPTY_HOWTO (86),
|
---|
527 | EMPTY_HOWTO (87),
|
---|
528 | EMPTY_HOWTO (88),
|
---|
529 | EMPTY_HOWTO (89),
|
---|
530 | EMPTY_HOWTO (90),
|
---|
531 | EMPTY_HOWTO (91),
|
---|
532 | EMPTY_HOWTO (92),
|
---|
533 | EMPTY_HOWTO (93),
|
---|
534 | EMPTY_HOWTO (94),
|
---|
535 | EMPTY_HOWTO (95),
|
---|
536 | EMPTY_HOWTO (96),
|
---|
537 | EMPTY_HOWTO (97),
|
---|
538 | EMPTY_HOWTO (98),
|
---|
539 | EMPTY_HOWTO (99),
|
---|
540 | EMPTY_HOWTO (100),
|
---|
541 | EMPTY_HOWTO (101),
|
---|
542 | EMPTY_HOWTO (102),
|
---|
543 | EMPTY_HOWTO (103),
|
---|
544 | EMPTY_HOWTO (104),
|
---|
545 | EMPTY_HOWTO (105),
|
---|
546 | EMPTY_HOWTO (106),
|
---|
547 | EMPTY_HOWTO (107),
|
---|
548 | EMPTY_HOWTO (108),
|
---|
549 | EMPTY_HOWTO (109),
|
---|
550 | EMPTY_HOWTO (110),
|
---|
551 | EMPTY_HOWTO (111),
|
---|
552 | EMPTY_HOWTO (112),
|
---|
553 | EMPTY_HOWTO (113),
|
---|
554 | EMPTY_HOWTO (114),
|
---|
555 | EMPTY_HOWTO (115),
|
---|
556 | EMPTY_HOWTO (116),
|
---|
557 | EMPTY_HOWTO (117),
|
---|
558 | EMPTY_HOWTO (118),
|
---|
559 | EMPTY_HOWTO (119),
|
---|
560 | EMPTY_HOWTO (120),
|
---|
561 | EMPTY_HOWTO (121),
|
---|
562 | EMPTY_HOWTO (122),
|
---|
563 | EMPTY_HOWTO (123),
|
---|
564 | EMPTY_HOWTO (124),
|
---|
565 | EMPTY_HOWTO (125),
|
---|
566 | EMPTY_HOWTO (126),
|
---|
567 | EMPTY_HOWTO (127),
|
---|
568 | EMPTY_HOWTO (128),
|
---|
569 | EMPTY_HOWTO (129),
|
---|
570 | EMPTY_HOWTO (130),
|
---|
571 | EMPTY_HOWTO (131),
|
---|
572 | EMPTY_HOWTO (132),
|
---|
573 | EMPTY_HOWTO (133),
|
---|
574 | EMPTY_HOWTO (134),
|
---|
575 | EMPTY_HOWTO (135),
|
---|
576 | EMPTY_HOWTO (136),
|
---|
577 | EMPTY_HOWTO (137),
|
---|
578 | EMPTY_HOWTO (138),
|
---|
579 | EMPTY_HOWTO (139),
|
---|
580 | EMPTY_HOWTO (140),
|
---|
581 | EMPTY_HOWTO (141),
|
---|
582 | EMPTY_HOWTO (142),
|
---|
583 | EMPTY_HOWTO (143),
|
---|
584 | EMPTY_HOWTO (144),
|
---|
585 | EMPTY_HOWTO (145),
|
---|
586 | EMPTY_HOWTO (146),
|
---|
587 | EMPTY_HOWTO (147),
|
---|
588 | EMPTY_HOWTO (148),
|
---|
589 | EMPTY_HOWTO (149),
|
---|
590 | EMPTY_HOWTO (150),
|
---|
591 | EMPTY_HOWTO (151),
|
---|
592 | EMPTY_HOWTO (152),
|
---|
593 | EMPTY_HOWTO (153),
|
---|
594 | EMPTY_HOWTO (154),
|
---|
595 | EMPTY_HOWTO (155),
|
---|
596 | EMPTY_HOWTO (156),
|
---|
597 | EMPTY_HOWTO (157),
|
---|
598 | EMPTY_HOWTO (158),
|
---|
599 | EMPTY_HOWTO (159),
|
---|
600 |
|
---|
601 | /* Relocs for dynamic linking for 32-bit SH would follow. We don't have
|
---|
602 | any dynamic linking support for 64-bit SH at present. */
|
---|
603 |
|
---|
604 | EMPTY_HOWTO (160),
|
---|
605 | EMPTY_HOWTO (161),
|
---|
606 | EMPTY_HOWTO (162),
|
---|
607 | EMPTY_HOWTO (163),
|
---|
608 | EMPTY_HOWTO (164),
|
---|
609 | EMPTY_HOWTO (165),
|
---|
610 | EMPTY_HOWTO (166),
|
---|
611 | EMPTY_HOWTO (167),
|
---|
612 | EMPTY_HOWTO (168),
|
---|
613 |
|
---|
614 | /* Back to SH5 relocations. */
|
---|
615 | /* Used in MOVI and SHORI (x & 65536). */
|
---|
616 | HOWTO (R_SH_GOT_LOW16, /* type */
|
---|
617 | 0, /* rightshift */
|
---|
618 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
619 | 64, /* bitsize */
|
---|
620 | FALSE, /* pc_relative */
|
---|
621 | 10, /* bitpos */
|
---|
622 | complain_overflow_dont, /* complain_on_overflow */
|
---|
623 | bfd_elf_generic_reloc, /* special_function */
|
---|
624 | "R_SH_GOT_LOW16", /* name */
|
---|
625 | FALSE, /* partial_inplace */
|
---|
626 | 0, /* src_mask */
|
---|
627 | 0x3fffc00, /* dst_mask */
|
---|
628 | FALSE), /* pcrel_offset */
|
---|
629 |
|
---|
630 | /* Used in MOVI and SHORI ((x >> 16) & 65536). */
|
---|
631 | HOWTO (R_SH_GOT_MEDLOW16, /* type */
|
---|
632 | 16, /* rightshift */
|
---|
633 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
634 | 64, /* bitsize */
|
---|
635 | FALSE, /* pc_relative */
|
---|
636 | 10, /* bitpos */
|
---|
637 | complain_overflow_dont, /* complain_on_overflow */
|
---|
638 | bfd_elf_generic_reloc, /* special_function */
|
---|
639 | "R_SH_GOT_MEDLOW16", /* name */
|
---|
640 | FALSE, /* partial_inplace */
|
---|
641 | 0, /* src_mask */
|
---|
642 | 0x3fffc00, /* dst_mask */
|
---|
643 | FALSE), /* pcrel_offset */
|
---|
644 |
|
---|
645 | /* Used in MOVI and SHORI ((x >> 32) & 65536). */
|
---|
646 | HOWTO (R_SH_GOT_MEDHI16, /* type */
|
---|
647 | 32, /* rightshift */
|
---|
648 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
649 | 64, /* bitsize */
|
---|
650 | FALSE, /* pc_relative */
|
---|
651 | 10, /* bitpos */
|
---|
652 | complain_overflow_dont, /* complain_on_overflow */
|
---|
653 | bfd_elf_generic_reloc, /* special_function */
|
---|
654 | "R_SH_GOT_MEDHI16", /* name */
|
---|
655 | FALSE, /* partial_inplace */
|
---|
656 | 0, /* src_mask */
|
---|
657 | 0x3fffc00, /* dst_mask */
|
---|
658 | FALSE), /* pcrel_offset */
|
---|
659 |
|
---|
660 | /* Used in MOVI and SHORI ((x >> 48) & 65536). */
|
---|
661 | HOWTO (R_SH_GOT_HI16, /* type */
|
---|
662 | 48, /* rightshift */
|
---|
663 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
664 | 64, /* bitsize */
|
---|
665 | FALSE, /* pc_relative */
|
---|
666 | 10, /* bitpos */
|
---|
667 | complain_overflow_dont, /* complain_on_overflow */
|
---|
668 | bfd_elf_generic_reloc, /* special_function */
|
---|
669 | "R_SH_GOT_HI16", /* name */
|
---|
670 | FALSE, /* partial_inplace */
|
---|
671 | 0, /* src_mask */
|
---|
672 | 0x3fffc00, /* dst_mask */
|
---|
673 | FALSE), /* pcrel_offset */
|
---|
674 |
|
---|
675 | /* Used in MOVI and SHORI (x & 65536). */
|
---|
676 | HOWTO (R_SH_GOTPLT_LOW16, /* type */
|
---|
677 | 0, /* rightshift */
|
---|
678 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
679 | 64, /* bitsize */
|
---|
680 | FALSE, /* pc_relative */
|
---|
681 | 10, /* bitpos */
|
---|
682 | complain_overflow_dont, /* complain_on_overflow */
|
---|
683 | bfd_elf_generic_reloc, /* special_function */
|
---|
684 | "R_SH_GOTPLT_LOW16", /* name */
|
---|
685 | FALSE, /* partial_inplace */
|
---|
686 | 0, /* src_mask */
|
---|
687 | 0x3fffc00, /* dst_mask */
|
---|
688 | FALSE), /* pcrel_offset */
|
---|
689 |
|
---|
690 | /* Used in MOVI and SHORI ((x >> 16) & 65536). */
|
---|
691 | HOWTO (R_SH_GOTPLT_MEDLOW16, /* type */
|
---|
692 | 16, /* rightshift */
|
---|
693 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
694 | 64, /* bitsize */
|
---|
695 | FALSE, /* pc_relative */
|
---|
696 | 10, /* bitpos */
|
---|
697 | complain_overflow_dont, /* complain_on_overflow */
|
---|
698 | bfd_elf_generic_reloc, /* special_function */
|
---|
699 | "R_SH_GOTPLT_MEDLOW16", /* name */
|
---|
700 | FALSE, /* partial_inplace */
|
---|
701 | 0, /* src_mask */
|
---|
702 | 0x3fffc00, /* dst_mask */
|
---|
703 | FALSE), /* pcrel_offset */
|
---|
704 |
|
---|
705 | /* Used in MOVI and SHORI ((x >> 32) & 65536). */
|
---|
706 | HOWTO (R_SH_GOTPLT_MEDHI16, /* type */
|
---|
707 | 32, /* rightshift */
|
---|
708 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
709 | 64, /* bitsize */
|
---|
710 | FALSE, /* pc_relative */
|
---|
711 | 10, /* bitpos */
|
---|
712 | complain_overflow_dont, /* complain_on_overflow */
|
---|
713 | bfd_elf_generic_reloc, /* special_function */
|
---|
714 | "R_SH_GOTPLT_MEDHI16", /* name */
|
---|
715 | FALSE, /* partial_inplace */
|
---|
716 | 0, /* src_mask */
|
---|
717 | 0x3fffc00, /* dst_mask */
|
---|
718 | FALSE), /* pcrel_offset */
|
---|
719 |
|
---|
720 | /* Used in MOVI and SHORI ((x >> 48) & 65536). */
|
---|
721 | HOWTO (R_SH_GOTPLT_HI16, /* type */
|
---|
722 | 48, /* rightshift */
|
---|
723 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
724 | 64, /* bitsize */
|
---|
725 | FALSE, /* pc_relative */
|
---|
726 | 10, /* bitpos */
|
---|
727 | complain_overflow_dont, /* complain_on_overflow */
|
---|
728 | bfd_elf_generic_reloc, /* special_function */
|
---|
729 | "R_SH_GOTPLT_HI16", /* name */
|
---|
730 | FALSE, /* partial_inplace */
|
---|
731 | 0, /* src_mask */
|
---|
732 | 0x3fffc00, /* dst_mask */
|
---|
733 | FALSE), /* pcrel_offset */
|
---|
734 |
|
---|
735 | /* Used in MOVI and SHORI (x & 65536). */
|
---|
736 | HOWTO (R_SH_PLT_LOW16, /* type */
|
---|
737 | 0, /* rightshift */
|
---|
738 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
739 | 64, /* bitsize */
|
---|
740 | TRUE, /* pc_relative */
|
---|
741 | 10, /* bitpos */
|
---|
742 | complain_overflow_dont, /* complain_on_overflow */
|
---|
743 | bfd_elf_generic_reloc, /* special_function */
|
---|
744 | "R_SH_PLT_LOW16", /* name */
|
---|
745 | FALSE, /* partial_inplace */
|
---|
746 | 0, /* src_mask */
|
---|
747 | 0x3fffc00, /* dst_mask */
|
---|
748 | TRUE), /* pcrel_offset */
|
---|
749 |
|
---|
750 | /* Used in MOVI and SHORI ((x >> 16) & 65536). */
|
---|
751 | HOWTO (R_SH_PLT_MEDLOW16, /* type */
|
---|
752 | 16, /* rightshift */
|
---|
753 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
754 | 64, /* bitsize */
|
---|
755 | TRUE, /* pc_relative */
|
---|
756 | 10, /* bitpos */
|
---|
757 | complain_overflow_dont, /* complain_on_overflow */
|
---|
758 | bfd_elf_generic_reloc, /* special_function */
|
---|
759 | "R_SH_PLT_MEDLOW16", /* name */
|
---|
760 | FALSE, /* partial_inplace */
|
---|
761 | 0, /* src_mask */
|
---|
762 | 0x3fffc00, /* dst_mask */
|
---|
763 | TRUE), /* pcrel_offset */
|
---|
764 |
|
---|
765 | /* Used in MOVI and SHORI ((x >> 32) & 65536). */
|
---|
766 | HOWTO (R_SH_PLT_MEDHI16, /* type */
|
---|
767 | 32, /* rightshift */
|
---|
768 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
769 | 64, /* bitsize */
|
---|
770 | TRUE, /* pc_relative */
|
---|
771 | 10, /* bitpos */
|
---|
772 | complain_overflow_dont, /* complain_on_overflow */
|
---|
773 | bfd_elf_generic_reloc, /* special_function */
|
---|
774 | "R_SH_PLT_MEDHI16", /* name */
|
---|
775 | FALSE, /* partial_inplace */
|
---|
776 | 0, /* src_mask */
|
---|
777 | 0x3fffc00, /* dst_mask */
|
---|
778 | TRUE), /* pcrel_offset */
|
---|
779 |
|
---|
780 | /* Used in MOVI and SHORI ((x >> 48) & 65536). */
|
---|
781 | HOWTO (R_SH_PLT_HI16, /* type */
|
---|
782 | 48, /* rightshift */
|
---|
783 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
784 | 64, /* bitsize */
|
---|
785 | TRUE, /* pc_relative */
|
---|
786 | 10, /* bitpos */
|
---|
787 | complain_overflow_dont, /* complain_on_overflow */
|
---|
788 | bfd_elf_generic_reloc, /* special_function */
|
---|
789 | "R_SH_PLT_HI16", /* name */
|
---|
790 | FALSE, /* partial_inplace */
|
---|
791 | 0, /* src_mask */
|
---|
792 | 0x3fffc00, /* dst_mask */
|
---|
793 | TRUE), /* pcrel_offset */
|
---|
794 |
|
---|
795 | /* Used in MOVI and SHORI (x & 65536). */
|
---|
796 | HOWTO (R_SH_GOTOFF_LOW16, /* type */
|
---|
797 | 0, /* rightshift */
|
---|
798 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
799 | 64, /* bitsize */
|
---|
800 | FALSE, /* pc_relative */
|
---|
801 | 10, /* bitpos */
|
---|
802 | complain_overflow_dont, /* complain_on_overflow */
|
---|
803 | bfd_elf_generic_reloc, /* special_function */
|
---|
804 | "R_SH_GOTOFF_LOW16", /* name */
|
---|
805 | FALSE, /* partial_inplace */
|
---|
806 | 0, /* src_mask */
|
---|
807 | 0x3fffc00, /* dst_mask */
|
---|
808 | FALSE), /* pcrel_offset */
|
---|
809 |
|
---|
810 | /* Used in MOVI and SHORI ((x >> 16) & 65536). */
|
---|
811 | HOWTO (R_SH_GOTOFF_MEDLOW16, /* type */
|
---|
812 | 16, /* rightshift */
|
---|
813 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
814 | 64, /* bitsize */
|
---|
815 | FALSE, /* pc_relative */
|
---|
816 | 10, /* bitpos */
|
---|
817 | complain_overflow_dont, /* complain_on_overflow */
|
---|
818 | bfd_elf_generic_reloc, /* special_function */
|
---|
819 | "R_SH_GOTOFF_MEDLOW16", /* name */
|
---|
820 | FALSE, /* partial_inplace */
|
---|
821 | 0, /* src_mask */
|
---|
822 | 0x3fffc00, /* dst_mask */
|
---|
823 | FALSE), /* pcrel_offset */
|
---|
824 |
|
---|
825 | /* Used in MOVI and SHORI ((x >> 32) & 65536). */
|
---|
826 | HOWTO (R_SH_GOTOFF_MEDHI16, /* type */
|
---|
827 | 32, /* rightshift */
|
---|
828 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
829 | 64, /* bitsize */
|
---|
830 | FALSE, /* pc_relative */
|
---|
831 | 10, /* bitpos */
|
---|
832 | complain_overflow_dont, /* complain_on_overflow */
|
---|
833 | bfd_elf_generic_reloc, /* special_function */
|
---|
834 | "R_SH_GOTOFF_MEDHI16", /* name */
|
---|
835 | FALSE, /* partial_inplace */
|
---|
836 | 0, /* src_mask */
|
---|
837 | 0x3fffc00, /* dst_mask */
|
---|
838 | FALSE), /* pcrel_offset */
|
---|
839 |
|
---|
840 | /* Used in MOVI and SHORI ((x >> 48) & 65536). */
|
---|
841 | HOWTO (R_SH_GOTOFF_HI16, /* type */
|
---|
842 | 48, /* rightshift */
|
---|
843 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
844 | 64, /* bitsize */
|
---|
845 | FALSE, /* pc_relative */
|
---|
846 | 10, /* bitpos */
|
---|
847 | complain_overflow_dont, /* complain_on_overflow */
|
---|
848 | bfd_elf_generic_reloc, /* special_function */
|
---|
849 | "R_SH_GOTOFF_HI16", /* name */
|
---|
850 | FALSE, /* partial_inplace */
|
---|
851 | 0, /* src_mask */
|
---|
852 | 0x3fffc00, /* dst_mask */
|
---|
853 | FALSE), /* pcrel_offset */
|
---|
854 |
|
---|
855 | /* Used in MOVI and SHORI (x & 65536). */
|
---|
856 | HOWTO (R_SH_GOTPC_LOW16, /* type */
|
---|
857 | 0, /* rightshift */
|
---|
858 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
859 | 64, /* bitsize */
|
---|
860 | TRUE, /* pc_relative */
|
---|
861 | 10, /* bitpos */
|
---|
862 | complain_overflow_dont, /* complain_on_overflow */
|
---|
863 | bfd_elf_generic_reloc, /* special_function */
|
---|
864 | "R_SH_GOTPC_LOW16", /* name */
|
---|
865 | FALSE, /* partial_inplace */
|
---|
866 | 0, /* src_mask */
|
---|
867 | 0x3fffc00, /* dst_mask */
|
---|
868 | TRUE), /* pcrel_offset */
|
---|
869 |
|
---|
870 | /* Used in MOVI and SHORI ((x >> 16) & 65536). */
|
---|
871 | HOWTO (R_SH_GOTPC_MEDLOW16, /* type */
|
---|
872 | 16, /* rightshift */
|
---|
873 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
874 | 64, /* bitsize */
|
---|
875 | TRUE, /* pc_relative */
|
---|
876 | 10, /* bitpos */
|
---|
877 | complain_overflow_dont, /* complain_on_overflow */
|
---|
878 | bfd_elf_generic_reloc, /* special_function */
|
---|
879 | "R_SH_GOTPC_MEDLOW16", /* name */
|
---|
880 | FALSE, /* partial_inplace */
|
---|
881 | 0, /* src_mask */
|
---|
882 | 0x3fffc00, /* dst_mask */
|
---|
883 | TRUE), /* pcrel_offset */
|
---|
884 |
|
---|
885 | /* Used in MOVI and SHORI ((x >> 32) & 65536). */
|
---|
886 | HOWTO (R_SH_GOTPC_MEDHI16, /* type */
|
---|
887 | 32, /* rightshift */
|
---|
888 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
889 | 64, /* bitsize */
|
---|
890 | TRUE, /* pc_relative */
|
---|
891 | 10, /* bitpos */
|
---|
892 | complain_overflow_dont, /* complain_on_overflow */
|
---|
893 | bfd_elf_generic_reloc, /* special_function */
|
---|
894 | "R_SH_GOTPC_MEDHI16", /* name */
|
---|
895 | FALSE, /* partial_inplace */
|
---|
896 | 0, /* src_mask */
|
---|
897 | 0x3fffc00, /* dst_mask */
|
---|
898 | TRUE), /* pcrel_offset */
|
---|
899 |
|
---|
900 | /* Used in MOVI and SHORI ((x >> 48) & 65536). */
|
---|
901 | HOWTO (R_SH_GOTPC_HI16, /* type */
|
---|
902 | 48, /* rightshift */
|
---|
903 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
904 | 64, /* bitsize */
|
---|
905 | TRUE, /* pc_relative */
|
---|
906 | 10, /* bitpos */
|
---|
907 | complain_overflow_dont, /* complain_on_overflow */
|
---|
908 | bfd_elf_generic_reloc, /* special_function */
|
---|
909 | "R_SH_GOTPC_HI16", /* name */
|
---|
910 | FALSE, /* partial_inplace */
|
---|
911 | 0, /* src_mask */
|
---|
912 | 0x3fffc00, /* dst_mask */
|
---|
913 | TRUE), /* pcrel_offset */
|
---|
914 |
|
---|
915 | /* Used in LD.L, FLD.S et al. */
|
---|
916 | HOWTO (R_SH_GOT10BY4, /* type */
|
---|
917 | 2, /* rightshift */
|
---|
918 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
919 | 12, /* bitsize */
|
---|
920 | FALSE, /* pc_relative */
|
---|
921 | 10, /* bitpos */
|
---|
922 | complain_overflow_signed, /* complain_on_overflow */
|
---|
923 | bfd_elf_generic_reloc, /* special_function */
|
---|
924 | "R_SH_GOT10BY4", /* name */
|
---|
925 | FALSE, /* partial_inplace */
|
---|
926 | 0, /* src_mask */
|
---|
927 | 0xffc00, /* dst_mask */
|
---|
928 | FALSE), /* pcrel_offset */
|
---|
929 |
|
---|
930 | /* Used in LD.L, FLD.S et al. */
|
---|
931 | HOWTO (R_SH_GOTPLT10BY4, /* type */
|
---|
932 | 2, /* rightshift */
|
---|
933 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
934 | 12, /* bitsize */
|
---|
935 | FALSE, /* pc_relative */
|
---|
936 | 10, /* bitpos */
|
---|
937 | complain_overflow_signed, /* complain_on_overflow */
|
---|
938 | bfd_elf_generic_reloc, /* special_function */
|
---|
939 | "R_SH_GOTPLT10BY4", /* name */
|
---|
940 | FALSE, /* partial_inplace */
|
---|
941 | 0, /* src_mask */
|
---|
942 | 0xffc00, /* dst_mask */
|
---|
943 | FALSE), /* pcrel_offset */
|
---|
944 |
|
---|
945 | /* Used in FLD.D, FST.P et al. */
|
---|
946 | HOWTO (R_SH_GOT10BY8, /* type */
|
---|
947 | 3, /* rightshift */
|
---|
948 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
949 | 13, /* bitsize */
|
---|
950 | FALSE, /* pc_relative */
|
---|
951 | 10, /* bitpos */
|
---|
952 | complain_overflow_signed, /* complain_on_overflow */
|
---|
953 | bfd_elf_generic_reloc, /* special_function */
|
---|
954 | "R_SH_GOT10BY8", /* name */
|
---|
955 | FALSE, /* partial_inplace */
|
---|
956 | 0, /* src_mask */
|
---|
957 | 0xffc00, /* dst_mask */
|
---|
958 | FALSE), /* pcrel_offset */
|
---|
959 |
|
---|
960 | /* Used in FLD.D, FST.P et al. */
|
---|
961 | HOWTO (R_SH_GOTPLT10BY8, /* type */
|
---|
962 | 3, /* rightshift */
|
---|
963 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
964 | 13, /* bitsize */
|
---|
965 | FALSE, /* pc_relative */
|
---|
966 | 10, /* bitpos */
|
---|
967 | complain_overflow_signed, /* complain_on_overflow */
|
---|
968 | bfd_elf_generic_reloc, /* special_function */
|
---|
969 | "R_SH_GOTPLT10BY8", /* name */
|
---|
970 | FALSE, /* partial_inplace */
|
---|
971 | 0, /* src_mask */
|
---|
972 | 0xffc00, /* dst_mask */
|
---|
973 | FALSE), /* pcrel_offset */
|
---|
974 |
|
---|
975 | HOWTO (R_SH_COPY64, /* type */
|
---|
976 | 0, /* rightshift */
|
---|
977 | 4, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
978 | 64, /* bitsize */
|
---|
979 | FALSE, /* pc_relative */
|
---|
980 | 0, /* bitpos */
|
---|
981 | complain_overflow_dont, /* complain_on_overflow */
|
---|
982 | bfd_elf_generic_reloc, /* special_function */
|
---|
983 | "R_SH_COPY64", /* name */
|
---|
984 | FALSE, /* partial_inplace */
|
---|
985 | 0, /* src_mask */
|
---|
986 | ((bfd_vma) 0) - 1, /* dst_mask */
|
---|
987 | FALSE), /* pcrel_offset */
|
---|
988 |
|
---|
989 | HOWTO (R_SH_GLOB_DAT64, /* type */
|
---|
990 | 0, /* rightshift */
|
---|
991 | 4, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
992 | 64, /* bitsize */
|
---|
993 | FALSE, /* pc_relative */
|
---|
994 | 0, /* bitpos */
|
---|
995 | complain_overflow_dont, /* complain_on_overflow */
|
---|
996 | bfd_elf_generic_reloc, /* special_function */
|
---|
997 | "R_SH_GLOB_DAT64", /* name */
|
---|
998 | FALSE, /* partial_inplace */
|
---|
999 | 0, /* src_mask */
|
---|
1000 | ((bfd_vma) 0) - 1, /* dst_mask */
|
---|
1001 | FALSE), /* pcrel_offset */
|
---|
1002 |
|
---|
1003 | HOWTO (R_SH_JMP_SLOT64, /* type */
|
---|
1004 | 0, /* rightshift */
|
---|
1005 | 4, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1006 | 64, /* bitsize */
|
---|
1007 | FALSE, /* pc_relative */
|
---|
1008 | 0, /* bitpos */
|
---|
1009 | complain_overflow_dont, /* complain_on_overflow */
|
---|
1010 | bfd_elf_generic_reloc, /* special_function */
|
---|
1011 | "R_SH_JMP_SLOT64", /* name */
|
---|
1012 | FALSE, /* partial_inplace */
|
---|
1013 | 0, /* src_mask */
|
---|
1014 | ((bfd_vma) 0) - 1, /* dst_mask */
|
---|
1015 | FALSE), /* pcrel_offset */
|
---|
1016 |
|
---|
1017 | HOWTO (R_SH_RELATIVE64, /* type */
|
---|
1018 | 0, /* rightshift */
|
---|
1019 | 4, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1020 | 64, /* bitsize */
|
---|
1021 | FALSE, /* pc_relative */
|
---|
1022 | 0, /* bitpos */
|
---|
1023 | complain_overflow_dont, /* complain_on_overflow */
|
---|
1024 | bfd_elf_generic_reloc, /* special_function */
|
---|
1025 | "R_SH_RELATIVE64", /* name */
|
---|
1026 | FALSE, /* partial_inplace */
|
---|
1027 | 0, /* src_mask */
|
---|
1028 | ((bfd_vma) 0) - 1, /* dst_mask */
|
---|
1029 | FALSE), /* pcrel_offset */
|
---|
1030 |
|
---|
1031 | EMPTY_HOWTO (197),
|
---|
1032 | EMPTY_HOWTO (198),
|
---|
1033 | EMPTY_HOWTO (199),
|
---|
1034 | EMPTY_HOWTO (200),
|
---|
1035 | EMPTY_HOWTO (201),
|
---|
1036 | EMPTY_HOWTO (202),
|
---|
1037 | EMPTY_HOWTO (203),
|
---|
1038 | EMPTY_HOWTO (204),
|
---|
1039 | EMPTY_HOWTO (205),
|
---|
1040 | EMPTY_HOWTO (206),
|
---|
1041 | EMPTY_HOWTO (207),
|
---|
1042 | EMPTY_HOWTO (208),
|
---|
1043 | EMPTY_HOWTO (209),
|
---|
1044 | EMPTY_HOWTO (210),
|
---|
1045 | EMPTY_HOWTO (211),
|
---|
1046 | EMPTY_HOWTO (212),
|
---|
1047 | EMPTY_HOWTO (213),
|
---|
1048 | EMPTY_HOWTO (214),
|
---|
1049 | EMPTY_HOWTO (215),
|
---|
1050 | EMPTY_HOWTO (216),
|
---|
1051 | EMPTY_HOWTO (217),
|
---|
1052 | EMPTY_HOWTO (218),
|
---|
1053 | EMPTY_HOWTO (219),
|
---|
1054 | EMPTY_HOWTO (220),
|
---|
1055 | EMPTY_HOWTO (221),
|
---|
1056 | EMPTY_HOWTO (222),
|
---|
1057 | EMPTY_HOWTO (223),
|
---|
1058 | EMPTY_HOWTO (224),
|
---|
1059 | EMPTY_HOWTO (225),
|
---|
1060 | EMPTY_HOWTO (226),
|
---|
1061 | EMPTY_HOWTO (227),
|
---|
1062 | EMPTY_HOWTO (228),
|
---|
1063 | EMPTY_HOWTO (229),
|
---|
1064 | EMPTY_HOWTO (230),
|
---|
1065 | EMPTY_HOWTO (231),
|
---|
1066 | EMPTY_HOWTO (232),
|
---|
1067 | EMPTY_HOWTO (233),
|
---|
1068 | EMPTY_HOWTO (234),
|
---|
1069 | EMPTY_HOWTO (235),
|
---|
1070 | EMPTY_HOWTO (236),
|
---|
1071 | EMPTY_HOWTO (237),
|
---|
1072 | EMPTY_HOWTO (238),
|
---|
1073 | EMPTY_HOWTO (239),
|
---|
1074 | EMPTY_HOWTO (240),
|
---|
1075 | EMPTY_HOWTO (241),
|
---|
1076 |
|
---|
1077 | /* Relocations for SHmedia code. None of these are partial_inplace or
|
---|
1078 | use the field being relocated. */
|
---|
1079 |
|
---|
1080 | /* The assembler will generate this reloc before a block of SHmedia
|
---|
1081 | instructions. A section should be processed as assuming it contains
|
---|
1082 | data, unless this reloc is seen. Note that a block of SHcompact
|
---|
1083 | instructions are instead preceded by R_SH_CODE.
|
---|
1084 | This is currently not implemented, but should be used for SHmedia
|
---|
1085 | linker relaxation. */
|
---|
1086 | HOWTO (R_SH_SHMEDIA_CODE, /* type */
|
---|
1087 | 0, /* rightshift */
|
---|
1088 | 1, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1089 | 0, /* bitsize */
|
---|
1090 | FALSE, /* pc_relative */
|
---|
1091 | 0, /* bitpos */
|
---|
1092 | complain_overflow_unsigned, /* complain_on_overflow */
|
---|
1093 | sh_elf64_ignore_reloc, /* special_function */
|
---|
1094 | "R_SH_SHMEDIA_CODE", /* name */
|
---|
1095 | FALSE, /* partial_inplace */
|
---|
1096 | 0, /* src_mask */
|
---|
1097 | 0, /* dst_mask */
|
---|
1098 | FALSE), /* pcrel_offset */
|
---|
1099 |
|
---|
1100 | /* The assembler will generate this reloc at a PTA or PTB instruction,
|
---|
1101 | and the linker checks the right type of target, or changes a PTA to a
|
---|
1102 | PTB, if the original insn was PT. */
|
---|
1103 | HOWTO (R_SH_PT_16, /* type */
|
---|
1104 | 2, /* rightshift */
|
---|
1105 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1106 | 18, /* bitsize */
|
---|
1107 | TRUE, /* pc_relative */
|
---|
1108 | 10, /* bitpos */
|
---|
1109 | complain_overflow_signed, /* complain_on_overflow */
|
---|
1110 | bfd_elf_generic_reloc, /* special_function */
|
---|
1111 | "R_SH_PT_16", /* name */
|
---|
1112 | FALSE, /* partial_inplace */
|
---|
1113 | 0, /* src_mask */
|
---|
1114 | 0x3fffc00, /* dst_mask */
|
---|
1115 | TRUE), /* pcrel_offset */
|
---|
1116 |
|
---|
1117 | /* Used in unexpanded MOVI. */
|
---|
1118 | HOWTO (R_SH_IMMS16, /* type */
|
---|
1119 | 0, /* rightshift */
|
---|
1120 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1121 | 16, /* bitsize */
|
---|
1122 | FALSE, /* pc_relative */
|
---|
1123 | 10, /* bitpos */
|
---|
1124 | complain_overflow_signed, /* complain_on_overflow */
|
---|
1125 | bfd_elf_generic_reloc, /* special_function */
|
---|
1126 | "R_SH_IMMS16", /* name */
|
---|
1127 | FALSE, /* partial_inplace */
|
---|
1128 | 0, /* src_mask */
|
---|
1129 | 0x3fffc00, /* dst_mask */
|
---|
1130 | FALSE), /* pcrel_offset */
|
---|
1131 |
|
---|
1132 | /* Used in SHORI. */
|
---|
1133 | HOWTO (R_SH_IMMU16, /* type */
|
---|
1134 | 0, /* rightshift */
|
---|
1135 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1136 | 16, /* bitsize */
|
---|
1137 | FALSE, /* pc_relative */
|
---|
1138 | 10, /* bitpos */
|
---|
1139 | complain_overflow_unsigned, /* complain_on_overflow */
|
---|
1140 | bfd_elf_generic_reloc, /* special_function */
|
---|
1141 | "R_SH_IMMU16", /* name */
|
---|
1142 | FALSE, /* partial_inplace */
|
---|
1143 | 0, /* src_mask */
|
---|
1144 | 0x3fffc00, /* dst_mask */
|
---|
1145 | FALSE), /* pcrel_offset */
|
---|
1146 |
|
---|
1147 | /* Used in MOVI and SHORI (x & 65536). */
|
---|
1148 | HOWTO (R_SH_IMM_LOW16, /* type */
|
---|
1149 | 0, /* rightshift */
|
---|
1150 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1151 | 64, /* bitsize */
|
---|
1152 | FALSE, /* pc_relative */
|
---|
1153 | 10, /* bitpos */
|
---|
1154 | complain_overflow_dont, /* complain_on_overflow */
|
---|
1155 | bfd_elf_generic_reloc, /* special_function */
|
---|
1156 | "R_SH_IMM_LOW16", /* name */
|
---|
1157 | FALSE, /* partial_inplace */
|
---|
1158 | 0, /* src_mask */
|
---|
1159 | 0x3fffc00, /* dst_mask */
|
---|
1160 | FALSE), /* pcrel_offset */
|
---|
1161 |
|
---|
1162 | /* Used in MOVI and SHORI ((x - $) & 65536). */
|
---|
1163 | HOWTO (R_SH_IMM_LOW16_PCREL, /* type */
|
---|
1164 | 0, /* rightshift */
|
---|
1165 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1166 | 64, /* bitsize */
|
---|
1167 | TRUE, /* pc_relative */
|
---|
1168 | 10, /* bitpos */
|
---|
1169 | complain_overflow_dont, /* complain_on_overflow */
|
---|
1170 | bfd_elf_generic_reloc, /* special_function */
|
---|
1171 | "R_SH_IMM_LOW16_PCREL", /* name */
|
---|
1172 | FALSE, /* partial_inplace */
|
---|
1173 | 0, /* src_mask */
|
---|
1174 | 0x3fffc00, /* dst_mask */
|
---|
1175 | TRUE), /* pcrel_offset */
|
---|
1176 |
|
---|
1177 | /* Used in MOVI and SHORI ((x >> 16) & 65536). */
|
---|
1178 | HOWTO (R_SH_IMM_MEDLOW16, /* type */
|
---|
1179 | 16, /* rightshift */
|
---|
1180 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1181 | 64, /* bitsize */
|
---|
1182 | FALSE, /* pc_relative */
|
---|
1183 | 10, /* bitpos */
|
---|
1184 | complain_overflow_dont, /* complain_on_overflow */
|
---|
1185 | bfd_elf_generic_reloc, /* special_function */
|
---|
1186 | "R_SH_IMM_MEDLOW16", /* name */
|
---|
1187 | FALSE, /* partial_inplace */
|
---|
1188 | 0, /* src_mask */
|
---|
1189 | 0x3fffc00, /* dst_mask */
|
---|
1190 | FALSE), /* pcrel_offset */
|
---|
1191 |
|
---|
1192 | /* Used in MOVI and SHORI (((x - $) >> 16) & 65536). */
|
---|
1193 | HOWTO (R_SH_IMM_MEDLOW16_PCREL, /* type */
|
---|
1194 | 16, /* rightshift */
|
---|
1195 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1196 | 64, /* bitsize */
|
---|
1197 | TRUE, /* pc_relative */
|
---|
1198 | 10, /* bitpos */
|
---|
1199 | complain_overflow_dont, /* complain_on_overflow */
|
---|
1200 | bfd_elf_generic_reloc, /* special_function */
|
---|
1201 | "R_SH_IMM_MEDLOW16_PCREL", /* name */
|
---|
1202 | FALSE, /* partial_inplace */
|
---|
1203 | 0, /* src_mask */
|
---|
1204 | 0x3fffc00, /* dst_mask */
|
---|
1205 | TRUE), /* pcrel_offset */
|
---|
1206 |
|
---|
1207 | /* Used in MOVI and SHORI ((x >> 32) & 65536). */
|
---|
1208 | HOWTO (R_SH_IMM_MEDHI16, /* type */
|
---|
1209 | 32, /* rightshift */
|
---|
1210 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1211 | 64, /* bitsize */
|
---|
1212 | FALSE, /* pc_relative */
|
---|
1213 | 10, /* bitpos */
|
---|
1214 | complain_overflow_dont, /* complain_on_overflow */
|
---|
1215 | bfd_elf_generic_reloc, /* special_function */
|
---|
1216 | "R_SH_IMM_MEDHI16", /* name */
|
---|
1217 | FALSE, /* partial_inplace */
|
---|
1218 | 0, /* src_mask */
|
---|
1219 | 0x3fffc00, /* dst_mask */
|
---|
1220 | FALSE), /* pcrel_offset */
|
---|
1221 |
|
---|
1222 | /* Used in MOVI and SHORI (((x - $) >> 32) & 65536). */
|
---|
1223 | HOWTO (R_SH_IMM_MEDHI16_PCREL, /* type */
|
---|
1224 | 32, /* rightshift */
|
---|
1225 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1226 | 64, /* bitsize */
|
---|
1227 | TRUE, /* pc_relative */
|
---|
1228 | 10, /* bitpos */
|
---|
1229 | complain_overflow_dont, /* complain_on_overflow */
|
---|
1230 | bfd_elf_generic_reloc, /* special_function */
|
---|
1231 | "R_SH_IMM_MEDHI16_PCREL", /* name */
|
---|
1232 | FALSE, /* partial_inplace */
|
---|
1233 | 0, /* src_mask */
|
---|
1234 | 0x3fffc00, /* dst_mask */
|
---|
1235 | TRUE), /* pcrel_offset */
|
---|
1236 |
|
---|
1237 | /* Used in MOVI and SHORI ((x >> 48) & 65536). */
|
---|
1238 | HOWTO (R_SH_IMM_HI16, /* type */
|
---|
1239 | 48, /* rightshift */
|
---|
1240 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1241 | 64, /* bitsize */
|
---|
1242 | FALSE, /* pc_relative */
|
---|
1243 | 10, /* bitpos */
|
---|
1244 | complain_overflow_dont, /* complain_on_overflow */
|
---|
1245 | bfd_elf_generic_reloc, /* special_function */
|
---|
1246 | "R_SH_IMM_HI16", /* name */
|
---|
1247 | FALSE, /* partial_inplace */
|
---|
1248 | 0, /* src_mask */
|
---|
1249 | 0x3fffc00, /* dst_mask */
|
---|
1250 | FALSE), /* pcrel_offset */
|
---|
1251 |
|
---|
1252 | /* Used in MOVI and SHORI (((x - $) >> 48) & 65536). */
|
---|
1253 | HOWTO (R_SH_IMM_HI16_PCREL, /* type */
|
---|
1254 | 48, /* rightshift */
|
---|
1255 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1256 | 64, /* bitsize */
|
---|
1257 | TRUE, /* pc_relative */
|
---|
1258 | 10, /* bitpos */
|
---|
1259 | complain_overflow_dont, /* complain_on_overflow */
|
---|
1260 | bfd_elf_generic_reloc, /* special_function */
|
---|
1261 | "R_SH_IMM_HI16_PCREL", /* name */
|
---|
1262 | FALSE, /* partial_inplace */
|
---|
1263 | 0, /* src_mask */
|
---|
1264 | 0x3fffc00, /* dst_mask */
|
---|
1265 | TRUE), /* pcrel_offset */
|
---|
1266 |
|
---|
1267 | /* For the .uaquad pseudo. */
|
---|
1268 | HOWTO (R_SH_64, /* type */
|
---|
1269 | 0, /* rightshift */
|
---|
1270 | 4, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1271 | 64, /* bitsize */
|
---|
1272 | FALSE, /* pc_relative */
|
---|
1273 | 0, /* bitpos */
|
---|
1274 | complain_overflow_dont, /* complain_on_overflow */
|
---|
1275 | bfd_elf_generic_reloc, /* special_function */
|
---|
1276 | "R_SH_64", /* name */
|
---|
1277 | FALSE, /* partial_inplace */
|
---|
1278 | 0, /* src_mask */
|
---|
1279 | ((bfd_vma) 0) - 1, /* dst_mask */
|
---|
1280 | FALSE), /* pcrel_offset */
|
---|
1281 |
|
---|
1282 | /* For the .uaquad pseudo, (x - $). */
|
---|
1283 | HOWTO (R_SH_64_PCREL, /* type */
|
---|
1284 | 48, /* rightshift */
|
---|
1285 | 2, /* size (0 = byte, 1 = short, 2 = long) */
|
---|
1286 | 64, /* bitsize */
|
---|
1287 | TRUE, /* pc_relative */
|
---|
1288 | 10, /* bitpos */
|
---|
1289 | complain_overflow_dont, /* complain_on_overflow */
|
---|
1290 | bfd_elf_generic_reloc, /* special_function */
|
---|
1291 | "R_SH_64_PCREL", /* name */
|
---|
1292 | FALSE, /* partial_inplace */
|
---|
1293 | 0, /* src_mask */
|
---|
1294 | ((bfd_vma) 0) - 1, /* dst_mask */
|
---|
1295 | TRUE), /* pcrel_offset */
|
---|
1296 |
|
---|
1297 | };
|
---|
1298 |
|
---|
1299 | /* This function is used for relocs which are only used for relaxing,
|
---|
1300 | which the linker should otherwise ignore. */
|
---|
1301 |
|
---|
1302 | static bfd_reloc_status_type
|
---|
1303 | sh_elf64_ignore_reloc (abfd, reloc_entry, symbol, data, input_section,
|
---|
1304 | output_bfd, error_message)
|
---|
1305 | bfd *abfd ATTRIBUTE_UNUSED;
|
---|
1306 | arelent *reloc_entry;
|
---|
1307 | asymbol *symbol ATTRIBUTE_UNUSED;
|
---|
1308 | PTR data ATTRIBUTE_UNUSED;
|
---|
1309 | asection *input_section;
|
---|
1310 | bfd *output_bfd;
|
---|
1311 | char **error_message ATTRIBUTE_UNUSED;
|
---|
1312 | {
|
---|
1313 | if (output_bfd != NULL)
|
---|
1314 | reloc_entry->address += input_section->output_offset;
|
---|
1315 | return bfd_reloc_ok;
|
---|
1316 | }
|
---|
1317 |
|
---|
1318 | /* This function is used for normal relocs. This used to be like the COFF
|
---|
1319 | function, and is almost certainly incorrect for other ELF targets.
|
---|
1320 |
|
---|
1321 | See sh_elf_reloc in elf32-sh.c for the original. */
|
---|
1322 |
|
---|
1323 | static bfd_reloc_status_type
|
---|
1324 | sh_elf64_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd,
|
---|
1325 | error_message)
|
---|
1326 | bfd *abfd;
|
---|
1327 | arelent *reloc_entry;
|
---|
1328 | asymbol *symbol_in;
|
---|
1329 | PTR data;
|
---|
1330 | asection *input_section;
|
---|
1331 | bfd *output_bfd;
|
---|
1332 | char **error_message ATTRIBUTE_UNUSED;
|
---|
1333 | {
|
---|
1334 | unsigned long insn;
|
---|
1335 | bfd_vma sym_value;
|
---|
1336 | enum elf_sh_reloc_type r_type;
|
---|
1337 | bfd_vma addr = reloc_entry->address;
|
---|
1338 | bfd_byte *hit_data = addr + (bfd_byte *) data;
|
---|
1339 |
|
---|
1340 | r_type = (enum elf_sh_reloc_type) reloc_entry->howto->type;
|
---|
1341 |
|
---|
1342 | if (output_bfd != NULL)
|
---|
1343 | {
|
---|
1344 | /* Partial linking--do nothing. */
|
---|
1345 | reloc_entry->address += input_section->output_offset;
|
---|
1346 | return bfd_reloc_ok;
|
---|
1347 | }
|
---|
1348 |
|
---|
1349 | if (symbol_in != NULL
|
---|
1350 | && bfd_is_und_section (symbol_in->section))
|
---|
1351 | return bfd_reloc_undefined;
|
---|
1352 |
|
---|
1353 | if (bfd_is_com_section (symbol_in->section))
|
---|
1354 | sym_value = 0;
|
---|
1355 | else
|
---|
1356 | sym_value = (symbol_in->value +
|
---|
1357 | symbol_in->section->output_section->vma +
|
---|
1358 | symbol_in->section->output_offset);
|
---|
1359 |
|
---|
1360 | switch (r_type)
|
---|
1361 | {
|
---|
1362 | case R_SH_DIR32:
|
---|
1363 | insn = bfd_get_32 (abfd, hit_data);
|
---|
1364 | insn += sym_value + reloc_entry->addend;
|
---|
1365 | bfd_put_32 (abfd, insn, hit_data);
|
---|
1366 | break;
|
---|
1367 |
|
---|
1368 | default:
|
---|
1369 | abort ();
|
---|
1370 | break;
|
---|
1371 | }
|
---|
1372 |
|
---|
1373 | return bfd_reloc_ok;
|
---|
1374 | }
|
---|
1375 |
|
---|
1376 | /* This structure is used to map BFD reloc codes to SH ELF relocs. */
|
---|
1377 |
|
---|
1378 | struct elf_reloc_map
|
---|
1379 | {
|
---|
1380 | bfd_reloc_code_real_type bfd_reloc_val;
|
---|
1381 | unsigned char elf_reloc_val;
|
---|
1382 | };
|
---|
1383 |
|
---|
1384 | /* An array mapping BFD reloc codes to SH ELF relocs. */
|
---|
1385 |
|
---|
1386 | static const struct elf_reloc_map sh64_reloc_map[] =
|
---|
1387 | {
|
---|
1388 | { BFD_RELOC_NONE, R_SH_NONE },
|
---|
1389 | { BFD_RELOC_32, R_SH_DIR32 },
|
---|
1390 | { BFD_RELOC_CTOR, R_SH_DIR32 },
|
---|
1391 | { BFD_RELOC_32_PCREL, R_SH_REL32 },
|
---|
1392 | { BFD_RELOC_8_PCREL, R_SH_SWITCH8 },
|
---|
1393 | { BFD_RELOC_SH_SWITCH16, R_SH_SWITCH16 },
|
---|
1394 | { BFD_RELOC_SH_SWITCH32, R_SH_SWITCH32 },
|
---|
1395 | { BFD_RELOC_VTABLE_INHERIT, R_SH_GNU_VTINHERIT },
|
---|
1396 | { BFD_RELOC_VTABLE_ENTRY, R_SH_GNU_VTENTRY },
|
---|
1397 | { BFD_RELOC_SH_GOT_LOW16, R_SH_GOT_LOW16 },
|
---|
1398 | { BFD_RELOC_SH_GOT_MEDLOW16, R_SH_GOT_MEDLOW16 },
|
---|
1399 | { BFD_RELOC_SH_GOT_MEDHI16, R_SH_GOT_MEDHI16 },
|
---|
1400 | { BFD_RELOC_SH_GOT_HI16, R_SH_GOT_HI16 },
|
---|
1401 | { BFD_RELOC_SH_GOTPLT_LOW16, R_SH_GOTPLT_LOW16 },
|
---|
1402 | { BFD_RELOC_SH_GOTPLT_MEDLOW16, R_SH_GOTPLT_MEDLOW16 },
|
---|
1403 | { BFD_RELOC_SH_GOTPLT_MEDHI16, R_SH_GOTPLT_MEDHI16 },
|
---|
1404 | { BFD_RELOC_SH_GOTPLT_HI16, R_SH_GOTPLT_HI16 },
|
---|
1405 | { BFD_RELOC_SH_PLT_LOW16, R_SH_PLT_LOW16 },
|
---|
1406 | { BFD_RELOC_SH_PLT_MEDLOW16, R_SH_PLT_MEDLOW16 },
|
---|
1407 | { BFD_RELOC_SH_PLT_MEDHI16, R_SH_PLT_MEDHI16 },
|
---|
1408 | { BFD_RELOC_SH_PLT_HI16, R_SH_PLT_HI16 },
|
---|
1409 | { BFD_RELOC_SH_GOTOFF_LOW16, R_SH_GOTOFF_LOW16 },
|
---|
1410 | { BFD_RELOC_SH_GOTOFF_MEDLOW16, R_SH_GOTOFF_MEDLOW16 },
|
---|
1411 | { BFD_RELOC_SH_GOTOFF_MEDHI16, R_SH_GOTOFF_MEDHI16 },
|
---|
1412 | { BFD_RELOC_SH_GOTOFF_HI16, R_SH_GOTOFF_HI16 },
|
---|
1413 | { BFD_RELOC_SH_GOTPC_LOW16, R_SH_GOTPC_LOW16 },
|
---|
1414 | { BFD_RELOC_SH_GOTPC_MEDLOW16, R_SH_GOTPC_MEDLOW16 },
|
---|
1415 | { BFD_RELOC_SH_GOTPC_MEDHI16, R_SH_GOTPC_MEDHI16 },
|
---|
1416 | { BFD_RELOC_SH_GOTPC_HI16, R_SH_GOTPC_HI16 },
|
---|
1417 | { BFD_RELOC_SH_COPY64, R_SH_COPY64 },
|
---|
1418 | { BFD_RELOC_SH_GLOB_DAT64, R_SH_GLOB_DAT64 },
|
---|
1419 | { BFD_RELOC_SH_JMP_SLOT64, R_SH_JMP_SLOT64 },
|
---|
1420 | { BFD_RELOC_SH_RELATIVE64, R_SH_RELATIVE64 },
|
---|
1421 | { BFD_RELOC_SH_GOT10BY4, R_SH_GOT10BY4 },
|
---|
1422 | { BFD_RELOC_SH_GOT10BY8, R_SH_GOT10BY8 },
|
---|
1423 | { BFD_RELOC_SH_GOTPLT10BY4, R_SH_GOTPLT10BY4 },
|
---|
1424 | { BFD_RELOC_SH_GOTPLT10BY8, R_SH_GOTPLT10BY8 },
|
---|
1425 | { BFD_RELOC_SH_PT_16, R_SH_PT_16 },
|
---|
1426 | { BFD_RELOC_SH_SHMEDIA_CODE, R_SH_SHMEDIA_CODE },
|
---|
1427 | { BFD_RELOC_SH_IMMU5, R_SH_DIR5U },
|
---|
1428 | { BFD_RELOC_SH_IMMS6, R_SH_DIR6S },
|
---|
1429 | { BFD_RELOC_SH_IMMU6, R_SH_DIR6U },
|
---|
1430 | { BFD_RELOC_SH_IMMS10, R_SH_DIR10S },
|
---|
1431 | { BFD_RELOC_SH_IMMS10BY2, R_SH_DIR10SW },
|
---|
1432 | { BFD_RELOC_SH_IMMS10BY4, R_SH_DIR10SL },
|
---|
1433 | { BFD_RELOC_SH_IMMS10BY8, R_SH_DIR10SQ },
|
---|
1434 | { BFD_RELOC_SH_IMMS16, R_SH_IMMS16 },
|
---|
1435 | { BFD_RELOC_SH_IMMU16, R_SH_IMMU16 },
|
---|
1436 | { BFD_RELOC_SH_IMM_LOW16, R_SH_IMM_LOW16 },
|
---|
1437 | { BFD_RELOC_SH_IMM_LOW16_PCREL, R_SH_IMM_LOW16_PCREL },
|
---|
1438 | { BFD_RELOC_SH_IMM_MEDLOW16, R_SH_IMM_MEDLOW16 },
|
---|
1439 | { BFD_RELOC_SH_IMM_MEDLOW16_PCREL, R_SH_IMM_MEDLOW16_PCREL },
|
---|
1440 | { BFD_RELOC_SH_IMM_MEDHI16, R_SH_IMM_MEDHI16 },
|
---|
1441 | { BFD_RELOC_SH_IMM_MEDHI16_PCREL, R_SH_IMM_MEDHI16_PCREL },
|
---|
1442 | { BFD_RELOC_SH_IMM_HI16, R_SH_IMM_HI16 },
|
---|
1443 | { BFD_RELOC_SH_IMM_HI16_PCREL, R_SH_IMM_HI16_PCREL },
|
---|
1444 | { BFD_RELOC_64, R_SH_64 },
|
---|
1445 | { BFD_RELOC_64_PCREL, R_SH_64_PCREL },
|
---|
1446 | };
|
---|
1447 |
|
---|
1448 | /* Given a BFD reloc code, return the howto structure for the
|
---|
1449 | corresponding SH ELf reloc. */
|
---|
1450 |
|
---|
1451 | static reloc_howto_type *
|
---|
1452 | sh_elf64_reloc_type_lookup (abfd, code)
|
---|
1453 | bfd *abfd ATTRIBUTE_UNUSED;
|
---|
1454 | bfd_reloc_code_real_type code;
|
---|
1455 | {
|
---|
1456 | unsigned int i;
|
---|
1457 |
|
---|
1458 | for (i = 0; i < sizeof (sh64_reloc_map) / sizeof (struct elf_reloc_map); i++)
|
---|
1459 | {
|
---|
1460 | if (sh64_reloc_map[i].bfd_reloc_val == code)
|
---|
1461 | return &sh_elf64_howto_table[(int) sh64_reloc_map[i].elf_reloc_val];
|
---|
1462 | }
|
---|
1463 |
|
---|
1464 | return NULL;
|
---|
1465 | }
|
---|
1466 |
|
---|
1467 | /* Given an ELF reloc, fill in the howto field of a relent.
|
---|
1468 |
|
---|
1469 | See sh_elf_info_to_howto in elf32-sh.c for the original. */
|
---|
1470 |
|
---|
1471 | static void
|
---|
1472 | sh_elf64_info_to_howto (abfd, cache_ptr, dst)
|
---|
1473 | bfd *abfd ATTRIBUTE_UNUSED;
|
---|
1474 | arelent *cache_ptr;
|
---|
1475 | Elf_Internal_Rela *dst;
|
---|
1476 | {
|
---|
1477 | unsigned int r;
|
---|
1478 |
|
---|
1479 | r = ELF64_R_TYPE (dst->r_info);
|
---|
1480 |
|
---|
1481 | BFD_ASSERT (r <= (unsigned int) R_SH_64_PCREL);
|
---|
1482 | BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC || r > R_SH_LAST_INVALID_RELOC);
|
---|
1483 | BFD_ASSERT (r < R_SH_DIR8WPN || r > R_SH_LAST_INVALID_RELOC_2);
|
---|
1484 | BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC_3 || r > R_SH_GOTPLT32);
|
---|
1485 | BFD_ASSERT (r < R_SH_FIRST_INVALID_RELOC_4 || r > R_SH_LAST_INVALID_RELOC_4);
|
---|
1486 |
|
---|
1487 | cache_ptr->howto = &sh_elf64_howto_table[r];
|
---|
1488 | }
|
---|
1489 |
|
---|
1490 | /* Relocate an SH ELF section.
|
---|
1491 |
|
---|
1492 | See sh_elf_info_to_howto in elf32-sh.c for the original. */
|
---|
1493 |
|
---|
1494 | static bfd_boolean
|
---|
1495 | sh_elf64_relocate_section (output_bfd, info, input_bfd, input_section,
|
---|
1496 | contents, relocs, local_syms, local_sections)
|
---|
1497 | bfd *output_bfd ATTRIBUTE_UNUSED;
|
---|
1498 | struct bfd_link_info *info;
|
---|
1499 | bfd *input_bfd;
|
---|
1500 | asection *input_section;
|
---|
1501 | bfd_byte *contents;
|
---|
1502 | Elf_Internal_Rela *relocs;
|
---|
1503 | Elf_Internal_Sym *local_syms;
|
---|
1504 | asection **local_sections;
|
---|
1505 | {
|
---|
1506 | Elf_Internal_Shdr *symtab_hdr;
|
---|
1507 | struct elf_link_hash_entry **sym_hashes;
|
---|
1508 | Elf_Internal_Rela *rel, *relend;
|
---|
1509 | bfd *dynobj;
|
---|
1510 | bfd_vma *local_got_offsets;
|
---|
1511 | asection *sgot;
|
---|
1512 | asection *sgotplt;
|
---|
1513 | asection *splt;
|
---|
1514 | asection *sreloc;
|
---|
1515 | bfd_vma disp, dropped;
|
---|
1516 |
|
---|
1517 | symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
|
---|
1518 | sym_hashes = elf_sym_hashes (input_bfd);
|
---|
1519 | dynobj = elf_hash_table (info)->dynobj;
|
---|
1520 | local_got_offsets = elf_local_got_offsets (input_bfd);
|
---|
1521 |
|
---|
1522 | sgot = NULL;
|
---|
1523 | sgotplt = NULL;
|
---|
1524 | splt = NULL;
|
---|
1525 | sreloc = NULL;
|
---|
1526 |
|
---|
1527 | rel = relocs;
|
---|
1528 | relend = relocs + input_section->reloc_count;
|
---|
1529 | for (; rel < relend; rel++)
|
---|
1530 | {
|
---|
1531 | int r_type;
|
---|
1532 | reloc_howto_type *howto;
|
---|
1533 | unsigned long r_symndx;
|
---|
1534 | Elf_Internal_Sym *sym;
|
---|
1535 | asection *sec;
|
---|
1536 | struct elf_link_hash_entry *h;
|
---|
1537 | bfd_vma relocation;
|
---|
1538 | bfd_vma addend = (bfd_vma)0;
|
---|
1539 | bfd_reloc_status_type r;
|
---|
1540 | int seen_stt_datalabel = 0;
|
---|
1541 |
|
---|
1542 | r_symndx = ELF64_R_SYM (rel->r_info);
|
---|
1543 |
|
---|
1544 | r_type = ELF64_R_TYPE (rel->r_info);
|
---|
1545 |
|
---|
1546 | if (r_type == (int) R_SH_NONE)
|
---|
1547 | continue;
|
---|
1548 |
|
---|
1549 | if (r_type < 0
|
---|
1550 | || r_type > R_SH_64_PCREL
|
---|
1551 | || (r_type >= (int) R_SH_FIRST_INVALID_RELOC
|
---|
1552 | && r_type <= (int) R_SH_LAST_INVALID_RELOC)
|
---|
1553 | || (r_type >= (int) R_SH_DIR8WPN
|
---|
1554 | && r_type <= (int) R_SH_LAST_INVALID_RELOC_2)
|
---|
1555 | || (r_type >= (int) R_SH_FIRST_INVALID_RELOC_3
|
---|
1556 | && r_type <= R_SH_GOTPLT32)
|
---|
1557 | || (r_type >= (int) R_SH_FIRST_INVALID_RELOC_4
|
---|
1558 | && r_type <= (int) R_SH_LAST_INVALID_RELOC_4))
|
---|
1559 | {
|
---|
1560 | bfd_set_error (bfd_error_bad_value);
|
---|
1561 | return FALSE;
|
---|
1562 | }
|
---|
1563 |
|
---|
1564 | howto = sh_elf64_howto_table + r_type;
|
---|
1565 |
|
---|
1566 | /* This is a final link. */
|
---|
1567 | h = NULL;
|
---|
1568 | sym = NULL;
|
---|
1569 | sec = NULL;
|
---|
1570 | if (r_symndx < symtab_hdr->sh_info)
|
---|
1571 | {
|
---|
1572 | sym = local_syms + r_symndx;
|
---|
1573 | sec = local_sections[r_symndx];
|
---|
1574 | relocation = ((sec->output_section->vma
|
---|
1575 | + sec->output_offset
|
---|
1576 | + sym->st_value)
|
---|
1577 | | ((sym->st_other & STO_SH5_ISA32) != 0));
|
---|
1578 |
|
---|
1579 | /* A local symbol never has STO_SH5_ISA32, so we don't need
|
---|
1580 | datalabel processing here. Make sure this does not change
|
---|
1581 | without notice. */
|
---|
1582 | if ((sym->st_other & STO_SH5_ISA32) != 0)
|
---|
1583 | ((*info->callbacks->reloc_dangerous)
|
---|
1584 | (info,
|
---|
1585 | _("Unexpected STO_SH5_ISA32 on local symbol is not handled"),
|
---|
1586 | input_bfd, input_section, rel->r_offset));
|
---|
1587 |
|
---|
1588 | if (info->relocateable)
|
---|
1589 | {
|
---|
1590 | /* This is a relocateable link. We don't have to change
|
---|
1591 | anything, unless the reloc is against a section symbol,
|
---|
1592 | in which case we have to adjust according to where the
|
---|
1593 | section symbol winds up in the output section. */
|
---|
1594 | sym = local_syms + r_symndx;
|
---|
1595 | if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
|
---|
1596 | goto final_link_relocate;
|
---|
1597 |
|
---|
1598 | continue;
|
---|
1599 | }
|
---|
1600 | else if (! howto->partial_inplace)
|
---|
1601 | {
|
---|
1602 | relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);
|
---|
1603 | relocation |= ((sym->st_other & STO_SH5_ISA32) != 0);
|
---|
1604 | }
|
---|
1605 | else if ((sec->flags & SEC_MERGE)
|
---|
1606 | && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
|
---|
1607 | {
|
---|
1608 | asection *msec;
|
---|
1609 |
|
---|
1610 | if (howto->rightshift || howto->src_mask != 0xffffffff)
|
---|
1611 | {
|
---|
1612 | (*_bfd_error_handler)
|
---|
1613 | (_("%s(%s+0x%lx): %s relocation against SEC_MERGE section"),
|
---|
1614 | bfd_archive_filename (input_bfd),
|
---|
1615 | bfd_get_section_name (input_bfd, input_section),
|
---|
1616 | (long) rel->r_offset, howto->name);
|
---|
1617 | return FALSE;
|
---|
1618 | }
|
---|
1619 |
|
---|
1620 | addend = bfd_get_32 (input_bfd, contents + rel->r_offset);
|
---|
1621 | msec = sec;
|
---|
1622 | addend =
|
---|
1623 | _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend)
|
---|
1624 | - relocation;
|
---|
1625 | addend += msec->output_section->vma + msec->output_offset;
|
---|
1626 | bfd_put_32 (input_bfd, addend, contents + rel->r_offset);
|
---|
1627 | addend = 0;
|
---|
1628 | }
|
---|
1629 | }
|
---|
1630 | else
|
---|
1631 | {
|
---|
1632 | /* Section symbols are never (?) placed in the hash table, so
|
---|
1633 | we can just ignore hash relocations when creating a
|
---|
1634 | relocateable object file. */
|
---|
1635 | if (info->relocateable)
|
---|
1636 | continue;
|
---|
1637 |
|
---|
1638 | h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
---|
1639 | while (h->root.type == bfd_link_hash_indirect
|
---|
1640 | || h->root.type == bfd_link_hash_warning)
|
---|
1641 | {
|
---|
1642 | /* If the reference passes a symbol marked with
|
---|
1643 | STT_DATALABEL, then any STO_SH5_ISA32 on the final value
|
---|
1644 | doesn't count. */
|
---|
1645 | seen_stt_datalabel |= h->type == STT_DATALABEL;
|
---|
1646 | h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
---|
1647 | }
|
---|
1648 |
|
---|
1649 | if (h->root.type == bfd_link_hash_defined
|
---|
1650 | || h->root.type == bfd_link_hash_defweak)
|
---|
1651 | {
|
---|
1652 | sec = h->root.u.def.section;
|
---|
1653 | /* In these cases, we don't need the relocation value.
|
---|
1654 | We check specially because in some obscure cases
|
---|
1655 | sec->output_section will be NULL. */
|
---|
1656 | if (r_type == R_SH_GOTPC_LOW16
|
---|
1657 | || r_type == R_SH_GOTPC_MEDLOW16
|
---|
1658 | || r_type == R_SH_GOTPC_MEDHI16
|
---|
1659 | || r_type == R_SH_GOTPC_HI16
|
---|
1660 | || ((r_type == R_SH_PLT_LOW16
|
---|
1661 | || r_type == R_SH_PLT_MEDLOW16
|
---|
1662 | || r_type == R_SH_PLT_MEDHI16
|
---|
1663 | || r_type == R_SH_PLT_HI16)
|
---|
1664 | && h->plt.offset != (bfd_vma) -1)
|
---|
1665 | || ((r_type == R_SH_GOT_LOW16
|
---|
1666 | || r_type == R_SH_GOT_MEDLOW16
|
---|
1667 | || r_type == R_SH_GOT_MEDHI16
|
---|
1668 | || r_type == R_SH_GOT_HI16)
|
---|
1669 | && elf_hash_table (info)->dynamic_sections_created
|
---|
1670 | && (! info->shared
|
---|
1671 | || (! info->symbolic && h->dynindx != -1)
|
---|
1672 | || (h->elf_link_hash_flags
|
---|
1673 | & ELF_LINK_HASH_DEF_REGULAR) == 0))
|
---|
1674 | /* The cases above are those in which relocation is
|
---|
1675 | overwritten in the switch block below. The cases
|
---|
1676 | below are those in which we must defer relocation
|
---|
1677 | to run-time, because we can't resolve absolute
|
---|
1678 | addresses when creating a shared library. */
|
---|
1679 | || (info->shared
|
---|
1680 | && ((! info->symbolic && h->dynindx != -1)
|
---|
1681 | || (h->elf_link_hash_flags
|
---|
1682 | & ELF_LINK_HASH_DEF_REGULAR) == 0)
|
---|
1683 | && ((r_type == R_SH_64
|
---|
1684 | && !(ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
|
---|
1685 | || ELF_ST_VISIBILITY (h->other) == STV_HIDDEN))
|
---|
1686 | || r_type == R_SH_64_PCREL)
|
---|
1687 | && ((input_section->flags & SEC_ALLOC) != 0
|
---|
1688 | /* DWARF will emit R_SH_DIR32 relocations in its
|
---|
1689 | sections against symbols defined externally
|
---|
1690 | in shared libraries. We can't do anything
|
---|
1691 | with them here. */
|
---|
1692 | || (input_section->flags & SEC_DEBUGGING) != 0))
|
---|
1693 | /* Dynamic relocs are not propagated for SEC_DEBUGGING
|
---|
1694 | sections because such sections are not SEC_ALLOC and
|
---|
1695 | thus ld.so will not process them. */
|
---|
1696 | || (sec->output_section == NULL
|
---|
1697 | && ((input_section->flags & SEC_DEBUGGING) != 0
|
---|
1698 | && (h->elf_link_hash_flags
|
---|
1699 | & ELF_LINK_HASH_DEF_DYNAMIC) != 0)))
|
---|
1700 | relocation = 0;
|
---|
1701 | else if (sec->output_section == NULL)
|
---|
1702 | {
|
---|
1703 | (*_bfd_error_handler)
|
---|
1704 | (_("%s: warning: unresolvable relocation against symbol `%s' from %s section"),
|
---|
1705 | bfd_get_filename (input_bfd), h->root.root.string,
|
---|
1706 | bfd_get_section_name (input_bfd, input_section));
|
---|
1707 | relocation = 0;
|
---|
1708 | }
|
---|
1709 | else
|
---|
1710 | relocation = ((h->root.u.def.value
|
---|
1711 | + sec->output_section->vma
|
---|
1712 | + sec->output_offset)
|
---|
1713 | /* A STO_SH5_ISA32 causes a "bitor 1" to the
|
---|
1714 | symbol value, unless we've seen
|
---|
1715 | STT_DATALABEL on the way to it. */
|
---|
1716 | | ((h->other & STO_SH5_ISA32) != 0
|
---|
1717 | && ! seen_stt_datalabel));
|
---|
1718 | }
|
---|
1719 | else if (h->root.type == bfd_link_hash_undefweak)
|
---|
1720 | relocation = 0;
|
---|
1721 | else if (info->shared && !info->symbolic && !info->no_undefined)
|
---|
1722 | relocation = 0;
|
---|
1723 | else
|
---|
1724 | {
|
---|
1725 | if (! ((*info->callbacks->undefined_symbol)
|
---|
1726 | (info, h->root.root.string, input_bfd,
|
---|
1727 | input_section, rel->r_offset, TRUE)))
|
---|
1728 | return FALSE;
|
---|
1729 | relocation = 0;
|
---|
1730 | }
|
---|
1731 | }
|
---|
1732 |
|
---|
1733 | disp = (relocation
|
---|
1734 | - input_section->output_section->vma
|
---|
1735 | - input_section->output_offset
|
---|
1736 | - rel->r_offset);
|
---|
1737 | dropped = 0;
|
---|
1738 | switch ((int)r_type)
|
---|
1739 | {
|
---|
1740 | case R_SH_PT_16: dropped = disp & 2; break;
|
---|
1741 | case R_SH_DIR10SW: dropped = disp & 1; break;
|
---|
1742 | case R_SH_DIR10SL: dropped = disp & 3; break;
|
---|
1743 | case R_SH_DIR10SQ: dropped = disp & 7; break;
|
---|
1744 | }
|
---|
1745 | if (dropped != 0)
|
---|
1746 | {
|
---|
1747 | (*_bfd_error_handler)
|
---|
1748 | (_("%s: error: unaligned relocation type %d at %08x reloc %08x\n"),
|
---|
1749 | bfd_get_filename (input_bfd), (int)r_type, (unsigned)rel->r_offset, (unsigned)relocation);
|
---|
1750 | bfd_set_error (bfd_error_bad_value);
|
---|
1751 | return FALSE;
|
---|
1752 | }
|
---|
1753 | switch ((int)r_type)
|
---|
1754 | {
|
---|
1755 | case R_SH_64:
|
---|
1756 | case R_SH_64_PCREL:
|
---|
1757 | if (info->shared
|
---|
1758 | && (input_section->flags & SEC_ALLOC) != 0
|
---|
1759 | && (r_type != R_SH_64_PCREL
|
---|
1760 | || (h != NULL
|
---|
1761 | && h->dynindx != -1
|
---|
1762 | && (! info->symbolic
|
---|
1763 | || (h->elf_link_hash_flags
|
---|
1764 | & ELF_LINK_HASH_DEF_REGULAR) == 0))))
|
---|
1765 | {
|
---|
1766 | Elf_Internal_Rela outrel;
|
---|
1767 | bfd_byte *loc;
|
---|
1768 | bfd_boolean skip, relocate;
|
---|
1769 |
|
---|
1770 | /* When generating a shared object, these relocations
|
---|
1771 | are copied into the output file to be resolved at run
|
---|
1772 | time. */
|
---|
1773 |
|
---|
1774 | if (sreloc == NULL)
|
---|
1775 | {
|
---|
1776 | const char *name;
|
---|
1777 |
|
---|
1778 | name = (bfd_elf_string_from_elf_section
|
---|
1779 | (input_bfd,
|
---|
1780 | elf_elfheader (input_bfd)->e_shstrndx,
|
---|
1781 | elf_section_data (input_section)->rel_hdr.sh_name));
|
---|
1782 | if (name == NULL)
|
---|
1783 | return FALSE;
|
---|
1784 |
|
---|
1785 | BFD_ASSERT (strncmp (name, ".rela", 5) == 0
|
---|
1786 | && strcmp (bfd_get_section_name (input_bfd,
|
---|
1787 | input_section),
|
---|
1788 | name + 5) == 0);
|
---|
1789 |
|
---|
1790 | sreloc = bfd_get_section_by_name (dynobj, name);
|
---|
1791 | BFD_ASSERT (sreloc != NULL);
|
---|
1792 | }
|
---|
1793 |
|
---|
1794 | skip = FALSE;
|
---|
1795 | relocate = FALSE;
|
---|
1796 |
|
---|
1797 | outrel.r_offset
|
---|
1798 | = _bfd_elf_section_offset (output_bfd, info,
|
---|
1799 | input_section, rel->r_offset);
|
---|
1800 |
|
---|
1801 | if (outrel.r_offset == (bfd_vma) -1)
|
---|
1802 | skip = TRUE;
|
---|
1803 | else if (outrel.r_offset == (bfd_vma) -2)
|
---|
1804 | skip = TRUE, relocate = TRUE;
|
---|
1805 |
|
---|
1806 | outrel.r_offset += (input_section->output_section->vma
|
---|
1807 | + input_section->output_offset);
|
---|
1808 |
|
---|
1809 | if (skip)
|
---|
1810 | memset (&outrel, 0, sizeof outrel);
|
---|
1811 | else if (r_type == R_SH_64_PCREL)
|
---|
1812 | {
|
---|
1813 | BFD_ASSERT (h != NULL && h->dynindx != -1);
|
---|
1814 | outrel.r_info = ELF64_R_INFO (h->dynindx, R_SH_64_PCREL);
|
---|
1815 | outrel.r_addend = rel->r_addend;
|
---|
1816 | }
|
---|
1817 | else
|
---|
1818 | {
|
---|
1819 | /* h->dynindx may be -1 if this symbol was marked to
|
---|
1820 | become local. */
|
---|
1821 | if (h == NULL
|
---|
1822 | || ((info->symbolic || h->dynindx == -1)
|
---|
1823 | && (h->elf_link_hash_flags
|
---|
1824 | & ELF_LINK_HASH_DEF_REGULAR) != 0))
|
---|
1825 | {
|
---|
1826 | relocate = TRUE;
|
---|
1827 | outrel.r_info = ELF64_R_INFO (0, R_SH_RELATIVE64);
|
---|
1828 | outrel.r_addend = relocation + rel->r_addend;
|
---|
1829 | }
|
---|
1830 | else
|
---|
1831 | {
|
---|
1832 | BFD_ASSERT (h->dynindx != -1);
|
---|
1833 | outrel.r_info = ELF64_R_INFO (h->dynindx, R_SH_64);
|
---|
1834 | outrel.r_addend = relocation + rel->r_addend;
|
---|
1835 | }
|
---|
1836 | }
|
---|
1837 |
|
---|
1838 | loc = sreloc->contents;
|
---|
1839 | loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela);
|
---|
1840 | bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
|
---|
1841 |
|
---|
1842 | /* If this reloc is against an external symbol, we do
|
---|
1843 | not want to fiddle with the addend. Otherwise, we
|
---|
1844 | need to include the symbol value so that it becomes
|
---|
1845 | an addend for the dynamic reloc. */
|
---|
1846 | if (! relocate)
|
---|
1847 | continue;
|
---|
1848 | }
|
---|
1849 | else if (r_type == R_SH_64)
|
---|
1850 | addend = rel->r_addend;
|
---|
1851 | goto final_link_relocate;
|
---|
1852 |
|
---|
1853 | case R_SH_GOTPLT_LOW16:
|
---|
1854 | case R_SH_GOTPLT_MEDLOW16:
|
---|
1855 | case R_SH_GOTPLT_MEDHI16:
|
---|
1856 | case R_SH_GOTPLT_HI16:
|
---|
1857 | case R_SH_GOTPLT10BY4:
|
---|
1858 | case R_SH_GOTPLT10BY8:
|
---|
1859 | /* Relocation is to the entry for this symbol in the
|
---|
1860 | procedure linkage table. */
|
---|
1861 |
|
---|
1862 | if (h == NULL
|
---|
1863 | || ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
|
---|
1864 | || ELF_ST_VISIBILITY (h->other) == STV_HIDDEN
|
---|
1865 | || ! info->shared
|
---|
1866 | || info->symbolic
|
---|
1867 | || h->dynindx == -1
|
---|
1868 | || h->plt.offset == (bfd_vma) -1
|
---|
1869 | || h->got.offset != (bfd_vma) -1)
|
---|
1870 | goto force_got;
|
---|
1871 |
|
---|
1872 | /* Relocation is to the entry for this symbol in the global
|
---|
1873 | offset table extension for the procedure linkage table. */
|
---|
1874 | if (sgotplt == NULL)
|
---|
1875 | {
|
---|
1876 | sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
|
---|
1877 | BFD_ASSERT (sgotplt != NULL);
|
---|
1878 | }
|
---|
1879 |
|
---|
1880 | relocation = (sgotplt->output_offset
|
---|
1881 | + ((h->plt.offset / elf_sh64_sizeof_plt (info)
|
---|
1882 | - 1 + 3) * 8));
|
---|
1883 |
|
---|
1884 | relocation -= GOT_BIAS;
|
---|
1885 |
|
---|
1886 | goto final_link_relocate;
|
---|
1887 |
|
---|
1888 | force_got:
|
---|
1889 | case R_SH_GOT_LOW16:
|
---|
1890 | case R_SH_GOT_MEDLOW16:
|
---|
1891 | case R_SH_GOT_MEDHI16:
|
---|
1892 | case R_SH_GOT_HI16:
|
---|
1893 | case R_SH_GOT10BY4:
|
---|
1894 | case R_SH_GOT10BY8:
|
---|
1895 | /* Relocation is to the entry for this symbol in the global
|
---|
1896 | offset table. */
|
---|
1897 | if (sgot == NULL)
|
---|
1898 | {
|
---|
1899 | sgot = bfd_get_section_by_name (dynobj, ".got");
|
---|
1900 | BFD_ASSERT (sgot != NULL);
|
---|
1901 | }
|
---|
1902 |
|
---|
1903 | if (h != NULL)
|
---|
1904 | {
|
---|
1905 | bfd_vma off;
|
---|
1906 |
|
---|
1907 | off = h->got.offset;
|
---|
1908 | if (seen_stt_datalabel)
|
---|
1909 | {
|
---|
1910 | struct elf_sh64_link_hash_entry *hsh;
|
---|
1911 |
|
---|
1912 | hsh = (struct elf_sh64_link_hash_entry *)h;
|
---|
1913 | off = hsh->datalabel_got_offset;
|
---|
1914 | }
|
---|
1915 | BFD_ASSERT (off != (bfd_vma) -1);
|
---|
1916 |
|
---|
1917 | if (! elf_hash_table (info)->dynamic_sections_created
|
---|
1918 | || (info->shared
|
---|
1919 | && (info->symbolic || h->dynindx == -1
|
---|
1920 | || ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
|
---|
1921 | || ELF_ST_VISIBILITY (h->other) == STV_HIDDEN)
|
---|
1922 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR)))
|
---|
1923 | {
|
---|
1924 | /* This is actually a static link, or it is a
|
---|
1925 | -Bsymbolic link and the symbol is defined
|
---|
1926 | locally, or the symbol was forced to be local
|
---|
1927 | because of a version file. We must initialize
|
---|
1928 | this entry in the global offset table. Since the
|
---|
1929 | offset must always be a multiple of 4, we use the
|
---|
1930 | least significant bit to record whether we have
|
---|
1931 | initialized it already.
|
---|
1932 |
|
---|
1933 | When doing a dynamic link, we create a .rela.got
|
---|
1934 | relocation entry to initialize the value. This
|
---|
1935 | is done in the finish_dynamic_symbol routine. */
|
---|
1936 | if ((off & 1) != 0)
|
---|
1937 | off &= ~1;
|
---|
1938 | else
|
---|
1939 | {
|
---|
1940 | bfd_put_64 (output_bfd, relocation,
|
---|
1941 | sgot->contents + off);
|
---|
1942 | if (seen_stt_datalabel)
|
---|
1943 | {
|
---|
1944 | struct elf_sh64_link_hash_entry *hsh;
|
---|
1945 |
|
---|
1946 | hsh = (struct elf_sh64_link_hash_entry *)h;
|
---|
1947 | hsh->datalabel_got_offset |= 1;
|
---|
1948 | }
|
---|
1949 | else
|
---|
1950 | h->got.offset |= 1;
|
---|
1951 | }
|
---|
1952 | }
|
---|
1953 |
|
---|
1954 | relocation = sgot->output_offset + off;
|
---|
1955 | }
|
---|
1956 | else
|
---|
1957 | {
|
---|
1958 | bfd_vma off;
|
---|
1959 |
|
---|
1960 | if (rel->r_addend)
|
---|
1961 | {
|
---|
1962 | BFD_ASSERT (local_got_offsets != NULL
|
---|
1963 | && (local_got_offsets[symtab_hdr->sh_info
|
---|
1964 | + r_symndx]
|
---|
1965 | != (bfd_vma) -1));
|
---|
1966 |
|
---|
1967 | off = local_got_offsets[symtab_hdr->sh_info
|
---|
1968 | + r_symndx];
|
---|
1969 | }
|
---|
1970 | else
|
---|
1971 | {
|
---|
1972 | BFD_ASSERT (local_got_offsets != NULL
|
---|
1973 | && local_got_offsets[r_symndx] != (bfd_vma) -1);
|
---|
1974 |
|
---|
1975 | off = local_got_offsets[r_symndx];
|
---|
1976 | }
|
---|
1977 |
|
---|
1978 | /* The offset must always be a multiple of 8. We use
|
---|
1979 | the least significant bit to record whether we have
|
---|
1980 | already generated the necessary reloc. */
|
---|
1981 | if ((off & 1) != 0)
|
---|
1982 | off &= ~1;
|
---|
1983 | else
|
---|
1984 | {
|
---|
1985 | bfd_put_64 (output_bfd, relocation, sgot->contents + off);
|
---|
1986 |
|
---|
1987 | if (info->shared)
|
---|
1988 | {
|
---|
1989 | asection *s;
|
---|
1990 | Elf_Internal_Rela outrel;
|
---|
1991 | bfd_byte *loc;
|
---|
1992 |
|
---|
1993 | s = bfd_get_section_by_name (dynobj, ".rela.got");
|
---|
1994 | BFD_ASSERT (s != NULL);
|
---|
1995 |
|
---|
1996 | outrel.r_offset = (sgot->output_section->vma
|
---|
1997 | + sgot->output_offset
|
---|
1998 | + off);
|
---|
1999 | outrel.r_info = ELF64_R_INFO (0, R_SH_RELATIVE64);
|
---|
2000 | outrel.r_addend = relocation;
|
---|
2001 | loc = s->contents;
|
---|
2002 | loc += s->reloc_count++ * sizeof (Elf64_External_Rela);
|
---|
2003 | bfd_elf64_swap_reloca_out (output_bfd, &outrel, loc);
|
---|
2004 | }
|
---|
2005 |
|
---|
2006 | if (rel->r_addend)
|
---|
2007 | local_got_offsets[symtab_hdr->sh_info + r_symndx] |= 1;
|
---|
2008 | else
|
---|
2009 | local_got_offsets[r_symndx] |= 1;
|
---|
2010 | }
|
---|
2011 |
|
---|
2012 | relocation = sgot->output_offset + off;
|
---|
2013 | }
|
---|
2014 |
|
---|
2015 | relocation -= GOT_BIAS;
|
---|
2016 |
|
---|
2017 | goto final_link_relocate;
|
---|
2018 |
|
---|
2019 | case R_SH_GOTOFF_LOW16:
|
---|
2020 | case R_SH_GOTOFF_MEDLOW16:
|
---|
2021 | case R_SH_GOTOFF_MEDHI16:
|
---|
2022 | case R_SH_GOTOFF_HI16:
|
---|
2023 | /* Relocation is relative to the start of the global offset
|
---|
2024 | table. */
|
---|
2025 |
|
---|
2026 | if (sgot == NULL)
|
---|
2027 | {
|
---|
2028 | sgot = bfd_get_section_by_name (dynobj, ".got");
|
---|
2029 | BFD_ASSERT (sgot != NULL);
|
---|
2030 | }
|
---|
2031 |
|
---|
2032 | /* Note that sgot->output_offset is not involved in this
|
---|
2033 | calculation. We always want the start of .got. If we
|
---|
2034 | defined _GLOBAL_OFFSET_TABLE in a different way, as is
|
---|
2035 | permitted by the ABI, we might have to change this
|
---|
2036 | calculation. */
|
---|
2037 | relocation -= sgot->output_section->vma;
|
---|
2038 |
|
---|
2039 | relocation -= GOT_BIAS;
|
---|
2040 |
|
---|
2041 | addend = rel->r_addend;
|
---|
2042 |
|
---|
2043 | goto final_link_relocate;
|
---|
2044 |
|
---|
2045 | case R_SH_GOTPC_LOW16:
|
---|
2046 | case R_SH_GOTPC_MEDLOW16:
|
---|
2047 | case R_SH_GOTPC_MEDHI16:
|
---|
2048 | case R_SH_GOTPC_HI16:
|
---|
2049 | /* Use global offset table as symbol value. */
|
---|
2050 |
|
---|
2051 | if (sgot == NULL)
|
---|
2052 | {
|
---|
2053 | sgot = bfd_get_section_by_name (dynobj, ".got");
|
---|
2054 | BFD_ASSERT (sgot != NULL);
|
---|
2055 | }
|
---|
2056 |
|
---|
2057 | relocation = sgot->output_section->vma;
|
---|
2058 |
|
---|
2059 | relocation += GOT_BIAS;
|
---|
2060 |
|
---|
2061 | addend = rel->r_addend;
|
---|
2062 |
|
---|
2063 | goto final_link_relocate;
|
---|
2064 |
|
---|
2065 | case R_SH_PLT_LOW16:
|
---|
2066 | case R_SH_PLT_MEDLOW16:
|
---|
2067 | case R_SH_PLT_MEDHI16:
|
---|
2068 | case R_SH_PLT_HI16:
|
---|
2069 | /* Relocation is to the entry for this symbol in the
|
---|
2070 | procedure linkage table. */
|
---|
2071 |
|
---|
2072 | /* Resolve a PLT reloc against a local symbol directly,
|
---|
2073 | without using the procedure linkage table. */
|
---|
2074 | if (h == NULL)
|
---|
2075 | goto final_link_relocate;
|
---|
2076 |
|
---|
2077 | if (ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
|
---|
2078 | || ELF_ST_VISIBILITY (h->other) == STV_HIDDEN)
|
---|
2079 | goto final_link_relocate;
|
---|
2080 |
|
---|
2081 | if (h->plt.offset == (bfd_vma) -1)
|
---|
2082 | {
|
---|
2083 | /* We didn't make a PLT entry for this symbol. This
|
---|
2084 | happens when statically linking PIC code, or when
|
---|
2085 | using -Bsymbolic. */
|
---|
2086 | goto final_link_relocate;
|
---|
2087 | }
|
---|
2088 |
|
---|
2089 | if (splt == NULL)
|
---|
2090 | {
|
---|
2091 | splt = bfd_get_section_by_name (dynobj, ".plt");
|
---|
2092 | BFD_ASSERT (splt != NULL);
|
---|
2093 | }
|
---|
2094 |
|
---|
2095 | relocation = (splt->output_section->vma
|
---|
2096 | + splt->output_offset
|
---|
2097 | + h->plt.offset);
|
---|
2098 | relocation++;
|
---|
2099 |
|
---|
2100 | addend = rel->r_addend;
|
---|
2101 |
|
---|
2102 | goto final_link_relocate;
|
---|
2103 |
|
---|
2104 | case R_SH_DIR32:
|
---|
2105 | case R_SH_SHMEDIA_CODE:
|
---|
2106 | case R_SH_PT_16:
|
---|
2107 | case R_SH_DIR5U:
|
---|
2108 | case R_SH_DIR6S:
|
---|
2109 | case R_SH_DIR6U:
|
---|
2110 | case R_SH_DIR10S:
|
---|
2111 | case R_SH_DIR10SW:
|
---|
2112 | case R_SH_DIR10SL:
|
---|
2113 | case R_SH_DIR10SQ:
|
---|
2114 | case R_SH_IMMS16:
|
---|
2115 | case R_SH_IMMU16:
|
---|
2116 | case R_SH_IMM_LOW16:
|
---|
2117 | case R_SH_IMM_LOW16_PCREL:
|
---|
2118 | case R_SH_IMM_MEDLOW16:
|
---|
2119 | case R_SH_IMM_MEDLOW16_PCREL:
|
---|
2120 | case R_SH_IMM_MEDHI16:
|
---|
2121 | case R_SH_IMM_MEDHI16_PCREL:
|
---|
2122 | case R_SH_IMM_HI16:
|
---|
2123 | case R_SH_IMM_HI16_PCREL:
|
---|
2124 | addend = rel->r_addend;
|
---|
2125 | /* Fall through. */
|
---|
2126 | case R_SH_REL32:
|
---|
2127 | final_link_relocate:
|
---|
2128 | r = _bfd_final_link_relocate (howto, input_bfd, input_section,
|
---|
2129 | contents, rel->r_offset,
|
---|
2130 | relocation, addend);
|
---|
2131 | break;
|
---|
2132 |
|
---|
2133 | default:
|
---|
2134 | bfd_set_error (bfd_error_bad_value);
|
---|
2135 | return FALSE;
|
---|
2136 |
|
---|
2137 | }
|
---|
2138 |
|
---|
2139 | if (r != bfd_reloc_ok)
|
---|
2140 | {
|
---|
2141 | switch (r)
|
---|
2142 | {
|
---|
2143 | default:
|
---|
2144 | case bfd_reloc_outofrange:
|
---|
2145 | abort ();
|
---|
2146 | case bfd_reloc_overflow:
|
---|
2147 | {
|
---|
2148 | const char *name;
|
---|
2149 |
|
---|
2150 | if (h != NULL)
|
---|
2151 | name = h->root.root.string;
|
---|
2152 | else
|
---|
2153 | {
|
---|
2154 | name = (bfd_elf_string_from_elf_section
|
---|
2155 | (input_bfd, symtab_hdr->sh_link, sym->st_name));
|
---|
2156 | if (name == NULL)
|
---|
2157 | return FALSE;
|
---|
2158 | if (*name == '\0')
|
---|
2159 | name = bfd_section_name (input_bfd, sec);
|
---|
2160 | }
|
---|
2161 | if (! ((*info->callbacks->reloc_overflow)
|
---|
2162 | (info, name, howto->name, (bfd_vma) 0,
|
---|
2163 | input_bfd, input_section, rel->r_offset)))
|
---|
2164 | return FALSE;
|
---|
2165 | }
|
---|
2166 | break;
|
---|
2167 | }
|
---|
2168 | }
|
---|
2169 | }
|
---|
2170 |
|
---|
2171 | return TRUE;
|
---|
2172 | }
|
---|
2173 |
|
---|
2174 | /* This is a version of bfd_generic_get_relocated_section_contents
|
---|
2175 | that uses sh_elf64_relocate_section.
|
---|
2176 |
|
---|
2177 | See sh_elf_relocate_section in elf32-sh.c for the original. */
|
---|
2178 |
|
---|
2179 | static bfd_byte *
|
---|
2180 | sh_elf64_get_relocated_section_contents (output_bfd, link_info, link_order,
|
---|
2181 | data, relocateable, symbols)
|
---|
2182 | bfd *output_bfd;
|
---|
2183 | struct bfd_link_info *link_info;
|
---|
2184 | struct bfd_link_order *link_order;
|
---|
2185 | bfd_byte *data;
|
---|
2186 | bfd_boolean relocateable;
|
---|
2187 | asymbol **symbols;
|
---|
2188 | {
|
---|
2189 | Elf_Internal_Shdr *symtab_hdr;
|
---|
2190 | asection *input_section = link_order->u.indirect.section;
|
---|
2191 | bfd *input_bfd = input_section->owner;
|
---|
2192 | asection **sections = NULL;
|
---|
2193 | Elf_Internal_Rela *internal_relocs = NULL;
|
---|
2194 | Elf_Internal_Sym *isymbuf = NULL;
|
---|
2195 |
|
---|
2196 | /* We only need to handle the case of relaxing, or of having a
|
---|
2197 | particular set of section contents, specially. */
|
---|
2198 | if (relocateable
|
---|
2199 | || elf_section_data (input_section)->this_hdr.contents == NULL)
|
---|
2200 | return bfd_generic_get_relocated_section_contents (output_bfd, link_info,
|
---|
2201 | link_order, data,
|
---|
2202 | relocateable,
|
---|
2203 | symbols);
|
---|
2204 |
|
---|
2205 | symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
|
---|
2206 |
|
---|
2207 | memcpy (data, elf_section_data (input_section)->this_hdr.contents,
|
---|
2208 | input_section->_raw_size);
|
---|
2209 |
|
---|
2210 | if ((input_section->flags & SEC_RELOC) != 0
|
---|
2211 | && input_section->reloc_count > 0)
|
---|
2212 | {
|
---|
2213 | Elf_Internal_Sym *isymp;
|
---|
2214 | Elf_Internal_Sym *isymend;
|
---|
2215 | asection **secpp;
|
---|
2216 |
|
---|
2217 | /* Read this BFD's local symbols. */
|
---|
2218 | if (symtab_hdr->sh_info != 0)
|
---|
2219 | {
|
---|
2220 | isymbuf = (Elf_Internal_Sym *) symtab_hdr->contents;
|
---|
2221 | if (isymbuf == NULL)
|
---|
2222 | isymbuf = bfd_elf_get_elf_syms (input_bfd, symtab_hdr,
|
---|
2223 | symtab_hdr->sh_info, 0,
|
---|
2224 | NULL, NULL, NULL);
|
---|
2225 | if (isymbuf == NULL)
|
---|
2226 | goto error_return;
|
---|
2227 | }
|
---|
2228 |
|
---|
2229 | internal_relocs = (_bfd_elf64_link_read_relocs
|
---|
2230 | (input_bfd, input_section, (PTR) NULL,
|
---|
2231 | (Elf_Internal_Rela *) NULL, FALSE));
|
---|
2232 | if (internal_relocs == NULL)
|
---|
2233 | goto error_return;
|
---|
2234 |
|
---|
2235 | sections = (asection **) bfd_malloc (symtab_hdr->sh_info
|
---|
2236 | * sizeof (asection *));
|
---|
2237 | if (sections == NULL && symtab_hdr->sh_info > 0)
|
---|
2238 | goto error_return;
|
---|
2239 |
|
---|
2240 | secpp = sections;
|
---|
2241 | isymend = isymbuf + symtab_hdr->sh_info;
|
---|
2242 | for (isymp = isymbuf; isymp < isymend; ++isymp, ++secpp)
|
---|
2243 | {
|
---|
2244 | asection *isec;
|
---|
2245 |
|
---|
2246 | if (isymp->st_shndx == SHN_UNDEF)
|
---|
2247 | isec = bfd_und_section_ptr;
|
---|
2248 | else if (isymp->st_shndx > 0 && isymp->st_shndx < SHN_LORESERVE)
|
---|
2249 | isec = bfd_section_from_elf_index (input_bfd, isymp->st_shndx);
|
---|
2250 | else if (isymp->st_shndx == SHN_ABS)
|
---|
2251 | isec = bfd_abs_section_ptr;
|
---|
2252 | else if (isymp->st_shndx == SHN_COMMON)
|
---|
2253 | isec = bfd_com_section_ptr;
|
---|
2254 | else
|
---|
2255 | {
|
---|
2256 | /* Who knows? */
|
---|
2257 | isec = NULL;
|
---|
2258 | }
|
---|
2259 |
|
---|
2260 | *secpp = isec;
|
---|
2261 | }
|
---|
2262 |
|
---|
2263 | if (! sh_elf64_relocate_section (output_bfd, link_info, input_bfd,
|
---|
2264 | input_section, data, internal_relocs,
|
---|
2265 | isymbuf, sections))
|
---|
2266 | goto error_return;
|
---|
2267 |
|
---|
2268 | if (sections != NULL)
|
---|
2269 | free (sections);
|
---|
2270 | if (internal_relocs != elf_section_data (input_section)->relocs)
|
---|
2271 | free (internal_relocs);
|
---|
2272 | if (isymbuf != NULL
|
---|
2273 | && (unsigned char *) isymbuf != symtab_hdr->contents)
|
---|
2274 | free (isymbuf);
|
---|
2275 | }
|
---|
2276 |
|
---|
2277 | return data;
|
---|
2278 |
|
---|
2279 | error_return:
|
---|
2280 | if (sections != NULL)
|
---|
2281 | free (sections);
|
---|
2282 | if (internal_relocs != NULL
|
---|
2283 | && internal_relocs != elf_section_data (input_section)->relocs)
|
---|
2284 | free (internal_relocs);
|
---|
2285 | if (isymbuf != NULL
|
---|
2286 | && (unsigned char *) isymbuf != symtab_hdr->contents)
|
---|
2287 | free (isymbuf);
|
---|
2288 | return NULL;
|
---|
2289 | }
|
---|
2290 |
|
---|
2291 | /* Set the SHF_SH5_ISA32 flag for ISA SHmedia code sections. */
|
---|
2292 |
|
---|
2293 | bfd_boolean
|
---|
2294 | sh64_elf64_fake_sections (output_bfd, elf_section_hdr, asect)
|
---|
2295 | bfd *output_bfd ATTRIBUTE_UNUSED;
|
---|
2296 | Elf_Internal_Shdr *elf_section_hdr;
|
---|
2297 | asection *asect;
|
---|
2298 | {
|
---|
2299 | /* Code sections can only contain SH64 code, so mark them as such. */
|
---|
2300 | if (bfd_get_section_flags (output_bfd, asect) & SEC_CODE)
|
---|
2301 | elf_section_hdr->sh_flags |= SHF_SH5_ISA32;
|
---|
2302 |
|
---|
2303 | return TRUE;
|
---|
2304 | }
|
---|
2305 |
|
---|
2306 | static bfd_boolean
|
---|
2307 | sh_elf64_set_mach_from_flags (abfd)
|
---|
2308 | bfd *abfd;
|
---|
2309 | {
|
---|
2310 | flagword flags = elf_elfheader (abfd)->e_flags;
|
---|
2311 |
|
---|
2312 | switch (flags & EF_SH_MACH_MASK)
|
---|
2313 | {
|
---|
2314 | case EF_SH5:
|
---|
2315 | /* Just one, but keep the switch construct to make additions easy. */
|
---|
2316 | bfd_default_set_arch_mach (abfd, bfd_arch_sh, bfd_mach_sh5);
|
---|
2317 | break;
|
---|
2318 |
|
---|
2319 | default:
|
---|
2320 | bfd_set_error (bfd_error_wrong_format);
|
---|
2321 | return FALSE;
|
---|
2322 | }
|
---|
2323 | return TRUE;
|
---|
2324 | }
|
---|
2325 |
|
---|
2326 | /* Function to keep SH64 specific file flags.
|
---|
2327 |
|
---|
2328 | See sh64_elf_set_private_flags in elf32-sh64.c for the original. */
|
---|
2329 |
|
---|
2330 | static bfd_boolean
|
---|
2331 | sh_elf64_set_private_flags (abfd, flags)
|
---|
2332 | bfd * abfd;
|
---|
2333 | flagword flags;
|
---|
2334 | {
|
---|
2335 | BFD_ASSERT (! elf_flags_init (abfd)
|
---|
2336 | || elf_elfheader (abfd)->e_flags == flags);
|
---|
2337 |
|
---|
2338 | elf_elfheader (abfd)->e_flags = flags;
|
---|
2339 | elf_flags_init (abfd) = TRUE;
|
---|
2340 | return sh_elf64_set_mach_from_flags (abfd);
|
---|
2341 | }
|
---|
2342 |
|
---|
2343 | /* Copy the SHF_SH5_ISA32 attribute that we keep on all sections with
|
---|
2344 | code, to keep attributes the same as for SHmedia in 32-bit ELF. */
|
---|
2345 |
|
---|
2346 | static bfd_boolean
|
---|
2347 | sh_elf64_copy_private_data_internal (ibfd, obfd)
|
---|
2348 | bfd * ibfd;
|
---|
2349 | bfd * obfd;
|
---|
2350 | {
|
---|
2351 | Elf_Internal_Shdr **o_shdrp;
|
---|
2352 | asection *isec;
|
---|
2353 | asection *osec;
|
---|
2354 |
|
---|
2355 | if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
|
---|
2356 | || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
|
---|
2357 | return TRUE;
|
---|
2358 |
|
---|
2359 | o_shdrp = elf_elfsections (obfd);
|
---|
2360 | for (osec = obfd->sections; osec; osec = osec->next)
|
---|
2361 | {
|
---|
2362 | int oIndex = ((struct bfd_elf_section_data *) elf_section_data (osec))->this_idx;
|
---|
2363 | for (isec = ibfd->sections; isec; isec = isec->next)
|
---|
2364 | {
|
---|
2365 | if (strcmp (osec->name, isec->name) == 0)
|
---|
2366 | {
|
---|
2367 | /* Note that we're not disallowing mixing data and code. */
|
---|
2368 | if ((elf_section_data (isec)->this_hdr.sh_flags
|
---|
2369 | & SHF_SH5_ISA32) != 0)
|
---|
2370 | o_shdrp[oIndex]->sh_flags |= SHF_SH5_ISA32;
|
---|
2371 | break;
|
---|
2372 | }
|
---|
2373 | }
|
---|
2374 | }
|
---|
2375 |
|
---|
2376 | return sh_elf64_set_private_flags (obfd, elf_elfheader (ibfd)->e_flags);
|
---|
2377 | }
|
---|
2378 |
|
---|
2379 | static bfd_boolean
|
---|
2380 | sh_elf64_copy_private_data (ibfd, obfd)
|
---|
2381 | bfd * ibfd;
|
---|
2382 | bfd * obfd;
|
---|
2383 | {
|
---|
2384 | return sh_elf64_copy_private_data_internal (ibfd, obfd);
|
---|
2385 | }
|
---|
2386 |
|
---|
2387 | static bfd_boolean
|
---|
2388 | sh_elf64_merge_private_data (ibfd, obfd)
|
---|
2389 | bfd *ibfd;
|
---|
2390 | bfd *obfd;
|
---|
2391 | {
|
---|
2392 | flagword old_flags, new_flags;
|
---|
2393 |
|
---|
2394 | if (! _bfd_generic_verify_endian_match (ibfd, obfd))
|
---|
2395 | return FALSE;
|
---|
2396 |
|
---|
2397 | if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour
|
---|
2398 | || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
|
---|
2399 | return TRUE;
|
---|
2400 |
|
---|
2401 | if (bfd_get_arch_size (ibfd) != bfd_get_arch_size (obfd))
|
---|
2402 | {
|
---|
2403 | const char *msg;
|
---|
2404 |
|
---|
2405 | if (bfd_get_arch_size (ibfd) == 32
|
---|
2406 | && bfd_get_arch_size (obfd) == 64)
|
---|
2407 | msg = _("%s: compiled as 32-bit object and %s is 64-bit");
|
---|
2408 | else if (bfd_get_arch_size (ibfd) == 64
|
---|
2409 | && bfd_get_arch_size (obfd) == 32)
|
---|
2410 | msg = _("%s: compiled as 64-bit object and %s is 32-bit");
|
---|
2411 | else
|
---|
2412 | msg = _("%s: object size does not match that of target %s");
|
---|
2413 |
|
---|
2414 | (*_bfd_error_handler) (msg, bfd_get_filename (ibfd),
|
---|
2415 | bfd_get_filename (obfd));
|
---|
2416 | bfd_set_error (bfd_error_wrong_format);
|
---|
2417 | return FALSE;
|
---|
2418 | }
|
---|
2419 |
|
---|
2420 | old_flags = elf_elfheader (obfd)->e_flags;
|
---|
2421 | new_flags = elf_elfheader (ibfd)->e_flags;
|
---|
2422 | if (! elf_flags_init (obfd))
|
---|
2423 | {
|
---|
2424 | /* This happens when ld starts out with a 'blank' output file. */
|
---|
2425 | elf_flags_init (obfd) = TRUE;
|
---|
2426 | elf_elfheader (obfd)->e_flags = old_flags = new_flags;
|
---|
2427 | }
|
---|
2428 | /* We don't allow linking in anything else than SH64 code, and since
|
---|
2429 | this is a 64-bit ELF, we assume the 64-bit ABI is used. Add code
|
---|
2430 | here as things change. */
|
---|
2431 | else if ((new_flags & EF_SH_MACH_MASK) != EF_SH5)
|
---|
2432 | {
|
---|
2433 | (*_bfd_error_handler)
|
---|
2434 | ("%s: does not use the SH64 64-bit ABI as previous modules do",
|
---|
2435 | bfd_get_filename (ibfd));
|
---|
2436 | bfd_set_error (bfd_error_bad_value);
|
---|
2437 | return FALSE;
|
---|
2438 | }
|
---|
2439 |
|
---|
2440 | sh_elf64_copy_private_data_internal (ibfd, obfd);
|
---|
2441 |
|
---|
2442 | /* I can't think of anything sane other than old_flags being EF_SH5 and
|
---|
2443 | that we need to preserve that. */
|
---|
2444 | elf_elfheader (obfd)->e_flags = old_flags;
|
---|
2445 |
|
---|
2446 | return sh_elf64_set_mach_from_flags (obfd);
|
---|
2447 | }
|
---|
2448 |
|
---|
2449 | /* Return the section that should be marked against GC for a given
|
---|
2450 | relocation. */
|
---|
2451 |
|
---|
2452 | static asection *
|
---|
2453 | sh_elf64_gc_mark_hook (sec, info, rel, h, sym)
|
---|
2454 | asection *sec;
|
---|
2455 | struct bfd_link_info *info ATTRIBUTE_UNUSED;
|
---|
2456 | Elf_Internal_Rela *rel;
|
---|
2457 | struct elf_link_hash_entry *h;
|
---|
2458 | Elf_Internal_Sym *sym;
|
---|
2459 | {
|
---|
2460 | if (h != NULL)
|
---|
2461 | {
|
---|
2462 | switch (ELF64_R_TYPE (rel->r_info))
|
---|
2463 | {
|
---|
2464 | case R_SH_GNU_VTINHERIT:
|
---|
2465 | case R_SH_GNU_VTENTRY:
|
---|
2466 | break;
|
---|
2467 |
|
---|
2468 | default:
|
---|
2469 | while (h->root.type == bfd_link_hash_indirect
|
---|
2470 | && h->root.u.i.link)
|
---|
2471 | h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
---|
2472 | switch (h->root.type)
|
---|
2473 | {
|
---|
2474 | case bfd_link_hash_defined:
|
---|
2475 | case bfd_link_hash_defweak:
|
---|
2476 | return h->root.u.def.section;
|
---|
2477 |
|
---|
2478 | case bfd_link_hash_common:
|
---|
2479 | return h->root.u.c.p->section;
|
---|
2480 |
|
---|
2481 | default:
|
---|
2482 | break;
|
---|
2483 | }
|
---|
2484 | }
|
---|
2485 | }
|
---|
2486 | else
|
---|
2487 | return bfd_section_from_elf_index (sec->owner, sym->st_shndx);
|
---|
2488 |
|
---|
2489 | return NULL;
|
---|
2490 | }
|
---|
2491 |
|
---|
2492 | /* Update the got entry reference counts for the section being removed. */
|
---|
2493 |
|
---|
2494 | static bfd_boolean
|
---|
2495 | sh_elf64_gc_sweep_hook (abfd, info, sec, relocs)
|
---|
2496 | bfd *abfd ATTRIBUTE_UNUSED;
|
---|
2497 | struct bfd_link_info *info ATTRIBUTE_UNUSED;
|
---|
2498 | asection *sec ATTRIBUTE_UNUSED;
|
---|
2499 | const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;
|
---|
2500 | {
|
---|
2501 | /* No got and plt entries for 64-bit SH at present. */
|
---|
2502 | return TRUE;
|
---|
2503 | }
|
---|
2504 |
|
---|
2505 | /* Look through the relocs for a section during the first phase.
|
---|
2506 | Since we don't do .gots or .plts, we just need to consider the
|
---|
2507 | virtual table relocs for gc. */
|
---|
2508 |
|
---|
2509 | static bfd_boolean
|
---|
2510 | sh_elf64_check_relocs (abfd, info, sec, relocs)
|
---|
2511 | bfd *abfd;
|
---|
2512 | struct bfd_link_info *info;
|
---|
2513 | asection *sec;
|
---|
2514 | const Elf_Internal_Rela *relocs;
|
---|
2515 | {
|
---|
2516 | Elf_Internal_Shdr *symtab_hdr;
|
---|
2517 | struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;
|
---|
2518 | const Elf_Internal_Rela *rel;
|
---|
2519 | const Elf_Internal_Rela *rel_end;
|
---|
2520 | bfd *dynobj;
|
---|
2521 | bfd_vma *local_got_offsets;
|
---|
2522 | asection *sgot;
|
---|
2523 | asection *srelgot;
|
---|
2524 | asection *sreloc;
|
---|
2525 |
|
---|
2526 | sgot = NULL;
|
---|
2527 | srelgot = NULL;
|
---|
2528 | sreloc = NULL;
|
---|
2529 |
|
---|
2530 | if (info->relocateable)
|
---|
2531 | return TRUE;
|
---|
2532 |
|
---|
2533 | symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
|
---|
2534 | sym_hashes = elf_sym_hashes (abfd);
|
---|
2535 | sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof(Elf64_External_Sym);
|
---|
2536 | if (!elf_bad_symtab (abfd))
|
---|
2537 | sym_hashes_end -= symtab_hdr->sh_info;
|
---|
2538 |
|
---|
2539 | dynobj = elf_hash_table (info)->dynobj;
|
---|
2540 | local_got_offsets = elf_local_got_offsets (abfd);
|
---|
2541 |
|
---|
2542 | rel_end = relocs + sec->reloc_count;
|
---|
2543 | for (rel = relocs; rel < rel_end; rel++)
|
---|
2544 | {
|
---|
2545 | struct elf_link_hash_entry *h;
|
---|
2546 | unsigned long r_symndx;
|
---|
2547 |
|
---|
2548 | r_symndx = ELF64_R_SYM (rel->r_info);
|
---|
2549 | if (r_symndx < symtab_hdr->sh_info)
|
---|
2550 | h = NULL;
|
---|
2551 | else
|
---|
2552 | h = sym_hashes[r_symndx - symtab_hdr->sh_info];
|
---|
2553 |
|
---|
2554 | /* Some relocs require a global offset table. */
|
---|
2555 | if (dynobj == NULL)
|
---|
2556 | {
|
---|
2557 | switch (ELF64_R_TYPE (rel->r_info))
|
---|
2558 | {
|
---|
2559 | case R_SH_GOTPLT_LOW16:
|
---|
2560 | case R_SH_GOTPLT_MEDLOW16:
|
---|
2561 | case R_SH_GOTPLT_MEDHI16:
|
---|
2562 | case R_SH_GOTPLT_HI16:
|
---|
2563 | case R_SH_GOTPLT10BY4:
|
---|
2564 | case R_SH_GOTPLT10BY8:
|
---|
2565 | case R_SH_GOT_LOW16:
|
---|
2566 | case R_SH_GOT_MEDLOW16:
|
---|
2567 | case R_SH_GOT_MEDHI16:
|
---|
2568 | case R_SH_GOT_HI16:
|
---|
2569 | case R_SH_GOT10BY4:
|
---|
2570 | case R_SH_GOT10BY8:
|
---|
2571 | case R_SH_GOTOFF_LOW16:
|
---|
2572 | case R_SH_GOTOFF_MEDLOW16:
|
---|
2573 | case R_SH_GOTOFF_MEDHI16:
|
---|
2574 | case R_SH_GOTOFF_HI16:
|
---|
2575 | case R_SH_GOTPC_LOW16:
|
---|
2576 | case R_SH_GOTPC_MEDLOW16:
|
---|
2577 | case R_SH_GOTPC_MEDHI16:
|
---|
2578 | case R_SH_GOTPC_HI16:
|
---|
2579 | elf_hash_table (info)->dynobj = dynobj = abfd;
|
---|
2580 | if (! _bfd_elf_create_got_section (dynobj, info))
|
---|
2581 | return FALSE;
|
---|
2582 | break;
|
---|
2583 |
|
---|
2584 | default:
|
---|
2585 | break;
|
---|
2586 | }
|
---|
2587 | }
|
---|
2588 |
|
---|
2589 | switch (ELF64_R_TYPE (rel->r_info))
|
---|
2590 | {
|
---|
2591 | /* This relocation describes the C++ object vtable hierarchy.
|
---|
2592 | Reconstruct it for later use during GC. */
|
---|
2593 | case R_SH_GNU_VTINHERIT:
|
---|
2594 | if (!_bfd_elf64_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
|
---|
2595 | return FALSE;
|
---|
2596 | break;
|
---|
2597 |
|
---|
2598 | /* This relocation describes which C++ vtable entries are actually
|
---|
2599 | used. Record for later use during GC. */
|
---|
2600 | case R_SH_GNU_VTENTRY:
|
---|
2601 | if (!_bfd_elf64_gc_record_vtentry (abfd, sec, h, rel->r_addend))
|
---|
2602 | return FALSE;
|
---|
2603 | break;
|
---|
2604 |
|
---|
2605 | force_got:
|
---|
2606 | case R_SH_GOT_LOW16:
|
---|
2607 | case R_SH_GOT_MEDLOW16:
|
---|
2608 | case R_SH_GOT_MEDHI16:
|
---|
2609 | case R_SH_GOT_HI16:
|
---|
2610 | case R_SH_GOT10BY4:
|
---|
2611 | case R_SH_GOT10BY8:
|
---|
2612 | /* This symbol requires a global offset table entry. */
|
---|
2613 |
|
---|
2614 | if (sgot == NULL)
|
---|
2615 | {
|
---|
2616 | sgot = bfd_get_section_by_name (dynobj, ".got");
|
---|
2617 | BFD_ASSERT (sgot != NULL);
|
---|
2618 | }
|
---|
2619 |
|
---|
2620 | if (srelgot == NULL
|
---|
2621 | && (h != NULL || info->shared))
|
---|
2622 | {
|
---|
2623 | srelgot = bfd_get_section_by_name (dynobj, ".rela.got");
|
---|
2624 | if (srelgot == NULL)
|
---|
2625 | {
|
---|
2626 | srelgot = bfd_make_section (dynobj, ".rela.got");
|
---|
2627 | if (srelgot == NULL
|
---|
2628 | || ! bfd_set_section_flags (dynobj, srelgot,
|
---|
2629 | (SEC_ALLOC
|
---|
2630 | | SEC_LOAD
|
---|
2631 | | SEC_HAS_CONTENTS
|
---|
2632 | | SEC_IN_MEMORY
|
---|
2633 | | SEC_LINKER_CREATED
|
---|
2634 | | SEC_READONLY))
|
---|
2635 | || ! bfd_set_section_alignment (dynobj, srelgot, 2))
|
---|
2636 | return FALSE;
|
---|
2637 | }
|
---|
2638 | }
|
---|
2639 |
|
---|
2640 | if (h != NULL)
|
---|
2641 | {
|
---|
2642 | if (h->type == STT_DATALABEL)
|
---|
2643 | {
|
---|
2644 | struct elf_sh64_link_hash_entry *hsh;
|
---|
2645 |
|
---|
2646 | h = (struct elf_link_hash_entry *) h->root.u.i.link;
|
---|
2647 | hsh = (struct elf_sh64_link_hash_entry *)h;
|
---|
2648 | if (hsh->datalabel_got_offset != (bfd_vma) -1)
|
---|
2649 | break;
|
---|
2650 |
|
---|
2651 | hsh->datalabel_got_offset = sgot->_raw_size;
|
---|
2652 | }
|
---|
2653 | else
|
---|
2654 | {
|
---|
2655 | if (h->got.offset != (bfd_vma) -1)
|
---|
2656 | {
|
---|
2657 | /* We have already allocated space in the .got. */
|
---|
2658 | break;
|
---|
2659 | }
|
---|
2660 | h->got.offset = sgot->_raw_size;
|
---|
2661 | }
|
---|
2662 |
|
---|
2663 | /* Make sure this symbol is output as a dynamic symbol. */
|
---|
2664 | if (h->dynindx == -1)
|
---|
2665 | {
|
---|
2666 | if (! bfd_elf64_link_record_dynamic_symbol (info, h))
|
---|
2667 | return FALSE;
|
---|
2668 | }
|
---|
2669 |
|
---|
2670 | srelgot->_raw_size += sizeof (Elf64_External_Rela);
|
---|
2671 | }
|
---|
2672 | else
|
---|
2673 | {
|
---|
2674 | /* This is a global offset table entry for a local
|
---|
2675 | symbol. */
|
---|
2676 | if (local_got_offsets == NULL)
|
---|
2677 | {
|
---|
2678 | size_t size;
|
---|
2679 | register unsigned int i;
|
---|
2680 |
|
---|
2681 | size = symtab_hdr->sh_info * sizeof (bfd_vma);
|
---|
2682 | /* Reserve space for both the datalabel and
|
---|
2683 | codelabel local GOT offsets. */
|
---|
2684 | size *= 2;
|
---|
2685 | local_got_offsets = (bfd_vma *) bfd_alloc (abfd, size);
|
---|
2686 | if (local_got_offsets == NULL)
|
---|
2687 | return FALSE;
|
---|
2688 | elf_local_got_offsets (abfd) = local_got_offsets;
|
---|
2689 | for (i = 0; i < symtab_hdr->sh_info; i++)
|
---|
2690 | local_got_offsets[i] = (bfd_vma) -1;
|
---|
2691 | for (; i < 2 * symtab_hdr->sh_info; i++)
|
---|
2692 | local_got_offsets[i] = (bfd_vma) -1;
|
---|
2693 | }
|
---|
2694 | if ((rel->r_addend & 1) != 0)
|
---|
2695 | {
|
---|
2696 | if (local_got_offsets[symtab_hdr->sh_info
|
---|
2697 | + r_symndx] != (bfd_vma) -1)
|
---|
2698 | {
|
---|
2699 | /* We have already allocated space in the .got. */
|
---|
2700 | break;
|
---|
2701 | }
|
---|
2702 | local_got_offsets[symtab_hdr->sh_info
|
---|
2703 | + r_symndx] = sgot->_raw_size;
|
---|
2704 | }
|
---|
2705 | else
|
---|
2706 | {
|
---|
2707 | if (local_got_offsets[r_symndx] != (bfd_vma) -1)
|
---|
2708 | {
|
---|
2709 | /* We have already allocated space in the .got. */
|
---|
2710 | break;
|
---|
2711 | }
|
---|
2712 | local_got_offsets[r_symndx] = sgot->_raw_size;
|
---|
2713 | }
|
---|
2714 |
|
---|
2715 | if (info->shared)
|
---|
2716 | {
|
---|
2717 | /* If we are generating a shared object, we need to
|
---|
2718 | output a R_SH_RELATIVE reloc so that the dynamic
|
---|
2719 | linker can adjust this GOT entry. */
|
---|
2720 | srelgot->_raw_size += sizeof (Elf64_External_Rela);
|
---|
2721 | }
|
---|
2722 | }
|
---|
2723 |
|
---|
2724 | sgot->_raw_size += 8;
|
---|
2725 |
|
---|
2726 | break;
|
---|
2727 |
|
---|
2728 | case R_SH_GOTPLT_LOW16:
|
---|
2729 | case R_SH_GOTPLT_MEDLOW16:
|
---|
2730 | case R_SH_GOTPLT_MEDHI16:
|
---|
2731 | case R_SH_GOTPLT_HI16:
|
---|
2732 | case R_SH_GOTPLT10BY4:
|
---|
2733 | case R_SH_GOTPLT10BY8:
|
---|
2734 | /* If this is a local symbol, we resolve it directly without
|
---|
2735 | creating a procedure linkage table entry. */
|
---|
2736 |
|
---|
2737 | if (h == NULL
|
---|
2738 | || ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
|
---|
2739 | || ELF_ST_VISIBILITY (h->other) == STV_HIDDEN
|
---|
2740 | || ! info->shared
|
---|
2741 | || info->symbolic
|
---|
2742 | || h->dynindx == -1
|
---|
2743 | || h->got.offset != (bfd_vma) -1)
|
---|
2744 | goto force_got;
|
---|
2745 |
|
---|
2746 | /* Make sure this symbol is output as a dynamic symbol. */
|
---|
2747 | if (h->dynindx == -1)
|
---|
2748 | {
|
---|
2749 | if (! bfd_elf64_link_record_dynamic_symbol (info, h))
|
---|
2750 | return FALSE;
|
---|
2751 | }
|
---|
2752 |
|
---|
2753 | h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
|
---|
2754 |
|
---|
2755 | break;
|
---|
2756 |
|
---|
2757 | case R_SH_PLT_LOW16:
|
---|
2758 | case R_SH_PLT_MEDLOW16:
|
---|
2759 | case R_SH_PLT_MEDHI16:
|
---|
2760 | case R_SH_PLT_HI16:
|
---|
2761 | /* This symbol requires a procedure linkage table entry. We
|
---|
2762 | actually build the entry in adjust_dynamic_symbol,
|
---|
2763 | because this might be a case of linking PIC code which is
|
---|
2764 | never referenced by a dynamic object, in which case we
|
---|
2765 | don't need to generate a procedure linkage table entry
|
---|
2766 | after all. */
|
---|
2767 |
|
---|
2768 | /* If this is a local symbol, we resolve it directly without
|
---|
2769 | creating a procedure linkage table entry. */
|
---|
2770 | if (h == NULL)
|
---|
2771 | continue;
|
---|
2772 |
|
---|
2773 | if (ELF_ST_VISIBILITY (h->other) == STV_INTERNAL
|
---|
2774 | || ELF_ST_VISIBILITY (h->other) == STV_HIDDEN)
|
---|
2775 | break;
|
---|
2776 |
|
---|
2777 | h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
|
---|
2778 |
|
---|
2779 | break;
|
---|
2780 |
|
---|
2781 | case R_SH_64:
|
---|
2782 | case R_SH_64_PCREL:
|
---|
2783 | if (h != NULL)
|
---|
2784 | h->elf_link_hash_flags |= ELF_LINK_NON_GOT_REF;
|
---|
2785 |
|
---|
2786 | /* If we are creating a shared library, and this is a reloc
|
---|
2787 | against a global symbol, or a non PC relative reloc
|
---|
2788 | against a local symbol, then we need to copy the reloc
|
---|
2789 | into the shared library. However, if we are linking with
|
---|
2790 | -Bsymbolic, we do not need to copy a reloc against a
|
---|
2791 | global symbol which is defined in an object we are
|
---|
2792 | including in the link (i.e., DEF_REGULAR is set). At
|
---|
2793 | this point we have not seen all the input files, so it is
|
---|
2794 | possible that DEF_REGULAR is not set now but will be set
|
---|
2795 | later (it is never cleared). We account for that
|
---|
2796 | possibility below by storing information in the
|
---|
2797 | pcrel_relocs_copied field of the hash table entry. */
|
---|
2798 | if (info->shared
|
---|
2799 | && (sec->flags & SEC_ALLOC) != 0
|
---|
2800 | && (ELF32_R_TYPE (rel->r_info) != R_SH_64_PCREL
|
---|
2801 | || (h != NULL
|
---|
2802 | && (! info->symbolic
|
---|
2803 | || (h->elf_link_hash_flags
|
---|
2804 | & ELF_LINK_HASH_DEF_REGULAR) == 0))))
|
---|
2805 | {
|
---|
2806 | /* When creating a shared object, we must copy these
|
---|
2807 | reloc types into the output file. We create a reloc
|
---|
2808 | section in dynobj and make room for this reloc. */
|
---|
2809 | if (sreloc == NULL)
|
---|
2810 | {
|
---|
2811 | const char *name;
|
---|
2812 |
|
---|
2813 | name = (bfd_elf_string_from_elf_section
|
---|
2814 | (abfd,
|
---|
2815 | elf_elfheader (abfd)->e_shstrndx,
|
---|
2816 | elf_section_data (sec)->rel_hdr.sh_name));
|
---|
2817 | if (name == NULL)
|
---|
2818 | return FALSE;
|
---|
2819 |
|
---|
2820 | BFD_ASSERT (strncmp (name, ".rela", 5) == 0
|
---|
2821 | && strcmp (bfd_get_section_name (abfd, sec),
|
---|
2822 | name + 5) == 0);
|
---|
2823 |
|
---|
2824 | sreloc = bfd_get_section_by_name (dynobj, name);
|
---|
2825 | if (sreloc == NULL)
|
---|
2826 | {
|
---|
2827 | flagword flags;
|
---|
2828 |
|
---|
2829 | sreloc = bfd_make_section (dynobj, name);
|
---|
2830 | flags = (SEC_HAS_CONTENTS | SEC_READONLY
|
---|
2831 | | SEC_IN_MEMORY | SEC_LINKER_CREATED);
|
---|
2832 | if ((sec->flags & SEC_ALLOC) != 0)
|
---|
2833 | flags |= SEC_ALLOC | SEC_LOAD;
|
---|
2834 | if (sreloc == NULL
|
---|
2835 | || ! bfd_set_section_flags (dynobj, sreloc, flags)
|
---|
2836 | || ! bfd_set_section_alignment (dynobj, sreloc, 2))
|
---|
2837 | return FALSE;
|
---|
2838 | }
|
---|
2839 | }
|
---|
2840 |
|
---|
2841 | sreloc->_raw_size += sizeof (Elf64_External_Rela);
|
---|
2842 |
|
---|
2843 | /* If we are linking with -Bsymbolic, and this is a
|
---|
2844 | global symbol, we count the number of PC relative
|
---|
2845 | relocations we have entered for this symbol, so that
|
---|
2846 | we can discard them again if the symbol is later
|
---|
2847 | defined by a regular object. Note that this function
|
---|
2848 | is only called if we are using an elf_sh linker
|
---|
2849 | hash table, which means that h is really a pointer to
|
---|
2850 | an elf_sh_link_hash_entry. */
|
---|
2851 | if (h != NULL && info->symbolic
|
---|
2852 | && ELF64_R_TYPE (rel->r_info) == R_SH_64_PCREL)
|
---|
2853 | {
|
---|
2854 | struct elf_sh64_link_hash_entry *eh;
|
---|
2855 | struct elf_sh64_pcrel_relocs_copied *p;
|
---|
2856 |
|
---|
2857 | eh = (struct elf_sh64_link_hash_entry *) h;
|
---|
2858 |
|
---|
2859 | for (p = eh->pcrel_relocs_copied; p != NULL; p = p->next)
|
---|
2860 | if (p->section == sreloc)
|
---|
2861 | break;
|
---|
2862 |
|
---|
2863 | if (p == NULL)
|
---|
2864 | {
|
---|
2865 | p = ((struct elf_sh64_pcrel_relocs_copied *)
|
---|
2866 | bfd_alloc (dynobj, sizeof *p));
|
---|
2867 | if (p == NULL)
|
---|
2868 | return FALSE;
|
---|
2869 | p->next = eh->pcrel_relocs_copied;
|
---|
2870 | eh->pcrel_relocs_copied = p;
|
---|
2871 | p->section = sreloc;
|
---|
2872 | p->count = 0;
|
---|
2873 | }
|
---|
2874 |
|
---|
2875 | ++p->count;
|
---|
2876 | }
|
---|
2877 | }
|
---|
2878 |
|
---|
2879 | break;
|
---|
2880 | }
|
---|
2881 | }
|
---|
2882 |
|
---|
2883 | return TRUE;
|
---|
2884 | }
|
---|
2885 |
|
---|
2886 | static int
|
---|
2887 | sh64_elf64_get_symbol_type (elf_sym, type)
|
---|
2888 | Elf_Internal_Sym * elf_sym;
|
---|
2889 | int type;
|
---|
2890 | {
|
---|
2891 | if (ELF_ST_TYPE (elf_sym->st_info) == STT_DATALABEL)
|
---|
2892 | return STT_DATALABEL;
|
---|
2893 |
|
---|
2894 | return type;
|
---|
2895 | }
|
---|
2896 |
|
---|
2897 | /* FIXME: This is a copy of sh64_elf_add_symbol_hook in elf32-sh64.c.
|
---|
2898 | Either file can presumably exist without the other, but do not differ
|
---|
2899 | in elf-size-ness. How to share?
|
---|
2900 |
|
---|
2901 | Hook called by the linker routine which adds symbols from an object
|
---|
2902 | file. We must make indirect symbols for undefined symbols marked with
|
---|
2903 | STT_DATALABEL, so relocations passing them will pick up that attribute
|
---|
2904 | and neutralize STO_SH5_ISA32 found on the symbol definition.
|
---|
2905 |
|
---|
2906 | There is a problem, though: We want to fill in the hash-table entry for
|
---|
2907 | this symbol and signal to the caller that no further processing is
|
---|
2908 | needed. But we don't have the index for this hash-table entry. We
|
---|
2909 | rely here on that the current entry is the first hash-entry with NULL,
|
---|
2910 | which seems brittle. Also, iterating over the hash-table to find that
|
---|
2911 | entry is a linear operation on the number of symbols in this input
|
---|
2912 | file, and this function should take constant time, so that's not good
|
---|
2913 | too. Only comfort is that DataLabel references should only be found in
|
---|
2914 | hand-written assembly code and thus be rare. FIXME: Talk maintainers
|
---|
2915 | into adding an option to elf_add_symbol_hook (preferably) for the index
|
---|
2916 | or the hash entry, alternatively adding the index to Elf_Internal_Sym
|
---|
2917 | (not so good). */
|
---|
2918 |
|
---|
2919 | static bfd_boolean
|
---|
2920 | sh64_elf64_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp)
|
---|
2921 | bfd *abfd;
|
---|
2922 | struct bfd_link_info *info;
|
---|
2923 | const Elf_Internal_Sym *sym;
|
---|
2924 | const char **namep;
|
---|
2925 | flagword *flagsp ATTRIBUTE_UNUSED;
|
---|
2926 | asection **secp;
|
---|
2927 | bfd_vma *valp;
|
---|
2928 | {
|
---|
2929 | /* We want to do this for relocatable as well as final linking. */
|
---|
2930 | if (ELF_ST_TYPE (sym->st_info) == STT_DATALABEL
|
---|
2931 | && info->hash->creator->flavour == bfd_target_elf_flavour)
|
---|
2932 | {
|
---|
2933 | struct elf_link_hash_entry *h;
|
---|
2934 |
|
---|
2935 | /* For relocateable links, we register the DataLabel sym in its own
|
---|
2936 | right, and tweak the name when it's output. Otherwise, we make
|
---|
2937 | an indirect symbol of it. */
|
---|
2938 | flagword flags
|
---|
2939 | = info->relocateable || info->emitrelocations
|
---|
2940 | ? BSF_GLOBAL : BSF_GLOBAL | BSF_INDIRECT;
|
---|
2941 |
|
---|
2942 | char *dl_name
|
---|
2943 | = bfd_malloc (strlen (*namep) + sizeof (DATALABEL_SUFFIX));
|
---|
2944 | struct elf_link_hash_entry ** sym_hash = elf_sym_hashes (abfd);
|
---|
2945 |
|
---|
2946 | BFD_ASSERT (sym_hash != NULL);
|
---|
2947 |
|
---|
2948 | /* Allocation may fail. */
|
---|
2949 | if (dl_name == NULL)
|
---|
2950 | return FALSE;
|
---|
2951 |
|
---|
2952 | strcpy (dl_name, *namep);
|
---|
2953 | strcat (dl_name, DATALABEL_SUFFIX);
|
---|
2954 |
|
---|
2955 | h = (struct elf_link_hash_entry *)
|
---|
2956 | bfd_link_hash_lookup (info->hash, dl_name, FALSE, FALSE, FALSE);
|
---|
2957 |
|
---|
2958 | if (h == NULL)
|
---|
2959 | {
|
---|
2960 | /* No previous datalabel symbol. Make one. */
|
---|
2961 | struct bfd_link_hash_entry *bh = NULL;
|
---|
2962 | struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
---|
2963 |
|
---|
2964 | if (! _bfd_generic_link_add_one_symbol (info, abfd, dl_name,
|
---|
2965 | flags, *secp, *valp,
|
---|
2966 | *namep, FALSE,
|
---|
2967 | bed->collect, &bh))
|
---|
2968 | {
|
---|
2969 | free (dl_name);
|
---|
2970 | return FALSE;
|
---|
2971 | }
|
---|
2972 |
|
---|
2973 | h = (struct elf_link_hash_entry *) bh;
|
---|
2974 | h->elf_link_hash_flags &=~ ELF_LINK_NON_ELF;
|
---|
2975 | h->type = STT_DATALABEL;
|
---|
2976 | }
|
---|
2977 | else
|
---|
2978 | /* If a new symbol was created, it holds the allocated name.
|
---|
2979 | Otherwise, we don't need it anymore and should deallocate it. */
|
---|
2980 | free (dl_name);
|
---|
2981 |
|
---|
2982 | if (h->type != STT_DATALABEL
|
---|
2983 | || ((info->relocateable || info->emitrelocations)
|
---|
2984 | && h->root.type != bfd_link_hash_undefined)
|
---|
2985 | || (! info->relocateable && !info->emitrelocations
|
---|
2986 | && h->root.type != bfd_link_hash_indirect))
|
---|
2987 | {
|
---|
2988 | /* Make sure we don't get confused on invalid input. */
|
---|
2989 | (*_bfd_error_handler)
|
---|
2990 | (_("%s: encountered datalabel symbol in input"),
|
---|
2991 | bfd_get_filename (abfd));
|
---|
2992 | bfd_set_error (bfd_error_bad_value);
|
---|
2993 | return FALSE;
|
---|
2994 | }
|
---|
2995 |
|
---|
2996 | /* Now find the hash-table slot for this entry and fill it in. */
|
---|
2997 | while (*sym_hash != NULL)
|
---|
2998 | sym_hash++;
|
---|
2999 | *sym_hash = h;
|
---|
3000 |
|
---|
3001 | /* Signal to caller to skip this symbol - we've handled it. */
|
---|
3002 | *namep = NULL;
|
---|
3003 | }
|
---|
3004 |
|
---|
3005 | return TRUE;
|
---|
3006 | }
|
---|
3007 |
|
---|
3008 | /* This hook function is called before the linker writes out a global
|
---|
3009 | symbol. For relocatable links, DataLabel symbols will be present in
|
---|
3010 | linker output. We cut off the special suffix on those symbols, so the
|
---|
3011 | right name appears in the output.
|
---|
3012 |
|
---|
3013 | When linking and emitting relocations, there can appear global symbols
|
---|
3014 | that are not referenced by relocs, but rather only implicitly through
|
---|
3015 | DataLabel references, a relation that is not visible to the linker.
|
---|
3016 | Since no stripping of global symbols in done when doing such linking,
|
---|
3017 | we don't need to look up and make sure to emit the main symbol for each
|
---|
3018 | DataLabel symbol. */
|
---|
3019 |
|
---|
3020 | static bfd_boolean
|
---|
3021 | sh64_elf64_link_output_symbol_hook (abfd, info, cname, sym, input_sec)
|
---|
3022 | bfd *abfd ATTRIBUTE_UNUSED;
|
---|
3023 | struct bfd_link_info *info;
|
---|
3024 | const char *cname;
|
---|
3025 | Elf_Internal_Sym *sym;
|
---|
3026 | asection *input_sec ATTRIBUTE_UNUSED;
|
---|
3027 | {
|
---|
3028 | char *name = (char *) cname;
|
---|
3029 |
|
---|
3030 | if (info->relocateable || info->emitrelocations)
|
---|
3031 | {
|
---|
3032 | if (ELF_ST_TYPE (sym->st_info) == STT_DATALABEL)
|
---|
3033 | name[strlen (name) - strlen (DATALABEL_SUFFIX)] = 0;
|
---|
3034 | }
|
---|
3035 |
|
---|
3036 | return TRUE;
|
---|
3037 | }
|
---|
3038 |
|
---|
3039 | /* Set bit 0 on the entry address; it always points to SHmedia code. This
|
---|
3040 | is mostly for symmetry with the 32-bit format, where code can be
|
---|
3041 | SHcompact and we need to make a distinction to make sure execution
|
---|
3042 | starts in the right ISA mode. It is also convenient for a loader,
|
---|
3043 | which would otherwise have to set this bit when loading a TR register
|
---|
3044 | before jumping to the program entry. */
|
---|
3045 |
|
---|
3046 | static void
|
---|
3047 | sh64_elf64_final_write_processing (abfd, linker)
|
---|
3048 | bfd *abfd;
|
---|
3049 | bfd_boolean linker ATTRIBUTE_UNUSED;
|
---|
3050 | {
|
---|
3051 | /* FIXME: Perhaps we shouldn't do this if the entry address was supplied
|
---|
3052 | numerically, but we currently lack the infrastructure to recognize
|
---|
3053 | that: The entry symbol, and info whether it is numeric or a symbol
|
---|
3054 | name is kept private in the linker. */
|
---|
3055 | if (elf_elfheader (abfd)->e_type == ET_EXEC)
|
---|
3056 | elf_elfheader (abfd)->e_entry |= 1;
|
---|
3057 | }
|
---|
3058 |
|
---|
3059 | /* First entry in an absolute procedure linkage table look like this. */
|
---|
3060 |
|
---|
3061 | static const bfd_byte elf_sh64_plt0_entry_be[PLT_ENTRY_SIZE] =
|
---|
3062 | {
|
---|
3063 | 0xcc, 0x00, 0x01, 0x10, /* movi .got.plt >> 48, r17 */
|
---|
3064 | 0xc8, 0x00, 0x01, 0x10, /* shori (.got.plt >> 32) & 65535, r17 */
|
---|
3065 | 0xc8, 0x00, 0x01, 0x10, /* shori (.got.plt >> 16) & 65535, r17 */
|
---|
3066 | 0xc8, 0x00, 0x01, 0x10, /* shori .got.plt & 65535, r17 */
|
---|
3067 | 0x8d, 0x10, 0x09, 0x90, /* ld.q r17, 16, r25 */
|
---|
3068 | 0x6b, 0xf1, 0x66, 0x00, /* ptabs r25, tr0 */
|
---|
3069 | 0x8d, 0x10, 0x05, 0x10, /* ld.q r17, 8, r17 */
|
---|
3070 | 0x44, 0x01, 0xff, 0xf0, /* blink tr0, r63 */
|
---|
3071 | 0x6f, 0xf0, 0xff, 0xf0, /* nop */
|
---|
3072 | 0x6f, 0xf0, 0xff, 0xf0, /* nop */
|
---|
3073 | 0x6f, 0xf0, 0xff, 0xf0, /* nop */
|
---|
3074 | 0x6f, 0xf0, 0xff, 0xf0, /* nop */
|
---|
3075 | 0x6f, 0xf0, 0xff, 0xf0, /* nop */
|
---|
3076 | 0x6f, 0xf0, 0xff, 0xf0, /* nop */
|
---|
3077 | 0x6f, 0xf0, 0xff, 0xf0, /* nop */
|
---|
3078 | 0x6f, 0xf0, 0xff, 0xf0, /* nop */
|
---|
3079 | };
|
---|
3080 |
|
---|
3081 | static const bfd_byte elf_sh64_plt0_entry_le[PLT_ENTRY_SIZE] =
|
---|
3082 | {
|
---|
3083 | 0x10, 0x01, 0x00, 0xcc, /* movi .got.plt >> 16, r17 */
|
---|
3084 | 0x10, 0x01, 0x00, 0xc8, /* shori (.got.plt >> 32) & 65535, r17 */
|
---|
3085 | 0x10, 0x01, 0x00, 0xc8, /* shori (.got.plt >> 16) & 65535, r17 */
|
---|
3086 | 0x10, 0x01, 0x00, 0xc8, /* shori .got.plt & 65535, r17 */
|
---|
3087 | 0x90, 0x09, 0x10, 0x8d, /* ld.q r17, 16, r25 */
|
---|
3088 | 0x00, 0x66, 0xf1, 0x6b, /* ptabs r25, tr0 */
|
---|
3089 | 0x10, 0x05, 0x10, 0x8d, /* ld.q r17, 8, r17 */
|
---|
3090 | 0xf0, 0xff, 0x01, 0x44, /* blink tr0, r63 */
|
---|
3091 | 0xf0, 0xff, 0xf0, 0x6f, /* nop */
|
---|
3092 | 0xf0, 0xff, 0xf0, 0x6f, /* nop */
|
---|
3093 | 0xf0, 0xff, 0xf0, 0x6f, /* nop */
|
---|
3094 | 0xf0, 0xff, 0xf0, 0x6f, /* nop */
|
---|
3095 | 0xf0, 0xff, 0xf0, 0x6f, /* nop */
|
---|
3096 | 0xf0, 0xff, 0xf0, 0x6f, /* nop */
|
---|
3097 | 0xf0, 0xff, 0xf0, 0x6f, /* nop */
|
---|
3098 | 0xf0, 0xff, 0xf0, 0x6f, /* nop */
|
---|
3099 | };
|
---|
3100 |
|
---|
3101 | /* Sebsequent entries in an absolute procedure linkage table look like
|
---|
3102 | this. */
|
---|
3103 |
|
---|
3104 | static const bfd_byte elf_sh64_plt_entry_be[PLT_ENTRY_SIZE] =
|
---|
3105 | {
|
---|
3106 | 0xcc, 0x00, 0x01, 0x90, /* movi nameN-in-GOT >> 48, r25 */
|
---|
3107 | 0xc8, 0x00, 0x01, 0x90, /* shori (nameN-in-GOT >> 32) & 65535, r25 */
|
---|
3108 | 0xc8, 0x00, 0x01, 0x90, /* shori (nameN-in-GOT >> 16) & 65535, r25 */
|
---|
3109 | 0xc8, 0x00, 0x01, 0x90, /* shori nameN-in-GOT & 65535, r25 */
|
---|
3110 | 0x8d, 0x90, 0x01, 0x90, /* ld.q r25, 0, r25 */
|
---|
3111 | 0x6b, 0xf1, 0x66, 0x00, /* ptabs r25, tr0 */
|
---|
3112 | 0x44, 0x01, 0xff, 0xf0, /* blink tr0, r63 */
|
---|
3113 | 0x6f, 0xf0, 0xff, 0xf0, /* nop */
|
---|
3114 | 0xcc, 0x00, 0x01, 0x90, /* movi (.+8-.PLT0) >> 16, r25 */
|
---|
3115 | 0xc8, 0x00, 0x01, 0x90, /* shori (.+4-.PLT0) & 65535, r25 */
|
---|
3116 | 0x6b, 0xf5, 0x66, 0x00, /* ptrel r25, tr0 */
|
---|
3117 | 0xcc, 0x00, 0x01, 0x50, /* movi reloc-offset >> 16, r21 */
|
---|
3118 | 0xc8, 0x00, 0x01, 0x50, /* shori reloc-offset & 65535, r21 */
|
---|
3119 | 0x44, 0x01, 0xff, 0xf0, /* blink tr0, r63 */
|
---|
3120 | 0x6f, 0xf0, 0xff, 0xf0, /* nop */
|
---|
3121 | 0x6f, 0xf0, 0xff, 0xf0, /* nop */
|
---|
3122 | };
|
---|
3123 |
|
---|
3124 | static const bfd_byte elf_sh64_plt_entry_le[PLT_ENTRY_SIZE] =
|
---|
3125 | {
|
---|
3126 | 0x90, 0x01, 0x00, 0xcc, /* movi nameN-in-GOT >> 16, r25 */
|
---|
3127 | 0x90, 0x01, 0x00, 0xc8, /* shori nameN-in-GOT & 65535, r25 */
|
---|
3128 | 0x90, 0x01, 0x00, 0xc8, /* shori nameN-in-GOT & 65535, r25 */
|
---|
3129 | 0x90, 0x01, 0x00, 0xc8, /* shori nameN-in-GOT & 65535, r25 */
|
---|
3130 | 0x90, 0x01, 0x90, 0x8d, /* ld.q r25, 0, r25 */
|
---|
3131 | 0x00, 0x66, 0xf1, 0x6b, /* ptabs r25, tr0 */
|
---|
3132 | 0xf0, 0xff, 0x01, 0x44, /* blink tr0, r63 */
|
---|
3133 | 0xf0, 0xff, 0xf0, 0x6f, /* nop */
|
---|
3134 | 0x90, 0x01, 0x00, 0xcc, /* movi (.+8-.PLT0) >> 16, r25 */
|
---|
3135 | 0x90, 0x01, 0x00, 0xc8, /* shori (.+4-.PLT0) & 65535, r25 */
|
---|
3136 | 0x00, 0x66, 0xf5, 0x6b, /* ptrel r25, tr0 */
|
---|
3137 | 0x50, 0x01, 0x00, 0xcc, /* movi reloc-offset >> 16, r21 */
|
---|
3138 | 0x50, 0x01, 0x00, 0xc8, /* shori reloc-offset & 65535, r21 */
|
---|
3139 | 0xf0, 0xff, 0x01, 0x44, /* blink tr0, r63 */
|
---|
3140 | 0xf0, 0xff, 0xf0, 0x6f, /* nop */
|
---|
3141 | 0xf0, 0xff, 0xf0, 0x6f, /* nop */
|
---|
3142 | };
|
---|
3143 |
|
---|
3144 | /* Entries in a PIC procedure linkage table look like this. */
|
---|
3145 |
|
---|
3146 | static const bfd_byte elf_sh64_pic_plt_entry_be[PLT_ENTRY_SIZE] =
|
---|
3147 | {
|
---|
3148 | 0xcc, 0x00, 0x01, 0x90, /* movi nameN@GOT >> 16, r25 */
|
---|
3149 | 0xc8, 0x00, 0x01, 0x90, /* shori nameN@GOT & 65535, r25 */
|
---|
3150 | 0x40, 0xc3, 0x65, 0x90, /* ldx.q r12, r25, r25 */
|
---|
3151 | 0x6b, 0xf1, 0x66, 0x00, /* ptabs r25, tr0 */
|
---|
3152 | 0x44, 0x01, 0xff, 0xf0, /* blink tr0, r63 */
|
---|
3153 | 0x6f, 0xf0, 0xff, 0xf0, /* nop */
|
---|
3154 | 0x6f, 0xf0, 0xff, 0xf0, /* nop */
|
---|
3155 | 0x6f, 0xf0, 0xff, 0xf0, /* nop */
|
---|
3156 | 0xce, 0x00, 0x01, 0x10, /* movi -GOT_BIAS, r17 */
|
---|
3157 | 0x00, 0xc9, 0x45, 0x10, /* add r12, r17, r17 */
|
---|
3158 | 0x8d, 0x10, 0x09, 0x90, /* ld.q r17, 16, r25 */
|
---|
3159 | 0x6b, 0xf1, 0x66, 0x00, /* ptabs r25, tr0 */
|
---|
3160 | 0x8d, 0x10, 0x05, 0x10, /* ld.q r17, 8, r17 */
|
---|
3161 | 0xcc, 0x00, 0x01, 0x50, /* movi reloc-offset >> 16, r21 */
|
---|
3162 | 0xc8, 0x00, 0x01, 0x50, /* shori reloc-offset & 65535, r21 */
|
---|
3163 | 0x44, 0x01, 0xff, 0xf0, /* blink tr0, r63 */
|
---|
3164 | };
|
---|
3165 |
|
---|
3166 | static const bfd_byte elf_sh64_pic_plt_entry_le[PLT_ENTRY_SIZE] =
|
---|
3167 | {
|
---|
3168 | 0x90, 0x01, 0x00, 0xcc, /* movi nameN@GOT >> 16, r25 */
|
---|
3169 | 0x90, 0x01, 0x00, 0xc8, /* shori nameN@GOT & 65535, r25 */
|
---|
3170 | 0x90, 0x65, 0xc3, 0x40, /* ldx.q r12, r25, r25 */
|
---|
3171 | 0x00, 0x66, 0xf1, 0x6b, /* ptabs r25, tr0 */
|
---|
3172 | 0xf0, 0xff, 0x01, 0x44, /* blink tr0, r63 */
|
---|
3173 | 0xf0, 0xff, 0xf0, 0x6f, /* nop */
|
---|
3174 | 0xf0, 0xff, 0xf0, 0x6f, /* nop */
|
---|
3175 | 0xf0, 0xff, 0xf0, 0x6f, /* nop */
|
---|
3176 | 0x10, 0x01, 0x00, 0xce, /* movi -GOT_BIAS, r17 */
|
---|
3177 | 0x10, 0x45, 0xc9, 0x00, /* add r12, r17, r17 */
|
---|
3178 | 0x90, 0x09, 0x10, 0x8d, /* ld.q r17, 16, r25 */
|
---|
3179 | 0x00, 0x66, 0xf1, 0x6b, /* ptabs r25, tr0 */
|
---|
3180 | 0x10, 0x05, 0x10, 0x8d, /* ld.q r17, 8, r17 */
|
---|
3181 | 0x50, 0x01, 0x00, 0xcc, /* movi reloc-offset >> 16, r21 */
|
---|
3182 | 0x50, 0x01, 0x00, 0xc8, /* shori reloc-offset & 65535, r21 */
|
---|
3183 | 0xf0, 0xff, 0x01, 0x44, /* blink tr0, r63 */
|
---|
3184 | };
|
---|
3185 |
|
---|
3186 | static const bfd_byte *elf_sh64_plt0_entry;
|
---|
3187 | static const bfd_byte *elf_sh64_plt_entry;
|
---|
3188 | static const bfd_byte *elf_sh64_pic_plt_entry;
|
---|
3189 |
|
---|
3190 | /* Create an entry in an sh ELF linker hash table. */
|
---|
3191 |
|
---|
3192 | static struct bfd_hash_entry *
|
---|
3193 | sh64_elf64_link_hash_newfunc (entry, table, string)
|
---|
3194 | struct bfd_hash_entry *entry;
|
---|
3195 | struct bfd_hash_table *table;
|
---|
3196 | const char *string;
|
---|
3197 | {
|
---|
3198 | struct elf_sh64_link_hash_entry *ret =
|
---|
3199 | (struct elf_sh64_link_hash_entry *) entry;
|
---|
3200 |
|
---|
3201 | /* Allocate the structure if it has not already been allocated by a
|
---|
3202 | subclass. */
|
---|
3203 | if (ret == (struct elf_sh64_link_hash_entry *) NULL)
|
---|
3204 | ret = ((struct elf_sh64_link_hash_entry *)
|
---|
3205 | bfd_hash_allocate (table,
|
---|
3206 | sizeof (struct elf_sh64_link_hash_entry)));
|
---|
3207 | if (ret == (struct elf_sh64_link_hash_entry *) NULL)
|
---|
3208 | return (struct bfd_hash_entry *) ret;
|
---|
3209 |
|
---|
3210 | /* Call the allocation method of the superclass. */
|
---|
3211 | ret = ((struct elf_sh64_link_hash_entry *)
|
---|
3212 | _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,
|
---|
3213 | table, string));
|
---|
3214 | if (ret != (struct elf_sh64_link_hash_entry *) NULL)
|
---|
3215 | {
|
---|
3216 | ret->pcrel_relocs_copied = NULL;
|
---|
3217 | ret->datalabel_got_offset = (bfd_vma) -1;
|
---|
3218 | }
|
---|
3219 |
|
---|
3220 | return (struct bfd_hash_entry *) ret;
|
---|
3221 | }
|
---|
3222 |
|
---|
3223 | /* Create an sh64 ELF linker hash table. */
|
---|
3224 |
|
---|
3225 | static struct bfd_link_hash_table *
|
---|
3226 | sh64_elf64_link_hash_table_create (abfd)
|
---|
3227 | bfd *abfd;
|
---|
3228 | {
|
---|
3229 | struct elf_sh64_link_hash_table *ret;
|
---|
3230 |
|
---|
3231 | ret = ((struct elf_sh64_link_hash_table *)
|
---|
3232 | bfd_malloc (sizeof (struct elf_sh64_link_hash_table)));
|
---|
3233 | if (ret == (struct elf_sh64_link_hash_table *) NULL)
|
---|
3234 | return NULL;
|
---|
3235 |
|
---|
3236 | if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,
|
---|
3237 | sh64_elf64_link_hash_newfunc))
|
---|
3238 | {
|
---|
3239 | free (ret);
|
---|
3240 | return NULL;
|
---|
3241 | }
|
---|
3242 |
|
---|
3243 | return &ret->root.root;
|
---|
3244 | }
|
---|
3245 |
|
---|
3246 | inline static void
|
---|
3247 | movi_shori_putval (output_bfd, value, addr)
|
---|
3248 | bfd *output_bfd;
|
---|
3249 | unsigned long value;
|
---|
3250 | char *addr;
|
---|
3251 | {
|
---|
3252 | bfd_put_32 (output_bfd,
|
---|
3253 | bfd_get_32 (output_bfd, addr)
|
---|
3254 | | ((value >> 6) & 0x3fffc00),
|
---|
3255 | addr);
|
---|
3256 | bfd_put_32 (output_bfd,
|
---|
3257 | bfd_get_32 (output_bfd, addr + 4)
|
---|
3258 | | ((value << 10) & 0x3fffc00),
|
---|
3259 | addr + 4);
|
---|
3260 | }
|
---|
3261 |
|
---|
3262 | inline static void
|
---|
3263 | movi_3shori_putval (output_bfd, value, addr)
|
---|
3264 | bfd *output_bfd;
|
---|
3265 | bfd_vma value;
|
---|
3266 | char *addr;
|
---|
3267 | {
|
---|
3268 | bfd_put_32 (output_bfd,
|
---|
3269 | bfd_get_32 (output_bfd, addr)
|
---|
3270 | | ((value >> 38) & 0x3fffc00),
|
---|
3271 | addr);
|
---|
3272 | bfd_put_32 (output_bfd,
|
---|
3273 | bfd_get_32 (output_bfd, addr + 4)
|
---|
3274 | | ((value >> 22) & 0x3fffc00),
|
---|
3275 | addr + 4);
|
---|
3276 | bfd_put_32 (output_bfd,
|
---|
3277 | bfd_get_32 (output_bfd, addr + 8)
|
---|
3278 | | ((value >> 6) & 0x3fffc00),
|
---|
3279 | addr + 8);
|
---|
3280 | bfd_put_32 (output_bfd,
|
---|
3281 | bfd_get_32 (output_bfd, addr + 12)
|
---|
3282 | | ((value << 10) & 0x3fffc00),
|
---|
3283 | addr + 12);
|
---|
3284 | }
|
---|
3285 |
|
---|
3286 | /* Create dynamic sections when linking against a dynamic object. */
|
---|
3287 |
|
---|
3288 | static bfd_boolean
|
---|
3289 | sh64_elf64_create_dynamic_sections (abfd, info)
|
---|
3290 | bfd *abfd;
|
---|
3291 | struct bfd_link_info *info;
|
---|
3292 | {
|
---|
3293 | flagword flags, pltflags;
|
---|
3294 | register asection *s;
|
---|
3295 | struct elf_backend_data *bed = get_elf_backend_data (abfd);
|
---|
3296 | int ptralign = 0;
|
---|
3297 |
|
---|
3298 | switch (bed->s->arch_size)
|
---|
3299 | {
|
---|
3300 | case 32:
|
---|
3301 | ptralign = 2;
|
---|
3302 | break;
|
---|
3303 |
|
---|
3304 | case 64:
|
---|
3305 | ptralign = 3;
|
---|
3306 | break;
|
---|
3307 |
|
---|
3308 | default:
|
---|
3309 | bfd_set_error (bfd_error_bad_value);
|
---|
3310 | return FALSE;
|
---|
3311 | }
|
---|
3312 |
|
---|
3313 | /* We need to create .plt, .rel[a].plt, .got, .got.plt, .dynbss, and
|
---|
3314 | .rel[a].bss sections. */
|
---|
3315 |
|
---|
3316 | flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
|
---|
3317 | | SEC_LINKER_CREATED);
|
---|
3318 |
|
---|
3319 | pltflags = flags;
|
---|
3320 | pltflags |= SEC_CODE;
|
---|
3321 | if (bed->plt_not_loaded)
|
---|
3322 | pltflags &= ~ (SEC_LOAD | SEC_HAS_CONTENTS);
|
---|
3323 | if (bed->plt_readonly)
|
---|
3324 | pltflags |= SEC_READONLY;
|
---|
3325 |
|
---|
3326 | s = bfd_make_section (abfd, ".plt");
|
---|
3327 | if (s == NULL
|
---|
3328 | || ! bfd_set_section_flags (abfd, s, pltflags)
|
---|
3329 | || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))
|
---|
3330 | return FALSE;
|
---|
3331 |
|
---|
3332 | if (bed->want_plt_sym)
|
---|
3333 | {
|
---|
3334 | /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the
|
---|
3335 | .plt section. */
|
---|
3336 | struct elf_link_hash_entry *h;
|
---|
3337 | struct bfd_link_hash_entry *bh = NULL;
|
---|
3338 |
|
---|
3339 | if (! (_bfd_generic_link_add_one_symbol
|
---|
3340 | (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,
|
---|
3341 | (bfd_vma) 0, (const char *) NULL, FALSE, bed->collect, &bh)))
|
---|
3342 | return FALSE;
|
---|
3343 |
|
---|
3344 | h = (struct elf_link_hash_entry *) bh;
|
---|
3345 | h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR;
|
---|
3346 | h->type = STT_OBJECT;
|
---|
3347 |
|
---|
3348 | if (info->shared
|
---|
3349 | && ! _bfd_elf_link_record_dynamic_symbol (info, h))
|
---|
3350 | return FALSE;
|
---|
3351 | }
|
---|
3352 |
|
---|
3353 | s = bfd_make_section (abfd,
|
---|
3354 | bed->default_use_rela_p ? ".rela.plt" : ".rel.plt");
|
---|
3355 | if (s == NULL
|
---|
3356 | || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
---|
3357 | || ! bfd_set_section_alignment (abfd, s, ptralign))
|
---|
3358 | return FALSE;
|
---|
3359 |
|
---|
3360 | if (! _bfd_elf_create_got_section (abfd, info))
|
---|
3361 | return FALSE;
|
---|
3362 |
|
---|
3363 | {
|
---|
3364 | const char *secname;
|
---|
3365 | char *relname;
|
---|
3366 | flagword secflags;
|
---|
3367 | asection *sec;
|
---|
3368 |
|
---|
3369 | for (sec = abfd->sections; sec; sec = sec->next)
|
---|
3370 | {
|
---|
3371 | secflags = bfd_get_section_flags (abfd, sec);
|
---|
3372 | if ((secflags & (SEC_DATA | SEC_LINKER_CREATED))
|
---|
3373 | || ((secflags & SEC_HAS_CONTENTS) != SEC_HAS_CONTENTS))
|
---|
3374 | continue;
|
---|
3375 | secname = bfd_get_section_name (abfd, sec);
|
---|
3376 | relname = (char *) bfd_malloc (strlen (secname) + 6);
|
---|
3377 | strcpy (relname, ".rela");
|
---|
3378 | strcat (relname, secname);
|
---|
3379 | s = bfd_make_section (abfd, relname);
|
---|
3380 | if (s == NULL
|
---|
3381 | || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
---|
3382 | || ! bfd_set_section_alignment (abfd, s, ptralign))
|
---|
3383 | return FALSE;
|
---|
3384 | }
|
---|
3385 | }
|
---|
3386 |
|
---|
3387 | if (bed->want_dynbss)
|
---|
3388 | {
|
---|
3389 | /* The .dynbss section is a place to put symbols which are defined
|
---|
3390 | by dynamic objects, are referenced by regular objects, and are
|
---|
3391 | not functions. We must allocate space for them in the process
|
---|
3392 | image and use a R_*_COPY reloc to tell the dynamic linker to
|
---|
3393 | initialize them at run time. The linker script puts the .dynbss
|
---|
3394 | section into the .bss section of the final image. */
|
---|
3395 | s = bfd_make_section (abfd, ".dynbss");
|
---|
3396 | if (s == NULL
|
---|
3397 | || ! bfd_set_section_flags (abfd, s, SEC_ALLOC))
|
---|
3398 | return FALSE;
|
---|
3399 |
|
---|
3400 | /* The .rel[a].bss section holds copy relocs. This section is not
|
---|
3401 | normally needed. We need to create it here, though, so that the
|
---|
3402 | linker will map it to an output section. We can't just create it
|
---|
3403 | only if we need it, because we will not know whether we need it
|
---|
3404 | until we have seen all the input files, and the first time the
|
---|
3405 | main linker code calls BFD after examining all the input files
|
---|
3406 | (size_dynamic_sections) the input sections have already been
|
---|
3407 | mapped to the output sections. If the section turns out not to
|
---|
3408 | be needed, we can discard it later. We will never need this
|
---|
3409 | section when generating a shared object, since they do not use
|
---|
3410 | copy relocs. */
|
---|
3411 | if (! info->shared)
|
---|
3412 | {
|
---|
3413 | s = bfd_make_section (abfd,
|
---|
3414 | (bed->default_use_rela_p
|
---|
3415 | ? ".rela.bss" : ".rel.bss"));
|
---|
3416 | if (s == NULL
|
---|
3417 | || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)
|
---|
3418 | || ! bfd_set_section_alignment (abfd, s, ptralign))
|
---|
3419 | return FALSE;
|
---|
3420 | }
|
---|
3421 | }
|
---|
3422 |
|
---|
3423 | return TRUE;
|
---|
3424 | }
|
---|
3425 | |
---|
3426 |
|
---|
3427 | /* Adjust a symbol defined by a dynamic object and referenced by a
|
---|
3428 | regular object. The current definition is in some section of the
|
---|
3429 | dynamic object, but we're not including those sections. We have to
|
---|
3430 | change the definition to something the rest of the link can
|
---|
3431 | understand. */
|
---|
3432 |
|
---|
3433 | static bfd_boolean
|
---|
3434 | sh64_elf64_adjust_dynamic_symbol (info, h)
|
---|
3435 | struct bfd_link_info *info;
|
---|
3436 | struct elf_link_hash_entry *h;
|
---|
3437 | {
|
---|
3438 | bfd *dynobj;
|
---|
3439 | asection *s;
|
---|
3440 | unsigned int power_of_two;
|
---|
3441 |
|
---|
3442 | dynobj = elf_hash_table (info)->dynobj;
|
---|
3443 |
|
---|
3444 | /* Make sure we know what is going on here. */
|
---|
3445 | BFD_ASSERT (dynobj != NULL
|
---|
3446 | && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)
|
---|
3447 | || h->weakdef != NULL
|
---|
3448 | || ((h->elf_link_hash_flags
|
---|
3449 | & ELF_LINK_HASH_DEF_DYNAMIC) != 0
|
---|
3450 | && (h->elf_link_hash_flags
|
---|
3451 | & ELF_LINK_HASH_REF_REGULAR) != 0
|
---|
3452 | && (h->elf_link_hash_flags
|
---|
3453 | & ELF_LINK_HASH_DEF_REGULAR) == 0)));
|
---|
3454 |
|
---|
3455 | /* If this is a function, put it in the procedure linkage table. We
|
---|
3456 | will fill in the contents of the procedure linkage table later,
|
---|
3457 | when we know the address of the .got section. */
|
---|
3458 | if (h->type == STT_FUNC
|
---|
3459 | || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0)
|
---|
3460 | {
|
---|
3461 | if (! info->shared
|
---|
3462 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) == 0
|
---|
3463 | && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) == 0)
|
---|
3464 | {
|
---|
3465 | /* This case can occur if we saw a PLT reloc in an input
|
---|
3466 | file, but the symbol was never referred to by a dynamic
|
---|
3467 | object. In such a case, we don't actually need to build
|
---|
3468 | a procedure linkage table, and we can just do a REL64
|
---|
3469 | reloc instead. */
|
---|
3470 | BFD_ASSERT ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) != 0);
|
---|
3471 | return TRUE;
|
---|
3472 | }
|
---|
3473 |
|
---|
3474 | /* Make sure this symbol is output as a dynamic symbol. */
|
---|
3475 | if (h->dynindx == -1)
|
---|
3476 | {
|
---|
3477 | if (! bfd_elf64_link_record_dynamic_symbol (info, h))
|
---|
3478 | return FALSE;
|
---|
3479 | }
|
---|
3480 |
|
---|
3481 | s = bfd_get_section_by_name (dynobj, ".plt");
|
---|
3482 | BFD_ASSERT (s != NULL);
|
---|
3483 |
|
---|
3484 | /* If this is the first .plt entry, make room for the special
|
---|
3485 | first entry. */
|
---|
3486 | if (s->_raw_size == 0)
|
---|
3487 | s->_raw_size += PLT_ENTRY_SIZE;
|
---|
3488 |
|
---|
3489 | /* If this symbol is not defined in a regular file, and we are
|
---|
3490 | not generating a shared library, then set the symbol to this
|
---|
3491 | location in the .plt. This is required to make function
|
---|
3492 | pointers compare as equal between the normal executable and
|
---|
3493 | the shared library. */
|
---|
3494 | if (! info->shared
|
---|
3495 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
|
---|
3496 | {
|
---|
3497 | h->root.u.def.section = s;
|
---|
3498 | h->root.u.def.value = s->_raw_size;
|
---|
3499 | }
|
---|
3500 |
|
---|
3501 | h->plt.offset = s->_raw_size;
|
---|
3502 |
|
---|
3503 | /* Make room for this entry. */
|
---|
3504 | s->_raw_size += elf_sh64_sizeof_plt (info);
|
---|
3505 |
|
---|
3506 | /* We also need to make an entry in the .got.plt section, which
|
---|
3507 | will be placed in the .got section by the linker script. */
|
---|
3508 |
|
---|
3509 | s = bfd_get_section_by_name (dynobj, ".got.plt");
|
---|
3510 | BFD_ASSERT (s != NULL);
|
---|
3511 | s->_raw_size += 8;
|
---|
3512 |
|
---|
3513 | /* We also need to make an entry in the .rela.plt section. */
|
---|
3514 |
|
---|
3515 | s = bfd_get_section_by_name (dynobj, ".rela.plt");
|
---|
3516 | BFD_ASSERT (s != NULL);
|
---|
3517 | s->_raw_size += sizeof (Elf64_External_Rela);
|
---|
3518 |
|
---|
3519 | return TRUE;
|
---|
3520 | }
|
---|
3521 |
|
---|
3522 | /* If this is a weak symbol, and there is a real definition, the
|
---|
3523 | processor independent code will have arranged for us to see the
|
---|
3524 | real definition first, and we can just use the same value. */
|
---|
3525 | if (h->weakdef != NULL)
|
---|
3526 | {
|
---|
3527 | BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
|
---|
3528 | || h->weakdef->root.type == bfd_link_hash_defweak);
|
---|
3529 | h->root.u.def.section = h->weakdef->root.u.def.section;
|
---|
3530 | h->root.u.def.value = h->weakdef->root.u.def.value;
|
---|
3531 | return TRUE;
|
---|
3532 | }
|
---|
3533 |
|
---|
3534 | /* This is a reference to a symbol defined by a dynamic object which
|
---|
3535 | is not a function. */
|
---|
3536 |
|
---|
3537 | /* If we are creating a shared library, we must presume that the
|
---|
3538 | only references to the symbol are via the global offset table.
|
---|
3539 | For such cases we need not do anything here; the relocations will
|
---|
3540 | be handled correctly by relocate_section. */
|
---|
3541 | if (info->shared)
|
---|
3542 | return TRUE;
|
---|
3543 |
|
---|
3544 | /* If there are no references to this symbol that do not use the
|
---|
3545 | GOT, we don't need to generate a copy reloc. */
|
---|
3546 | if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) == 0)
|
---|
3547 | return TRUE;
|
---|
3548 |
|
---|
3549 | /* We must allocate the symbol in our .dynbss section, which will
|
---|
3550 | become part of the .bss section of the executable. There will be
|
---|
3551 | an entry for this symbol in the .dynsym section. The dynamic
|
---|
3552 | object will contain position independent code, so all references
|
---|
3553 | from the dynamic object to this symbol will go through the global
|
---|
3554 | offset table. The dynamic linker will use the .dynsym entry to
|
---|
3555 | determine the address it must put in the global offset table, so
|
---|
3556 | both the dynamic object and the regular object will refer to the
|
---|
3557 | same memory location for the variable. */
|
---|
3558 |
|
---|
3559 | s = bfd_get_section_by_name (dynobj, ".dynbss");
|
---|
3560 | BFD_ASSERT (s != NULL);
|
---|
3561 |
|
---|
3562 | /* We must generate a R_SH_COPY reloc to tell the dynamic linker to
|
---|
3563 | copy the initial value out of the dynamic object and into the
|
---|
3564 | runtime process image. We need to remember the offset into the
|
---|
3565 | .rela.bss section we are going to use. */
|
---|
3566 | if ((h->root.u.def.section->flags & SEC_ALLOC) != 0)
|
---|
3567 | {
|
---|
3568 | asection *srel;
|
---|
3569 |
|
---|
3570 | srel = bfd_get_section_by_name (dynobj, ".rela.bss");
|
---|
3571 | BFD_ASSERT (srel != NULL);
|
---|
3572 | srel->_raw_size += sizeof (Elf64_External_Rela);
|
---|
3573 | h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY;
|
---|
3574 | }
|
---|
3575 |
|
---|
3576 | /* We need to figure out the alignment required for this symbol. I
|
---|
3577 | have no idea how ELF linkers handle this. */
|
---|
3578 | power_of_two = bfd_log2 (h->size);
|
---|
3579 | if (power_of_two > 3)
|
---|
3580 | power_of_two = 3;
|
---|
3581 |
|
---|
3582 | /* Apply the required alignment. */
|
---|
3583 | s->_raw_size = BFD_ALIGN (s->_raw_size,
|
---|
3584 | (bfd_size_type) (1 << power_of_two));
|
---|
3585 | if (power_of_two > bfd_get_section_alignment (dynobj, s))
|
---|
3586 | {
|
---|
3587 | if (! bfd_set_section_alignment (dynobj, s, power_of_two))
|
---|
3588 | return FALSE;
|
---|
3589 | }
|
---|
3590 |
|
---|
3591 | /* Define the symbol as being at this point in the section. */
|
---|
3592 | h->root.u.def.section = s;
|
---|
3593 | h->root.u.def.value = s->_raw_size;
|
---|
3594 |
|
---|
3595 | /* Increment the section size to make room for the symbol. */
|
---|
3596 | s->_raw_size += h->size;
|
---|
3597 |
|
---|
3598 | return TRUE;
|
---|
3599 | }
|
---|
3600 |
|
---|
3601 | /* This function is called via sh_elf_link_hash_traverse if we are
|
---|
3602 | creating a shared object with -Bsymbolic. It discards the space
|
---|
3603 | allocated to copy PC relative relocs against symbols which are
|
---|
3604 | defined in regular objects. We allocated space for them in the
|
---|
3605 | check_relocs routine, but we won't fill them in in the
|
---|
3606 | relocate_section routine. */
|
---|
3607 |
|
---|
3608 | static bfd_boolean
|
---|
3609 | sh64_elf64_discard_copies (h, ignore)
|
---|
3610 | struct elf_sh64_link_hash_entry *h;
|
---|
3611 | PTR ignore ATTRIBUTE_UNUSED;
|
---|
3612 | {
|
---|
3613 | struct elf_sh64_pcrel_relocs_copied *s;
|
---|
3614 |
|
---|
3615 | if (h->root.root.type == bfd_link_hash_warning)
|
---|
3616 | h = (struct elf_sh64_link_hash_entry *) h->root.root.u.i.link;
|
---|
3617 |
|
---|
3618 | /* We only discard relocs for symbols defined in a regular object. */
|
---|
3619 | if ((h->root.elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
|
---|
3620 | return TRUE;
|
---|
3621 |
|
---|
3622 | for (s = h->pcrel_relocs_copied; s != NULL; s = s->next)
|
---|
3623 | s->section->_raw_size -= s->count * sizeof (Elf64_External_Rela);
|
---|
3624 |
|
---|
3625 | return TRUE;
|
---|
3626 | }
|
---|
3627 |
|
---|
3628 | /* Set the sizes of the dynamic sections. */
|
---|
3629 |
|
---|
3630 | static bfd_boolean
|
---|
3631 | sh64_elf64_size_dynamic_sections (output_bfd, info)
|
---|
3632 | bfd *output_bfd;
|
---|
3633 | struct bfd_link_info *info;
|
---|
3634 | {
|
---|
3635 | bfd *dynobj;
|
---|
3636 | asection *s;
|
---|
3637 | bfd_boolean plt;
|
---|
3638 | bfd_boolean relocs;
|
---|
3639 | bfd_boolean reltext;
|
---|
3640 |
|
---|
3641 | dynobj = elf_hash_table (info)->dynobj;
|
---|
3642 | BFD_ASSERT (dynobj != NULL);
|
---|
3643 |
|
---|
3644 | if (elf_hash_table (info)->dynamic_sections_created)
|
---|
3645 | {
|
---|
3646 | /* Set the contents of the .interp section to the interpreter. */
|
---|
3647 | if (! info->shared)
|
---|
3648 | {
|
---|
3649 | s = bfd_get_section_by_name (dynobj, ".interp");
|
---|
3650 | BFD_ASSERT (s != NULL);
|
---|
3651 | s->_raw_size = sizeof ELF_DYNAMIC_INTERPRETER;
|
---|
3652 | s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER;
|
---|
3653 | }
|
---|
3654 | }
|
---|
3655 | else
|
---|
3656 | {
|
---|
3657 | /* We may have created entries in the .rela.got section.
|
---|
3658 | However, if we are not creating the dynamic sections, we will
|
---|
3659 | not actually use these entries. Reset the size of .rela.got,
|
---|
3660 | which will cause it to get stripped from the output file
|
---|
3661 | below. */
|
---|
3662 | s = bfd_get_section_by_name (dynobj, ".rela.got");
|
---|
3663 | if (s != NULL)
|
---|
3664 | s->_raw_size = 0;
|
---|
3665 | }
|
---|
3666 |
|
---|
3667 | /* If this is a -Bsymbolic shared link, then we need to discard all
|
---|
3668 | PC relative relocs against symbols defined in a regular object.
|
---|
3669 | We allocated space for them in the check_relocs routine, but we
|
---|
3670 | will not fill them in in the relocate_section routine. */
|
---|
3671 | if (info->shared && info->symbolic)
|
---|
3672 | sh64_elf64_link_hash_traverse (sh64_elf64_hash_table (info),
|
---|
3673 | sh64_elf64_discard_copies,
|
---|
3674 | (PTR) NULL);
|
---|
3675 |
|
---|
3676 | /* The check_relocs and adjust_dynamic_symbol entry points have
|
---|
3677 | determined the sizes of the various dynamic sections. Allocate
|
---|
3678 | memory for them. */
|
---|
3679 | plt = FALSE;
|
---|
3680 | relocs = FALSE;
|
---|
3681 | reltext = FALSE;
|
---|
3682 | for (s = dynobj->sections; s != NULL; s = s->next)
|
---|
3683 | {
|
---|
3684 | const char *name;
|
---|
3685 | bfd_boolean strip;
|
---|
3686 |
|
---|
3687 | if ((s->flags & SEC_LINKER_CREATED) == 0)
|
---|
3688 | continue;
|
---|
3689 |
|
---|
3690 | /* It's OK to base decisions on the section name, because none
|
---|
3691 | of the dynobj section names depend upon the input files. */
|
---|
3692 | name = bfd_get_section_name (dynobj, s);
|
---|
3693 |
|
---|
3694 | strip = FALSE;
|
---|
3695 |
|
---|
3696 | if (strcmp (name, ".plt") == 0)
|
---|
3697 | {
|
---|
3698 | if (s->_raw_size == 0)
|
---|
3699 | {
|
---|
3700 | /* Strip this section if we don't need it; see the
|
---|
3701 | comment below. */
|
---|
3702 | strip = TRUE;
|
---|
3703 | }
|
---|
3704 | else
|
---|
3705 | {
|
---|
3706 | /* Remember whether there is a PLT. */
|
---|
3707 | plt = TRUE;
|
---|
3708 | }
|
---|
3709 | }
|
---|
3710 | else if (strncmp (name, ".rela", 5) == 0)
|
---|
3711 | {
|
---|
3712 | if (s->_raw_size == 0)
|
---|
3713 | {
|
---|
3714 | /* If we don't need this section, strip it from the
|
---|
3715 | output file. This is mostly to handle .rela.bss and
|
---|
3716 | .rela.plt. We must create both sections in
|
---|
3717 | create_dynamic_sections, because they must be created
|
---|
3718 | before the linker maps input sections to output
|
---|
3719 | sections. The linker does that before
|
---|
3720 | adjust_dynamic_symbol is called, and it is that
|
---|
3721 | function which decides whether anything needs to go
|
---|
3722 | into these sections. */
|
---|
3723 | strip = TRUE;
|
---|
3724 | }
|
---|
3725 | else
|
---|
3726 | {
|
---|
3727 | asection *target;
|
---|
3728 |
|
---|
3729 | /* Remember whether there are any reloc sections other
|
---|
3730 | than .rela.plt. */
|
---|
3731 | if (strcmp (name, ".rela.plt") != 0)
|
---|
3732 | {
|
---|
3733 | const char *outname;
|
---|
3734 |
|
---|
3735 | relocs = TRUE;
|
---|
3736 |
|
---|
3737 | /* If this relocation section applies to a read only
|
---|
3738 | section, then we probably need a DT_TEXTREL
|
---|
3739 | entry. The entries in the .rela.plt section
|
---|
3740 | really apply to the .got section, which we
|
---|
3741 | created ourselves and so know is not readonly. */
|
---|
3742 | outname = bfd_get_section_name (output_bfd,
|
---|
3743 | s->output_section);
|
---|
3744 | target = bfd_get_section_by_name (output_bfd, outname + 5);
|
---|
3745 | if (target != NULL
|
---|
3746 | && (target->flags & SEC_READONLY) != 0
|
---|
3747 | && (target->flags & SEC_ALLOC) != 0)
|
---|
3748 | reltext = TRUE;
|
---|
3749 | }
|
---|
3750 |
|
---|
3751 | /* We use the reloc_count field as a counter if we need
|
---|
3752 | to copy relocs into the output file. */
|
---|
3753 | s->reloc_count = 0;
|
---|
3754 | }
|
---|
3755 | }
|
---|
3756 | else if (strncmp (name, ".got", 4) != 0)
|
---|
3757 | {
|
---|
3758 | /* It's not one of our sections, so don't allocate space. */
|
---|
3759 | continue;
|
---|
3760 | }
|
---|
3761 |
|
---|
3762 | if (strip)
|
---|
3763 | {
|
---|
3764 | _bfd_strip_section_from_output (info, s);
|
---|
3765 | continue;
|
---|
3766 | }
|
---|
3767 |
|
---|
3768 | /* Allocate memory for the section contents. */
|
---|
3769 | s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);
|
---|
3770 | if (s->contents == NULL && s->_raw_size != 0)
|
---|
3771 | return FALSE;
|
---|
3772 | }
|
---|
3773 |
|
---|
3774 | if (elf_hash_table (info)->dynamic_sections_created)
|
---|
3775 | {
|
---|
3776 | /* Add some entries to the .dynamic section. We fill in the
|
---|
3777 | values later, in sh64_elf64_finish_dynamic_sections, but we
|
---|
3778 | must add the entries now so that we get the correct size for
|
---|
3779 | the .dynamic section. The DT_DEBUG entry is filled in by the
|
---|
3780 | dynamic linker and used by the debugger. */
|
---|
3781 | if (! info->shared)
|
---|
3782 | {
|
---|
3783 | if (! bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0))
|
---|
3784 | return FALSE;
|
---|
3785 | }
|
---|
3786 |
|
---|
3787 | if (plt)
|
---|
3788 | {
|
---|
3789 | if (! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0)
|
---|
3790 | || ! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0)
|
---|
3791 | || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA)
|
---|
3792 | || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0))
|
---|
3793 | return FALSE;
|
---|
3794 | }
|
---|
3795 |
|
---|
3796 | if (relocs)
|
---|
3797 | {
|
---|
3798 | if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0)
|
---|
3799 | || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0)
|
---|
3800 | || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT,
|
---|
3801 | sizeof (Elf64_External_Rela)))
|
---|
3802 | return FALSE;
|
---|
3803 | }
|
---|
3804 |
|
---|
3805 | if (reltext)
|
---|
3806 | {
|
---|
3807 | if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0))
|
---|
3808 | return FALSE;
|
---|
3809 | }
|
---|
3810 | }
|
---|
3811 |
|
---|
3812 | return TRUE;
|
---|
3813 | }
|
---|
3814 |
|
---|
3815 | /* Finish up dynamic symbol handling. We set the contents of various
|
---|
3816 | dynamic sections here. */
|
---|
3817 |
|
---|
3818 | static bfd_boolean
|
---|
3819 | sh64_elf64_finish_dynamic_symbol (output_bfd, info, h, sym)
|
---|
3820 | bfd *output_bfd;
|
---|
3821 | struct bfd_link_info *info;
|
---|
3822 | struct elf_link_hash_entry *h;
|
---|
3823 | Elf_Internal_Sym *sym;
|
---|
3824 | {
|
---|
3825 | bfd *dynobj;
|
---|
3826 |
|
---|
3827 | dynobj = elf_hash_table (info)->dynobj;
|
---|
3828 |
|
---|
3829 | if (h->plt.offset != (bfd_vma) -1)
|
---|
3830 | {
|
---|
3831 | asection *splt;
|
---|
3832 | asection *sgot;
|
---|
3833 | asection *srel;
|
---|
3834 |
|
---|
3835 | bfd_vma plt_index;
|
---|
3836 | bfd_vma got_offset;
|
---|
3837 | Elf_Internal_Rela rel;
|
---|
3838 | bfd_byte *loc;
|
---|
3839 |
|
---|
3840 | /* This symbol has an entry in the procedure linkage table. Set
|
---|
3841 | it up. */
|
---|
3842 |
|
---|
3843 | BFD_ASSERT (h->dynindx != -1);
|
---|
3844 |
|
---|
3845 | splt = bfd_get_section_by_name (dynobj, ".plt");
|
---|
3846 | sgot = bfd_get_section_by_name (dynobj, ".got.plt");
|
---|
3847 | srel = bfd_get_section_by_name (dynobj, ".rela.plt");
|
---|
3848 | BFD_ASSERT (splt != NULL && sgot != NULL && srel != NULL);
|
---|
3849 |
|
---|
3850 | /* Get the index in the procedure linkage table which
|
---|
3851 | corresponds to this symbol. This is the index of this symbol
|
---|
3852 | in all the symbols for which we are making plt entries. The
|
---|
3853 | first entry in the procedure linkage table is reserved. */
|
---|
3854 | plt_index = h->plt.offset / elf_sh64_sizeof_plt (info) - 1;
|
---|
3855 |
|
---|
3856 | /* Get the offset into the .got table of the entry that
|
---|
3857 | corresponds to this function. Each .got entry is 8 bytes.
|
---|
3858 | The first three are reserved. */
|
---|
3859 | got_offset = (plt_index + 3) * 8;
|
---|
3860 |
|
---|
3861 | if (info->shared)
|
---|
3862 | got_offset -= GOT_BIAS;
|
---|
3863 |
|
---|
3864 | /* Fill in the entry in the procedure linkage table. */
|
---|
3865 | if (! info->shared)
|
---|
3866 | {
|
---|
3867 | if (elf_sh64_plt_entry == NULL)
|
---|
3868 | {
|
---|
3869 | elf_sh64_plt_entry = (bfd_big_endian (output_bfd) ?
|
---|
3870 | elf_sh64_plt_entry_be : elf_sh64_plt_entry_le);
|
---|
3871 | }
|
---|
3872 | memcpy (splt->contents + h->plt.offset, elf_sh64_plt_entry,
|
---|
3873 | elf_sh64_sizeof_plt (info));
|
---|
3874 | movi_3shori_putval (output_bfd,
|
---|
3875 | (sgot->output_section->vma
|
---|
3876 | + sgot->output_offset
|
---|
3877 | + got_offset),
|
---|
3878 | (splt->contents + h->plt.offset
|
---|
3879 | + elf_sh64_plt_symbol_offset (info)));
|
---|
3880 |
|
---|
3881 | /* Set bottom bit because its for a branch to SHmedia */
|
---|
3882 | movi_shori_putval (output_bfd,
|
---|
3883 | -(h->plt.offset
|
---|
3884 | + elf_sh64_plt_plt0_offset (info) + 8)
|
---|
3885 | | 1,
|
---|
3886 | (splt->contents + h->plt.offset
|
---|
3887 | + elf_sh64_plt_plt0_offset (info)));
|
---|
3888 | }
|
---|
3889 | else
|
---|
3890 | {
|
---|
3891 | if (elf_sh64_pic_plt_entry == NULL)
|
---|
3892 | {
|
---|
3893 | elf_sh64_pic_plt_entry = (bfd_big_endian (output_bfd) ?
|
---|
3894 | elf_sh64_pic_plt_entry_be :
|
---|
3895 | elf_sh64_pic_plt_entry_le);
|
---|
3896 | }
|
---|
3897 | memcpy (splt->contents + h->plt.offset, elf_sh64_pic_plt_entry,
|
---|
3898 | elf_sh64_sizeof_plt (info));
|
---|
3899 | movi_shori_putval (output_bfd, got_offset,
|
---|
3900 | (splt->contents + h->plt.offset
|
---|
3901 | + elf_sh64_plt_symbol_offset (info)));
|
---|
3902 | }
|
---|
3903 |
|
---|
3904 | if (info->shared)
|
---|
3905 | got_offset += GOT_BIAS;
|
---|
3906 |
|
---|
3907 | movi_shori_putval (output_bfd,
|
---|
3908 | plt_index * sizeof (Elf64_External_Rela),
|
---|
3909 | (splt->contents + h->plt.offset
|
---|
3910 | + elf_sh64_plt_reloc_offset (info)));
|
---|
3911 |
|
---|
3912 | /* Fill in the entry in the global offset table. */
|
---|
3913 | bfd_put_64 (output_bfd,
|
---|
3914 | (splt->output_section->vma
|
---|
3915 | + splt->output_offset
|
---|
3916 | + h->plt.offset
|
---|
3917 | + elf_sh64_plt_temp_offset (info)),
|
---|
3918 | sgot->contents + got_offset);
|
---|
3919 |
|
---|
3920 | /* Fill in the entry in the .rela.plt section. */
|
---|
3921 | rel.r_offset = (sgot->output_section->vma
|
---|
3922 | + sgot->output_offset
|
---|
3923 | + got_offset);
|
---|
3924 | rel.r_info = ELF64_R_INFO (h->dynindx, R_SH_JMP_SLOT64);
|
---|
3925 | rel.r_addend = 0;
|
---|
3926 | rel.r_addend = GOT_BIAS;
|
---|
3927 | loc = srel->contents + plt_index * sizeof (Elf64_External_Rela);
|
---|
3928 | bfd_elf64_swap_reloca_out (output_bfd, &rel, loc);
|
---|
3929 |
|
---|
3930 | if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0)
|
---|
3931 | {
|
---|
3932 | /* Mark the symbol as undefined, rather than as defined in
|
---|
3933 | the .plt section. Leave the value alone. */
|
---|
3934 | sym->st_shndx = SHN_UNDEF;
|
---|
3935 | }
|
---|
3936 | }
|
---|
3937 |
|
---|
3938 | if (h->got.offset != (bfd_vma) -1)
|
---|
3939 | {
|
---|
3940 | asection *sgot;
|
---|
3941 | asection *srel;
|
---|
3942 | Elf_Internal_Rela rel;
|
---|
3943 | bfd_byte *loc;
|
---|
3944 |
|
---|
3945 | /* This symbol has an entry in the global offset table. Set it
|
---|
3946 | up. */
|
---|
3947 |
|
---|
3948 | sgot = bfd_get_section_by_name (dynobj, ".got");
|
---|
3949 | srel = bfd_get_section_by_name (dynobj, ".rela.got");
|
---|
3950 | BFD_ASSERT (sgot != NULL && srel != NULL);
|
---|
3951 |
|
---|
3952 | rel.r_offset = (sgot->output_section->vma
|
---|
3953 | + sgot->output_offset
|
---|
3954 | + (h->got.offset &~ 1));
|
---|
3955 |
|
---|
3956 | /* If this is a -Bsymbolic link, and the symbol is defined
|
---|
3957 | locally, we just want to emit a RELATIVE reloc. Likewise if
|
---|
3958 | the symbol was forced to be local because of a version file.
|
---|
3959 | The entry in the global offset table will already have been
|
---|
3960 | initialized in the relocate_section function. */
|
---|
3961 | if (info->shared
|
---|
3962 | && (info->symbolic || h->dynindx == -1)
|
---|
3963 | && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
|
---|
3964 | {
|
---|
3965 | rel.r_info = ELF64_R_INFO (0, R_SH_RELATIVE64);
|
---|
3966 | rel.r_addend = (h->root.u.def.value
|
---|
3967 | + h->root.u.def.section->output_section->vma
|
---|
3968 | + h->root.u.def.section->output_offset);
|
---|
3969 | }
|
---|
3970 | else
|
---|
3971 | {
|
---|
3972 | bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset);
|
---|
3973 | rel.r_info = ELF64_R_INFO (h->dynindx, R_SH_GLOB_DAT64);
|
---|
3974 | rel.r_addend = 0;
|
---|
3975 | }
|
---|
3976 |
|
---|
3977 | loc = srel->contents;
|
---|
3978 | loc += srel->reloc_count++ * sizeof (Elf64_External_Rela);
|
---|
3979 | bfd_elf64_swap_reloca_out (output_bfd, &rel, loc);
|
---|
3980 | }
|
---|
3981 |
|
---|
3982 | if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) != 0)
|
---|
3983 | {
|
---|
3984 | asection *s;
|
---|
3985 | Elf_Internal_Rela rel;
|
---|
3986 | bfd_byte *loc;
|
---|
3987 |
|
---|
3988 | /* This symbol needs a copy reloc. Set it up. */
|
---|
3989 |
|
---|
3990 | BFD_ASSERT (h->dynindx != -1
|
---|
3991 | && (h->root.type == bfd_link_hash_defined
|
---|
3992 | || h->root.type == bfd_link_hash_defweak));
|
---|
3993 |
|
---|
3994 | s = bfd_get_section_by_name (h->root.u.def.section->owner,
|
---|
3995 | ".rela.bss");
|
---|
3996 | BFD_ASSERT (s != NULL);
|
---|
3997 |
|
---|
3998 | rel.r_offset = (h->root.u.def.value
|
---|
3999 | + h->root.u.def.section->output_section->vma
|
---|
4000 | + h->root.u.def.section->output_offset);
|
---|
4001 | rel.r_info = ELF64_R_INFO (h->dynindx, R_SH_COPY64);
|
---|
4002 | rel.r_addend = 0;
|
---|
4003 | loc = s->contents;
|
---|
4004 | loc += s->reloc_count++ * sizeof (Elf64_External_Rela);
|
---|
4005 | bfd_elf64_swap_reloca_out (output_bfd, &rel, loc);
|
---|
4006 | }
|
---|
4007 |
|
---|
4008 | /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
|
---|
4009 | if (strcmp (h->root.root.string, "_DYNAMIC") == 0
|
---|
4010 | || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0)
|
---|
4011 | sym->st_shndx = SHN_ABS;
|
---|
4012 |
|
---|
4013 | return TRUE;
|
---|
4014 | }
|
---|
4015 |
|
---|
4016 | /* Finish up the dynamic sections. */
|
---|
4017 |
|
---|
4018 | static bfd_boolean
|
---|
4019 | sh64_elf64_finish_dynamic_sections (output_bfd, info)
|
---|
4020 | bfd *output_bfd;
|
---|
4021 | struct bfd_link_info *info;
|
---|
4022 | {
|
---|
4023 | bfd *dynobj;
|
---|
4024 | asection *sgot;
|
---|
4025 | asection *sdyn;
|
---|
4026 |
|
---|
4027 | dynobj = elf_hash_table (info)->dynobj;
|
---|
4028 |
|
---|
4029 | sgot = bfd_get_section_by_name (dynobj, ".got.plt");
|
---|
4030 | BFD_ASSERT (sgot != NULL);
|
---|
4031 | sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
|
---|
4032 |
|
---|
4033 | if (elf_hash_table (info)->dynamic_sections_created)
|
---|
4034 | {
|
---|
4035 | asection *splt;
|
---|
4036 | Elf64_External_Dyn *dyncon, *dynconend;
|
---|
4037 |
|
---|
4038 | BFD_ASSERT (sdyn != NULL);
|
---|
4039 |
|
---|
4040 | dyncon = (Elf64_External_Dyn *) sdyn->contents;
|
---|
4041 | dynconend = (Elf64_External_Dyn *) (sdyn->contents + sdyn->_raw_size);
|
---|
4042 | for (; dyncon < dynconend; dyncon++)
|
---|
4043 | {
|
---|
4044 | Elf_Internal_Dyn dyn;
|
---|
4045 | const char *name;
|
---|
4046 | asection *s;
|
---|
4047 | struct elf_link_hash_entry *h;
|
---|
4048 |
|
---|
4049 | bfd_elf64_swap_dyn_in (dynobj, dyncon, &dyn);
|
---|
4050 |
|
---|
4051 | switch (dyn.d_tag)
|
---|
4052 | {
|
---|
4053 | default:
|
---|
4054 | break;
|
---|
4055 |
|
---|
4056 | case DT_INIT:
|
---|
4057 | name = info->init_function;
|
---|
4058 | goto get_sym;
|
---|
4059 |
|
---|
4060 | case DT_FINI:
|
---|
4061 | name = info->fini_function;
|
---|
4062 | get_sym:
|
---|
4063 | if (dyn.d_un.d_val != 0)
|
---|
4064 | {
|
---|
4065 | h = elf_link_hash_lookup (elf_hash_table (info), name,
|
---|
4066 | FALSE, FALSE, TRUE);
|
---|
4067 | if (h != NULL && (h->other & STO_SH5_ISA32))
|
---|
4068 | {
|
---|
4069 | dyn.d_un.d_val |= 1;
|
---|
4070 | bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
|
---|
4071 | }
|
---|
4072 | }
|
---|
4073 | break;
|
---|
4074 |
|
---|
4075 | case DT_PLTGOT:
|
---|
4076 | name = ".got";
|
---|
4077 | goto get_vma;
|
---|
4078 |
|
---|
4079 | case DT_JMPREL:
|
---|
4080 | name = ".rela.plt";
|
---|
4081 | get_vma:
|
---|
4082 | s = bfd_get_section_by_name (output_bfd, name);
|
---|
4083 | BFD_ASSERT (s != NULL);
|
---|
4084 | dyn.d_un.d_ptr = s->vma;
|
---|
4085 | bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
|
---|
4086 | break;
|
---|
4087 |
|
---|
4088 | case DT_PLTRELSZ:
|
---|
4089 | s = bfd_get_section_by_name (output_bfd, ".rela.plt");
|
---|
4090 | BFD_ASSERT (s != NULL);
|
---|
4091 | if (s->_cooked_size != 0)
|
---|
4092 | dyn.d_un.d_val = s->_cooked_size;
|
---|
4093 | else
|
---|
4094 | dyn.d_un.d_val = s->_raw_size;
|
---|
4095 | bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
|
---|
4096 | break;
|
---|
4097 |
|
---|
4098 | case DT_RELASZ:
|
---|
4099 | /* My reading of the SVR4 ABI indicates that the
|
---|
4100 | procedure linkage table relocs (DT_JMPREL) should be
|
---|
4101 | included in the overall relocs (DT_RELA). This is
|
---|
4102 | what Solaris does. However, UnixWare can not handle
|
---|
4103 | that case. Therefore, we override the DT_RELASZ entry
|
---|
4104 | here to make it not include the JMPREL relocs. Since
|
---|
4105 | the linker script arranges for .rela.plt to follow all
|
---|
4106 | other relocation sections, we don't have to worry
|
---|
4107 | about changing the DT_RELA entry. */
|
---|
4108 | s = bfd_get_section_by_name (output_bfd, ".rela.plt");
|
---|
4109 | if (s != NULL)
|
---|
4110 | {
|
---|
4111 | if (s->_cooked_size != 0)
|
---|
4112 | dyn.d_un.d_val -= s->_cooked_size;
|
---|
4113 | else
|
---|
4114 | dyn.d_un.d_val -= s->_raw_size;
|
---|
4115 | }
|
---|
4116 | bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon);
|
---|
4117 | break;
|
---|
4118 | }
|
---|
4119 | }
|
---|
4120 |
|
---|
4121 | /* Fill in the first entry in the procedure linkage table. */
|
---|
4122 | splt = bfd_get_section_by_name (dynobj, ".plt");
|
---|
4123 | if (splt && splt->_raw_size > 0)
|
---|
4124 | {
|
---|
4125 | if (info->shared)
|
---|
4126 | {
|
---|
4127 | if (elf_sh64_pic_plt_entry == NULL)
|
---|
4128 | {
|
---|
4129 | elf_sh64_pic_plt_entry = (bfd_big_endian (output_bfd) ?
|
---|
4130 | elf_sh64_pic_plt_entry_be :
|
---|
4131 | elf_sh64_pic_plt_entry_le);
|
---|
4132 | }
|
---|
4133 | memcpy (splt->contents, elf_sh64_pic_plt_entry,
|
---|
4134 | elf_sh64_sizeof_plt (info));
|
---|
4135 | }
|
---|
4136 | else
|
---|
4137 | {
|
---|
4138 | if (elf_sh64_plt0_entry == NULL)
|
---|
4139 | {
|
---|
4140 | elf_sh64_plt0_entry = (bfd_big_endian (output_bfd) ?
|
---|
4141 | elf_sh64_plt0_entry_be :
|
---|
4142 | elf_sh64_plt0_entry_le);
|
---|
4143 | }
|
---|
4144 | memcpy (splt->contents, elf_sh64_plt0_entry, PLT_ENTRY_SIZE);
|
---|
4145 | movi_3shori_putval (output_bfd,
|
---|
4146 | sgot->output_section->vma
|
---|
4147 | + sgot->output_offset,
|
---|
4148 | splt->contents
|
---|
4149 | + elf_sh64_plt0_gotplt_offset (info));
|
---|
4150 | }
|
---|
4151 |
|
---|
4152 | /* UnixWare sets the entsize of .plt to 8, although that doesn't
|
---|
4153 | really seem like the right value. */
|
---|
4154 | elf_section_data (splt->output_section)->this_hdr.sh_entsize = 8;
|
---|
4155 | }
|
---|
4156 | }
|
---|
4157 |
|
---|
4158 | /* Fill in the first three entries in the global offset table. */
|
---|
4159 | if (sgot->_raw_size > 0)
|
---|
4160 | {
|
---|
4161 | if (sdyn == NULL)
|
---|
4162 | bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents);
|
---|
4163 | else
|
---|
4164 | bfd_put_64 (output_bfd,
|
---|
4165 | sdyn->output_section->vma + sdyn->output_offset,
|
---|
4166 | sgot->contents);
|
---|
4167 | bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents + 8);
|
---|
4168 | bfd_put_64 (output_bfd, (bfd_vma) 0, sgot->contents + 16);
|
---|
4169 | }
|
---|
4170 |
|
---|
4171 | elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 8;
|
---|
4172 |
|
---|
4173 | return TRUE;
|
---|
4174 | }
|
---|
4175 |
|
---|
4176 | #define TARGET_BIG_SYM bfd_elf64_sh64_vec
|
---|
4177 | #define TARGET_BIG_NAME "elf64-sh64"
|
---|
4178 | #define TARGET_LITTLE_SYM bfd_elf64_sh64l_vec
|
---|
4179 | #define TARGET_LITTLE_NAME "elf64-sh64l"
|
---|
4180 | #define ELF_ARCH bfd_arch_sh
|
---|
4181 | #define ELF_MACHINE_CODE EM_SH
|
---|
4182 | #define ELF_MAXPAGESIZE 128
|
---|
4183 |
|
---|
4184 | #define elf_symbol_leading_char '_'
|
---|
4185 |
|
---|
4186 | #define bfd_elf64_bfd_reloc_type_lookup sh_elf64_reloc_type_lookup
|
---|
4187 | #define elf_info_to_howto sh_elf64_info_to_howto
|
---|
4188 |
|
---|
4189 | /* Note: there's no relaxation at present. */
|
---|
4190 |
|
---|
4191 | #define elf_backend_relocate_section sh_elf64_relocate_section
|
---|
4192 | #define bfd_elf64_bfd_get_relocated_section_contents \
|
---|
4193 | sh_elf64_get_relocated_section_contents
|
---|
4194 | #define elf_backend_object_p sh_elf64_set_mach_from_flags
|
---|
4195 | #define bfd_elf64_bfd_set_private_flags \
|
---|
4196 | sh_elf64_set_private_flags
|
---|
4197 | #define bfd_elf64_bfd_copy_private_bfd_data \
|
---|
4198 | sh_elf64_copy_private_data
|
---|
4199 | #define bfd_elf64_bfd_merge_private_bfd_data \
|
---|
4200 | sh_elf64_merge_private_data
|
---|
4201 | #define elf_backend_fake_sections sh64_elf64_fake_sections
|
---|
4202 |
|
---|
4203 | #define elf_backend_gc_mark_hook sh_elf64_gc_mark_hook
|
---|
4204 | #define elf_backend_gc_sweep_hook sh_elf64_gc_sweep_hook
|
---|
4205 | #define elf_backend_check_relocs sh_elf64_check_relocs
|
---|
4206 |
|
---|
4207 | #define elf_backend_can_gc_sections 1
|
---|
4208 |
|
---|
4209 | #define elf_backend_get_symbol_type sh64_elf64_get_symbol_type
|
---|
4210 |
|
---|
4211 | #define elf_backend_add_symbol_hook sh64_elf64_add_symbol_hook
|
---|
4212 |
|
---|
4213 | #define elf_backend_link_output_symbol_hook \
|
---|
4214 | sh64_elf64_link_output_symbol_hook
|
---|
4215 |
|
---|
4216 | #define elf_backend_final_write_processing \
|
---|
4217 | sh64_elf64_final_write_processing
|
---|
4218 |
|
---|
4219 | #define elf_backend_create_dynamic_sections \
|
---|
4220 | sh64_elf64_create_dynamic_sections
|
---|
4221 | #define bfd_elf64_bfd_link_hash_table_create \
|
---|
4222 | sh64_elf64_link_hash_table_create
|
---|
4223 | #define elf_backend_adjust_dynamic_symbol \
|
---|
4224 | sh64_elf64_adjust_dynamic_symbol
|
---|
4225 | #define elf_backend_size_dynamic_sections \
|
---|
4226 | sh64_elf64_size_dynamic_sections
|
---|
4227 | #define elf_backend_finish_dynamic_symbol \
|
---|
4228 | sh64_elf64_finish_dynamic_symbol
|
---|
4229 | #define elf_backend_finish_dynamic_sections \
|
---|
4230 | sh64_elf64_finish_dynamic_sections
|
---|
4231 |
|
---|
4232 | #define elf_backend_want_got_plt 1
|
---|
4233 | #define elf_backend_plt_readonly 1
|
---|
4234 | #define elf_backend_want_plt_sym 0
|
---|
4235 | #define elf_backend_got_header_size 24
|
---|
4236 | #define elf_backend_plt_header_size PLT_ENTRY_SIZE
|
---|
4237 |
|
---|
4238 | #include "elf64-target.h"
|
---|
4239 |
|
---|
4240 | /* NetBSD support. */
|
---|
4241 | #undef TARGET_BIG_SYM
|
---|
4242 | #define TARGET_BIG_SYM bfd_elf64_sh64nbsd_vec
|
---|
4243 | #undef TARGET_BIG_NAME
|
---|
4244 | #define TARGET_BIG_NAME "elf64-sh64-nbsd"
|
---|
4245 | #undef TARGET_LITTLE_SYM
|
---|
4246 | #define TARGET_LITTLE_SYM bfd_elf64_sh64lnbsd_vec
|
---|
4247 | #undef TARGET_LITTLE_NAME
|
---|
4248 | #define TARGET_LITTLE_NAME "elf64-sh64l-nbsd"
|
---|
4249 | #undef ELF_MAXPAGESIZE
|
---|
4250 | #define ELF_MAXPAGESIZE 0x10000
|
---|
4251 | #undef elf_symbol_leading_char
|
---|
4252 | #define elf_symbol_leading_char 0
|
---|
4253 |
|
---|
4254 | #define elf64_bed elf64_sh64_nbsd_bed
|
---|
4255 |
|
---|
4256 | #include "elf64-target.h"
|
---|
4257 |
|
---|
4258 | /* Linux support. */
|
---|
4259 | #undef TARGET_BIG_SYM
|
---|
4260 | #define TARGET_BIG_SYM bfd_elf64_sh64blin_vec
|
---|
4261 | #undef TARGET_BIG_NAME
|
---|
4262 | #define TARGET_BIG_NAME "elf64-sh64big-linux"
|
---|
4263 | #undef TARGET_LITTLE_SYM
|
---|
4264 | #define TARGET_LITTLE_SYM bfd_elf64_sh64lin_vec
|
---|
4265 | #undef TARGET_LITTLE_NAME
|
---|
4266 | #define TARGET_LITTLE_NAME "elf64-sh64-linux"
|
---|
4267 |
|
---|
4268 | #define INCLUDED_TARGET_FILE
|
---|
4269 | #include "elf64-target.h"
|
---|