00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "bfd.h"
00027 #include "sysdep.h"
00028 #include "libbfd.h"
00029
00030 static bfd_boolean
00031 h8300_scan (const struct bfd_arch_info *info, const char *string)
00032 {
00033 if (*string != 'h' && *string != 'H')
00034 return FALSE;
00035
00036 string++;
00037 if (*string != '8')
00038 return FALSE;
00039
00040 string++;
00041 if (*string == '/')
00042 string++;
00043
00044 if (*string != '3')
00045 return FALSE;
00046 string++;
00047 if (*string != '0')
00048 return FALSE;
00049 string++;
00050 if (*string != '0')
00051 return FALSE;
00052 string++;
00053 if (*string == '-')
00054 string++;
00055
00056
00057
00058
00059
00060
00061 if (*string == ':')
00062 {
00063 string++;
00064 return h8300_scan (info, string);
00065 }
00066
00067 if (*string == 'h' || *string == 'H')
00068 {
00069 string++;
00070 if (*string == 'n' || *string == 'N')
00071 return (info->mach == bfd_mach_h8300hn);
00072
00073 return (info->mach == bfd_mach_h8300h);
00074 }
00075 else if (*string == 's' || *string == 'S')
00076 {
00077 string++;
00078 if (*string == 'n' || *string == 'N')
00079 return (info->mach == bfd_mach_h8300sn);
00080
00081 if (*string == 'x' || *string == 'X')
00082 {
00083 string++;
00084 if (*string == 'n' || *string == 'N')
00085 return (info->mach == bfd_mach_h8300sxn);
00086
00087 return (info->mach == bfd_mach_h8300sx);
00088 }
00089
00090 return (info->mach == bfd_mach_h8300s);
00091 }
00092 else
00093 return info->mach == bfd_mach_h8300;
00094 }
00095
00096
00097
00098
00099
00100 static const bfd_arch_info_type *
00101 compatible (const bfd_arch_info_type *in, const bfd_arch_info_type *out)
00102 {
00103 if (in->arch != out->arch)
00104 return 0;
00105 if (in->mach == bfd_mach_h8300sx && out->mach == bfd_mach_h8300s)
00106 return in;
00107 if (in->mach == bfd_mach_h8300s && out->mach == bfd_mach_h8300sx)
00108 return out;
00109 if (in->mach == bfd_mach_h8300sxn && out->mach == bfd_mach_h8300sn)
00110 return in;
00111 if (in->mach == bfd_mach_h8300sn && out->mach == bfd_mach_h8300sxn)
00112 return out;
00113
00114 if (in->mach != out->mach)
00115 return 0;
00116 else
00117 return in;
00118 }
00119
00120 static const bfd_arch_info_type h8300sxn_info_struct =
00121 {
00122 32,
00123 16,
00124 8,
00125 bfd_arch_h8300,
00126 bfd_mach_h8300sxn,
00127 "h8300sxn",
00128 "h8300sxn",
00129 1,
00130 FALSE,
00131 compatible,
00132 h8300_scan,
00133 0
00134 };
00135
00136 static const bfd_arch_info_type h8300sx_info_struct =
00137 {
00138 32,
00139 32,
00140 8,
00141 bfd_arch_h8300,
00142 bfd_mach_h8300sx,
00143 "h8300sx",
00144 "h8300sx",
00145 1,
00146 FALSE,
00147 compatible,
00148 h8300_scan,
00149 &h8300sxn_info_struct
00150 };
00151
00152 static const bfd_arch_info_type h8300sn_info_struct =
00153 {
00154 32,
00155 16,
00156 8,
00157 bfd_arch_h8300,
00158 bfd_mach_h8300sn,
00159 "h8300sn",
00160 "h8300sn",
00161 1,
00162 FALSE,
00163 compatible,
00164 h8300_scan,
00165 &h8300sx_info_struct
00166 };
00167
00168 static const bfd_arch_info_type h8300hn_info_struct =
00169 {
00170 32,
00171 16,
00172 8,
00173 bfd_arch_h8300,
00174 bfd_mach_h8300hn,
00175 "h8300hn",
00176 "h8300hn",
00177 1,
00178 FALSE,
00179 compatible,
00180 h8300_scan,
00181 &h8300sn_info_struct
00182 };
00183
00184 static const bfd_arch_info_type h8300s_info_struct =
00185 {
00186 32,
00187 32,
00188 8,
00189 bfd_arch_h8300,
00190 bfd_mach_h8300s,
00191 "h8300s",
00192 "h8300s",
00193 1,
00194 FALSE,
00195 compatible,
00196 h8300_scan,
00197 & h8300hn_info_struct
00198 };
00199
00200 static const bfd_arch_info_type h8300h_info_struct =
00201 {
00202 32,
00203 32,
00204 8,
00205 bfd_arch_h8300,
00206 bfd_mach_h8300h,
00207 "h8300h",
00208 "h8300h",
00209 1,
00210 FALSE,
00211 compatible,
00212 h8300_scan,
00213 &h8300s_info_struct
00214 };
00215
00216 const bfd_arch_info_type bfd_h8300_arch =
00217 {
00218 16,
00219 16,
00220 8,
00221 bfd_arch_h8300,
00222 bfd_mach_h8300,
00223 "h8300",
00224 "h8300",
00225 1,
00226 TRUE,
00227 compatible,
00228 h8300_scan,
00229 &h8300h_info_struct
00230 };
00231
00232
00233
00234
00235 bfd_vma
00236 bfd_h8300_pad_address (bfd *abfd, bfd_vma address)
00237 {
00238
00239 address &= 0xffffffffu;
00240
00241 switch (bfd_get_mach (abfd))
00242 {
00243 case bfd_mach_h8300:
00244 case bfd_mach_h8300hn:
00245 case bfd_mach_h8300sn:
00246 case bfd_mach_h8300sxn:
00247
00248 if (address >= 0x8000)
00249 return address | 0xffff0000u;
00250 return address;
00251
00252 case bfd_mach_h8300h:
00253
00254 if (address >= 0x800000)
00255 return address | 0xff000000u;
00256 return address;
00257
00258 case bfd_mach_h8300s:
00259 case bfd_mach_h8300sx:
00260 return address;
00261
00262 default:
00263 abort ();
00264 }
00265 }