/[gcl]/gcl/binutils/bfd/elf-m10200.c
ViewVC logotype

Diff of /gcl/binutils/bfd/elf-m10200.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by camm, Fri Aug 9 05:35:07 2002 UTC revision 1.1.1.1.20.1 by camm, Fri Sep 30 02:08:57 2005 UTC
# Line 1  Line 1 
1  /* Matsushita 10200 specific support for 32-bit ELF  /* Matsushita 10200 specific support for 32-bit ELF
2     Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002     Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3     Free Software Foundation, Inc.     Free Software Foundation, Inc.
4    
5  This file is part of BFD, the Binary File Descriptor library.  This file is part of BFD, the Binary File Descriptor library.
# Line 26  Foundation, Inc., 59 Temple Place - Suit Line 26  Foundation, Inc., 59 Temple Place - Suit
26  static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup  static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
27    PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));    PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
28  static void mn10200_info_to_howto  static void mn10200_info_to_howto
29    PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));    PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));
30  static boolean mn10200_elf_relax_delete_bytes  static bfd_boolean mn10200_elf_relax_delete_bytes
31    PARAMS ((bfd *, asection *, bfd_vma, int));    PARAMS ((bfd *, asection *, bfd_vma, int));
32  static boolean mn10200_elf_symbol_address_p  static bfd_boolean mn10200_elf_symbol_address_p
33    PARAMS ((bfd *, asection *, Elf_Internal_Sym *, bfd_vma));    PARAMS ((bfd *, asection *, Elf_Internal_Sym *, bfd_vma));
34  static bfd_reloc_status_type mn10200_elf_final_link_relocate  static bfd_reloc_status_type mn10200_elf_final_link_relocate
35    PARAMS ((reloc_howto_type *, bfd *, bfd *, asection *,    PARAMS ((reloc_howto_type *, bfd *, bfd *, asection *,
36             bfd_byte *, bfd_vma, bfd_vma, bfd_vma,             bfd_byte *, bfd_vma, bfd_vma, bfd_vma,
37             struct bfd_link_info *, asection *, int));             struct bfd_link_info *, asection *, int));
38  static boolean mn10200_elf_relocate_section  static bfd_boolean mn10200_elf_relocate_section
39  PARAMS (( bfd *, struct bfd_link_info *, bfd *, asection *,    PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *,
40            bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *,             bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *,
41            asection **));             asection **));
42  static boolean mn10200_elf_relax_section  static bfd_boolean mn10200_elf_relax_section
43    PARAMS ((bfd *, asection *, struct bfd_link_info *, boolean *));    PARAMS ((bfd *, asection *, struct bfd_link_info *, bfd_boolean *));
44  static bfd_byte * mn10200_elf_get_relocated_section_contents  static bfd_byte * mn10200_elf_get_relocated_section_contents
45    PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,    PARAMS ((bfd *, struct bfd_link_info *, struct bfd_link_order *,
46             bfd_byte *, boolean, asymbol **));             bfd_byte *, bfd_boolean, asymbol **));
   
 /* We have to use RELA instructions since md_apply_fix3 in the assembler  
    does absolutely nothing.  */  
 #define USE_RELA  
47    
48  enum reloc_type {  enum reloc_type {
49    R_MN10200_NONE = 0,    R_MN10200_NONE = 0,
# Line 67  static reloc_howto_type elf_mn10200_howt Line 63  static reloc_howto_type elf_mn10200_howt
63           0,           0,
64           2,           2,
65           16,           16,
66           false,           FALSE,
67           0,           0,
68           complain_overflow_bitfield,           complain_overflow_bitfield,
69           bfd_elf_generic_reloc,           bfd_elf_generic_reloc,
70           "R_MN10200_NONE",           "R_MN10200_NONE",
71           false,           FALSE,
72           0,           0,
73           0,           0,
74           false),           FALSE),
75    /* Standard 32 bit reloc.  */    /* Standard 32 bit reloc.  */
76    HOWTO (R_MN10200_32,    HOWTO (R_MN10200_32,
77           0,           0,
78           2,           2,
79           32,           32,
80           false,           FALSE,
81           0,           0,
82           complain_overflow_bitfield,           complain_overflow_bitfield,
83           bfd_elf_generic_reloc,           bfd_elf_generic_reloc,
84           "R_MN10200_32",           "R_MN10200_32",
85           false,           FALSE,
86           0xffffffff,           0xffffffff,
87           0xffffffff,           0xffffffff,
88           false),           FALSE),
89    /* Standard 16 bit reloc.  */    /* Standard 16 bit reloc.  */
90    HOWTO (R_MN10200_16,    HOWTO (R_MN10200_16,
91           0,           0,
92           1,           1,
93           16,           16,
94           false,           FALSE,
95           0,           0,
96           complain_overflow_bitfield,           complain_overflow_bitfield,
97           bfd_elf_generic_reloc,           bfd_elf_generic_reloc,
98           "R_MN10200_16",           "R_MN10200_16",
99           false,           FALSE,
100           0xffff,           0xffff,
101           0xffff,           0xffff,
102           false),           FALSE),
103    /* Standard 8 bit reloc.  */    /* Standard 8 bit reloc.  */
104    HOWTO (R_MN10200_8,    HOWTO (R_MN10200_8,
105           0,           0,
106           0,           0,
107           8,           8,
108           false,           FALSE,
109           0,           0,
110           complain_overflow_bitfield,           complain_overflow_bitfield,
111           bfd_elf_generic_reloc,           bfd_elf_generic_reloc,
112           "R_MN10200_8",           "R_MN10200_8",
113           false,           FALSE,
114           0xff,           0xff,
115           0xff,           0xff,
116           false),           FALSE),
117    /* Standard 24 bit reloc.  */    /* Standard 24 bit reloc.  */
118    HOWTO (R_MN10200_24,    HOWTO (R_MN10200_24,
119           0,           0,
120           2,           2,
121           24,           24,
122           false,           FALSE,
123           0,           0,
124           complain_overflow_bitfield,           complain_overflow_bitfield,
125           bfd_elf_generic_reloc,           bfd_elf_generic_reloc,
126           "R_MN10200_24",           "R_MN10200_24",
127           false,           FALSE,
128           0xffffff,           0xffffff,
129           0xffffff,           0xffffff,
130           false),           FALSE),
131    /* Simple 8 pc-relative reloc.  */    /* Simple 8 pc-relative reloc.  */
132    HOWTO (R_MN10200_PCREL8,    HOWTO (R_MN10200_PCREL8,
133           0,           0,
134           0,           0,
135           8,           8,
136           true,           TRUE,
137           0,           0,
138           complain_overflow_bitfield,           complain_overflow_bitfield,
139           bfd_elf_generic_reloc,           bfd_elf_generic_reloc,
140           "R_MN10200_PCREL8",           "R_MN10200_PCREL8",
141           false,           FALSE,
142           0xff,           0xff,
143           0xff,           0xff,
144           true),           TRUE),
145    /* Simple 16 pc-relative reloc.  */    /* Simple 16 pc-relative reloc.  */
146    HOWTO (R_MN10200_PCREL16,    HOWTO (R_MN10200_PCREL16,
147           0,           0,
148           1,           1,
149           16,           16,
150           true,           TRUE,
151           0,           0,
152           complain_overflow_bitfield,           complain_overflow_bitfield,
153           bfd_elf_generic_reloc,           bfd_elf_generic_reloc,
154           "R_MN10200_PCREL16",           "R_MN10200_PCREL16",
155           false,           FALSE,
156           0xffff,           0xffff,
157           0xffff,           0xffff,
158           true),           TRUE),
159    /* Simple 32bit pc-relative reloc with a 1 byte adjustment    /* Simple 32bit pc-relative reloc with a 1 byte adjustment
160       to get the pc-relative offset correct.  */       to get the pc-relative offset correct.  */
161    HOWTO (R_MN10200_PCREL24,    HOWTO (R_MN10200_PCREL24,
162           0,           0,
163           2,           2,
164           24,           24,
165           true,           TRUE,
166           0,           0,
167           complain_overflow_bitfield,           complain_overflow_bitfield,
168           bfd_elf_generic_reloc,           bfd_elf_generic_reloc,
169           "R_MN10200_PCREL24",           "R_MN10200_PCREL24",
170           false,           FALSE,
171           0xffffff,           0xffffff,
172           0xffffff,           0xffffff,
173           true),           TRUE),
174  };  };
175    
176  struct mn10200_reloc_map {  struct mn10200_reloc_map {
# Line 217  static void Line 213  static void
213  mn10200_info_to_howto (abfd, cache_ptr, dst)  mn10200_info_to_howto (abfd, cache_ptr, dst)
214       bfd *abfd ATTRIBUTE_UNUSED;       bfd *abfd ATTRIBUTE_UNUSED;
215       arelent *cache_ptr;       arelent *cache_ptr;
216       Elf32_Internal_Rela *dst;       Elf_Internal_Rela *dst;
217  {  {
218    unsigned int r_type;    unsigned int r_type;
219    
# Line 331  mn10200_elf_final_link_relocate (howto, Line 327  mn10200_elf_final_link_relocate (howto,
327  }  }
328    
329  /* Relocate an MN10200 ELF section.  */  /* Relocate an MN10200 ELF section.  */
330  static boolean  static bfd_boolean
331  mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_section,  mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_section,
332                                contents, relocs, local_syms, local_sections)                                contents, relocs, local_syms, local_sections)
333       bfd *output_bfd;       bfd *output_bfd;
# Line 347  mn10200_elf_relocate_section (output_bfd Line 343  mn10200_elf_relocate_section (output_bfd
343    struct elf_link_hash_entry **sym_hashes;    struct elf_link_hash_entry **sym_hashes;
344    Elf_Internal_Rela *rel, *relend;    Elf_Internal_Rela *rel, *relend;
345    
346    if (info->relocateable)    if (info->relocatable)
347      return true;      return TRUE;
348    
349    symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;    symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
350    sym_hashes = elf_sym_hashes (input_bfd);    sym_hashes = elf_sym_hashes (input_bfd);
# Line 377  mn10200_elf_relocate_section (output_bfd Line 373  mn10200_elf_relocate_section (output_bfd
373          {          {
374            sym = local_syms + r_symndx;            sym = local_syms + r_symndx;
375            sec = local_sections[r_symndx];            sec = local_sections[r_symndx];
376            relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel);            relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
377          }          }
378        else        else
379          {          {
380            h = sym_hashes[r_symndx - symtab_hdr->sh_info];            bfd_boolean unresolved_reloc, warned;
381            while (h->root.type == bfd_link_hash_indirect  
382                   || h->root.type == bfd_link_hash_warning)            RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
383              h = (struct elf_link_hash_entry *) h->root.u.i.link;                                     r_symndx, symtab_hdr, sym_hashes,
384            if (h->root.type == bfd_link_hash_defined                                     h, sec, relocation,
385                || h->root.type == bfd_link_hash_defweak)                                     unresolved_reloc, warned);
             {  
               sec = h->root.u.def.section;  
               relocation = (h->root.u.def.value  
                             + sec->output_section->vma  
                             + sec->output_offset);  
             }  
           else if (h->root.type == bfd_link_hash_undefweak)  
             relocation = 0;  
           else  
             {  
               if (! ((*info->callbacks->undefined_symbol)  
                      (info, h->root.root.string, input_bfd,  
                       input_section, rel->r_offset, true)))  
                 return false;  
               relocation = 0;  
             }  
386          }          }
387    
388        r = mn10200_elf_final_link_relocate (howto, input_bfd, output_bfd,        r = mn10200_elf_final_link_relocate (howto, input_bfd, output_bfd,
# Line 430  mn10200_elf_relocate_section (output_bfd Line 410  mn10200_elf_relocate_section (output_bfd
410              {              {
411              case bfd_reloc_overflow:              case bfd_reloc_overflow:
412                if (! ((*info->callbacks->reloc_overflow)                if (! ((*info->callbacks->reloc_overflow)
413                       (info, name, howto->name, (bfd_vma) 0,                       (info, (h ? &h->root : NULL), name, howto->name,
414                        input_bfd, input_section, rel->r_offset)))                        (bfd_vma) 0, input_bfd, input_section,
415                  return false;                        rel->r_offset)))
416                    return FALSE;
417                break;                break;
418    
419              case bfd_reloc_undefined:              case bfd_reloc_undefined:
420                if (! ((*info->callbacks->undefined_symbol)                if (! ((*info->callbacks->undefined_symbol)
421                       (info, name, input_bfd, input_section,                       (info, name, input_bfd, input_section,
422                        rel->r_offset, true)))                        rel->r_offset, TRUE)))
423                  return false;                  return FALSE;
424                break;                break;
425    
426              case bfd_reloc_outofrange:              case bfd_reloc_outofrange:
# Line 462  mn10200_elf_relocate_section (output_bfd Line 443  mn10200_elf_relocate_section (output_bfd
443                if (!((*info->callbacks->warning)                if (!((*info->callbacks->warning)
444                      (info, msg, name, input_bfd, input_section,                      (info, msg, name, input_bfd, input_section,
445                       rel->r_offset)))                       rel->r_offset)))
446                  return false;                  return FALSE;
447                break;                break;
448              }              }
449          }          }
450      }      }
451    
452    return true;    return TRUE;
453  }  }
454    
455  /* This function handles relaxing for the mn10200.  /* This function handles relaxing for the mn10200.
456    
457     There's quite a few relaxing opportunites available on the mn10200:     There are quite a few relaxing opportunities available on the mn10200:
458    
459          * jsr:24 -> jsr:16                                         2 bytes          * jsr:24 -> jsr:16                                         2 bytes
460    
# Line 500  mn10200_elf_relocate_section (output_bfd Line 481  mn10200_elf_relocate_section (output_bfd
481          We don't handle imm16->imm8 or d16->d8 as they're very rare          We don't handle imm16->imm8 or d16->d8 as they're very rare
482          and somewhat more difficult to support.  */          and somewhat more difficult to support.  */
483    
484  static boolean  static bfd_boolean
485  mn10200_elf_relax_section (abfd, sec, link_info, again)  mn10200_elf_relax_section (abfd, sec, link_info, again)
486       bfd *abfd;       bfd *abfd;
487       asection *sec;       asection *sec;
488       struct bfd_link_info *link_info;       struct bfd_link_info *link_info;
489       boolean *again;       bfd_boolean *again;
490  {  {
491    Elf_Internal_Shdr *symtab_hdr;    Elf_Internal_Shdr *symtab_hdr;
492    Elf_Internal_Rela *internal_relocs;    Elf_Internal_Rela *internal_relocs;
# Line 514  mn10200_elf_relax_section (abfd, sec, li Line 495  mn10200_elf_relax_section (abfd, sec, li
495    Elf_Internal_Sym *isymbuf = NULL;    Elf_Internal_Sym *isymbuf = NULL;
496    
497    /* Assume nothing changes.  */    /* Assume nothing changes.  */
498    *again = false;    *again = FALSE;
499    
500    /* We don't have to do anything for a relocateable link, if    /* We don't have to do anything for a relocatable link, if
501       this section does not have relocs, or if this is not a       this section does not have relocs, or if this is not a
502       code section.  */       code section.  */
503    if (link_info->relocateable    if (link_info->relocatable
504        || (sec->flags & SEC_RELOC) == 0        || (sec->flags & SEC_RELOC) == 0
505        || sec->reloc_count == 0        || sec->reloc_count == 0
506        || (sec->flags & SEC_CODE) == 0)        || (sec->flags & SEC_CODE) == 0)
507      return true;      return TRUE;
   
   /* If this is the first time we have been called for this section,  
      initialize the cooked size.  */  
   if (sec->_cooked_size == 0)  
     sec->_cooked_size = sec->_raw_size;  
508    
509    symtab_hdr = &elf_tdata (abfd)->symtab_hdr;    symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
510    
511    /* Get a copy of the native relocations.  */    /* Get a copy of the native relocations.  */
512    internal_relocs = (_bfd_elf32_link_read_relocs    internal_relocs = (_bfd_elf_link_read_relocs
513                       (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,                       (abfd, sec, (PTR) NULL, (Elf_Internal_Rela *) NULL,
514                        link_info->keep_memory));                        link_info->keep_memory));
515    if (internal_relocs == NULL)    if (internal_relocs == NULL)
# Line 561  mn10200_elf_relax_section (abfd, sec, li Line 537  mn10200_elf_relax_section (abfd, sec, li
537            else            else
538              {              {
539                /* Go get them off disk.  */                /* Go get them off disk.  */
540                contents = (bfd_byte *) bfd_malloc (sec->_raw_size);                if (!bfd_malloc_and_get_section (abfd, sec, &contents))
               if (contents == NULL)  
                 goto error_return;  
   
               if (! bfd_get_section_contents (abfd, sec, contents,  
                                               (file_ptr) 0, sec->_raw_size))  
541                  goto error_return;                  goto error_return;
542              }              }
543          }          }
# Line 683  mn10200_elf_relax_section (abfd, sec, li Line 654  mn10200_elf_relax_section (abfd, sec, li
654    
655                /* That will change things, so, we should relax again.                /* That will change things, so, we should relax again.
656                   Note that this is not required, and it may be slow.  */                   Note that this is not required, and it may be slow.  */
657                *again = true;                *again = TRUE;
658              }              }
659          }          }
660    
# Line 730  mn10200_elf_relax_section (abfd, sec, li Line 701  mn10200_elf_relax_section (abfd, sec, li
701    
702                /* That will change things, so, we should relax again.                /* That will change things, so, we should relax again.
703                   Note that this is not required, and it may be slow.  */                   Note that this is not required, and it may be slow.  */
704                *again = true;                *again = TRUE;
705              }              }
706          }          }
707    
# Line 757  mn10200_elf_relax_section (abfd, sec, li Line 728  mn10200_elf_relax_section (abfd, sec, li
728            value += irel->r_addend;            value += irel->r_addend;
729    
730            /* Do nothing if this reloc is the last byte in the section.  */            /* Do nothing if this reloc is the last byte in the section.  */
731            if (irel->r_offset == sec->_cooked_size)            if (irel->r_offset == sec->size)
732              continue;              continue;
733    
734            /* See if the next instruction is an unconditional pc-relative            /* See if the next instruction is an unconditional pc-relative
# Line 883  mn10200_elf_relax_section (abfd, sec, li Line 854  mn10200_elf_relax_section (abfd, sec, li
854    
855            /* That will change things, so, we should relax again.            /* That will change things, so, we should relax again.
856               Note that this is not required, and it may be slow.  */               Note that this is not required, and it may be slow.  */
857            *again = true;            *again = TRUE;
858          }          }
859    
860        /* Try to turn a 24bit immediate, displacement or absolute address        /* Try to turn a 24bit immediate, displacement or absolute address
# Line 922  mn10200_elf_relax_section (abfd, sec, li Line 893  mn10200_elf_relax_section (abfd, sec, li
893                    if (value & 0x8000)                    if (value & 0x8000)
894                      continue;                      continue;
895    
896                    /* Note that we've changed the reldection contents, etc.  */                    /* Note that we've changed the relocation contents, etc.  */
897                    elf_section_data (sec)->relocs = internal_relocs;                    elf_section_data (sec)->relocs = internal_relocs;
898                    elf_section_data (sec)->this_hdr.contents = contents;                    elf_section_data (sec)->this_hdr.contents = contents;
899                    symtab_hdr->contents = (unsigned char *) isymbuf;                    symtab_hdr->contents = (unsigned char *) isymbuf;
# Line 946  mn10200_elf_relax_section (abfd, sec, li Line 917  mn10200_elf_relax_section (abfd, sec, li
917    
918                    /* That will change things, so, we should relax again.                    /* That will change things, so, we should relax again.
919                       Note that this is not required, and it may be slow.  */                       Note that this is not required, and it may be slow.  */
920                    *again = true;                    *again = TRUE;
921                    break;                    break;
922    
923                  /* mov imm24,an -> mov imm16,an                  /* mov imm24,an -> mov imm16,an
# Line 961  mn10200_elf_relax_section (abfd, sec, li Line 932  mn10200_elf_relax_section (abfd, sec, li
932                  case 0x40:                  case 0x40:
933                  case 0x44:                  case 0x44:
934                  case 0xc8:                  case 0xc8:
935                    /* Note that we've changed the reldection contents, etc.  */                    /* Note that we've changed the relocation contents, etc.  */
936                    elf_section_data (sec)->relocs = internal_relocs;                    elf_section_data (sec)->relocs = internal_relocs;
937                    elf_section_data (sec)->this_hdr.contents = contents;                    elf_section_data (sec)->this_hdr.contents = contents;
938                    symtab_hdr->contents = (unsigned char *) isymbuf;                    symtab_hdr->contents = (unsigned char *) isymbuf;
# Line 997  mn10200_elf_relax_section (abfd, sec, li Line 968  mn10200_elf_relax_section (abfd, sec, li
968    
969                    /* That will change things, so, we should relax again.                    /* That will change things, so, we should relax again.
970                       Note that this is not required, and it may be slow.  */                       Note that this is not required, and it may be slow.  */
971                    *again = true;                    *again = TRUE;
972                    break;                    break;
973    
974                  /* cmp imm24,dn -> cmp imm16,dn                  /* cmp imm24,dn -> cmp imm16,dn
# Line 1044  mn10200_elf_relax_section (abfd, sec, li Line 1015  mn10200_elf_relax_section (abfd, sec, li
1015                        && (value & 0x8000) != 0)                        && (value & 0x8000) != 0)
1016                      continue;                      continue;
1017    
1018                    /* Note that we've changed the reldection contents, etc.  */                    /* Note that we've changed the relocation contents, etc.  */
1019                    elf_section_data (sec)->relocs = internal_relocs;                    elf_section_data (sec)->relocs = internal_relocs;
1020                    elf_section_data (sec)->this_hdr.contents = contents;                    elf_section_data (sec)->this_hdr.contents = contents;
1021                    symtab_hdr->contents = (unsigned char *) isymbuf;                    symtab_hdr->contents = (unsigned char *) isymbuf;
# Line 1098  mn10200_elf_relax_section (abfd, sec, li Line 1069  mn10200_elf_relax_section (abfd, sec, li
1069    
1070                    /* That will change things, so, we should relax again.                    /* That will change things, so, we should relax again.
1071                       Note that this is not required, and it may be slow.  */                       Note that this is not required, and it may be slow.  */
1072                    *again = true;                    *again = TRUE;
1073                    break;                    break;
1074    
1075                  /* movb (abs24),dn ->movbu (abs16),dn extxb bn */                  /* movb (abs24),dn ->movbu (abs16),dn extxb bn */
# Line 1129  mn10200_elf_relax_section (abfd, sec, li Line 1100  mn10200_elf_relax_section (abfd, sec, li
1100    
1101                    /* That will change things, so, we should relax again.                    /* That will change things, so, we should relax again.
1102                       Note that this is not required, and it may be slow.  */                       Note that this is not required, and it may be slow.  */
1103                    *again = true;                    *again = TRUE;
1104                    break;                    break;
1105                  }                  }
1106              }              }
# Line 1164  mn10200_elf_relax_section (abfd, sec, li Line 1135  mn10200_elf_relax_section (abfd, sec, li
1135        && elf_section_data (sec)->relocs != internal_relocs)        && elf_section_data (sec)->relocs != internal_relocs)
1136      free (internal_relocs);      free (internal_relocs);
1137    
1138    return true;    return TRUE;
1139    
1140   error_return:   error_return:
1141    if (isymbuf != NULL    if (isymbuf != NULL
# Line 1177  mn10200_elf_relax_section (abfd, sec, li Line 1148  mn10200_elf_relax_section (abfd, sec, li
1148        && elf_section_data (sec)->relocs != internal_relocs)        && elf_section_data (sec)->relocs != internal_relocs)
1149      free (internal_relocs);      free (internal_relocs);
1150    
1151    return false;    return FALSE;
1152  }  }
1153    
1154  /* Delete some bytes from a section while relaxing.  */  /* Delete some bytes from a section while relaxing.  */
1155    
1156  static boolean  static bfd_boolean
1157  mn10200_elf_relax_delete_bytes (abfd, sec, addr, count)  mn10200_elf_relax_delete_bytes (abfd, sec, addr, count)
1158       bfd *abfd;       bfd *abfd;
1159       asection *sec;       asection *sec;
# Line 1209  mn10200_elf_relax_delete_bytes (abfd, se Line 1180  mn10200_elf_relax_delete_bytes (abfd, se
1180       power larger than the number of bytes we are deleting.  */       power larger than the number of bytes we are deleting.  */
1181    
1182    irelalign = NULL;    irelalign = NULL;
1183    toaddr = sec->_cooked_size;    toaddr = sec->size;
1184    
1185    irel = elf_section_data (sec)->relocs;    irel = elf_section_data (sec)->relocs;
1186    irelend = irel + sec->reloc_count;    irelend = irel + sec->reloc_count;
# Line 1217  mn10200_elf_relax_delete_bytes (abfd, se Line 1188  mn10200_elf_relax_delete_bytes (abfd, se
1188    /* Actually delete the bytes.  */    /* Actually delete the bytes.  */
1189    memmove (contents + addr, contents + addr + count,    memmove (contents + addr, contents + addr + count,
1190             (size_t) (toaddr - addr - count));             (size_t) (toaddr - addr - count));
1191    sec->_cooked_size -= count;    sec->size -= count;
1192    
1193    /* Adjust all the relocs.  */    /* Adjust all the relocs.  */
1194    for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)    for (irel = elf_section_data (sec)->relocs; irel < irelend; irel++)
# Line 1257  mn10200_elf_relax_delete_bytes (abfd, se Line 1228  mn10200_elf_relax_delete_bytes (abfd, se
1228          }          }
1229      }      }
1230    
1231    return true;    return TRUE;
1232  }  }
1233    
1234  /* Return true if a symbol exists at the given address, else return  /* Return TRUE if a symbol exists at the given address, else return
1235     false.  */     FALSE.  */
1236  static boolean  static bfd_boolean
1237  mn10200_elf_symbol_address_p (abfd, sec, isym, addr)  mn10200_elf_symbol_address_p (abfd, sec, isym, addr)
1238       bfd *abfd;       bfd *abfd;
1239       asection *sec;       asection *sec;
# Line 1284  mn10200_elf_symbol_address_p (abfd, sec, Line 1255  mn10200_elf_symbol_address_p (abfd, sec,
1255      {      {
1256        if (isym->st_shndx == sec_shndx        if (isym->st_shndx == sec_shndx
1257            && isym->st_value == addr)            && isym->st_value == addr)
1258          return true;          return TRUE;
1259      }      }
1260    
1261    symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)    symcount = (symtab_hdr->sh_size / sizeof (Elf32_External_Sym)
# Line 1298  mn10200_elf_symbol_address_p (abfd, sec, Line 1269  mn10200_elf_symbol_address_p (abfd, sec,
1269             || sym_hash->root.type == bfd_link_hash_defweak)             || sym_hash->root.type == bfd_link_hash_defweak)
1270            && sym_hash->root.u.def.section == sec            && sym_hash->root.u.def.section == sec
1271            && sym_hash->root.u.def.value == addr)            && sym_hash->root.u.def.value == addr)
1272          return true;          return TRUE;
1273      }      }
1274    
1275    return false;    return FALSE;
1276  }  }
1277    
1278  /* This is a version of bfd_generic_get_relocated_section_contents  /* This is a version of bfd_generic_get_relocated_section_contents
# Line 1309  mn10200_elf_symbol_address_p (abfd, sec, Line 1280  mn10200_elf_symbol_address_p (abfd, sec,
1280    
1281  static bfd_byte *  static bfd_byte *
1282  mn10200_elf_get_relocated_section_contents (output_bfd, link_info, link_order,  mn10200_elf_get_relocated_section_contents (output_bfd, link_info, link_order,
1283                                              data, relocateable, symbols)                                              data, relocatable, symbols)
1284       bfd *output_bfd;       bfd *output_bfd;
1285       struct bfd_link_info *link_info;       struct bfd_link_info *link_info;
1286       struct bfd_link_order *link_order;       struct bfd_link_order *link_order;
1287       bfd_byte *data;       bfd_byte *data;
1288       boolean relocateable;       bfd_boolean relocatable;
1289       asymbol **symbols;       asymbol **symbols;
1290  {  {
1291    Elf_Internal_Shdr *symtab_hdr;    Elf_Internal_Shdr *symtab_hdr;
# Line 1326  mn10200_elf_get_relocated_section_conten Line 1297  mn10200_elf_get_relocated_section_conten
1297    
1298    /* We only need to handle the case of relaxing, or of having a    /* We only need to handle the case of relaxing, or of having a
1299       particular set of section contents, specially.  */       particular set of section contents, specially.  */
1300    if (relocateable    if (relocatable
1301        || elf_section_data (input_section)->this_hdr.contents == NULL)        || elf_section_data (input_section)->this_hdr.contents == NULL)
1302      return bfd_generic_get_relocated_section_contents (output_bfd, link_info,      return bfd_generic_get_relocated_section_contents (output_bfd, link_info,
1303                                                         link_order, data,                                                         link_order, data,
1304                                                         relocateable,                                                         relocatable,
1305                                                         symbols);                                                         symbols);
1306    
1307    symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;    symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
1308    
1309    memcpy (data, elf_section_data (input_section)->this_hdr.contents,    memcpy (data, elf_section_data (input_section)->this_hdr.contents,
1310            (size_t) input_section->_raw_size);            (size_t) input_section->size);
1311    
1312    if ((input_section->flags & SEC_RELOC) != 0    if ((input_section->flags & SEC_RELOC) != 0
1313        && input_section->reloc_count > 0)        && input_section->reloc_count > 0)
# Line 1346  mn10200_elf_get_relocated_section_conten Line 1317  mn10200_elf_get_relocated_section_conten
1317        asection **secpp;        asection **secpp;
1318        bfd_size_type amt;        bfd_size_type amt;
1319    
1320        internal_relocs = (_bfd_elf32_link_read_relocs        internal_relocs = (_bfd_elf_link_read_relocs
1321                           (input_bfd, input_section, (PTR) NULL,                           (input_bfd, input_section, (PTR) NULL,
1322                            (Elf_Internal_Rela *) NULL, false));                            (Elf_Internal_Rela *) NULL, FALSE));
1323        if (internal_relocs == NULL)        if (internal_relocs == NULL)
1324          goto error_return;          goto error_return;
1325    

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.1.20.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26