archures.c
来自「基于4个mips核的noc设计」· C语言 代码 · 共 1,055 行 · 第 1/2 页
C
1,055 行
*/const bfd_arch_info_type bfd_default_arch_struct = { 32, 32, 8, bfd_arch_unknown, 0, "unknown", "unknown", 2, true, bfd_default_compatible, bfd_default_scan, 0,};/*FUNCTION bfd_set_arch_infoSYNOPSIS void bfd_set_arch_info(bfd *abfd, const bfd_arch_info_type *arg);DESCRIPTION Set the architecture info of @var{abfd} to @var{arg}.*/voidbfd_set_arch_info (abfd, arg) bfd *abfd; const bfd_arch_info_type *arg;{ abfd->arch_info = arg;}/*INTERNAL_FUNCTION bfd_default_set_arch_machSYNOPSIS boolean bfd_default_set_arch_mach(bfd *abfd, enum bfd_architecture arch, unsigned long mach);DESCRIPTION Set the architecture and machine type in BFD @var{abfd} to @var{arch} and @var{mach}. Find the correct pointer to a structure and insert it into the <<arch_info>> pointer.*/booleanbfd_default_set_arch_mach (abfd, arch, mach) bfd *abfd; enum bfd_architecture arch; unsigned long mach;{ const bfd_arch_info_type * const *app, *ap; for (app = bfd_archures_list; *app != NULL; app++) { for (ap = *app; ap != NULL; ap = ap->next) { if (ap->arch == arch && (ap->mach == mach || (mach == 0 && ap->the_default))) { abfd->arch_info = ap; return true; } } } abfd->arch_info = &bfd_default_arch_struct; bfd_set_error (bfd_error_bad_value); return false;}/*FUNCTION bfd_get_archSYNOPSIS enum bfd_architecture bfd_get_arch(bfd *abfd);DESCRIPTION Return the enumerated type which describes the BFD @var{abfd}'s architecture.*/enum bfd_architecturebfd_get_arch (abfd) bfd *abfd;{ return abfd->arch_info->arch;}/*FUNCTION bfd_get_machSYNOPSIS unsigned long bfd_get_mach(bfd *abfd);DESCRIPTION Return the long type which describes the BFD @var{abfd}'s machine.*/unsigned longbfd_get_mach (abfd) bfd *abfd;{ return abfd->arch_info->mach;}/*FUNCTION bfd_arch_bits_per_byteSYNOPSIS unsigned int bfd_arch_bits_per_byte(bfd *abfd);DESCRIPTION Return the number of bits in one of the BFD @var{abfd}'s architecture's bytes.*/unsigned intbfd_arch_bits_per_byte (abfd) bfd *abfd;{ return abfd->arch_info->bits_per_byte;}/*FUNCTION bfd_arch_bits_per_addressSYNOPSIS unsigned int bfd_arch_bits_per_address(bfd *abfd);DESCRIPTION Return the number of bits in one of the BFD @var{abfd}'s architecture's addresses.*/unsigned intbfd_arch_bits_per_address (abfd) bfd *abfd;{ return abfd->arch_info->bits_per_address;}/*INTERNAL_FUNCTION bfd_default_compatibleSYNOPSIS const bfd_arch_info_type *bfd_default_compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b);DESCRIPTION The default function for testing for compatibility.*/const bfd_arch_info_type *bfd_default_compatible (a, b) const bfd_arch_info_type *a; const bfd_arch_info_type *b;{ if (a->arch != b->arch) return NULL; if (a->mach > b->mach) return a; if (b->mach > a->mach) return b; return a;}/*INTERNAL_FUNCTION bfd_default_scanSYNOPSIS boolean bfd_default_scan(const struct bfd_arch_info *info, const char *string);DESCRIPTION The default function for working out whether this is an architecture hit and a machine hit.*/booleanbfd_default_scan (info, string) const struct bfd_arch_info *info; const char *string;{ const char *ptr_src; const char *ptr_tst; unsigned long number; enum bfd_architecture arch; const char *printable_name_colon; /* Exact match of the architecture name (ARCH_NAME) and also the default architecture? */ if (strcasecmp (string, info->arch_name) == 0 && info->the_default) return true; /* Exact match of the machine name (PRINTABLE_NAME)? */ if (strcasecmp (string, info->printable_name) == 0) return true; /* Given that printable_name contains no colon, attempt to match: ARCH_NAME [ ":" ] PRINTABLE_NAME? */ printable_name_colon = strchr (info->printable_name, ':'); if (printable_name_colon == NULL) { int strlen_arch_name = strlen (info->arch_name); if (strncasecmp (string, info->arch_name, strlen_arch_name) == 0) { if (string[strlen_arch_name] == ':') { if (strcasecmp (string + strlen_arch_name + 1, info->printable_name) == 0) return true; } else { if (strcasecmp (string + strlen_arch_name, info->printable_name) == 0) return true; } } } /* Given that PRINTABLE_NAME has the form: <arch> ":" <mach>; Attempt to match: <arch> <mach>? */ if (printable_name_colon != NULL) { int colon_index = printable_name_colon - info->printable_name; if (strncasecmp (string, info->printable_name, colon_index) == 0 && strcasecmp (string + colon_index, info->printable_name + colon_index + 1) == 0) return true; } /* Given that PRINTABLE_NAME has the form: <arch> ":" <mach>; Do not attempt to match just <mach>, it could be ambigious. This test is left until later. */ /* NOTE: The below is retained for compatibility only. Please do not add to this code. */ /* See how much of the supplied string matches with the architecture, eg the string m68k:68020 would match the 68k entry up to the :, then we get left with the machine number. */ for (ptr_src = string, ptr_tst = info->arch_name; *ptr_src && *ptr_tst; ptr_src++, ptr_tst++) { if (*ptr_src != *ptr_tst) break; } /* Chewed up as much of the architecture as will match, skip any colons. */ if (*ptr_src == ':') ptr_src++; if (*ptr_src == 0) { /* Nothing more, then only keep this one if it is the default machine for this architecture. */ return info->the_default; } number = 0; while (isdigit ((unsigned char) *ptr_src)) { number = number * 10 + *ptr_src - '0'; ptr_src++; } /* NOTE: The below is retained for compatibility only. PLEASE DO NOT ADD TO THIS CODE. */ switch (number) { /* FIXME: These are needed to parse IEEE objects. */ /* The following seven case's are here only for compatibility with older binutils (at least IEEE objects from binutils 2.9.1 require them). */ case bfd_mach_m68000: case bfd_mach_m68010: case bfd_mach_m68020: case bfd_mach_m68030: case bfd_mach_m68040: case bfd_mach_m68060: case bfd_mach_cpu32: arch = bfd_arch_m68k; break; case 68000: arch = bfd_arch_m68k; number = bfd_mach_m68000; break; case 68010: arch = bfd_arch_m68k; number = bfd_mach_m68010; break; case 68020: arch = bfd_arch_m68k; number = bfd_mach_m68020; break; case 68030: arch = bfd_arch_m68k; number = bfd_mach_m68030; break; case 68040: arch = bfd_arch_m68k; number = bfd_mach_m68040; break; case 68060: arch = bfd_arch_m68k; number = bfd_mach_m68060; break; case 68332: arch = bfd_arch_m68k; number = bfd_mach_cpu32; break; case 5200: arch = bfd_arch_m68k; number = bfd_mach_mcf5200; break; case 5206: arch = bfd_arch_m68k; number = bfd_mach_mcf5206e; break; case 5307: arch = bfd_arch_m68k; number = bfd_mach_mcf5307; break; case 5407: arch = bfd_arch_m68k; number = bfd_mach_mcf5407; break; case 32000: arch = bfd_arch_we32k; break; case 3000: arch = bfd_arch_mips; number = bfd_mach_mips3000; break; case 4000: arch = bfd_arch_mips; number = bfd_mach_mips4000; break; case 6000: arch = bfd_arch_rs6000; break; case 7410: arch = bfd_arch_sh; number = bfd_mach_sh_dsp; break; case 7708: arch = bfd_arch_sh; number = bfd_mach_sh3; break; case 7729: arch = bfd_arch_sh; number = bfd_mach_sh3_dsp; break; case 7750: arch = bfd_arch_sh; number = bfd_mach_sh4; break; default: return false; } if (arch != info->arch) return false; if (number != info->mach) return false; return true;}/*FUNCTION bfd_get_arch_infoSYNOPSIS const bfd_arch_info_type * bfd_get_arch_info(bfd *abfd);DESCRIPTION Return the architecture info struct in @var{abfd}.*/const bfd_arch_info_type *bfd_get_arch_info (abfd) bfd *abfd;{ return abfd->arch_info;}/*FUNCTION bfd_lookup_archSYNOPSIS const bfd_arch_info_type *bfd_lookup_arch (enum bfd_architecture arch, unsigned long machine);DESCRIPTION Look for the architecure info structure which matches the arguments @var{arch} and @var{machine}. A machine of 0 matches the machine/architecture structure which marks itself as the default.*/const bfd_arch_info_type *bfd_lookup_arch (arch, machine) enum bfd_architecture arch; unsigned long machine;{ const bfd_arch_info_type * const *app, *ap; for (app = bfd_archures_list; *app != NULL; app++) { for (ap = *app; ap != NULL; ap = ap->next) { if (ap->arch == arch && (ap->mach == machine || (machine == 0 && ap->the_default))) return ap; } } return NULL;}/*FUNCTION bfd_printable_arch_machSYNOPSIS const char *bfd_printable_arch_mach (enum bfd_architecture arch, unsigned long machine);DESCRIPTION Return a printable string representing the architecture and machine type. This routine is depreciated.*/const char *bfd_printable_arch_mach (arch, machine) enum bfd_architecture arch; unsigned long machine;{ const bfd_arch_info_type *ap = bfd_lookup_arch (arch, machine); if (ap) return ap->printable_name; return "UNKNOWN!";}/*FUNCTION bfd_octets_per_byteSYNOPSIS unsigned int bfd_octets_per_byte(bfd *abfd);DESCRIPTION Return the number of octets (8-bit quantities) per target byte (minimum addressable unit). In most cases, this will be one, but some DSP targets have 16, 32, or even 48 bits per byte.*/unsigned intbfd_octets_per_byte (abfd) bfd *abfd;{ return bfd_arch_mach_octets_per_byte (bfd_get_arch (abfd), bfd_get_mach (abfd));}/*FUNCTION bfd_arch_mach_octets_per_byteSYNOPSIS unsigned int bfd_arch_mach_octets_per_byte(enum bfd_architecture arch, unsigned long machine);DESCRIPTION See bfd_octets_per_byte. This routine is provided for those cases where a bfd * is not available*/unsigned intbfd_arch_mach_octets_per_byte (arch, mach) enum bfd_architecture arch; unsigned long mach;{ const bfd_arch_info_type *ap = bfd_lookup_arch (arch, mach); if (ap) return ap->bits_per_byte / 8; return 1;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?