Missing from 2003-07-11 commit.

This commit is contained in:
Richard Sandiford 2003-07-14 06:27:24 +00:00
parent 542df965d0
commit 2808c7aac4
1 changed files with 35 additions and 0 deletions

View File

@ -220,3 +220,38 @@ const bfd_arch_info_type bfd_h8300_arch =
h8300_scan,
&h8300h_info_struct
};
/* Pad the given address to 32 bits, converting 16-bit and 24-bit
addresses into the values they would have had on a h8s target. */
bfd_vma
bfd_h8300_pad_address (bfd *abfd, bfd_vma address)
{
/* Cope with bfd_vma's larger than 32 bits. */
address &= 0xffffffffu;
switch (bfd_get_mach (abfd))
{
case bfd_mach_h8300:
case bfd_mach_h8300hn:
case bfd_mach_h8300sn:
case bfd_mach_h8300sxn:
/* Sign extend a 16-bit address. */
if (address >= 0x8000)
return address | 0xffff0000u;
return address;
case bfd_mach_h8300h:
/* Sign extend a 24-bit address. */
if (address >= 0x800000)
return address | 0xff000000u;
return address;
case bfd_mach_h8300s:
case bfd_mach_h8300sx:
return address;
default:
abort ();
}
}