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