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