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