diff options
Diffstat (limited to 'bfd/coff-sh.c')
-rw-r--r-- | bfd/coff-sh.c | 80 |
1 files changed, 43 insertions, 37 deletions
diff --git a/bfd/coff-sh.c b/bfd/coff-sh.c index f3b74e91fba..eb1120b566a 100644 --- a/bfd/coff-sh.c +++ b/bfd/coff-sh.c @@ -379,8 +379,8 @@ static reloc_howto_type sh_coff_howtos[] = #ifndef COFF_WITH_PE /* Swap the r_offset field in and out. */ -#define SWAP_IN_RELOC_OFFSET bfd_h_get_32 -#define SWAP_OUT_RELOC_OFFSET bfd_h_put_32 +#define SWAP_IN_RELOC_OFFSET H_GET_32 +#define SWAP_OUT_RELOC_OFFSET H_PUT_32 /* Swap out extra information in the reloc structure. */ #define SWAP_OUT_RELOC_EXTRA(abfd, src, dst) \ @@ -589,14 +589,14 @@ sh_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, #endif insn = bfd_get_32 (abfd, hit_data); insn += sym_value + reloc_entry->addend; - bfd_put_32 (abfd, insn, hit_data); + bfd_put_32 (abfd, (bfd_vma) insn, hit_data); break; #ifdef COFF_WITH_PE case R_SH_IMAGEBASE: insn = bfd_get_32 (abfd, hit_data); - insn += (sym_value + reloc_entry->addend - - pe_data (input_section->output_section->owner)->pe_opthdr.ImageBase); - bfd_put_32 (abfd, insn, hit_data); + insn += sym_value + reloc_entry->addend; + insn -= pe_data (input_section->output_section->owner)->pe_opthdr.ImageBase; + bfd_put_32 (abfd, (bfd_vma) insn, hit_data); break; #endif case R_SH_PCDISP: @@ -610,7 +610,7 @@ sh_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, if (insn & 0x800) sym_value -= 0x1000; insn = (insn & 0xf000) | (sym_value & 0xfff); - bfd_put_16 (abfd, insn, hit_data); + bfd_put_16 (abfd, (bfd_vma) insn, hit_data); if (sym_value < (bfd_vma) -0x1000 || sym_value >= 0x1000) return bfd_reloc_overflow; break; @@ -784,7 +784,7 @@ sh_relax_section (abfd, sec, link_info, again) on a four byte boundary. */ paddr = insn & 0xff; paddr *= 4; - paddr += (laddr + 4) &~ 3; + paddr += (laddr + 4) &~ (bfd_vma) 3; if (paddr >= sec->_raw_size) { ((*_bfd_error_handler) @@ -886,8 +886,8 @@ sh_relax_section (abfd, sec, link_info, again) if (coff_section_data (abfd, sec) == NULL) { - sec->used_by_bfd = - ((PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata))); + bfd_size_type amt = sizeof (struct coff_section_tdata); + sec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt); if (sec->used_by_bfd == NULL) goto error_return; } @@ -914,7 +914,7 @@ sh_relax_section (abfd, sec, link_info, again) it will be handled here like other internal PCDISP relocs. */ bfd_put_16 (abfd, - 0xb000 | ((foff >> 1) & 0xfff), + (bfd_vma) 0xb000 | ((foff >> 1) & 0xfff), contents + irel->r_vaddr - sec->vma); } else @@ -922,7 +922,8 @@ sh_relax_section (abfd, sec, link_info, again) /* We can't fully resolve this yet, because the external symbol value may be changed by future relaxing. We let the final link phase handle it. */ - bfd_put_16 (abfd, 0xb000, contents + irel->r_vaddr - sec->vma); + bfd_put_16 (abfd, (bfd_vma) 0xb000, + contents + irel->r_vaddr - sec->vma); } /* See if there is another R_SH_USES reloc referring to the same @@ -1023,8 +1024,8 @@ sh_relax_section (abfd, sec, link_info, again) { if (coff_section_data (abfd, sec) == NULL) { - sec->used_by_bfd = - ((PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata))); + bfd_size_type amt = sizeof (struct coff_section_tdata); + sec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt); if (sec->used_by_bfd == NULL) goto error_return; } @@ -1056,8 +1057,8 @@ sh_relax_section (abfd, sec, link_info, again) /* Cache the section contents for coff_link_input_bfd. */ if (coff_section_data (abfd, sec) == NULL) { - sec->used_by_bfd = - ((PTR) bfd_zalloc (abfd, sizeof (struct coff_section_tdata))); + bfd_size_type amt = sizeof (struct coff_section_tdata); + sec->used_by_bfd = (PTR) bfd_zalloc (abfd, amt); if (sec->used_by_bfd == NULL) goto error_return; coff_section_data (abfd, sec)->relocs = NULL; @@ -1117,7 +1118,8 @@ sh_relax_delete_bytes (abfd, sec, addr, count) } /* Actually delete the bytes. */ - memmove (contents + addr, contents + addr + count, toaddr - addr - count); + memmove (contents + addr, contents + addr + count, + (size_t) (toaddr - addr - count)); if (irelalign == NULL) sec->_cooked_size -= count; else @@ -1128,7 +1130,7 @@ sh_relax_delete_bytes (abfd, sec, addr, count) BFD_ASSERT ((count & 1) == 0); for (i = 0; i < count; i += 2) - bfd_put_16 (abfd, NOP_OPCODE, contents + toaddr - count + i); + bfd_put_16 (abfd, (bfd_vma) NOP_OPCODE, contents + toaddr - count + i); } /* Adjust all the relocs. */ @@ -1314,14 +1316,14 @@ sh_relax_delete_bytes (abfd, sec, addr, count) insn += adjust / 2; if ((oinsn & 0xff00) != (insn & 0xff00)) overflow = true; - bfd_put_16 (abfd, insn, contents + nraddr); + bfd_put_16 (abfd, (bfd_vma) insn, contents + nraddr); break; case R_SH_PCDISP: insn += adjust / 2; if ((oinsn & 0xf000) != (insn & 0xf000)) overflow = true; - bfd_put_16 (abfd, insn, contents + nraddr); + bfd_put_16 (abfd, (bfd_vma) insn, contents + nraddr); break; case R_SH_PCRELIMM8BY4: @@ -1335,26 +1337,26 @@ sh_relax_delete_bytes (abfd, sec, addr, count) } if ((oinsn & 0xff00) != (insn & 0xff00)) overflow = true; - bfd_put_16 (abfd, insn, contents + nraddr); + bfd_put_16 (abfd, (bfd_vma) insn, contents + nraddr); break; case R_SH_SWITCH8: voff += adjust; if (voff < 0 || voff >= 0xff) overflow = true; - bfd_put_8 (abfd, voff, contents + nraddr); + bfd_put_8 (abfd, (bfd_vma) voff, contents + nraddr); break; case R_SH_SWITCH16: voff += adjust; if (voff < - 0x8000 || voff >= 0x8000) overflow = true; - bfd_put_signed_16 (abfd, voff, contents + nraddr); + bfd_put_signed_16 (abfd, (bfd_vma) voff, contents + nraddr); break; case R_SH_SWITCH32: voff += adjust; - bfd_put_signed_32 (abfd, voff, contents + nraddr); + bfd_put_signed_32 (abfd, (bfd_vma) voff, contents + nraddr); break; case R_SH_USES: @@ -1517,7 +1519,7 @@ sh_relax_delete_bytes (abfd, sec, addr, count) { /* Tail recursion. */ return sh_relax_delete_bytes (abfd, sec, alignaddr, - alignto - alignaddr); + (int) (alignto - alignaddr)); } } @@ -2643,13 +2645,15 @@ sh_align_loads (abfd, sec, internal_relocs, contents, pswapped) struct internal_reloc *irel, *irelend; bfd_vma *labels = NULL; bfd_vma *label, *label_end; + bfd_size_type amt; *pswapped = false; irelend = internal_relocs + sec->reloc_count; /* Get all the addresses with labels on them. */ - labels = (bfd_vma *) bfd_malloc (sec->reloc_count * sizeof (bfd_vma)); + amt = (bfd_size_type) sec->reloc_count * sizeof (bfd_vma); + labels = (bfd_vma *) bfd_malloc (amt); if (labels == NULL) goto error_return; label_end = labels; @@ -2718,8 +2722,8 @@ sh_swap_insns (abfd, sec, relocs, contents, addr) /* Swap the instructions themselves. */ i1 = bfd_get_16 (abfd, contents + addr); i2 = bfd_get_16 (abfd, contents + addr + 2); - bfd_put_16 (abfd, i2, contents + addr); - bfd_put_16 (abfd, i1, contents + addr + 2); + bfd_put_16 (abfd, (bfd_vma) i2, contents + addr); + bfd_put_16 (abfd, (bfd_vma) i1, contents + addr + 2); /* Adjust all reloc addresses. */ irelend = internal_relocs + sec->reloc_count; @@ -2787,7 +2791,7 @@ sh_swap_insns (abfd, sec, relocs, contents, addr) insn += add / 2; if ((oinsn & 0xff00) != (insn & 0xff00)) overflow = true; - bfd_put_16 (abfd, insn, loc); + bfd_put_16 (abfd, (bfd_vma) insn, loc); break; case R_SH_PCDISP: @@ -2796,7 +2800,7 @@ sh_swap_insns (abfd, sec, relocs, contents, addr) insn += add / 2; if ((oinsn & 0xf000) != (insn & 0xf000)) overflow = true; - bfd_put_16 (abfd, insn, loc); + bfd_put_16 (abfd, (bfd_vma) insn, loc); break; case R_SH_PCRELIMM8BY4: @@ -2813,7 +2817,7 @@ sh_swap_insns (abfd, sec, relocs, contents, addr) insn += add / 2; if ((oinsn & 0xff00) != (insn & 0xff00)) overflow = true; - bfd_put_16 (abfd, insn, loc); + bfd_put_16 (abfd, (bfd_vma) insn, loc); } break; @@ -3035,7 +3039,7 @@ sh_coff_get_relocated_section_contents (output_bfd, link_info, link_order, symbols); memcpy (data, coff_section_data (input_bfd, input_section)->contents, - input_section->_raw_size); + (size_t) input_section->_raw_size); if ((input_section->flags & SEC_RELOC) != 0 && input_section->reloc_count > 0) @@ -3044,6 +3048,7 @@ sh_coff_get_relocated_section_contents (output_bfd, link_info, link_order, bfd_byte *esym, *esymend; struct internal_syment *isymp; asection **secpp; + bfd_size_type amt; if (! _bfd_coff_get_external_symbols (input_bfd)) goto error_return; @@ -3054,14 +3059,15 @@ sh_coff_get_relocated_section_contents (output_bfd, link_info, link_order, if (internal_relocs == NULL) goto error_return; - internal_syms = ((struct internal_syment *) - bfd_malloc (obj_raw_syment_count (input_bfd) - * sizeof (struct internal_syment))); + amt = obj_raw_syment_count (input_bfd); + amt *= sizeof (struct internal_syment); + internal_syms = (struct internal_syment *) bfd_malloc (amt); if (internal_syms == NULL) goto error_return; - sections = (asection **) bfd_malloc (obj_raw_syment_count (input_bfd) - * sizeof (asection *)); + amt = obj_raw_syment_count (input_bfd); + amt *= sizeof (asection *); + sections = (asection **) bfd_malloc (amt); if (sections == NULL) goto error_return; |