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