]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - bfd/elf32-i860.c
bfd/
[thirdparty/binutils-gdb.git] / bfd / elf32-i860.c
CommitLineData
0e5136c6 1/* Intel i860 specific support for 32-bit ELF.
b2a8e766 2 Copyright 1993, 1995, 1999, 2000, 2001, 2002, 2003, 2004
b491616a 3 Free Software Foundation, Inc.
9d751335 4
0e5136c6 5 Full i860 support contributed by Jason Eckhardt <jle@cygnus.com>.
252b5132
RH
6
7This file is part of BFD, the Binary File Descriptor library.
8
9This program is free software; you can redistribute it and/or modify
10it under the terms of the GNU General Public License as published by
11the Free Software Foundation; either version 2 of the License, or
12(at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22
23#include "bfd.h"
24#include "sysdep.h"
25#include "libbfd.h"
26#include "elf-bfd.h"
0e5136c6
JE
27#include "elf/i860.h"
28
32d920dd 29/* special_function for R_860_PC26 relocation. */
d539b3aa
CG
30static bfd_reloc_status_type
31i860_howto_pc26_reloc (bfd *abfd ATTRIBUTE_UNUSED,
32 arelent *reloc_entry,
33 asymbol *symbol,
34 void *data ATTRIBUTE_UNUSED,
35 asection *input_section,
36 bfd *output_bfd,
37 char **error_message ATTRIBUTE_UNUSED)
38{
1c0881dd
CG
39 bfd_vma insn;
40 bfd_vma relocation;
eea6121a 41 bfd_size_type sz;
1c0881dd
CG
42 bfd_byte *addr;
43
d539b3aa
CG
44 if (output_bfd != NULL
45 && (symbol->flags & BSF_SECTION_SYM) == 0
46 && (! reloc_entry->howto->partial_inplace
47 || reloc_entry->addend == 0))
48 {
49 reloc_entry->address += input_section->output_offset;
50 return bfd_reloc_ok;
51 }
52
1c0881dd
CG
53 /* Used elf32-mips.c as an example. */
54 if (bfd_is_und_section (symbol->section)
55 && output_bfd == (bfd *) NULL)
56 return bfd_reloc_undefined;
57
58 if (bfd_is_com_section (symbol->section))
59 relocation = 0;
60 else
61 relocation = symbol->value;
62
63 relocation += symbol->section->output_section->vma;
64 relocation += symbol->section->output_offset;
65 relocation += reloc_entry->addend;
66
eea6121a
AM
67 sz = input_section->rawsize ? input_section->rawsize : input_section->size;
68 if (reloc_entry->address > sz)
1c0881dd
CG
69 return bfd_reloc_outofrange;
70
71 /* Adjust for PC-relative relocation. */
72 relocation -= (input_section->output_section->vma
73 + input_section->output_offset
74 + reloc_entry->address
75 + 4);
76
77 /* Check for target out of range. */
78 if ((bfd_signed_vma)relocation > (0x3ffffff << 2)
79 || (bfd_signed_vma)relocation < (-0x4000000 << 2))
80 return bfd_reloc_outofrange;
81
82 addr = (bfd_byte *) data + reloc_entry->address;
83 insn = bfd_get_32 (abfd, addr);
84
85 relocation >>= reloc_entry->howto->rightshift;
86 insn = (insn & ~reloc_entry->howto->dst_mask)
87 | (relocation & reloc_entry->howto->dst_mask);
88
89 bfd_put_32 (abfd, (bfd_vma) insn, addr);
90
91 return bfd_reloc_ok;
d539b3aa
CG
92}
93
94/* special_function for R_860_PC16 relocation. */
95static bfd_reloc_status_type
96i860_howto_pc16_reloc (bfd *abfd,
97 arelent *reloc_entry,
98 asymbol *symbol,
99 void *data,
100 asection *input_section,
101 bfd *output_bfd,
102 char **error_message ATTRIBUTE_UNUSED)
103{
104 bfd_vma insn;
105 bfd_vma relocation;
eea6121a 106 bfd_size_type sz;
d539b3aa
CG
107 bfd_byte *addr;
108
109 if (output_bfd != NULL
110 && (symbol->flags & BSF_SECTION_SYM) == 0
111 && (! reloc_entry->howto->partial_inplace
112 || reloc_entry->addend == 0))
113 {
114 reloc_entry->address += input_section->output_offset;
115 return bfd_reloc_ok;
116 }
117
118 /* Used elf32-mips.c as an example. */
119 if (bfd_is_und_section (symbol->section)
120 && output_bfd == (bfd *) NULL)
121 return bfd_reloc_undefined;
122
123 if (bfd_is_com_section (symbol->section))
124 relocation = 0;
125 else
126 relocation = symbol->value;
127
128 relocation += symbol->section->output_section->vma;
129 relocation += symbol->section->output_offset;
130 relocation += reloc_entry->addend;
131
eea6121a
AM
132 sz = input_section->rawsize ? input_section->rawsize : input_section->size;
133 if (reloc_entry->address > sz)
d539b3aa
CG
134 return bfd_reloc_outofrange;
135
136 /* Adjust for PC-relative relocation. */
137 relocation -= (input_section->output_section->vma
138 + input_section->output_offset
139 + reloc_entry->address
140 + 4);
141
142 /* Check for target out of range. */
143 if ((bfd_signed_vma)relocation > (0x7fff << 2)
144 || (bfd_signed_vma)relocation < (-0x8000 << 2))
145 return bfd_reloc_outofrange;
146
147 addr = (bfd_byte *) data + reloc_entry->address;
148 insn = bfd_get_32 (abfd, addr);
149
150 relocation >>= reloc_entry->howto->rightshift;
151 relocation = (((relocation & 0xf800) << 5) | (relocation & 0x7ff))
152 & reloc_entry->howto->dst_mask;
153 insn = (insn & ~reloc_entry->howto->dst_mask) | relocation;
154
155 bfd_put_32 (abfd, (bfd_vma) insn, addr);
156
157 return bfd_reloc_ok;
158}
159
160/* special_function for R_860_HIGHADJ relocation. */
161static bfd_reloc_status_type
162i860_howto_highadj_reloc (bfd *abfd,
163 arelent *reloc_entry,
164 asymbol *symbol,
165 void *data,
166 asection *input_section,
167 bfd *output_bfd,
168 char **error_message ATTRIBUTE_UNUSED)
169{
170 bfd_vma insn;
171 bfd_vma relocation;
eea6121a 172 bfd_size_type sz;
d539b3aa
CG
173 bfd_byte *addr;
174
175 if (output_bfd != NULL
176 && (symbol->flags & BSF_SECTION_SYM) == 0
177 && (! reloc_entry->howto->partial_inplace
178 || reloc_entry->addend == 0))
179 {
180 reloc_entry->address += input_section->output_offset;
181 return bfd_reloc_ok;
182 }
183
184 /* Used elf32-mips.c as an example. */
185 if (bfd_is_und_section (symbol->section)
186 && output_bfd == (bfd *) NULL)
187 return bfd_reloc_undefined;
188
189 if (bfd_is_com_section (symbol->section))
190 relocation = 0;
191 else
192 relocation = symbol->value;
193
194 relocation += symbol->section->output_section->vma;
195 relocation += symbol->section->output_offset;
196 relocation += reloc_entry->addend;
197 relocation += 0x8000;
198
eea6121a
AM
199 sz = input_section->rawsize ? input_section->rawsize : input_section->size;
200 if (reloc_entry->address > sz)
d539b3aa
CG
201 return bfd_reloc_outofrange;
202
203 addr = (bfd_byte *) data + reloc_entry->address;
204 insn = bfd_get_32 (abfd, addr);
205
206 relocation = ((relocation >> 16) & 0xffff);
207
208 insn = (insn & 0xffff0000) | relocation;
209
210 bfd_put_32 (abfd, (bfd_vma) insn, addr);
211
212 return bfd_reloc_ok;
213}
214
215/* special_function for R_860_SPLITn relocations. */
216static bfd_reloc_status_type
217i860_howto_splitn_reloc (bfd *abfd,
218 arelent *reloc_entry,
219 asymbol *symbol,
220 void *data,
221 asection *input_section,
222 bfd *output_bfd,
223 char **error_message ATTRIBUTE_UNUSED)
224{
225 bfd_vma insn;
226 bfd_vma relocation;
eea6121a 227 bfd_size_type sz;
d539b3aa
CG
228 bfd_byte *addr;
229
230 if (output_bfd != NULL
231 && (symbol->flags & BSF_SECTION_SYM) == 0
232 && (! reloc_entry->howto->partial_inplace
233 || reloc_entry->addend == 0))
234 {
235 reloc_entry->address += input_section->output_offset;
236 return bfd_reloc_ok;
237 }
238
239 /* Used elf32-mips.c as an example. */
240 if (bfd_is_und_section (symbol->section)
241 && output_bfd == (bfd *) NULL)
242 return bfd_reloc_undefined;
243
244 if (bfd_is_com_section (symbol->section))
245 relocation = 0;
246 else
247 relocation = symbol->value;
248
249 relocation += symbol->section->output_section->vma;
250 relocation += symbol->section->output_offset;
251 relocation += reloc_entry->addend;
252
eea6121a
AM
253 sz = input_section->rawsize ? input_section->rawsize : input_section->size;
254 if (reloc_entry->address > sz)
d539b3aa
CG
255 return bfd_reloc_outofrange;
256
257 addr = (bfd_byte *) data + reloc_entry->address;
258 insn = bfd_get_32 (abfd, addr);
259
260 relocation = (((relocation & 0xf800) << 5) | (relocation & 0x7ff))
261 & reloc_entry->howto->dst_mask;
262 insn = (insn & ~reloc_entry->howto->dst_mask) | relocation;
263
264 bfd_put_32 (abfd, (bfd_vma) insn, addr);
265
266 return bfd_reloc_ok;
267}
de24da47 268
0e5136c6
JE
269/* This howto table is preliminary. */
270static reloc_howto_type elf32_i860_howto_table [] =
271{
272 /* This relocation does nothing. */
273 HOWTO (R_860_NONE, /* type */
274 0, /* rightshift */
275 2, /* size (0 = byte, 1 = short, 2 = long) */
276 32, /* bitsize */
b34976b6 277 FALSE, /* pc_relative */
0e5136c6
JE
278 0, /* bitpos */
279 complain_overflow_bitfield, /* complain_on_overflow */
280 bfd_elf_generic_reloc, /* special_function */
281 "R_860_NONE", /* name */
b34976b6 282 FALSE, /* partial_inplace */
0e5136c6
JE
283 0, /* src_mask */
284 0, /* dst_mask */
b34976b6 285 FALSE), /* pcrel_offset */
0e5136c6
JE
286
287 /* A 32-bit absolute relocation. */
288 HOWTO (R_860_32, /* type */
289 0, /* rightshift */
290 2, /* size (0 = byte, 1 = short, 2 = long) */
291 32, /* bitsize */
b34976b6 292 FALSE, /* pc_relative */
0e5136c6
JE
293 0, /* bitpos */
294 complain_overflow_bitfield, /* complain_on_overflow */
295 bfd_elf_generic_reloc, /* special_function */
296 "R_860_32", /* name */
b34976b6 297 FALSE, /* partial_inplace */
0e5136c6
JE
298 0xffffffff, /* src_mask */
299 0xffffffff, /* dst_mask */
b34976b6 300 FALSE), /* pcrel_offset */
0e5136c6
JE
301
302 HOWTO (R_860_COPY, /* type */
303 0, /* rightshift */
304 2, /* size (0 = byte, 1 = short, 2 = long) */
305 32, /* bitsize */
b34976b6 306 FALSE, /* pc_relative */
0e5136c6
JE
307 0, /* bitpos */
308 complain_overflow_bitfield, /* complain_on_overflow */
309 bfd_elf_generic_reloc, /* special_function */
310 "R_860_COPY", /* name */
b34976b6 311 TRUE, /* partial_inplace */
0e5136c6
JE
312 0xffffffff, /* src_mask */
313 0xffffffff, /* dst_mask */
b34976b6 314 FALSE), /* pcrel_offset */
0e5136c6
JE
315
316 HOWTO (R_860_GLOB_DAT, /* type */
317 0, /* rightshift */
318 2, /* size (0 = byte, 1 = short, 2 = long) */
319 32, /* bitsize */
b34976b6 320 FALSE, /* pc_relative */
0e5136c6
JE
321 0, /* bitpos */
322 complain_overflow_bitfield, /* complain_on_overflow */
323 bfd_elf_generic_reloc, /* special_function */
324 "R_860_GLOB_DAT", /* name */
b34976b6 325 TRUE, /* partial_inplace */
0e5136c6
JE
326 0xffffffff, /* src_mask */
327 0xffffffff, /* dst_mask */
b34976b6 328 FALSE), /* pcrel_offset */
0e5136c6
JE
329
330 HOWTO (R_860_JUMP_SLOT, /* type */
331 0, /* rightshift */
332 2, /* size (0 = byte, 1 = short, 2 = long) */
333 32, /* bitsize */
b34976b6 334 FALSE, /* pc_relative */
0e5136c6
JE
335 0, /* bitpos */
336 complain_overflow_bitfield, /* complain_on_overflow */
337 bfd_elf_generic_reloc, /* special_function */
338 "R_860_JUMP_SLOT", /* name */
b34976b6 339 TRUE, /* partial_inplace */
0e5136c6
JE
340 0xffffffff, /* src_mask */
341 0xffffffff, /* dst_mask */
b34976b6 342 FALSE), /* pcrel_offset */
0e5136c6
JE
343
344 HOWTO (R_860_RELATIVE, /* type */
345 0, /* rightshift */
346 2, /* size (0 = byte, 1 = short, 2 = long) */
347 32, /* bitsize */
b34976b6 348 FALSE, /* pc_relative */
0e5136c6
JE
349 0, /* bitpos */
350 complain_overflow_bitfield, /* complain_on_overflow */
351 bfd_elf_generic_reloc, /* special_function */
352 "R_860_RELATIVE", /* name */
b34976b6 353 TRUE, /* partial_inplace */
0e5136c6
JE
354 0xffffffff, /* src_mask */
355 0xffffffff, /* dst_mask */
b34976b6 356 FALSE), /* pcrel_offset */
0e5136c6
JE
357
358 /* A 26-bit PC-relative relocation. */
359 HOWTO (R_860_PC26, /* type */
fdeafce7 360 2, /* rightshift */
0e5136c6
JE
361 2, /* size (0 = byte, 1 = short, 2 = long) */
362 26, /* bitsize */
b34976b6 363 TRUE, /* pc_relative */
0e5136c6
JE
364 0, /* bitpos */
365 complain_overflow_bitfield, /* complain_on_overflow */
d539b3aa 366 i860_howto_pc26_reloc, /* special_function */
0e5136c6 367 "R_860_PC26", /* name */
b34976b6 368 FALSE, /* partial_inplace */
0e5136c6
JE
369 0x3ffffff, /* src_mask */
370 0x3ffffff, /* dst_mask */
b34976b6 371 TRUE), /* pcrel_offset */
0e5136c6
JE
372
373 HOWTO (R_860_PLT26, /* type */
374 0, /* rightshift */
375 2, /* size (0 = byte, 1 = short, 2 = long) */
376 26, /* bitsize */
b34976b6 377 TRUE, /* pc_relative */
0e5136c6
JE
378 0, /* bitpos */
379 complain_overflow_bitfield, /* complain_on_overflow */
380 bfd_elf_generic_reloc, /* special_function */
381 "R_860_PLT26", /* name */
b34976b6 382 TRUE, /* partial_inplace */
0e5136c6
JE
383 0xffffffff, /* src_mask */
384 0xffffffff, /* dst_mask */
b34976b6 385 TRUE), /* pcrel_offset */
0e5136c6
JE
386
387 /* A 16-bit PC-relative relocation. */
388 HOWTO (R_860_PC16, /* type */
fdeafce7 389 2, /* rightshift */
0e5136c6
JE
390 2, /* size (0 = byte, 1 = short, 2 = long) */
391 16, /* bitsize */
b34976b6 392 TRUE, /* pc_relative */
0e5136c6
JE
393 0, /* bitpos */
394 complain_overflow_bitfield, /* complain_on_overflow */
d539b3aa 395 i860_howto_pc16_reloc, /* special_function */
0e5136c6 396 "R_860_PC16", /* name */
b34976b6 397 FALSE, /* partial_inplace */
305d537e
JE
398 0x1f07ff, /* src_mask */
399 0x1f07ff, /* dst_mask */
b34976b6 400 TRUE), /* pcrel_offset */
0e5136c6
JE
401
402 HOWTO (R_860_LOW0, /* type */
403 0, /* rightshift */
404 2, /* size (0 = byte, 1 = short, 2 = long) */
405 16, /* bitsize */
b34976b6 406 FALSE, /* pc_relative */
0e5136c6
JE
407 0, /* bitpos */
408 complain_overflow_dont, /* complain_on_overflow */
409 bfd_elf_generic_reloc, /* special_function */
410 "R_860_LOW0", /* name */
b34976b6 411 FALSE, /* partial_inplace */
0e5136c6
JE
412 0xffff, /* src_mask */
413 0xffff, /* dst_mask */
b34976b6 414 FALSE), /* pcrel_offset */
0e5136c6
JE
415
416 HOWTO (R_860_SPLIT0, /* type */
417 0, /* rightshift */
418 2, /* size (0 = byte, 1 = short, 2 = long) */
419 16, /* bitsize */
b34976b6 420 FALSE, /* pc_relative */
0e5136c6
JE
421 0, /* bitpos */
422 complain_overflow_dont, /* complain_on_overflow */
d539b3aa 423 i860_howto_splitn_reloc, /* special_function */
0e5136c6 424 "R_860_SPLIT0", /* name */
b34976b6 425 FALSE, /* partial_inplace */
0e5136c6
JE
426 0x1f07ff, /* src_mask */
427 0x1f07ff, /* dst_mask */
b34976b6 428 FALSE), /* pcrel_offset */
0e5136c6
JE
429
430 HOWTO (R_860_LOW1, /* type */
431 0, /* rightshift */
432 2, /* size (0 = byte, 1 = short, 2 = long) */
433 16, /* bitsize */
b34976b6 434 FALSE, /* pc_relative */
0e5136c6
JE
435 0, /* bitpos */
436 complain_overflow_dont, /* complain_on_overflow */
437 bfd_elf_generic_reloc, /* special_function */
438 "R_860_LOW1", /* name */
b34976b6 439 FALSE, /* partial_inplace */
0e5136c6
JE
440 0xfffe, /* src_mask */
441 0xfffe, /* dst_mask */
b34976b6 442 FALSE), /* pcrel_offset */
0e5136c6
JE
443
444 HOWTO (R_860_SPLIT1, /* type */
445 0, /* rightshift */
446 2, /* size (0 = byte, 1 = short, 2 = long) */
447 16, /* bitsize */
b34976b6 448 FALSE, /* pc_relative */
0e5136c6
JE
449 0, /* bitpos */
450 complain_overflow_dont, /* complain_on_overflow */
d539b3aa 451 i860_howto_splitn_reloc, /* special_function */
0e5136c6 452 "R_860_SPLIT1", /* name */
b34976b6 453 FALSE, /* partial_inplace */
305d537e
JE
454 0x1f07fe, /* src_mask */
455 0x1f07fe, /* dst_mask */
b34976b6 456 FALSE), /* pcrel_offset */
0e5136c6
JE
457
458 HOWTO (R_860_LOW2, /* type */
459 0, /* rightshift */
460 2, /* size (0 = byte, 1 = short, 2 = long) */
461 16, /* bitsize */
b34976b6 462 FALSE, /* pc_relative */
0e5136c6
JE
463 0, /* bitpos */
464 complain_overflow_dont, /* complain_on_overflow */
465 bfd_elf_generic_reloc, /* special_function */
466 "R_860_LOW2", /* name */
b34976b6 467 FALSE, /* partial_inplace */
0e5136c6
JE
468 0xfffc, /* src_mask */
469 0xfffc, /* dst_mask */
b34976b6 470 FALSE), /* pcrel_offset */
0e5136c6
JE
471
472 HOWTO (R_860_SPLIT2, /* type */
473 0, /* rightshift */
474 2, /* size (0 = byte, 1 = short, 2 = long) */
475 16, /* bitsize */
b34976b6 476 FALSE, /* pc_relative */
0e5136c6
JE
477 0, /* bitpos */
478 complain_overflow_dont, /* complain_on_overflow */
d539b3aa 479 i860_howto_splitn_reloc, /* special_function */
0e5136c6 480 "R_860_SPLIT2", /* name */
b34976b6 481 FALSE, /* partial_inplace */
305d537e
JE
482 0x1f07fc, /* src_mask */
483 0x1f07fc, /* dst_mask */
b34976b6 484 FALSE), /* pcrel_offset */
0e5136c6
JE
485
486 HOWTO (R_860_LOW3, /* type */
487 0, /* rightshift */
488 2, /* size (0 = byte, 1 = short, 2 = long) */
489 16, /* bitsize */
b34976b6 490 FALSE, /* pc_relative */
0e5136c6
JE
491 0, /* bitpos */
492 complain_overflow_dont, /* complain_on_overflow */
493 bfd_elf_generic_reloc, /* special_function */
494 "R_860_LOW3", /* name */
b34976b6 495 FALSE, /* partial_inplace */
0e5136c6
JE
496 0xfff8, /* src_mask */
497 0xfff8, /* dst_mask */
b34976b6 498 FALSE), /* pcrel_offset */
0e5136c6
JE
499
500 HOWTO (R_860_LOGOT0, /* type */
501 0, /* rightshift */
502 2, /* size (0 = byte, 1 = short, 2 = long) */
503 16, /* bitsize */
b34976b6 504 FALSE, /* pc_relative */
0e5136c6
JE
505 0, /* bitpos */
506 complain_overflow_dont, /* complain_on_overflow */
507 bfd_elf_generic_reloc, /* special_function */
508 "R_860_LOGOT0", /* name */
b34976b6 509 FALSE, /* partial_inplace */
0e5136c6
JE
510 0, /* src_mask */
511 0xffff, /* dst_mask */
b34976b6 512 TRUE), /* pcrel_offset */
0e5136c6
JE
513
514 HOWTO (R_860_SPGOT0, /* type */
515 0, /* rightshift */
516 2, /* size (0 = byte, 1 = short, 2 = long) */
517 16, /* bitsize */
b34976b6 518 FALSE, /* pc_relative */
0e5136c6
JE
519 0, /* bitpos */
520 complain_overflow_dont, /* complain_on_overflow */
521 bfd_elf_generic_reloc, /* special_function */
522 "R_860_SPGOT0", /* name */
b34976b6 523 FALSE, /* partial_inplace */
0e5136c6
JE
524 0, /* src_mask */
525 0xffff, /* dst_mask */
b34976b6 526 TRUE), /* pcrel_offset */
0e5136c6
JE
527
528 HOWTO (R_860_LOGOT1, /* type */
529 0, /* rightshift */
530 2, /* size (0 = byte, 1 = short, 2 = long) */
531 16, /* bitsize */
b34976b6 532 FALSE, /* pc_relative */
0e5136c6
JE
533 0, /* bitpos */
534 complain_overflow_dont, /* complain_on_overflow */
535 bfd_elf_generic_reloc, /* special_function */
536 "R_860_LOGOT1", /* name */
b34976b6 537 FALSE, /* partial_inplace */
0e5136c6
JE
538 0, /* src_mask */
539 0xffff, /* dst_mask */
b34976b6 540 TRUE), /* pcrel_offset */
0e5136c6
JE
541
542 HOWTO (R_860_SPGOT1, /* type */
543 0, /* rightshift */
544 2, /* size (0 = byte, 1 = short, 2 = long) */
545 16, /* bitsize */
b34976b6 546 FALSE, /* pc_relative */
0e5136c6
JE
547 0, /* bitpos */
548 complain_overflow_dont, /* complain_on_overflow */
549 bfd_elf_generic_reloc, /* special_function */
550 "R_860_SPGOT1", /* name */
b34976b6 551 FALSE, /* partial_inplace */
0e5136c6
JE
552 0, /* src_mask */
553 0xffff, /* dst_mask */
b34976b6 554 TRUE), /* pcrel_offset */
0e5136c6
JE
555
556 HOWTO (R_860_LOGOTOFF0, /* type */
557 0, /* rightshift */
558 2, /* size (0 = byte, 1 = short, 2 = long) */
559 32, /* bitsize */
b34976b6 560 FALSE, /* pc_relative */
0e5136c6
JE
561 0, /* bitpos */
562 complain_overflow_dont, /* complain_on_overflow */
563 bfd_elf_generic_reloc, /* special_function */
564 "R_860_LOGOTOFF0", /* name */
b34976b6 565 TRUE, /* partial_inplace */
0e5136c6
JE
566 0xffffffff, /* src_mask */
567 0xffffffff, /* dst_mask */
b34976b6 568 FALSE), /* pcrel_offset */
0e5136c6
JE
569
570 HOWTO (R_860_SPGOTOFF0, /* type */
571 0, /* rightshift */
572 2, /* size (0 = byte, 1 = short, 2 = long) */
573 32, /* bitsize */
b34976b6 574 FALSE, /* pc_relative */
0e5136c6
JE
575 0, /* bitpos */
576 complain_overflow_dont, /* complain_on_overflow */
577 bfd_elf_generic_reloc, /* special_function */
578 "R_860_SPGOTOFF0", /* name */
b34976b6 579 TRUE, /* partial_inplace */
0e5136c6
JE
580 0xffffffff, /* src_mask */
581 0xffffffff, /* dst_mask */
b34976b6 582 FALSE), /* pcrel_offset */
0e5136c6
JE
583
584 HOWTO (R_860_LOGOTOFF1, /* type */
585 0, /* rightshift */
586 2, /* size (0 = byte, 1 = short, 2 = long) */
587 32, /* bitsize */
b34976b6 588 FALSE, /* pc_relative */
0e5136c6
JE
589 0, /* bitpos */
590 complain_overflow_dont, /* complain_on_overflow */
591 bfd_elf_generic_reloc, /* special_function */
592 "R_860_LOGOTOFF1", /* name */
b34976b6 593 TRUE, /* partial_inplace */
0e5136c6
JE
594 0xffffffff, /* src_mask */
595 0xffffffff, /* dst_mask */
b34976b6 596 FALSE), /* pcrel_offset */
0e5136c6
JE
597
598 HOWTO (R_860_SPGOTOFF1, /* type */
599 0, /* rightshift */
600 2, /* size (0 = byte, 1 = short, 2 = long) */
601 32, /* bitsize */
b34976b6 602 FALSE, /* pc_relative */
0e5136c6
JE
603 0, /* bitpos */
604 complain_overflow_dont, /* complain_on_overflow */
605 bfd_elf_generic_reloc, /* special_function */
606 "R_860_SPGOTOFF1", /* name */
b34976b6 607 TRUE, /* partial_inplace */
0e5136c6
JE
608 0xffffffff, /* src_mask */
609 0xffffffff, /* dst_mask */
b34976b6 610 FALSE), /* pcrel_offset */
0e5136c6
JE
611
612 HOWTO (R_860_LOGOTOFF2, /* type */
613 0, /* rightshift */
614 2, /* size (0 = byte, 1 = short, 2 = long) */
615 32, /* bitsize */
b34976b6 616 FALSE, /* pc_relative */
0e5136c6
JE
617 0, /* bitpos */
618 complain_overflow_dont, /* complain_on_overflow */
619 bfd_elf_generic_reloc, /* special_function */
620 "R_860_LOGOTOFF2", /* name */
b34976b6 621 TRUE, /* partial_inplace */
0e5136c6
JE
622 0xffffffff, /* src_mask */
623 0xffffffff, /* dst_mask */
b34976b6 624 FALSE), /* pcrel_offset */
0e5136c6
JE
625
626 HOWTO (R_860_LOGOTOFF3, /* type */
627 0, /* rightshift */
628 2, /* size (0 = byte, 1 = short, 2 = long) */
629 32, /* bitsize */
b34976b6 630 FALSE, /* pc_relative */
0e5136c6
JE
631 0, /* bitpos */
632 complain_overflow_dont, /* complain_on_overflow */
633 bfd_elf_generic_reloc, /* special_function */
634 "R_860_LOGOTOFF3", /* name */
b34976b6 635 TRUE, /* partial_inplace */
0e5136c6
JE
636 0xffffffff, /* src_mask */
637 0xffffffff, /* dst_mask */
b34976b6 638 FALSE), /* pcrel_offset */
0e5136c6
JE
639
640 HOWTO (R_860_LOPC, /* type */
641 0, /* rightshift */
642 2, /* size (0 = byte, 1 = short, 2 = long) */
643 16, /* bitsize */
b34976b6 644 TRUE, /* pc_relative */
0e5136c6
JE
645 0, /* bitpos */
646 complain_overflow_bitfield, /* complain_on_overflow */
647 bfd_elf_generic_reloc, /* special_function */
648 "R_860_LOPC", /* name */
b34976b6 649 FALSE, /* partial_inplace */
0e5136c6
JE
650 0xffff, /* src_mask */
651 0xffff, /* dst_mask */
b34976b6 652 TRUE), /* pcrel_offset */
0e5136c6
JE
653
654 HOWTO (R_860_HIGHADJ, /* type */
655 0, /* rightshift */
656 2, /* size (0 = byte, 1 = short, 2 = long) */
657 16, /* bitsize */
b34976b6 658 FALSE, /* pc_relative */
0e5136c6
JE
659 0, /* bitpos */
660 complain_overflow_dont, /* complain_on_overflow */
d539b3aa 661 i860_howto_highadj_reloc, /* special_function */
0e5136c6 662 "R_860_HIGHADJ", /* name */
b34976b6 663 FALSE, /* partial_inplace */
0e5136c6
JE
664 0xffff, /* src_mask */
665 0xffff, /* dst_mask */
b34976b6 666 FALSE), /* pcrel_offset */
0e5136c6
JE
667
668 HOWTO (R_860_HAGOT, /* type */
669 0, /* rightshift */
670 2, /* size (0 = byte, 1 = short, 2 = long) */
671 16, /* bitsize */
b34976b6 672 FALSE, /* pc_relative */
0e5136c6
JE
673 0, /* bitpos */
674 complain_overflow_dont, /* complain_on_overflow */
675 bfd_elf_generic_reloc, /* special_function */
676 "R_860_HAGOT", /* name */
b34976b6 677 FALSE, /* partial_inplace */
0e5136c6
JE
678 0, /* src_mask */
679 0xffff, /* dst_mask */
b34976b6 680 TRUE), /* pcrel_offset */
0e5136c6
JE
681
682 HOWTO (R_860_HAGOTOFF, /* type */
683 0, /* rightshift */
684 2, /* size (0 = byte, 1 = short, 2 = long) */
685 32, /* bitsize */
b34976b6 686 FALSE, /* pc_relative */
0e5136c6
JE
687 0, /* bitpos */
688 complain_overflow_dont, /* complain_on_overflow */
689 bfd_elf_generic_reloc, /* special_function */
690 "R_860_HAGOTOFF", /* name */
b34976b6 691 TRUE, /* partial_inplace */
0e5136c6
JE
692 0xffffffff, /* src_mask */
693 0xffffffff, /* dst_mask */
b34976b6 694 FALSE), /* pcrel_offset */
0e5136c6
JE
695
696 HOWTO (R_860_HAPC, /* type */
697 0, /* rightshift */
698 2, /* size (0 = byte, 1 = short, 2 = long) */
699 16, /* bitsize */
b34976b6 700 TRUE, /* pc_relative */
0e5136c6
JE
701 0, /* bitpos */
702 complain_overflow_bitfield, /* complain_on_overflow */
703 bfd_elf_generic_reloc, /* special_function */
704 "R_860_HAPC", /* name */
b34976b6 705 FALSE, /* partial_inplace */
0e5136c6
JE
706 0xffff, /* src_mask */
707 0xffff, /* dst_mask */
b34976b6 708 TRUE), /* pcrel_offset */
0e5136c6
JE
709
710 HOWTO (R_860_HIGH, /* type */
fdeafce7 711 16, /* rightshift */
0e5136c6
JE
712 2, /* size (0 = byte, 1 = short, 2 = long) */
713 16, /* bitsize */
b34976b6 714 FALSE, /* pc_relative */
0e5136c6
JE
715 0, /* bitpos */
716 complain_overflow_dont, /* complain_on_overflow */
717 bfd_elf_generic_reloc, /* special_function */
718 "R_860_HIGH", /* name */
b34976b6 719 FALSE, /* partial_inplace */
0e5136c6
JE
720 0xffff, /* src_mask */
721 0xffff, /* dst_mask */
b34976b6 722 FALSE), /* pcrel_offset */
0e5136c6
JE
723
724 HOWTO (R_860_HIGOT, /* type */
725 0, /* rightshift */
726 2, /* size (0 = byte, 1 = short, 2 = long) */
727 16, /* bitsize */
b34976b6 728 FALSE, /* pc_relative */
0e5136c6
JE
729 0, /* bitpos */
730 complain_overflow_dont, /* complain_on_overflow */
731 bfd_elf_generic_reloc, /* special_function */
732 "R_860_HIGOT", /* name */
b34976b6 733 FALSE, /* partial_inplace */
0e5136c6
JE
734 0, /* src_mask */
735 0xffff, /* dst_mask */
b34976b6 736 TRUE), /* pcrel_offset */
0e5136c6
JE
737
738 HOWTO (R_860_HIGOTOFF, /* type */
739 0, /* rightshift */
740 2, /* size (0 = byte, 1 = short, 2 = long) */
741 32, /* bitsize */
b34976b6 742 FALSE, /* pc_relative */
0e5136c6
JE
743 0, /* bitpos */
744 complain_overflow_dont, /* complain_on_overflow */
745 bfd_elf_generic_reloc, /* special_function */
746 "R_860_HIGOTOFF", /* name */
b34976b6 747 TRUE, /* partial_inplace */
0e5136c6
JE
748 0xffffffff, /* src_mask */
749 0xffffffff, /* dst_mask */
b34976b6 750 FALSE), /* pcrel_offset */
0e5136c6 751};
0e5136c6
JE
752\f
753static unsigned char elf_code_to_howto_index[R_860_max + 1];
754
755static reloc_howto_type *
7734b6e9 756lookup_howto (unsigned int rtype)
0e5136c6
JE
757{
758 static int initialized = 0;
759 int i;
760 int howto_tbl_size = (int) (sizeof (elf32_i860_howto_table)
761 / sizeof (elf32_i860_howto_table[0]));
762
763 if (! initialized)
764 {
765 initialized = 1;
766 memset (elf_code_to_howto_index, 0xff,
767 sizeof (elf_code_to_howto_index));
768 for (i = 0; i < howto_tbl_size; i++)
769 elf_code_to_howto_index[elf32_i860_howto_table[i].type] = i;
770 }
771
772 BFD_ASSERT (rtype <= R_860_max);
773 i = elf_code_to_howto_index[rtype];
774 if (i >= howto_tbl_size)
775 return 0;
776 return elf32_i860_howto_table + i;
777}
778
0e5136c6
JE
779/* Given a BFD reloc, return the matching HOWTO structure. */
780static reloc_howto_type *
7734b6e9
JE
781elf32_i860_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
782 bfd_reloc_code_real_type code)
0e5136c6
JE
783{
784 unsigned int rtype;
785
786 switch (code)
787 {
788 case BFD_RELOC_NONE:
789 rtype = R_860_NONE;
790 break;
791 case BFD_RELOC_32:
792 rtype = R_860_32;
793 break;
794 case BFD_RELOC_860_COPY:
795 rtype = R_860_COPY;
796 break;
797 case BFD_RELOC_860_GLOB_DAT:
6609fa74 798 rtype = R_860_GLOB_DAT;
0e5136c6
JE
799 break;
800 case BFD_RELOC_860_JUMP_SLOT:
801 rtype = R_860_JUMP_SLOT;
802 break;
803 case BFD_RELOC_860_RELATIVE:
804 rtype = R_860_RELATIVE;
805 break;
806 case BFD_RELOC_860_PC26:
807 rtype = R_860_PC26;
808 break;
809 case BFD_RELOC_860_PLT26:
810 rtype = R_860_PLT26;
811 break;
812 case BFD_RELOC_860_PC16:
813 rtype = R_860_PC16;
814 break;
815 case BFD_RELOC_860_LOW0:
816 rtype = R_860_LOW0;
817 break;
818 case BFD_RELOC_860_SPLIT0:
819 rtype = R_860_SPLIT0;
820 break;
821 case BFD_RELOC_860_LOW1:
822 rtype = R_860_LOW1;
823 break;
824 case BFD_RELOC_860_SPLIT1:
825 rtype = R_860_SPLIT1;
826 break;
827 case BFD_RELOC_860_LOW2:
828 rtype = R_860_LOW2;
829 break;
830 case BFD_RELOC_860_SPLIT2:
831 rtype = R_860_SPLIT2;
832 break;
833 case BFD_RELOC_860_LOW3:
834 rtype = R_860_LOW3;
835 break;
836 case BFD_RELOC_860_LOGOT0:
837 rtype = R_860_LOGOT0;
838 break;
839 case BFD_RELOC_860_SPGOT0:
840 rtype = R_860_SPGOT0;
841 break;
842 case BFD_RELOC_860_LOGOT1:
843 rtype = R_860_LOGOT1;
844 break;
845 case BFD_RELOC_860_SPGOT1:
846 rtype = R_860_SPGOT1;
847 break;
848 case BFD_RELOC_860_LOGOTOFF0:
849 rtype = R_860_LOGOTOFF0;
850 break;
851 case BFD_RELOC_860_SPGOTOFF0:
852 rtype = R_860_SPGOTOFF0;
853 break;
854 case BFD_RELOC_860_LOGOTOFF1:
855 rtype = R_860_LOGOTOFF1;
856 break;
857 case BFD_RELOC_860_SPGOTOFF1:
858 rtype = R_860_SPGOTOFF1;
859 break;
860 case BFD_RELOC_860_LOGOTOFF2:
861 rtype = R_860_LOGOTOFF2;
862 break;
863 case BFD_RELOC_860_LOGOTOFF3:
864 rtype = R_860_LOGOTOFF3;
865 break;
866 case BFD_RELOC_860_LOPC:
867 rtype = R_860_LOPC;
868 break;
869 case BFD_RELOC_860_HIGHADJ:
870 rtype = R_860_HIGHADJ;
871 break;
872 case BFD_RELOC_860_HAGOT:
873 rtype = R_860_HAGOT;
874 break;
875 case BFD_RELOC_860_HAGOTOFF:
876 rtype = R_860_HAGOTOFF;
877 break;
878 case BFD_RELOC_860_HAPC:
879 rtype = R_860_HAPC;
880 break;
881 case BFD_RELOC_860_HIGH:
882 rtype = R_860_HIGH;
883 break;
884 case BFD_RELOC_860_HIGOT:
885 rtype = R_860_HIGOT;
886 break;
887 case BFD_RELOC_860_HIGOTOFF:
888 rtype = R_860_HIGOTOFF;
889 break;
890 default:
891 rtype = 0;
892 break;
893 }
894 return lookup_howto (rtype);
895}
896
0e5136c6
JE
897/* Given a ELF reloc, return the matching HOWTO structure. */
898static void
7734b6e9
JE
899elf32_i860_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED,
900 arelent *bfd_reloc,
901 Elf_Internal_Rela *elf_reloc)
0e5136c6 902{
dc810e39
AM
903 bfd_reloc->howto
904 = lookup_howto ((unsigned) ELF32_R_TYPE (elf_reloc->r_info));
0e5136c6 905}
fdeafce7
JE
906\f
907/* Specialized relocation handler for R_860_SPLITn. These relocations
908 involves a 16-bit field that is split into two contiguous parts. */
909static bfd_reloc_status_type
7734b6e9
JE
910elf32_i860_relocate_splitn (bfd *input_bfd,
911 Elf_Internal_Rela *rello,
912 bfd_byte *contents,
913 bfd_vma value)
fdeafce7 914{
ded0649c 915 bfd_vma insn;
fdeafce7 916 reloc_howto_type *howto;
dc810e39 917 howto = lookup_howto ((unsigned) ELF32_R_TYPE (rello->r_info));
fdeafce7
JE
918 insn = bfd_get_32 (input_bfd, contents + rello->r_offset);
919
fdeafce7 920 /* Relocate. */
ded0649c 921 value += rello->r_addend;
fdeafce7 922
ded0649c 923 /* Separate the fields and insert. */
a48c6a54 924 value = (((value & 0xf800) << 5) | (value & 0x7ff)) & howto->dst_mask;
fdeafce7
JE
925 insn = (insn & ~howto->dst_mask) | value;
926
927 bfd_put_32 (input_bfd, insn, contents + rello->r_offset);
928 return bfd_reloc_ok;
929}
930
fdeafce7
JE
931/* Specialized relocation handler for R_860_PC16. This relocation
932 involves a 16-bit, PC-relative field that is split into two contiguous
933 parts. */
934static bfd_reloc_status_type
7734b6e9
JE
935elf32_i860_relocate_pc16 (bfd *input_bfd,
936 asection *input_section,
937 Elf_Internal_Rela *rello,
938 bfd_byte *contents,
939 bfd_vma value)
fdeafce7 940{
ded0649c 941 bfd_vma insn;
d670a150 942 reloc_howto_type *howto;
dc810e39 943 howto = lookup_howto ((unsigned) ELF32_R_TYPE (rello->r_info));
d670a150
JE
944 insn = bfd_get_32 (input_bfd, contents + rello->r_offset);
945
946 /* Adjust for PC-relative relocation. */
947 value -= (input_section->output_section->vma
948 + input_section->output_offset);
949 value -= rello->r_offset;
950
d670a150 951 /* Relocate. */
ded0649c 952 value += rello->r_addend;
d670a150 953
f680ea79
JE
954 /* Adjust the value by 4, then separate the fields and insert. */
955 value = (value - 4) >> howto->rightshift;
a48c6a54 956 value = (((value & 0xf800) << 5) | (value & 0x7ff)) & howto->dst_mask;
d670a150
JE
957 insn = (insn & ~howto->dst_mask) | value;
958
959 bfd_put_32 (input_bfd, insn, contents + rello->r_offset);
960 return bfd_reloc_ok;
961
fdeafce7 962}
fdeafce7 963
c1e8b710
JE
964/* Specialized relocation handler for R_860_PC26. This relocation
965 involves a 26-bit, PC-relative field which must be adjusted by 4. */
966static bfd_reloc_status_type
7734b6e9
JE
967elf32_i860_relocate_pc26 (bfd *input_bfd,
968 asection *input_section,
969 Elf_Internal_Rela *rello,
970 bfd_byte *contents,
971 bfd_vma value)
c1e8b710
JE
972{
973 bfd_vma insn;
974 reloc_howto_type *howto;
dc810e39 975 howto = lookup_howto ((unsigned) ELF32_R_TYPE (rello->r_info));
c1e8b710
JE
976 insn = bfd_get_32 (input_bfd, contents + rello->r_offset);
977
978 /* Adjust for PC-relative relocation. */
979 value -= (input_section->output_section->vma
980 + input_section->output_offset);
981 value -= rello->r_offset;
982
983 /* Relocate. */
984 value += rello->r_addend;
985
986 /* Adjust value by 4 and insert the field. */
6609fa74 987 value = ((value - 4) >> howto->rightshift) & howto->dst_mask;
c1e8b710
JE
988 insn = (insn & ~howto->dst_mask) | value;
989
990 bfd_put_32 (input_bfd, insn, contents + rello->r_offset);
991 return bfd_reloc_ok;
992
993}
994
fdeafce7
JE
995/* Specialized relocation handler for R_860_HIGHADJ. */
996static bfd_reloc_status_type
7734b6e9
JE
997elf32_i860_relocate_highadj (bfd *input_bfd,
998 Elf_Internal_Rela *rel,
999 bfd_byte *contents,
1000 bfd_vma value)
fdeafce7
JE
1001{
1002 bfd_vma insn;
1003
1004 insn = bfd_get_32 (input_bfd, contents + rel->r_offset);
1005
fdeafce7 1006 value += rel->r_addend;
b645cb17 1007 value += 0x8000;
fdeafce7 1008 value = ((value >> 16) & 0xffff);
fdeafce7
JE
1009
1010 insn = (insn & 0xffff0000) | value;
1011
1012 bfd_put_32 (input_bfd, insn, contents + rel->r_offset);
1013 return bfd_reloc_ok;
1014}
1015
fdeafce7
JE
1016/* Perform a single relocation. By default we use the standard BFD
1017 routines. However, we handle some specially. */
1018static bfd_reloc_status_type
7734b6e9
JE
1019i860_final_link_relocate (reloc_howto_type *howto,
1020 bfd *input_bfd,
1021 asection *input_section,
1022 bfd_byte *contents,
1023 Elf_Internal_Rela *rel,
1024 bfd_vma relocation)
fdeafce7
JE
1025{
1026 return _bfd_final_link_relocate (howto, input_bfd, input_section,
1027 contents, rel->r_offset, relocation,
1028 rel->r_addend);
1029}
1030
fdeafce7 1031/* Relocate an i860 ELF section.
252b5132 1032
fdeafce7 1033 This is boiler-plate code copied from fr30.
fdeafce7
JE
1034
1035 The RELOCATE_SECTION function is called by the new ELF backend linker
1036 to handle the relocations for a section.
1037
1038 The relocs are always passed as Rela structures; if the section
1039 actually uses Rel structures, the r_addend field will always be
1040 zero.
1041
1042 This function is responsible for adjusting the section contents as
1049f94e 1043 necessary, and (if using Rela relocs and generating a relocatable
fdeafce7
JE
1044 output file) adjusting the reloc addend as necessary.
1045
1046 This function does not have to worry about setting the reloc
1047 address or the reloc symbol index.
1048
1049 LOCAL_SYMS is a pointer to the swapped in local symbols.
1050
1051 LOCAL_SECTIONS is an array giving the section in the input file
1052 corresponding to the st_shndx field of each local symbol.
1053
1054 The global hash table entry for the global symbols can be found
1055 via elf_sym_hashes (input_bfd).
1056
1049f94e 1057 When generating relocatable output, this function must handle
fdeafce7
JE
1058 STB_LOCAL/STT_SECTION symbols specially. The output symbol is
1059 going to be the section symbol corresponding to the output
1060 section, which means that the addend must be adjusted
1061 accordingly. */
b34976b6 1062static bfd_boolean
7734b6e9
JE
1063elf32_i860_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
1064 struct bfd_link_info *info,
1065 bfd *input_bfd,
1066 asection *input_section,
1067 bfd_byte *contents,
1068 Elf_Internal_Rela *relocs,
1069 Elf_Internal_Sym *local_syms,
1070 asection **local_sections)
fdeafce7 1071{
b34976b6
AM
1072 Elf_Internal_Shdr *symtab_hdr;
1073 struct elf_link_hash_entry **sym_hashes;
1074 Elf_Internal_Rela *rel;
1075 Elf_Internal_Rela *relend;
fdeafce7 1076
1049f94e 1077 if (info->relocatable)
b34976b6 1078 return TRUE;
b491616a 1079
fdeafce7
JE
1080 symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr;
1081 sym_hashes = elf_sym_hashes (input_bfd);
1082 relend = relocs + input_section->reloc_count;
1083
1084 for (rel = relocs; rel < relend; rel ++)
1085 {
1086 reloc_howto_type * howto;
1087 unsigned long r_symndx;
1088 Elf_Internal_Sym * sym;
1089 asection * sec;
1090 struct elf_link_hash_entry * h;
1091 bfd_vma relocation;
1092 bfd_reloc_status_type r;
1093 const char * name = NULL;
1094 int r_type;
6609fa74 1095
fdeafce7 1096 r_type = ELF32_R_TYPE (rel->r_info);
6609fa74 1097
fdeafce7
JE
1098#if 0
1099 if ( r_type == R_860_GNU_VTINHERIT
1100 || r_type == R_860_GNU_VTENTRY)
1101 continue;
1102#endif
6609fa74 1103
fdeafce7
JE
1104 r_symndx = ELF32_R_SYM (rel->r_info);
1105
dc810e39
AM
1106 howto = lookup_howto ((unsigned) ELF32_R_TYPE (rel->r_info));
1107 h = NULL;
1108 sym = NULL;
1109 sec = NULL;
6609fa74 1110
fdeafce7
JE
1111 if (r_symndx < symtab_hdr->sh_info)
1112 {
1113 sym = local_syms + r_symndx;
1114 sec = local_sections [r_symndx];
8517fae7 1115 relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
6609fa74 1116
fdeafce7
JE
1117 name = bfd_elf_string_from_elf_section
1118 (input_bfd, symtab_hdr->sh_link, sym->st_name);
1119 name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name;
1120 }
1121 else
1122 {
59c2e50f
L
1123 bfd_boolean unresolved_reloc, warned;
1124
b2a8e766
AM
1125 RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
1126 r_symndx, symtab_hdr, sym_hashes,
1127 h, sec, relocation,
1128 unresolved_reloc, warned);
fdeafce7 1129 }
6609fa74 1130
fdeafce7
JE
1131 switch (r_type)
1132 {
1133 default:
1134 r = i860_final_link_relocate (howto, input_bfd, input_section,
1135 contents, rel, relocation);
1136 break;
1137
1138 case R_860_HIGHADJ:
1139 r = elf32_i860_relocate_highadj (input_bfd, rel, contents,
1140 relocation);
1141 break;
1142
fdeafce7 1143 case R_860_PC16:
d670a150
JE
1144 r = elf32_i860_relocate_pc16 (input_bfd, input_section, rel,
1145 contents, relocation);
fdeafce7 1146 break;
fdeafce7 1147
c1e8b710
JE
1148 case R_860_PC26:
1149 r = elf32_i860_relocate_pc26 (input_bfd, input_section, rel,
1150 contents, relocation);
1151 break;
1152
fdeafce7
JE
1153 case R_860_SPLIT0:
1154 case R_860_SPLIT1:
1155 case R_860_SPLIT2:
1156 r = elf32_i860_relocate_splitn (input_bfd, rel, contents,
1157 relocation);
1158 break;
1159
1160 /* We do not yet handle GOT/PLT/Dynamic relocations. */
1161 case R_860_COPY:
1162 case R_860_GLOB_DAT:
1163 case R_860_JUMP_SLOT:
1164 case R_860_RELATIVE:
1165 case R_860_PLT26:
1166 case R_860_LOGOT0:
1167 case R_860_SPGOT0:
1168 case R_860_LOGOT1:
1169 case R_860_SPGOT1:
1170 case R_860_LOGOTOFF0:
1171 case R_860_SPGOTOFF0:
1172 case R_860_LOGOTOFF1:
1173 case R_860_SPGOTOFF1:
1174 case R_860_LOGOTOFF2:
1175 case R_860_LOGOTOFF3:
1176 case R_860_LOPC:
1177 case R_860_HAGOT:
1178 case R_860_HAGOTOFF:
1179 case R_860_HAPC:
1180 case R_860_HIGOT:
1181 case R_860_HIGOTOFF:
1182 r = bfd_reloc_notsupported;
1183 break;
6609fa74 1184 }
fdeafce7
JE
1185
1186 if (r != bfd_reloc_ok)
1187 {
1188 const char * msg = (const char *) NULL;
1189
1190 switch (r)
1191 {
1192 case bfd_reloc_overflow:
1193 r = info->callbacks->reloc_overflow
1194 (info, name, howto->name, (bfd_vma) 0,
1195 input_bfd, input_section, rel->r_offset);
1196 break;
6609fa74 1197
fdeafce7
JE
1198 case bfd_reloc_undefined:
1199 r = info->callbacks->undefined_symbol
b34976b6 1200 (info, name, input_bfd, input_section, rel->r_offset, TRUE);
fdeafce7 1201 break;
6609fa74 1202
fdeafce7
JE
1203 case bfd_reloc_outofrange:
1204 msg = _("internal error: out of range error");
1205 break;
1206
1207 case bfd_reloc_notsupported:
1208 msg = _("internal error: unsupported relocation error");
1209 break;
1210
1211 case bfd_reloc_dangerous:
1212 msg = _("internal error: dangerous relocation");
1213 break;
1214
1215 default:
1216 msg = _("internal error: unknown error");
1217 break;
1218 }
1219
1220 if (msg)
1221 r = info->callbacks->warning
1222 (info, msg, name, input_bfd, input_section, rel->r_offset);
1223
1224 if (! r)
b34976b6 1225 return FALSE;
fdeafce7
JE
1226 }
1227 }
1228
b34976b6 1229 return TRUE;
fdeafce7
JE
1230}
1231
de24da47
JE
1232/* Return whether a symbol name implies a local label. SVR4/860 compilers
1233 generate labels of the form ".ep.function_name" to denote the end of a
1234 function prolog. These should be local.
1235 ??? Do any other SVR4 compilers have this convention? If so, this should
1236 be added to the generic routine. */
b34976b6 1237static bfd_boolean
7734b6e9 1238elf32_i860_is_local_label_name (bfd *abfd, const char *name)
de24da47
JE
1239{
1240 if (name[0] == '.' && name[1] == 'e' && name[2] == 'p' && name[3] == '.')
b34976b6 1241 return TRUE;
de24da47
JE
1242
1243 return _bfd_elf_is_local_label_name (abfd, name);
1244}
fdeafce7 1245\f
9d751335
JE
1246#define TARGET_BIG_SYM bfd_elf32_i860_vec
1247#define TARGET_BIG_NAME "elf32-i860"
1248#define TARGET_LITTLE_SYM bfd_elf32_i860_little_vec
1249#define TARGET_LITTLE_NAME "elf32-i860-little"
0e5136c6
JE
1250#define ELF_ARCH bfd_arch_i860
1251#define ELF_MACHINE_CODE EM_860
1252#define ELF_MAXPAGESIZE 4096
1253
b491616a 1254#define elf_backend_rela_normal 1
fdeafce7 1255#define elf_info_to_howto_rel NULL
0e5136c6 1256#define elf_info_to_howto elf32_i860_info_to_howto_rela
fdeafce7 1257#define elf_backend_relocate_section elf32_i860_relocate_section
0e5136c6 1258#define bfd_elf32_bfd_reloc_type_lookup elf32_i860_reloc_type_lookup
de24da47 1259#define bfd_elf32_bfd_is_local_label_name elf32_i860_is_local_label_name
252b5132
RH
1260
1261#include "elf32-target.h"