#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) \
#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:
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;
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)
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;
}
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
/* 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
{
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;
}
/* 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;
}
/* 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
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. */
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:
}
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:
{
/* Tail recursion. */
return sh_relax_delete_bytes (abfd, sec, alignaddr,
- alignto - alignaddr);
+ (int) (alignto - alignaddr));
}
}
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;
/* 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;
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:
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:
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;
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)
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;
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;