From: Richard Sandiford Date: Mon, 14 Jul 2003 06:27:24 +0000 (+0000) Subject: Missing from 2003-07-11 commit. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2808c7aac49eec873c21ea6e2b95f732f38c8626;p=binutils-gdb.git Missing from 2003-07-11 commit. --- diff --git a/bfd/cpu-h8300.c b/bfd/cpu-h8300.c index 6ed0fff3638..1a4f4d7a065 100644 --- a/bfd/cpu-h8300.c +++ b/bfd/cpu-h8300.c @@ -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 (); + } +}