Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Side by Side Diff: bfd/coff-i960.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « bfd/coff-i386.c ('k') | bfd/coff-ia64.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* BFD back-end for Intel 960 COFF files. 1 /* BFD back-end for Intel 960 COFF files.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1997, 1999, 2000, 2001,
3 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2011 3 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2011, 2012
4 Free Software Foundation, Inc. 4 Free Software Foundation, Inc.
5 Written by Cygnus Support. 5 Written by Cygnus Support.
6 6
7 This file is part of BFD, the Binary File Descriptor library. 7 This file is part of BFD, the Binary File Descriptor library.
8 8
9 This program is free software; you can redistribute it and/or modify 9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or 11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version. 12 (at your option) any later version.
13 13
(...skipping 15 matching lines...) Expand all
29 #include "libbfd.h" 29 #include "libbfd.h"
30 #include "coff/i960.h" 30 #include "coff/i960.h"
31 #include "coff/internal.h" 31 #include "coff/internal.h"
32 32
33 #ifndef bfd_pe_print_pdata 33 #ifndef bfd_pe_print_pdata
34 #define bfd_pe_print_pdata NULL 34 #define bfd_pe_print_pdata NULL
35 #endif 35 #endif
36 36
37 #include "libcoff.h" /* To allow easier abstraction-breaking. */ 37 #include "libcoff.h" /* To allow easier abstraction-breaking. */
38 38
39 static bfd_boolean coff_i960_is_local_label_name
40 PARAMS ((bfd *, const char *));
41 static bfd_reloc_status_type optcall_callback
42 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
43 static bfd_reloc_status_type coff_i960_relocate
44 PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **));
45 static reloc_howto_type *coff_i960_reloc_type_lookup
46 PARAMS ((bfd *, bfd_reloc_code_real_type));
47 static bfd_boolean coff_i960_start_final_link
48 PARAMS ((bfd *, struct bfd_link_info *));
49 static bfd_boolean coff_i960_relocate_section
50 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
51 struct internal_reloc *, struct internal_syment *, asection **));
52 static bfd_boolean coff_i960_adjust_symndx
53 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
54 struct internal_reloc *, bfd_boolean *));
55 39
56 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3) 40 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (3)
57 #define COFF_ALIGN_IN_SECTION_HEADER 1 41 #define COFF_ALIGN_IN_SECTION_HEADER 1
58 42
59 #define GET_SCNHDR_ALIGN H_GET_32 43 #define GET_SCNHDR_ALIGN H_GET_32
60 #define PUT_SCNHDR_ALIGN H_PUT_32 44 #define PUT_SCNHDR_ALIGN H_PUT_32
61 45
62 /* The i960 does not support an MMU, so COFF_PAGE_SIZE can be 46 /* The i960 does not support an MMU, so COFF_PAGE_SIZE can be
63 arbitrarily small. */ 47 arbitrarily small. */
64 #define COFF_PAGE_SIZE 1 48 #define COFF_PAGE_SIZE 1
65 49
66 #define COFF_LONG_FILENAMES 50 #define COFF_LONG_FILENAMES
67 51
68 /* This set of local label names is taken from gas. */ 52 /* This set of local label names is taken from gas. */
69 53
70 static bfd_boolean 54 static bfd_boolean
71 coff_i960_is_local_label_name (abfd, name) 55 coff_i960_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED, const char *name)
72 bfd *abfd ATTRIBUTE_UNUSED;
73 const char *name;
74 { 56 {
75 return (name[0] == 'L' 57 return (name[0] == 'L'
76 || (name[0] == '.' 58 || (name[0] == '.'
77 && (name[1] == 'C' 59 && (name[1] == 'C'
78 || name[1] == 'I' 60 || name[1] == 'I'
79 || name[1] == '.'))); 61 || name[1] == '.')));
80 } 62 }
81 63
82 /* This is just like the usual CALC_ADDEND, but it includes the 64 /* This is just like the usual CALC_ADDEND, but it includes the
83 section VMA for PC relative relocs. */ 65 section VMA for PC relative relocs. */
(...skipping 17 matching lines...) Expand all
101 if (ptr && (reloc.r_type == 25 || reloc.r_type == 27)) \ 83 if (ptr && (reloc.r_type == 25 || reloc.r_type == 27)) \
102 cache_ptr->addend += asect->vma; \ 84 cache_ptr->addend += asect->vma; \
103 } 85 }
104 #endif 86 #endif
105 87
106 #define CALLS 0x66003800 /* Template for 'calls' instruction */ 88 #define CALLS 0x66003800 /* Template for 'calls' instruction */
107 #define BAL 0x0b000000 /* Template for 'bal' instruction */ 89 #define BAL 0x0b000000 /* Template for 'bal' instruction */
108 #define BAL_MASK 0x00ffffff 90 #define BAL_MASK 0x00ffffff
109 91
110 static bfd_reloc_status_type 92 static bfd_reloc_status_type
111 optcall_callback (abfd, reloc_entry, symbol_in, data, 93 optcall_callback (bfd *abfd,
112 » » input_section, ignore_bfd, error_message) 94 » » arelent *reloc_entry,
113 bfd *abfd; 95 » » asymbol *symbol_in,
114 arelent *reloc_entry; 96 » » void * data,
115 asymbol *symbol_in; 97 » » asection *input_section,
116 PTR data; 98 » » bfd *ignore_bfd ATTRIBUTE_UNUSED,
117 asection *input_section; 99 » » char **error_message)
118 bfd *ignore_bfd ATTRIBUTE_UNUSED;
119 char **error_message;
120 { 100 {
121 /* This item has already been relocated correctly, but we may be 101 /* This item has already been relocated correctly, but we may be
122 * able to patch in yet better code - done by digging out the 102 * able to patch in yet better code - done by digging out the
123 * correct info on this symbol */ 103 * correct info on this symbol */
124 bfd_reloc_status_type result; 104 bfd_reloc_status_type result;
125 coff_symbol_type *cs = coffsymbol(symbol_in); 105 coff_symbol_type *cs = coffsymbol(symbol_in);
126 106
127 /* Don't do anything with symbols which aren't tied up yet, 107 /* Don't do anything with symbols which aren't tied up yet,
128 except move the reloc. */ 108 except move the reloc. */
129 if (bfd_is_und_section (cs->symbol.section)) { 109 if (bfd_is_und_section (cs->symbol.section)) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 file. 171 file.
192 172
193 Note that this function is only called if we are not using the COFF 173 Note that this function is only called if we are not using the COFF
194 specific backend linker. It only does something when doing a 174 specific backend linker. It only does something when doing a
195 relocatable link, which will almost certainly fail when not 175 relocatable link, which will almost certainly fail when not
196 generating COFF i960 output, so this function is actually no longer 176 generating COFF i960 output, so this function is actually no longer
197 useful. It was used before this target was converted to use the 177 useful. It was used before this target was converted to use the
198 COFF specific backend linker. */ 178 COFF specific backend linker. */
199 179
200 static bfd_reloc_status_type 180 static bfd_reloc_status_type
201 coff_i960_relocate (abfd, reloc_entry, symbol, data, input_section, 181 coff_i960_relocate (bfd *abfd,
202 » » output_bfd, error_message) 182 » » arelent *reloc_entry,
203 bfd *abfd; 183 » » asymbol *symbol,
204 arelent *reloc_entry; 184 » » void * data ATTRIBUTE_UNUSED,
205 asymbol *symbol; 185 » » asection *input_section ATTRIBUTE_UNUSED,
206 PTR data ATTRIBUTE_UNUSED; 186 » » bfd *output_bfd,
207 asection *input_section ATTRIBUTE_UNUSED; 187 » » char **error_message ATTRIBUTE_UNUSED)
208 bfd *output_bfd;
209 char **error_message ATTRIBUTE_UNUSED;
210 { 188 {
211 asection *osec; 189 asection *osec;
212 190
213 if (output_bfd == NULL) 191 if (output_bfd == NULL)
214 { 192 {
215 /* Not generating relocatable output file. */ 193 /* Not generating relocatable output file. */
216 return bfd_reloc_continue; 194 return bfd_reloc_continue;
217 } 195 }
218 196
219 if (bfd_is_und_section (bfd_get_section (symbol))) 197 if (bfd_is_und_section (bfd_get_section (symbol)))
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 } 232 }
255 233
256 if (syms >= sym_end) 234 if (syms >= sym_end)
257 abort (); 235 abort ();
258 236
259 reloc_entry->sym_ptr_ptr = syms; 237 reloc_entry->sym_ptr_ptr = syms;
260 238
261 if (coff_section_data (output_bfd, osec) == NULL) 239 if (coff_section_data (output_bfd, osec) == NULL)
262 { 240 {
263 bfd_size_type amt = sizeof (struct coff_section_tdata); 241 bfd_size_type amt = sizeof (struct coff_section_tdata);
264 » osec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt); 242 » osec->used_by_bfd = bfd_zalloc (abfd, amt);
265 if (osec->used_by_bfd == NULL) 243 if (osec->used_by_bfd == NULL)
266 return bfd_reloc_overflow; 244 return bfd_reloc_overflow;
267 } 245 }
268 coff_section_data (output_bfd, osec)->tdata = (PTR) syms; 246 coff_section_data (output_bfd, osec)->tdata = syms;
269 } 247 }
270 248
271 /* Let bfd_perform_relocation do its thing, which will include 249 /* Let bfd_perform_relocation do its thing, which will include
272 stuffing the symbol addend into the object file. */ 250 stuffing the symbol addend into the object file. */
273 return bfd_reloc_continue; 251 return bfd_reloc_continue;
274 } 252 }
275 253
276 static reloc_howto_type howto_rellong = 254 static reloc_howto_type howto_rellong =
277 HOWTO ((unsigned int) R_RELLONG, 0, 2, 32,FALSE, 0, 255 HOWTO ((unsigned int) R_RELLONG, 0, 2, 32,FALSE, 0,
278 complain_overflow_bitfield, coff_i960_relocate,"rellong", TRUE, 256 complain_overflow_bitfield, coff_i960_relocate,"rellong", TRUE,
279 0xffffffff, 0xffffffff, 0); 257 0xffffffff, 0xffffffff, 0);
280 static reloc_howto_type howto_iprmed = 258 static reloc_howto_type howto_iprmed =
281 HOWTO (R_IPRMED, 0, 2, 24,TRUE,0, complain_overflow_signed, 259 HOWTO (R_IPRMED, 0, 2, 24,TRUE,0, complain_overflow_signed,
282 coff_i960_relocate, "iprmed ", TRUE, 0x00ffffff, 0x00ffffff, 0); 260 coff_i960_relocate, "iprmed ", TRUE, 0x00ffffff, 0x00ffffff, 0);
283 static reloc_howto_type howto_optcall = 261 static reloc_howto_type howto_optcall =
284 HOWTO (R_OPTCALL, 0,2,24,TRUE,0, complain_overflow_signed, 262 HOWTO (R_OPTCALL, 0,2,24,TRUE,0, complain_overflow_signed,
285 optcall_callback, "optcall", TRUE, 0x00ffffff, 0x00ffffff, 0); 263 optcall_callback, "optcall", TRUE, 0x00ffffff, 0x00ffffff, 0);
286 264
287 static reloc_howto_type * 265 static reloc_howto_type *
288 coff_i960_reloc_type_lookup (abfd, code) 266 coff_i960_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
289 bfd *abfd ATTRIBUTE_UNUSED; 267 » » » bfd_reloc_code_real_type code)
290 bfd_reloc_code_real_type code;
291 { 268 {
292 switch (code) 269 switch (code)
293 { 270 {
294 default: 271 default:
295 return 0; 272 return 0;
296 case BFD_RELOC_I960_CALLJ: 273 case BFD_RELOC_I960_CALLJ:
297 return &howto_optcall; 274 return &howto_optcall;
298 case BFD_RELOC_32: 275 case BFD_RELOC_32:
299 case BFD_RELOC_CTOR: 276 case BFD_RELOC_CTOR:
300 return &howto_rellong; 277 return &howto_rellong;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 /* i960 COFF is used by VxWorks 5.1. However, VxWorks 5.1 does not 311 /* i960 COFF is used by VxWorks 5.1. However, VxWorks 5.1 does not
335 appear to correctly handle a reloc against a symbol defined in the 312 appear to correctly handle a reloc against a symbol defined in the
336 same object file. It appears to simply discard such relocs, rather 313 same object file. It appears to simply discard such relocs, rather
337 than adding their values into the object file. We handle this by 314 than adding their values into the object file. We handle this by
338 converting all relocs against global symbols into relocs against 315 converting all relocs against global symbols into relocs against
339 internal symbols at the start of the section. This routine is 316 internal symbols at the start of the section. This routine is
340 called at the start of the linking process, and it creates the 317 called at the start of the linking process, and it creates the
341 necessary symbols. */ 318 necessary symbols. */
342 319
343 static bfd_boolean 320 static bfd_boolean
344 coff_i960_start_final_link (abfd, info) 321 coff_i960_start_final_link (bfd *abfd, struct bfd_link_info *info)
345 bfd *abfd;
346 struct bfd_link_info *info;
347 { 322 {
348 bfd_size_type symesz = bfd_coff_symesz (abfd); 323 bfd_size_type symesz = bfd_coff_symesz (abfd);
349 asection *o; 324 asection *o;
350 bfd_byte *esym; 325 bfd_byte *esym;
351 326
352 if (! info->relocatable) 327 if (! info->relocatable)
353 return TRUE; 328 return TRUE;
354 329
355 esym = (bfd_byte *) bfd_malloc (symesz); 330 esym = (bfd_byte *) bfd_malloc (symesz);
356 if (esym == NULL) 331 if (esym == NULL)
357 return FALSE; 332 return FALSE;
358 333
359 if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0) 334 if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0)
360 return FALSE; 335 return FALSE;
361 336
362 for (o = abfd->sections; o != NULL; o = o->next) 337 for (o = abfd->sections; o != NULL; o = o->next)
363 { 338 {
364 struct internal_syment isym; 339 struct internal_syment isym;
365 340
366 strncpy (isym._n._n_name, o->name, SYMNMLEN); 341 strncpy (isym._n._n_name, o->name, SYMNMLEN);
367 isym.n_value = 0; 342 isym.n_value = 0;
368 isym.n_scnum = o->target_index; 343 isym.n_scnum = o->target_index;
369 isym.n_type = T_NULL; 344 isym.n_type = T_NULL;
370 isym.n_sclass = C_STAT; 345 isym.n_sclass = C_STAT;
371 isym.n_numaux = 0; 346 isym.n_numaux = 0;
372 347
373 bfd_coff_swap_sym_out (abfd, (PTR) &isym, (PTR) esym); 348 bfd_coff_swap_sym_out (abfd, &isym, esym);
374 349
375 if (bfd_bwrite (esym, symesz, abfd) != symesz) 350 if (bfd_bwrite (esym, symesz, abfd) != symesz)
376 { 351 {
377 free (esym); 352 free (esym);
378 return FALSE; 353 return FALSE;
379 } 354 }
380 355
381 obj_raw_syment_count (abfd) += 1; 356 obj_raw_syment_count (abfd) += 1;
382 } 357 }
383 358
384 free (esym); 359 free (esym);
385 360
386 return TRUE; 361 return TRUE;
387 } 362 }
388 363
389 /* The reloc processing routine for the optimized COFF linker. */ 364 /* The reloc processing routine for the optimized COFF linker. */
390 365
391 static bfd_boolean 366 static bfd_boolean
392 coff_i960_relocate_section (output_bfd, info, input_bfd, input_section, 367 coff_i960_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
393 » » » contents, relocs, syms, sections) 368 » » » struct bfd_link_info *info,
394 bfd *output_bfd ATTRIBUTE_UNUSED; 369 » » » bfd *input_bfd,
395 struct bfd_link_info *info; 370 » » » asection *input_section,
396 bfd *input_bfd; 371 » » » bfd_byte *contents,
397 asection *input_section; 372 » » » struct internal_reloc *relocs,
398 bfd_byte *contents; 373 » » » struct internal_syment *syms,
399 struct internal_reloc *relocs; 374 » » » asection **sections)
400 struct internal_syment *syms;
401 asection **sections;
402 { 375 {
403 struct internal_reloc *rel; 376 struct internal_reloc *rel;
404 struct internal_reloc *relend; 377 struct internal_reloc *relend;
405 378
406 rel = relocs; 379 rel = relocs;
407 relend = rel + input_section->reloc_count; 380 relend = rel + input_section->reloc_count;
408 for (; rel < relend; rel++) 381 for (; rel < relend; rel++)
409 { 382 {
410 long symndx; 383 long symndx;
411 struct coff_link_hash_entry *h; 384 struct coff_link_hash_entry *h;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 olf = h->aux[1].x_bal.x_balntry; 496 olf = h->aux[1].x_bal.x_balntry;
524 } 497 }
525 else 498 else
526 { 499 {
527 bfd_byte *esyms; 500 bfd_byte *esyms;
528 union internal_auxent aux; 501 union internal_auxent aux;
529 502
530 BFD_ASSERT (sym->n_numaux == 2); 503 BFD_ASSERT (sym->n_numaux == 2);
531 esyms = (bfd_byte *) obj_coff_external_syms (input_bfd); 504 esyms = (bfd_byte *) obj_coff_external_syms (input_bfd);
532 esyms += (symndx + 2) * bfd_coff_symesz (input_bfd); 505 esyms += (symndx + 2) * bfd_coff_symesz (input_bfd);
533 » » bfd_coff_swap_aux_in (input_bfd, (PTR) esyms, sym->n_type, 506 » » bfd_coff_swap_aux_in (input_bfd, esyms, sym->n_type,
534 sym->n_sclass, 1, sym->n_numaux, 507 sym->n_sclass, 1, sym->n_numaux,
535 » » » » » (PTR) &aux); 508 » » » » » &aux);
536 olf = aux.x_bal.x_balntry; 509 olf = aux.x_bal.x_balntry;
537 } 510 }
538 511
539 word = bfd_get_32 (input_bfd, 512 word = bfd_get_32 (input_bfd,
540 (contents 513 (contents
541 + (rel->r_vaddr - input_section->vma))); 514 + (rel->r_vaddr - input_section->vma)));
542 word = ((word + olf - val) & BAL_MASK) | BAL; 515 word = ((word + olf - val) & BAL_MASK) | BAL;
543 bfd_put_32 (input_bfd, 516 bfd_put_32 (input_bfd,
544 (bfd_vma) word, 517 (bfd_vma) word,
545 contents + (rel->r_vaddr - input_section->vma)); 518 contents + (rel->r_vaddr - input_section->vma));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 } 567 }
595 568
596 return TRUE; 569 return TRUE;
597 } 570 }
598 571
599 /* Adjust the symbol index of any reloc against a global symbol to 572 /* Adjust the symbol index of any reloc against a global symbol to
600 instead be a reloc against the internal symbol we created specially 573 instead be a reloc against the internal symbol we created specially
601 for the section. */ 574 for the section. */
602 575
603 static bfd_boolean 576 static bfd_boolean
604 coff_i960_adjust_symndx (obfd, info, ibfd, sec, irel, adjustedp) 577 coff_i960_adjust_symndx (bfd *obfd ATTRIBUTE_UNUSED,
605 bfd *obfd ATTRIBUTE_UNUSED; 578 » » » struct bfd_link_info *info ATTRIBUTE_UNUSED,
606 struct bfd_link_info *info ATTRIBUTE_UNUSED; 579 » » » bfd *ibfd,
607 bfd *ibfd; 580 » » » asection *sec ATTRIBUTE_UNUSED,
608 asection *sec ATTRIBUTE_UNUSED; 581 » » » struct internal_reloc *irel,
609 struct internal_reloc *irel; 582 » » » bfd_boolean *adjustedp)
610 bfd_boolean *adjustedp;
611 { 583 {
612 struct coff_link_hash_entry *h; 584 struct coff_link_hash_entry *h;
613 585
614 *adjustedp = FALSE; 586 *adjustedp = FALSE;
615 587
616 h = obj_coff_sym_hashes (ibfd)[irel->r_symndx]; 588 h = obj_coff_sym_hashes (ibfd)[irel->r_symndx];
617 if (h == NULL 589 if (h == NULL
618 || (h->root.type != bfd_link_hash_defined 590 || (h->root.type != bfd_link_hash_defined
619 && h->root.type != bfd_link_hash_defweak)) 591 && h->root.type != bfd_link_hash_defweak))
620 return TRUE; 592 return TRUE;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 BFD_JUMP_TABLE_SYMBOLS (coff), 652 BFD_JUMP_TABLE_SYMBOLS (coff),
681 BFD_JUMP_TABLE_RELOCS (coff), 653 BFD_JUMP_TABLE_RELOCS (coff),
682 BFD_JUMP_TABLE_WRITE (coff), 654 BFD_JUMP_TABLE_WRITE (coff),
683 BFD_JUMP_TABLE_LINK (coff), 655 BFD_JUMP_TABLE_LINK (coff),
684 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), 656 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
685 657
686 & icoff_little_vec, 658 & icoff_little_vec,
687 659
688 COFF_SWAP_TABLE 660 COFF_SWAP_TABLE
689 }; 661 };
OLDNEW
« no previous file with comments | « bfd/coff-i386.c ('k') | bfd/coff-ia64.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698