Commit | Line | Data |
---|---|---|
3b16e843 | 1 | /* BFD back-end for OpenRISC 1000 COFF binaries. |
4b95cf5c | 2 | Copyright (C) 2002-2014 Free Software Foundation, Inc. |
3b16e843 NC |
3 | Contributed by Ivan Guzvinec <ivang@opencores.org> |
4 | ||
5 | This file is part of BFD, the Binary File Descriptor library. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
cd123cb7 | 9 | the Free Software Foundation; either version 3 of the License, or |
3b16e843 NC |
10 | (at your option) any later version. |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
cd123cb7 NC |
19 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
20 | MA 02110-1301, USA. */ | |
3b16e843 NC |
21 | |
22 | #define OR32 1 | |
23 | ||
3b16e843 | 24 | #include "sysdep.h" |
3db64b00 | 25 | #include "bfd.h" |
3b16e843 NC |
26 | #include "libbfd.h" |
27 | #include "coff/or32.h" | |
28 | #include "coff/internal.h" | |
29 | #include "libcoff.h" | |
30 | ||
b34976b6 | 31 | static bfd_reloc_status_type or32_reloc |
2c3fc389 | 32 | (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); |
3b16e843 NC |
33 | |
34 | #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2) | |
35 | ||
36 | #define INSERT_HWORD(WORD,HWORD) \ | |
37 | (((WORD) & 0xffff0000) | ((HWORD)& 0x0000ffff)) | |
38 | #define EXTRACT_HWORD(WORD) \ | |
39 | ((WORD) & 0x0000ffff) | |
40 | #define SIGN_EXTEND_HWORD(HWORD) \ | |
41 | ((HWORD) & 0x8000 ? (HWORD)|(~0xffffL) : (HWORD)) | |
42 | ||
43 | #define INSERT_JUMPTARG(WORD,JT) \ | |
44 | (((WORD) & 0xfc000000) | ((JT)& 0x03ffffff)) | |
45 | #define EXTRACT_JUMPTARG(WORD) \ | |
46 | ((WORD) & 0x03ffffff) | |
47 | #define SIGN_EXTEND_JUMPTARG(JT) \ | |
48 | ((JT) & 0x04000000 ? (JT)|(~0x03ffffffL) : (JT)) | |
49 | ||
50 | /* Provided the symbol, returns the value reffed. */ | |
51 | ||
52 | static long | |
2c3fc389 | 53 | get_symbol_value (asymbol *symbol) |
b34976b6 | 54 | { |
3b16e843 NC |
55 | long relocation = 0; |
56 | ||
57 | if (bfd_is_com_section (symbol->section)) | |
b34976b6 AM |
58 | relocation = 0; |
59 | else | |
3b16e843 NC |
60 | relocation = symbol->value + |
61 | symbol->section->output_section->vma + | |
62 | symbol->section->output_offset; | |
63 | ||
64 | return relocation; | |
65 | } | |
66 | ||
67 | /* This function is in charge of performing all the or32 relocations. */ | |
68 | ||
69 | static bfd_reloc_status_type | |
2c3fc389 NC |
70 | or32_reloc (bfd *abfd, |
71 | arelent *reloc_entry, | |
72 | asymbol *symbol_in, | |
73 | void * data, | |
74 | asection *input_section, | |
75 | bfd *output_bfd, | |
76 | char **error_message) | |
3b16e843 NC |
77 | { |
78 | /* The consth relocation comes in two parts, we have to remember | |
79 | the state between calls, in these variables. */ | |
b34976b6 | 80 | static bfd_boolean part1_consth_active = FALSE; |
3b16e843 NC |
81 | static unsigned long part1_consth_value; |
82 | ||
83 | unsigned long insn; | |
84 | unsigned long sym_value; | |
85 | unsigned long unsigned_value; | |
86 | unsigned short r_type; | |
87 | long signed_value; | |
88 | ||
89 | unsigned long addr = reloc_entry->address ; /*+ input_section->vma*/ | |
90 | bfd_byte *hit_data =addr + (bfd_byte *)(data); | |
b34976b6 | 91 | |
3b16e843 NC |
92 | r_type = reloc_entry->howto->type; |
93 | ||
b34976b6 | 94 | if (output_bfd) |
3b16e843 NC |
95 | { |
96 | /* Partial linking - do nothing. */ | |
97 | reloc_entry->address += input_section->output_offset; | |
98 | return bfd_reloc_ok; | |
99 | } | |
100 | ||
101 | if (symbol_in != NULL | |
102 | && bfd_is_und_section (symbol_in->section)) | |
103 | { | |
104 | /* Keep the state machine happy in case we're called again. */ | |
b34976b6 | 105 | if (r_type == R_IHIHALF) |
3b16e843 | 106 | { |
b34976b6 | 107 | part1_consth_active = TRUE; |
3b16e843 NC |
108 | part1_consth_value = 0; |
109 | } | |
110 | ||
111 | return bfd_reloc_undefined; | |
112 | } | |
113 | ||
b34976b6 | 114 | if ((part1_consth_active) && (r_type != R_IHCONST)) |
3b16e843 | 115 | { |
b34976b6 | 116 | part1_consth_active = FALSE; |
3b16e843 NC |
117 | *error_message = (char *) "Missing IHCONST"; |
118 | ||
119 | return bfd_reloc_dangerous; | |
120 | } | |
121 | ||
122 | sym_value = get_symbol_value (symbol_in); | |
123 | ||
b34976b6 | 124 | switch (r_type) |
3b16e843 | 125 | { |
b34976b6 AM |
126 | case R_IREL: |
127 | insn = bfd_get_32(abfd, hit_data); | |
3b16e843 NC |
128 | |
129 | /* Take the value in the field and sign extend it. */ | |
130 | signed_value = EXTRACT_JUMPTARG (insn); | |
131 | signed_value = SIGN_EXTEND_JUMPTARG (signed_value); | |
132 | signed_value <<= 2; | |
133 | ||
134 | /* See the note on the R_IREL reloc in coff_or32_relocate_section. */ | |
135 | if (signed_value == - (long) reloc_entry->address) | |
136 | signed_value = 0; | |
137 | ||
138 | signed_value += sym_value + reloc_entry->addend; | |
0e71e495 BE |
139 | /* Relative jmp/call, so subtract from the value the |
140 | address of the place we're coming from. */ | |
141 | signed_value -= (reloc_entry->address | |
142 | + input_section->output_section->vma | |
143 | + input_section->output_offset); | |
144 | if (signed_value > 0x7ffffff || signed_value < -0x8000000) | |
145 | return bfd_reloc_overflow; | |
146 | ||
3b16e843 NC |
147 | signed_value >>= 2; |
148 | insn = INSERT_JUMPTARG (insn, signed_value); | |
b34976b6 | 149 | bfd_put_32 (abfd, insn, hit_data); |
3b16e843 NC |
150 | break; |
151 | ||
b34976b6 AM |
152 | case R_ILOHALF: |
153 | insn = bfd_get_32 (abfd, hit_data); | |
3b16e843 NC |
154 | unsigned_value = EXTRACT_HWORD (insn); |
155 | unsigned_value += sym_value + reloc_entry->addend; | |
156 | insn = INSERT_HWORD (insn, unsigned_value); | |
b34976b6 | 157 | bfd_put_32 (abfd, insn, hit_data); |
3b16e843 NC |
158 | break; |
159 | ||
160 | case R_IHIHALF: | |
b34976b6 | 161 | insn = bfd_get_32 (abfd, hit_data); |
3b16e843 | 162 | |
b34976b6 | 163 | /* consth, part 1 |
3b16e843 | 164 | Just get the symbol value that is referenced. */ |
b34976b6 | 165 | part1_consth_active = TRUE; |
3b16e843 NC |
166 | part1_consth_value = sym_value + reloc_entry->addend; |
167 | ||
168 | /* Don't modify insn until R_IHCONST. */ | |
169 | break; | |
170 | ||
b34976b6 AM |
171 | case R_IHCONST: |
172 | insn = bfd_get_32 (abfd, hit_data); | |
3b16e843 | 173 | |
b34976b6 | 174 | /* consth, part 2 |
3b16e843 | 175 | Now relocate the reference. */ |
b34976b6 | 176 | if (! part1_consth_active) |
3b16e843 NC |
177 | { |
178 | *error_message = (char *) "Missing IHIHALF"; | |
179 | return bfd_reloc_dangerous; | |
180 | } | |
181 | ||
182 | /* sym_ptr_ptr = r_symndx, in coff_slurp_reloc_table() */ | |
183 | unsigned_value = 0; /*EXTRACT_HWORD(insn) << 16;*/ | |
184 | unsigned_value += reloc_entry->addend; /* r_symndx */ | |
185 | unsigned_value += part1_consth_value; | |
186 | unsigned_value = unsigned_value >> 16; | |
187 | insn = INSERT_HWORD (insn, unsigned_value); | |
b34976b6 AM |
188 | part1_consth_active = FALSE; |
189 | bfd_put_32 (abfd, insn, hit_data); | |
3b16e843 NC |
190 | break; |
191 | ||
192 | case R_BYTE: | |
b34976b6 AM |
193 | insn = bfd_get_8 (abfd, hit_data); |
194 | unsigned_value = insn + sym_value + reloc_entry->addend; | |
3b16e843 NC |
195 | if (unsigned_value & 0xffffff00) |
196 | return bfd_reloc_overflow; | |
b34976b6 | 197 | bfd_put_8 (abfd, unsigned_value, hit_data); |
3b16e843 NC |
198 | break; |
199 | ||
200 | case R_HWORD: | |
b34976b6 AM |
201 | insn = bfd_get_16 (abfd, hit_data); |
202 | unsigned_value = insn + sym_value + reloc_entry->addend; | |
3b16e843 NC |
203 | if (unsigned_value & 0xffff0000) |
204 | return bfd_reloc_overflow; | |
b34976b6 | 205 | bfd_put_16 (abfd, insn, hit_data); |
3b16e843 NC |
206 | break; |
207 | ||
208 | case R_WORD: | |
b34976b6 AM |
209 | insn = bfd_get_32 (abfd, hit_data); |
210 | insn += sym_value + reloc_entry->addend; | |
3b16e843 NC |
211 | bfd_put_32 (abfd, insn, hit_data); |
212 | break; | |
213 | ||
214 | default: | |
215 | *error_message = _("Unrecognized reloc"); | |
216 | return bfd_reloc_dangerous; | |
217 | } | |
218 | ||
219 | return bfd_reloc_ok; | |
220 | } | |
221 | ||
222 | /* type rightshift | |
223 | size | |
224 | bitsize | |
225 | pc-relative | |
226 | bitpos | |
227 | absolute | |
228 | complain_on_overflow | |
229 | special_function | |
230 | relocation name | |
b34976b6 | 231 | partial_inplace |
3b16e843 NC |
232 | src_mask |
233 | */ | |
234 | ||
235 | /* FIXME: I'm not real sure about this table. */ | |
b34976b6 | 236 | static reloc_howto_type howto_table[] = |
3b16e843 | 237 | { |
b34976b6 | 238 | { R_ABS, 0, 3, 32, FALSE, 0, complain_overflow_bitfield, or32_reloc, "ABS", TRUE, 0xffffffff,0xffffffff, FALSE }, |
5e37cc46 NC |
239 | EMPTY_HOWTO (1), |
240 | EMPTY_HOWTO (2), | |
241 | EMPTY_HOWTO (3), | |
242 | EMPTY_HOWTO (4), | |
243 | EMPTY_HOWTO (5), | |
244 | EMPTY_HOWTO (6), | |
245 | EMPTY_HOWTO (7), | |
246 | EMPTY_HOWTO (8), | |
247 | EMPTY_HOWTO (9), | |
248 | EMPTY_HOWTO (10), | |
249 | EMPTY_HOWTO (11), | |
250 | EMPTY_HOWTO (12), | |
251 | EMPTY_HOWTO (13), | |
252 | EMPTY_HOWTO (14), | |
253 | EMPTY_HOWTO (15), | |
254 | EMPTY_HOWTO (16), | |
255 | EMPTY_HOWTO (17), | |
256 | EMPTY_HOWTO (18), | |
257 | EMPTY_HOWTO (19), | |
258 | EMPTY_HOWTO (20), | |
259 | EMPTY_HOWTO (21), | |
260 | EMPTY_HOWTO (22), | |
261 | EMPTY_HOWTO (23), | |
b34976b6 AM |
262 | { R_IREL, 0, 3, 32, TRUE, 0, complain_overflow_signed, or32_reloc, "IREL", TRUE, 0xffffffff,0xffffffff, FALSE }, |
263 | { R_IABS, 0, 3, 32, FALSE, 0, complain_overflow_bitfield, or32_reloc, "IABS", TRUE, 0xffffffff,0xffffffff, FALSE }, | |
264 | { R_ILOHALF, 0, 3, 16, TRUE, 0, complain_overflow_signed, or32_reloc, "ILOHALF", TRUE, 0x0000ffff,0x0000ffff, FALSE }, | |
265 | { R_IHIHALF, 0, 3, 16, TRUE, 16,complain_overflow_signed, or32_reloc, "IHIHALF", TRUE, 0xffff0000,0xffff0000, FALSE }, | |
266 | { R_IHCONST, 0, 3, 16, TRUE, 0, complain_overflow_signed, or32_reloc, "IHCONST", TRUE, 0xffff0000,0xffff0000, FALSE }, | |
267 | { R_BYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, or32_reloc, "BYTE", TRUE, 0x000000ff,0x000000ff, FALSE }, | |
268 | { R_HWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, or32_reloc, "HWORD", TRUE, 0x0000ffff,0x0000ffff, FALSE }, | |
269 | { R_WORD, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, or32_reloc, "WORD", TRUE, 0xffffffff,0xffffffff, FALSE }, | |
3b16e843 NC |
270 | }; |
271 | ||
272 | #define BADMAG(x) OR32BADMAG (x) | |
273 | ||
274 | #define RELOC_PROCESSING(relent, reloc, symbols, abfd, section) \ | |
275 | reloc_processing (relent, reloc, symbols, abfd, section) | |
276 | ||
277 | static void | |
2c3fc389 NC |
278 | reloc_processing (arelent *relent, |
279 | struct internal_reloc *reloc, | |
280 | asymbol **symbols, | |
281 | bfd *abfd, | |
282 | asection *section) | |
3b16e843 NC |
283 | { |
284 | static bfd_vma ihihalf_vaddr = (bfd_vma) -1; | |
285 | ||
b34976b6 | 286 | relent->address = reloc->r_vaddr; |
3b16e843 NC |
287 | relent->howto = howto_table + reloc->r_type; |
288 | ||
b34976b6 AM |
289 | if (reloc->r_type == R_IHCONST) |
290 | { | |
3b16e843 NC |
291 | /* The address of an R_IHCONST should always be the address of |
292 | the immediately preceding R_IHIHALF. relocs generated by gas | |
293 | are correct, but relocs generated by High C are different (I | |
294 | can't figure out what the address means for High C). We can | |
295 | handle both gas and High C by ignoring the address here, and | |
296 | simply reusing the address saved for R_IHIHALF. */ | |
297 | if (ihihalf_vaddr == (bfd_vma) -1) | |
298 | abort (); | |
299 | ||
300 | relent->address = ihihalf_vaddr; | |
301 | ihihalf_vaddr = (bfd_vma) -1; | |
302 | relent->addend = reloc->r_symndx; | |
303 | relent->sym_ptr_ptr= bfd_abs_section_ptr->symbol_ptr_ptr; | |
304 | } | |
305 | else | |
306 | { | |
3b16e843 | 307 | relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx]; |
3b16e843 NC |
308 | relent->addend = 0; |
309 | relent->address-= section->vma; | |
310 | ||
311 | if (reloc->r_type == R_IHIHALF) | |
312 | ihihalf_vaddr = relent->address; | |
313 | else if (ihihalf_vaddr != (bfd_vma) -1) | |
314 | abort (); | |
315 | } | |
316 | } | |
317 | ||
318 | /* The reloc processing routine for the optimized COFF linker. */ | |
319 | ||
b34976b6 | 320 | static bfd_boolean |
2c3fc389 NC |
321 | coff_or32_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, |
322 | struct bfd_link_info *info, | |
323 | bfd *input_bfd, | |
324 | asection *input_section, | |
325 | bfd_byte *contents, | |
326 | struct internal_reloc *relocs, | |
327 | struct internal_syment *syms, | |
328 | asection **sections) | |
3b16e843 NC |
329 | { |
330 | struct internal_reloc *rel; | |
331 | struct internal_reloc *relend; | |
b34976b6 | 332 | bfd_boolean hihalf; |
3b16e843 NC |
333 | bfd_vma hihalf_val; |
334 | ||
1049f94e | 335 | /* If we are performing a relocatable link, we don't need to do a |
3b16e843 NC |
336 | thing. The caller will take care of adjusting the reloc |
337 | addresses and symbol indices. */ | |
1049f94e | 338 | if (info->relocatable) |
b34976b6 | 339 | return TRUE; |
3b16e843 | 340 | |
b34976b6 | 341 | hihalf = FALSE; |
3b16e843 NC |
342 | hihalf_val = 0; |
343 | ||
344 | rel = relocs; | |
345 | relend = rel + input_section->reloc_count; | |
346 | ||
347 | for (; rel < relend; rel++) | |
348 | { | |
349 | long symndx; | |
350 | bfd_byte *loc; | |
351 | struct coff_link_hash_entry *h; | |
352 | struct internal_syment *sym; | |
353 | asection *sec; | |
354 | bfd_vma val; | |
b34976b6 | 355 | bfd_boolean overflow; |
3b16e843 NC |
356 | unsigned long insn; |
357 | long signed_value; | |
358 | unsigned long unsigned_value; | |
359 | bfd_reloc_status_type rstat; | |
360 | ||
361 | symndx = rel->r_symndx; | |
362 | loc = contents + rel->r_vaddr - input_section->vma; | |
363 | ||
364 | if (symndx == -1 || rel->r_type == R_IHCONST) | |
365 | h = NULL; | |
366 | else | |
367 | h = obj_coff_sym_hashes (input_bfd)[symndx]; | |
368 | ||
369 | sym = NULL; | |
370 | sec = NULL; | |
371 | val = 0; | |
372 | ||
373 | /* An R_IHCONST reloc does not have a symbol. Instead, the | |
374 | symbol index is an addend. R_IHCONST is always used in | |
375 | conjunction with R_IHHALF. */ | |
376 | if (rel->r_type != R_IHCONST) | |
377 | { | |
378 | if (h == NULL) | |
379 | { | |
380 | if (symndx == -1) | |
381 | sec = bfd_abs_section_ptr; | |
382 | else | |
383 | { | |
384 | sym = syms + symndx; | |
385 | sec = sections[symndx]; | |
386 | val = (sec->output_section->vma | |
387 | + sec->output_offset | |
388 | + sym->n_value | |
389 | - sec->vma); | |
390 | } | |
391 | } | |
392 | else | |
393 | { | |
394 | if (h->root.type == bfd_link_hash_defined | |
395 | || h->root.type == bfd_link_hash_defweak) | |
396 | { | |
397 | sec = h->root.u.def.section; | |
398 | val = (h->root.u.def.value | |
399 | + sec->output_section->vma | |
400 | + sec->output_offset); | |
401 | } | |
402 | else | |
403 | { | |
404 | if (! ((*info->callbacks->undefined_symbol) | |
405 | (info, h->root.root.string, input_bfd, input_section, | |
b34976b6 AM |
406 | rel->r_vaddr - input_section->vma, TRUE))) |
407 | return FALSE; | |
3b16e843 NC |
408 | } |
409 | } | |
410 | ||
411 | if (hihalf) | |
412 | { | |
413 | if (! ((*info->callbacks->reloc_dangerous) | |
414 | (info, "missing IHCONST reloc", input_bfd, | |
415 | input_section, rel->r_vaddr - input_section->vma))) | |
b34976b6 AM |
416 | return FALSE; |
417 | hihalf = FALSE; | |
3b16e843 NC |
418 | } |
419 | } | |
420 | ||
b34976b6 | 421 | overflow = FALSE; |
3b16e843 NC |
422 | |
423 | switch (rel->r_type) | |
424 | { | |
425 | default: | |
426 | bfd_set_error (bfd_error_bad_value); | |
b34976b6 | 427 | return FALSE; |
3b16e843 NC |
428 | |
429 | case R_IREL: | |
430 | insn = bfd_get_32 (input_bfd, loc); | |
431 | ||
432 | /* Extract the addend. */ | |
433 | signed_value = EXTRACT_JUMPTARG (insn); | |
434 | signed_value = SIGN_EXTEND_JUMPTARG (signed_value); | |
435 | signed_value <<= 2; | |
436 | ||
437 | /* Determine the destination of the jump. */ | |
438 | signed_value += val; | |
439 | ||
0e71e495 BE |
440 | /* Make the destination PC relative. */ |
441 | signed_value -= (input_section->output_section->vma | |
442 | + input_section->output_offset | |
443 | + (rel->r_vaddr - input_section->vma)); | |
444 | if (signed_value > 0x7ffffff || signed_value < - 0x8000000) | |
445 | { | |
446 | overflow = TRUE; | |
447 | signed_value = 0; | |
448 | } | |
3b16e843 NC |
449 | |
450 | /* Put the adjusted value back into the instruction. */ | |
451 | signed_value >>= 2; | |
452 | insn = INSERT_JUMPTARG(insn, signed_value); | |
453 | ||
454 | bfd_put_32 (input_bfd, (bfd_vma) insn, loc); | |
455 | break; | |
456 | ||
457 | case R_ILOHALF: | |
458 | insn = bfd_get_32 (input_bfd, loc); | |
459 | unsigned_value = EXTRACT_HWORD (insn); | |
460 | unsigned_value += val; | |
461 | insn = INSERT_HWORD (insn, unsigned_value); | |
462 | bfd_put_32 (input_bfd, insn, loc); | |
463 | break; | |
464 | ||
465 | case R_IHIHALF: | |
466 | /* Save the value for the R_IHCONST reloc. */ | |
b34976b6 | 467 | hihalf = TRUE; |
3b16e843 NC |
468 | hihalf_val = val; |
469 | break; | |
470 | ||
471 | case R_IHCONST: | |
472 | if (! hihalf) | |
473 | { | |
474 | if (! ((*info->callbacks->reloc_dangerous) | |
475 | (info, "missing IHIHALF reloc", input_bfd, | |
476 | input_section, rel->r_vaddr - input_section->vma))) | |
b34976b6 | 477 | return FALSE; |
3b16e843 NC |
478 | hihalf_val = 0; |
479 | } | |
480 | ||
481 | insn = bfd_get_32 (input_bfd, loc); | |
482 | unsigned_value = rel->r_symndx + hihalf_val; | |
483 | unsigned_value >>= 16; | |
484 | insn = INSERT_HWORD (insn, unsigned_value); | |
485 | bfd_put_32 (input_bfd, (bfd_vma) insn, loc); | |
486 | ||
b34976b6 | 487 | hihalf = FALSE; |
3b16e843 NC |
488 | break; |
489 | ||
490 | case R_BYTE: | |
491 | case R_HWORD: | |
492 | case R_WORD: | |
493 | rstat = _bfd_relocate_contents (howto_table + rel->r_type, | |
494 | input_bfd, val, loc); | |
495 | if (rstat == bfd_reloc_overflow) | |
b34976b6 | 496 | overflow = TRUE; |
3b16e843 NC |
497 | else if (rstat != bfd_reloc_ok) |
498 | abort (); | |
499 | break; | |
500 | } | |
501 | ||
502 | if (overflow) | |
503 | { | |
504 | const char *name; | |
505 | char buf[SYMNMLEN + 1]; | |
506 | ||
507 | if (symndx == -1) | |
508 | name = "*ABS*"; | |
509 | else if (h != NULL) | |
dfeffb9f | 510 | name = NULL; |
3b16e843 NC |
511 | else if (sym == NULL) |
512 | name = "*unknown*"; | |
513 | else if (sym->_n._n_n._n_zeroes == 0 | |
514 | && sym->_n._n_n._n_offset != 0) | |
515 | name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset; | |
516 | else | |
517 | { | |
518 | strncpy (buf, sym->_n._n_name, SYMNMLEN); | |
519 | buf[SYMNMLEN] = '\0'; | |
520 | name = buf; | |
521 | } | |
522 | ||
523 | if (! ((*info->callbacks->reloc_overflow) | |
dfeffb9f L |
524 | (info, (h ? &h->root : NULL), name, |
525 | howto_table[rel->r_type].name, (bfd_vma) 0, input_bfd, | |
526 | input_section, rel->r_vaddr - input_section->vma))) | |
b34976b6 | 527 | return FALSE; |
3b16e843 | 528 | } |
b34976b6 | 529 | } |
3b16e843 | 530 | |
b34976b6 | 531 | return TRUE; |
3b16e843 NC |
532 | } |
533 | ||
534 | #define coff_relocate_section coff_or32_relocate_section | |
535 | ||
536 | /* We don't want to change the symndx of a R_IHCONST reloc, since it | |
537 | is actually an addend, not a symbol index at all. */ | |
538 | ||
b34976b6 | 539 | static bfd_boolean |
2c3fc389 NC |
540 | coff_or32_adjust_symndx (bfd *obfd ATTRIBUTE_UNUSED, |
541 | struct bfd_link_info *info ATTRIBUTE_UNUSED, | |
542 | bfd *ibfd ATTRIBUTE_UNUSED, | |
543 | asection *sec ATTRIBUTE_UNUSED, | |
544 | struct internal_reloc *irel, | |
545 | bfd_boolean *adjustedp) | |
3b16e843 NC |
546 | { |
547 | if (irel->r_type == R_IHCONST) | |
b34976b6 | 548 | *adjustedp = TRUE; |
3b16e843 | 549 | else |
b34976b6 AM |
550 | *adjustedp = FALSE; |
551 | return TRUE; | |
3b16e843 NC |
552 | } |
553 | ||
554 | #define coff_adjust_symndx coff_or32_adjust_symndx | |
555 | ||
2b5c217d NC |
556 | #ifndef bfd_pe_print_pdata |
557 | #define bfd_pe_print_pdata NULL | |
558 | #endif | |
559 | ||
3b16e843 NC |
560 | #include "coffcode.h" |
561 | ||
562 | const bfd_target or32coff_big_vec = | |
563 | { | |
564 | "coff-or32-big", /* Name. */ | |
565 | bfd_target_coff_flavour, | |
566 | BFD_ENDIAN_BIG, /* Data byte order is big. */ | |
567 | BFD_ENDIAN_BIG, /* Header byte order is big. */ | |
568 | ||
569 | (HAS_RELOC | EXEC_P | /* Object flags. */ | |
570 | HAS_LINENO | HAS_DEBUG | | |
571 | HAS_SYMS | HAS_LOCALS | WP_TEXT), | |
572 | ||
573 | (SEC_HAS_CONTENTS | SEC_ALLOC | /* Section flags. */ | |
b34976b6 | 574 | SEC_LOAD | SEC_RELOC | |
3b16e843 NC |
575 | SEC_READONLY ), |
576 | '_', /* Leading underscore. */ | |
577 | '/', /* ar_pad_char. */ | |
578 | 15, /* ar_max_namelen. */ | |
0aabe54e | 579 | 0, /* match priority. */ |
3b16e843 NC |
580 | |
581 | /* Data. */ | |
582 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, | |
583 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
584 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, | |
585 | ||
586 | /* Headers. */ | |
587 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, | |
588 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
589 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, | |
590 | ||
b34976b6 | 591 | { |
3b16e843 NC |
592 | _bfd_dummy_target, |
593 | coff_object_p, | |
594 | bfd_generic_archive_p, | |
595 | _bfd_dummy_target | |
596 | }, | |
597 | { | |
598 | bfd_false, | |
599 | coff_mkobject, | |
600 | _bfd_generic_mkarchive, | |
601 | bfd_false | |
602 | }, | |
603 | { | |
604 | bfd_false, | |
605 | coff_write_object_contents, | |
606 | _bfd_write_archive_contents, | |
607 | bfd_false | |
608 | }, | |
609 | ||
610 | BFD_JUMP_TABLE_GENERIC (coff), | |
611 | BFD_JUMP_TABLE_COPY (coff), | |
612 | BFD_JUMP_TABLE_CORE (_bfd_nocore), | |
613 | BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), | |
614 | BFD_JUMP_TABLE_SYMBOLS (coff), | |
615 | BFD_JUMP_TABLE_RELOCS (coff), | |
616 | BFD_JUMP_TABLE_WRITE (coff), | |
617 | BFD_JUMP_TABLE_LINK (coff), | |
618 | BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), | |
b34976b6 | 619 | |
3b16e843 NC |
620 | /* Alternative_target. */ |
621 | #ifdef TARGET_LITTLE_SYM | |
622 | & TARGET_LITTLE_SYM, | |
623 | #else | |
624 | NULL, | |
625 | #endif | |
626 | ||
627 | COFF_SWAP_TABLE | |
628 | }; |