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

Side by Side Diff: bfd/coff-i386.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-h8500.c ('k') | bfd/coff-i960.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 386 COFF files. 1 /* BFD back-end for Intel 386 COFF files.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 3 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 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 22 matching lines...) Expand all
36 #ifdef COFF_GO32_EXE 36 #ifdef COFF_GO32_EXE
37 #include "coff/go32exe.h" 37 #include "coff/go32exe.h"
38 #endif 38 #endif
39 39
40 #ifndef bfd_pe_print_pdata 40 #ifndef bfd_pe_print_pdata
41 #define bfd_pe_print_pdata NULL 41 #define bfd_pe_print_pdata NULL
42 #endif 42 #endif
43 43
44 #include "libcoff.h" 44 #include "libcoff.h"
45 45
46 static bfd_reloc_status_type coff_i386_reloc
47 (bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **);
48 static reloc_howto_type *coff_i386_rtype_to_howto 46 static reloc_howto_type *coff_i386_rtype_to_howto
49 (bfd *, asection *, struct internal_reloc *, 47 (bfd *, asection *, struct internal_reloc *,
50 struct coff_link_hash_entry *, struct internal_syment *, 48 struct coff_link_hash_entry *, struct internal_syment *,
51 bfd_vma *); 49 bfd_vma *);
52 static reloc_howto_type *coff_i386_reloc_type_lookup 50 static reloc_howto_type *coff_i386_reloc_type_lookup
53 (bfd *, bfd_reloc_code_real_type); 51 (bfd *, bfd_reloc_code_real_type);
54 52
55 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2) 53 #define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2)
56 /* The page size is a guess based on ELF. */ 54 /* The page size is a guess based on ELF. */
57 55
58 #define COFF_PAGE_SIZE 0x1000 56 #define COFF_PAGE_SIZE 0x1000
59 57
60 /* For some reason when using i386 COFF the value stored in the .text 58 /* For some reason when using i386 COFF the value stored in the .text
61 section for a reference to a common symbol is the value itself plus 59 section for a reference to a common symbol is the value itself plus
62 any desired offset. Ian Taylor, Cygnus Support. */ 60 any desired offset. Ian Taylor, Cygnus Support. */
63 61
64 /* If we are producing relocatable output, we need to do some 62 /* If we are producing relocatable output, we need to do some
65 adjustments to the object file that are not done by the 63 adjustments to the object file that are not done by the
66 bfd_perform_relocation function. This function is called by every 64 bfd_perform_relocation function. This function is called by every
67 reloc type to make any required adjustments. */ 65 reloc type to make any required adjustments. */
68 66
69 static bfd_reloc_status_type 67 static bfd_reloc_status_type
70 coff_i386_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, 68 coff_i386_reloc (bfd *abfd,
71 » » error_message) 69 » » arelent *reloc_entry,
72 bfd *abfd; 70 » » asymbol *symbol,
73 arelent *reloc_entry; 71 » » void * data,
74 asymbol *symbol; 72 » » asection *input_section ATTRIBUTE_UNUSED,
75 PTR data; 73 » » bfd *output_bfd,
76 asection *input_section ATTRIBUTE_UNUSED; 74 » » char **error_message ATTRIBUTE_UNUSED)
77 bfd *output_bfd;
78 char **error_message ATTRIBUTE_UNUSED;
79 { 75 {
80 symvalue diff; 76 symvalue diff;
81 77
82 #ifndef COFF_WITH_PE 78 #ifndef COFF_WITH_PE
83 if (output_bfd == (bfd *) NULL) 79 if (output_bfd == (bfd *) NULL)
84 return bfd_reloc_continue; 80 return bfd_reloc_continue;
85 #endif 81 #endif
86 82
87 if (bfd_is_com_section (symbol->section)) 83 if (bfd_is_com_section (symbol->section))
88 { 84 {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 178 }
183 179
184 /* Now let bfd_perform_relocation finish everything up. */ 180 /* Now let bfd_perform_relocation finish everything up. */
185 return bfd_reloc_continue; 181 return bfd_reloc_continue;
186 } 182 }
187 183
188 #ifdef COFF_WITH_PE 184 #ifdef COFF_WITH_PE
189 /* Return TRUE if this relocation should appear in the output .reloc 185 /* Return TRUE if this relocation should appear in the output .reloc
190 section. */ 186 section. */
191 187
192 static bfd_boolean in_reloc_p PARAMS ((bfd *, reloc_howto_type *)); 188 static bfd_boolean in_reloc_p (bfd * abfd ATTRIBUTE_UNUSED,
193 189 » » » reloc_howto_type *howto)
194 static bfd_boolean in_reloc_p (abfd, howto)
195 bfd * abfd ATTRIBUTE_UNUSED;
196 reloc_howto_type *howto;
197 { 190 {
198 return ! howto->pc_relative && howto->type != R_IMAGEBASE 191 return ! howto->pc_relative && howto->type != R_IMAGEBASE
199 && howto->type != R_SECREL32; 192 && howto->type != R_SECREL32;
200 } 193 }
201 #endif /* COFF_WITH_PE */ 194 #endif /* COFF_WITH_PE */
202 195
203 #ifndef PCRELOFFSET 196 #ifndef PCRELOFFSET
204 #define PCRELOFFSET FALSE 197 #define PCRELOFFSET FALSE
205 #endif 198 #endif
206 199
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 #ifndef COFF_WITH_PE 399 #ifndef COFF_WITH_PE
407 400
408 #define coff_relocate_section _bfd_coff_generic_relocate_section 401 #define coff_relocate_section _bfd_coff_generic_relocate_section
409 402
410 #else /* COFF_WITH_PE */ 403 #else /* COFF_WITH_PE */
411 404
412 /* The PE relocate section routine. The only difference between this 405 /* The PE relocate section routine. The only difference between this
413 and the regular routine is that we don't want to do anything for a 406 and the regular routine is that we don't want to do anything for a
414 relocatable link. */ 407 relocatable link. */
415 408
416 static bfd_boolean coff_pe_i386_relocate_section
417 PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
418 struct internal_reloc *, struct internal_syment *, asection **));
419
420 static bfd_boolean 409 static bfd_boolean
421 coff_pe_i386_relocate_section (output_bfd, info, input_bfd, 410 coff_pe_i386_relocate_section (bfd *output_bfd,
422 » » » input_section, contents, relocs, syms, 411 » » » struct bfd_link_info *info,
423 » » » sections) 412 » » » bfd *input_bfd,
424 bfd *output_bfd; 413 » » » asection *input_section,
425 struct bfd_link_info *info; 414 » » » bfd_byte *contents,
426 bfd *input_bfd; 415 » » » struct internal_reloc *relocs,
427 asection *input_section; 416 » » » struct internal_syment *syms,
428 bfd_byte *contents; 417 » » » asection **sections)
429 struct internal_reloc *relocs;
430 struct internal_syment *syms;
431 asection **sections;
432 { 418 {
433 if (info->relocatable) 419 if (info->relocatable)
434 return TRUE; 420 return TRUE;
435 421
436 return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd, 422 return _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,
437 input_section, contents, 423 input_section, contents,
438 relocs, syms, sections); 424 relocs, syms, sections);
439 } 425 }
440 426
441 #define coff_relocate_section coff_pe_i386_relocate_section 427 #define coff_relocate_section coff_pe_i386_relocate_section
442 428
443 #endif /* COFF_WITH_PE */ 429 #endif /* COFF_WITH_PE */
444 430
445 /* Convert an rtype to howto for the COFF backend linker. */ 431 /* Convert an rtype to howto for the COFF backend linker. */
446 432
447 static reloc_howto_type * 433 static reloc_howto_type *
448 coff_i386_rtype_to_howto (abfd, sec, rel, h, sym, addendp) 434 coff_i386_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
449 bfd *abfd ATTRIBUTE_UNUSED; 435 » » » asection *sec,
450 asection *sec; 436 » » » struct internal_reloc *rel,
451 struct internal_reloc *rel; 437 » » » struct coff_link_hash_entry *h,
452 struct coff_link_hash_entry *h; 438 » » » struct internal_syment *sym,
453 struct internal_syment *sym; 439 » » » bfd_vma *addendp)
454 bfd_vma *addendp;
455 { 440 {
456 reloc_howto_type *howto; 441 reloc_howto_type *howto;
457 442
458 if (rel->r_type >= sizeof (howto_table) / sizeof (howto_table[0])) 443 if (rel->r_type >= sizeof (howto_table) / sizeof (howto_table[0]))
459 { 444 {
460 bfd_set_error (bfd_error_bad_value); 445 bfd_set_error (bfd_error_bad_value);
461 return NULL; 446 return NULL;
462 } 447 }
463 448
464 howto = howto_table + rel->r_type; 449 howto = howto_table + rel->r_type;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 == bfd_target_coff_flavour)) 506 == bfd_target_coff_flavour))
522 { 507 {
523 *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase; 508 *addendp -= pe_data(sec->output_section->owner)->pe_opthdr.ImageBase;
524 } 509 }
525 510
526 BFD_ASSERT (sym != NULL); 511 BFD_ASSERT (sym != NULL);
527 if (rel->r_type == R_SECREL32 && sym != NULL) 512 if (rel->r_type == R_SECREL32 && sym != NULL)
528 { 513 {
529 bfd_vma osect_vma; 514 bfd_vma osect_vma;
530 515
531 if (h && (h->type == bfd_link_hash_defined 516 if (h && (h->root.type == bfd_link_hash_defined
532 » » || h->type == bfd_link_hash_defweak)) 517 » » || h->root.type == bfd_link_hash_defweak))
533 osect_vma = h->root.u.def.section->output_section->vma; 518 osect_vma = h->root.u.def.section->output_section->vma;
534 else 519 else
535 { 520 {
536 asection *s; 521 asection *s;
537 int i; 522 int i;
538 523
539 /* Sigh, the only way to get the section to offset against 524 /* Sigh, the only way to get the section to offset against
540 is to find it the hard way. */ 525 is to find it the hard way. */
541 526
542 for (s = abfd->sections, i = 1; i < sym->n_scnum; i++) 527 for (s = abfd->sections, i = 1; i < sym->n_scnum; i++)
543 s = s->next; 528 s = s->next;
544 529
545 osect_vma = s->output_section->vma; 530 osect_vma = s->output_section->vma;
546 } 531 }
547 532
548 *addendp -= osect_vma; 533 *addendp -= osect_vma;
549 } 534 }
550 #endif 535 #endif
551 536
552 return howto; 537 return howto;
553 } 538 }
554 539
555 #define coff_bfd_reloc_type_lookup coff_i386_reloc_type_lookup 540 #define coff_bfd_reloc_type_lookup coff_i386_reloc_type_lookup
556 #define coff_bfd_reloc_name_lookup coff_i386_reloc_name_lookup 541 #define coff_bfd_reloc_name_lookup coff_i386_reloc_name_lookup
557 542
558 static reloc_howto_type * 543 static reloc_howto_type *
559 coff_i386_reloc_type_lookup (abfd, code) 544 coff_i386_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
560 bfd *abfd ATTRIBUTE_UNUSED; 545 » » » bfd_reloc_code_real_type code)
561 bfd_reloc_code_real_type code;
562 { 546 {
563 switch (code) 547 switch (code)
564 { 548 {
565 case BFD_RELOC_RVA: 549 case BFD_RELOC_RVA:
566 return howto_table + R_IMAGEBASE; 550 return howto_table + R_IMAGEBASE;
567 case BFD_RELOC_32: 551 case BFD_RELOC_32:
568 return howto_table + R_DIR32; 552 return howto_table + R_DIR32;
569 case BFD_RELOC_32_PCREL: 553 case BFD_RELOC_32_PCREL:
570 return howto_table + R_PCRLONG; 554 return howto_table + R_PCRLONG;
571 case BFD_RELOC_16: 555 case BFD_RELOC_16:
(...skipping 29 matching lines...) Expand all
601 } 585 }
602 586
603 #define coff_rtype_to_howto coff_i386_rtype_to_howto 587 #define coff_rtype_to_howto coff_i386_rtype_to_howto
604 588
605 #ifdef TARGET_UNDERSCORE 589 #ifdef TARGET_UNDERSCORE
606 590
607 /* If i386 gcc uses underscores for symbol names, then it does not use 591 /* If i386 gcc uses underscores for symbol names, then it does not use
608 a leading dot for local labels, so if TARGET_UNDERSCORE is defined 592 a leading dot for local labels, so if TARGET_UNDERSCORE is defined
609 we treat all symbols starting with L as local. */ 593 we treat all symbols starting with L as local. */
610 594
611 static bfd_boolean coff_i386_is_local_label_name
612 PARAMS ((bfd *, const char *));
613
614 static bfd_boolean 595 static bfd_boolean
615 coff_i386_is_local_label_name (abfd, name) 596 coff_i386_is_local_label_name (bfd *abfd, const char *name)
616 bfd *abfd;
617 const char *name;
618 { 597 {
619 if (name[0] == 'L') 598 if (name[0] == 'L')
620 return TRUE; 599 return TRUE;
621 600
622 return _bfd_coff_is_local_label_name (abfd, name); 601 return _bfd_coff_is_local_label_name (abfd, name);
623 } 602 }
624 603
625 #define coff_bfd_is_local_label_name coff_i386_is_local_label_name 604 #define coff_bfd_is_local_label_name coff_i386_is_local_label_name
626 605
627 #endif /* TARGET_UNDERSCORE */ 606 #endif /* TARGET_UNDERSCORE */
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 BFD_JUMP_TABLE_SYMBOLS (coff), 669 BFD_JUMP_TABLE_SYMBOLS (coff),
691 BFD_JUMP_TABLE_RELOCS (coff), 670 BFD_JUMP_TABLE_RELOCS (coff),
692 BFD_JUMP_TABLE_WRITE (coff), 671 BFD_JUMP_TABLE_WRITE (coff),
693 BFD_JUMP_TABLE_LINK (coff), 672 BFD_JUMP_TABLE_LINK (coff),
694 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), 673 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
695 674
696 NULL, 675 NULL,
697 676
698 COFF_SWAP_TABLE 677 COFF_SWAP_TABLE
699 }; 678 };
OLDNEW
« no previous file with comments | « bfd/coff-h8500.c ('k') | bfd/coff-i960.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698