coffcode.h
来自「基于4个mips核的noc设计」· C头文件 代码 · 共 2,097 行 · 第 1/5 页
H
2,097 行
pei_section_data (abfd, section)->virt_size = hdr->s_paddr; pei_section_data (abfd, section)->pe_flags = hdr->s_flags; section->lma = hdr->s_vaddr; /* check for extended relocs */ if (hdr->s_flags & IMAGE_SCN_LNK_NRELOC_OVFL) { struct external_reloc dst; struct internal_reloc n; int oldpos = bfd_tell (abfd); bfd_seek (abfd, hdr->s_relptr, 0); if (bfd_read ((PTR) & dst, 1, bfd_coff_relsz (abfd), abfd) != bfd_coff_relsz (abfd)) return; coff_swap_reloc_in (abfd, &dst, &n); bfd_seek (abfd, oldpos, 0); section->reloc_count = hdr->s_nreloc = n.r_vaddr; }}#undef ALIGN_SET#undef ELIFALIGN_SET#else /* ! COFF_WITH_PE */#ifdef RS6000COFF_C/* We grossly abuse this function to handle XCOFF overflow headers. When we see one, we correct the reloc and line number counts in the real header, and remove the section we just created. */static void coff_set_alignment_hook PARAMS ((bfd *, asection *, PTR));static voidcoff_set_alignment_hook (abfd, section, scnhdr) bfd *abfd; asection *section; PTR scnhdr;{ struct internal_scnhdr *hdr = (struct internal_scnhdr *) scnhdr; asection *real_sec; asection **ps; if ((hdr->s_flags & STYP_OVRFLO) == 0) return; real_sec = coff_section_from_bfd_index (abfd, hdr->s_nreloc); if (real_sec == NULL) return; real_sec->reloc_count = hdr->s_paddr; real_sec->lineno_count = hdr->s_vaddr; for (ps = &abfd->sections; *ps != NULL; ps = &(*ps)->next) { if (*ps == section) { *ps = (*ps)->next; --abfd->section_count; break; } }}#else /* ! RS6000COFF_C */#define coff_set_alignment_hook \ ((void (*) PARAMS ((bfd *, asection *, PTR))) bfd_void)#endif /* ! RS6000COFF_C */#endif /* ! COFF_WITH_PE */#endif /* ! COFF_ALIGN_IN_SECTION_HEADER */#ifndef coff_mkobjectstatic boolean coff_mkobject PARAMS ((bfd *));static booleancoff_mkobject (abfd) bfd * abfd;{ coff_data_type *coff; abfd->tdata.coff_obj_data = (struct coff_tdata *) bfd_zalloc (abfd, sizeof (coff_data_type)); if (abfd->tdata.coff_obj_data == 0) return false; coff = coff_data (abfd); coff->symbols = (coff_symbol_type *) NULL; coff->conversion_table = (unsigned int *) NULL; coff->raw_syments = (struct coff_ptr_struct *) NULL; coff->relocbase = 0; coff->local_toc_sym_map = 0;/* make_abs_section(abfd);*/ return true;}#endif/* Create the COFF backend specific information. */#ifndef coff_mkobject_hookstatic PTRcoff_mkobject_hook (abfd, filehdr, aouthdr) bfd * abfd; PTR filehdr; PTR aouthdr ATTRIBUTE_UNUSED;{ struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; coff_data_type *coff; if (coff_mkobject (abfd) == false) return NULL; coff = coff_data (abfd); coff->sym_filepos = internal_f->f_symptr; /* These members communicate important constants about the symbol table to GDB's symbol-reading code. These `constants' unfortunately vary among coff implementations... */ coff->local_n_btmask = N_BTMASK; coff->local_n_btshft = N_BTSHFT; coff->local_n_tmask = N_TMASK; coff->local_n_tshift = N_TSHIFT; coff->local_symesz = bfd_coff_symesz (abfd); coff->local_auxesz = bfd_coff_auxesz (abfd); coff->local_linesz = bfd_coff_linesz (abfd); coff->timestamp = internal_f->f_timdat; obj_raw_syment_count (abfd) = obj_conv_table_size (abfd) = internal_f->f_nsyms;#ifdef RS6000COFF_C if ((internal_f->f_flags & F_SHROBJ) != 0) abfd->flags |= DYNAMIC; if (aouthdr != NULL && internal_f->f_opthdr >= bfd_coff_aoutsz (abfd)) { struct internal_aouthdr *internal_a = (struct internal_aouthdr *) aouthdr; struct xcoff_tdata *xcoff; xcoff = xcoff_data (abfd);# ifdef U803XTOCMAGIC xcoff->xcoff64 = internal_f->f_magic == U803XTOCMAGIC;# else xcoff->xcoff64 = 0;# endif xcoff->full_aouthdr = true; xcoff->toc = internal_a->o_toc; xcoff->sntoc = internal_a->o_sntoc; xcoff->snentry = internal_a->o_snentry; xcoff->text_align_power = internal_a->o_algntext; xcoff->data_align_power = internal_a->o_algndata; xcoff->modtype = internal_a->o_modtype; xcoff->cputype = internal_a->o_cputype; xcoff->maxdata = internal_a->o_maxdata; xcoff->maxstack = internal_a->o_maxstack; }#endif#ifdef ARM /* Set the flags field from the COFF header read in */ if (! _bfd_coff_arm_set_private_flags (abfd, internal_f->f_flags)) coff->flags = 0;#endif#ifdef COFF_WITH_PE /* FIXME: I'm not sure this is ever executed, since peicode.h defines coff_mkobject_hook. */ if ((internal_f->f_flags & IMAGE_FILE_DEBUG_STRIPPED) == 0) abfd->flags |= HAS_DEBUG;#endif return (PTR) coff;}#endif/* Determine the machine architecture and type. FIXME: This is target dependent because the magic numbers are defined in the target dependent header files. But there is no particular need for this. If the magic numbers were moved to a separate file, this function would be target independent and would also be much more successful at linking together COFF files for different architectures. */static booleancoff_set_arch_mach_hook (abfd, filehdr) bfd *abfd; PTR filehdr;{ long machine; enum bfd_architecture arch; struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; machine = 0; switch (internal_f->f_magic) {#ifdef PPCMAGIC case PPCMAGIC: arch = bfd_arch_powerpc; machine = 0; /* what does this mean? (krk) */ break;#endif#ifdef I386MAGIC case I386MAGIC: case I386PTXMAGIC: case I386AIXMAGIC: /* Danbury PS/2 AIX C Compiler */ case LYNXCOFFMAGIC: /* shadows the m68k Lynx number below, sigh */ arch = bfd_arch_i386; machine = 0; break;#endif#ifdef IA64MAGIC case IA64MAGIC: arch = bfd_arch_ia64; machine = 0; break;#endif#ifdef A29K_MAGIC_BIG case A29K_MAGIC_BIG: case A29K_MAGIC_LITTLE: arch = bfd_arch_a29k; machine = 0; break;#endif#ifdef ARMMAGIC case ARMMAGIC: case ARMPEMAGIC: case THUMBPEMAGIC: arch = bfd_arch_arm; switch (internal_f->f_flags & F_ARM_ARCHITECTURE_MASK) { case F_ARM_2: machine = bfd_mach_arm_2; break; case F_ARM_2a: machine = bfd_mach_arm_2a; break; case F_ARM_3: machine = bfd_mach_arm_3; break; default: case F_ARM_3M: machine = bfd_mach_arm_3M; break; case F_ARM_4: machine = bfd_mach_arm_4; break; case F_ARM_4T: machine = bfd_mach_arm_4T; break; case F_ARM_5: machine = bfd_mach_arm_5; break; } break;#endif#ifdef MC68MAGIC case MC68MAGIC: case M68MAGIC:#ifdef MC68KBCSMAGIC case MC68KBCSMAGIC:#endif#ifdef APOLLOM68KMAGIC case APOLLOM68KMAGIC:#endif#ifdef LYNXCOFFMAGIC case LYNXCOFFMAGIC:#endif arch = bfd_arch_m68k; machine = bfd_mach_m68020; break;#endif#ifdef MC88MAGIC case MC88MAGIC: case MC88DMAGIC: case MC88OMAGIC: arch = bfd_arch_m88k; machine = 88100; break;#endif#ifdef Z8KMAGIC case Z8KMAGIC: arch = bfd_arch_z8k; switch (internal_f->f_flags & F_MACHMASK) { case F_Z8001: machine = bfd_mach_z8001; break; case F_Z8002: machine = bfd_mach_z8002; break; default: return false; } break;#endif#ifdef I860 case I860MAGIC: arch = bfd_arch_i860; break;#endif#ifdef I960#ifdef I960ROMAGIC case I960ROMAGIC: case I960RWMAGIC: arch = bfd_arch_i960; switch (F_I960TYPE & internal_f->f_flags) { default: case F_I960CORE: machine = bfd_mach_i960_core; break; case F_I960KB: machine = bfd_mach_i960_kb_sb; break; case F_I960MC: machine = bfd_mach_i960_mc; break; case F_I960XA: machine = bfd_mach_i960_xa; break; case F_I960CA: machine = bfd_mach_i960_ca; break; case F_I960KA: machine = bfd_mach_i960_ka_sa; break; case F_I960JX: machine = bfd_mach_i960_jx; break; case F_I960HX: machine = bfd_mach_i960_hx; break; } break;#endif#endif#ifdef RS6000COFF_C#ifdef XCOFF64 case U803XTOCMAGIC:#else case U802ROMAGIC: case U802WRMAGIC: case U802TOCMAGIC:#endif { int cputype; if (xcoff_data (abfd)->cputype != -1) cputype = xcoff_data (abfd)->cputype & 0xff; else { /* We did not get a value from the a.out header. If the file has not been stripped, we may be able to get the architecture information from the first symbol, if it is a .file symbol. */ if (obj_raw_syment_count (abfd) == 0) cputype = 0; else { bfd_byte *buf; struct internal_syment sym; buf = (bfd_byte *) bfd_malloc (bfd_coff_symesz (abfd)); if (bfd_seek (abfd, obj_sym_filepos (abfd), SEEK_SET) != 0 || (bfd_read (buf, 1, bfd_coff_symesz (abfd), abfd) != bfd_coff_symesz (abfd))) { free (buf); return false; } bfd_coff_swap_sym_in (abfd, (PTR) buf, (PTR) &sym); if (sym.n_sclass == C_FILE) cputype = sym.n_type & 0xff; else cputype = 0; free (buf); } } /* FIXME: We don't handle all cases here. */ switch (cputype) { default: case 0:#ifdef POWERMAC /* PowerPC Macs use the same magic numbers as RS/6000 (because that's how they were bootstrapped originally), but they are always PowerPC architecture. */ arch = bfd_arch_powerpc; machine = bfd_mach_ppc;#else#ifdef XCOFF64 arch = bfd_arch_powerpc; machine = bfd_mach_ppc_620;#else arch = bfd_arch_rs6000; machine = bfd_mach_rs6k;#endif#endif /* POWERMAC */ break; case 1: arch = bfd_arch_powerpc; machine = bfd_mach_ppc_601; break; case 2: /* 64 bit PowerPC */ arch = bfd_arch_powerpc; machine = bfd_mach_ppc_620; break; case 3: arch = bfd_arch_powerpc; machine = bfd_mach_ppc; break; case 4: arch = bfd_arch_rs6000; machine = bfd_mach_rs6k; break; } } break;#endif#ifdef WE32KMAGIC case WE32KMAGIC: arch = bfd_arch_we32k;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?