coffcode.h
来自「基于4个mips核的noc设计」· C头文件 代码 · 共 2,097 行 · 第 1/5 页
H
2,097 行
/* FIXME: Microsoft uses NODUPLICATES and ASSOCIATIVE, but gnu uses ANY and SAME_SIZE. Unfortunately, gnu doesn't do the comdat symbols right. So, until we can fix it to do the right thing, we are temporarily disabling comdats for the MS types (they're used in DLLs and C++, but we don't support *their* C++ libraries anyway - DJ. */ /* Cygwin does not follow the MS style, and uses ANY and SAME_SIZE where NODUPLICATES and ASSOCIATIVE should be used. For Interix, we just do the right thing up front. */ switch (aux.x_scn.x_comdat) { case IMAGE_COMDAT_SELECT_NODUPLICATES:#ifdef STRICT_PE_FORMAT sec_flags |= SEC_LINK_DUPLICATES_ONE_ONLY;#else sec_flags &= ~SEC_LINK_ONCE;#endif break; case IMAGE_COMDAT_SELECT_ANY: sec_flags |= SEC_LINK_DUPLICATES_DISCARD; break; case IMAGE_COMDAT_SELECT_SAME_SIZE: sec_flags |= SEC_LINK_DUPLICATES_SAME_SIZE; break; case IMAGE_COMDAT_SELECT_EXACT_MATCH: /* Not yet fully implemented ??? */ sec_flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS; break; /* debug$S gets this case; other implications ??? */ /* There may be no symbol... we'll search the whole table... Is this the right place to play this game? Or should we do it when reading it in. */ case IMAGE_COMDAT_SELECT_ASSOCIATIVE:#ifdef STRICT_PE_FORMAT /* FIXME: This is not currently implemented. */ sec_flags |= SEC_LINK_DUPLICATES_DISCARD;#else sec_flags &= ~SEC_LINK_ONCE;#endif break; default: /* 0 means "no symbol" */ /* debug$F gets this case; other implications ??? */ sec_flags |= SEC_LINK_DUPLICATES_DISCARD; break; } } break; case 2: /* Gas mode: the first matching on partial name. */#ifndef TARGET_UNDERSCORE#define TARGET_UNDERSCORE 0#endif /* Is this the name we're looking for? */ if (strcmp (target_name, symname + (TARGET_UNDERSCORE ? 1 : 0)) != 0) { /* Not the name we're looking for */ esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd); continue; } /* Fall through. */ case 1: /* MSVC mode: the lexically second symbol (or drop through from the above). */ { char *newname; /* This must the the second symbol with the section #. It is the actual symbol name. Intel puts the two adjacent, but Alpha (at least) spreads them out. */ section->comdat = bfd_alloc (abfd, sizeof (struct bfd_comdat_info)); if (section->comdat == NULL) abort (); section->comdat->symbol = (esym - esymstart) / bfd_coff_symesz (abfd); newname = bfd_alloc (abfd, strlen (symname) + 1); if (newname == NULL) abort (); strcpy (newname, symname); section->comdat->name = newname; } goto breakloop; } } esym += (isym.n_numaux + 1) * bfd_coff_symesz (abfd); } breakloop: return sec_flags;}/* The PE version; see above for the general comments. Since to set the SEC_LINK_ONCE and associated flags, we have to look at the symbol table anyway, we return the symbol table index of the symbol being used as the COMDAT symbol. This is admittedly ugly, but there's really nowhere else that we have access to the required information. FIXME: Is the COMDAT symbol index used for any purpose other than objdump? */static flagwordstyp_to_sec_flags (abfd, hdr, name, section) bfd *abfd; PTR hdr; const char *name; asection *section;{ struct internal_scnhdr *internal_s = (struct internal_scnhdr *) hdr; long styp_flags = internal_s->s_flags; flagword sec_flags; /* Assume read only unless IMAGE_SCN_MEM_WRITE is specified. */ sec_flags = SEC_READONLY; /* Process each flag bit in styp_flags in turn. */ while (styp_flags) { long flag = styp_flags & - styp_flags; char * unhandled = NULL; styp_flags &= ~ flag; /* We infer from the distinct read/write/execute bits the settings of some of the bfd flags; the actual values, should we need them, are also in pei_section_data (abfd, section)->pe_flags. */ switch (flag) { case STYP_DSECT: unhandled = "STYP_DSECT"; break; case STYP_GROUP: unhandled = "STYP_GROUP"; break; case STYP_COPY: unhandled = "STYP_COPY"; break; case STYP_OVER: unhandled = "STYP_OVER"; break;#ifdef SEC_NEVER_LOAD case STYP_NOLOAD: sec_flags |= SEC_NEVER_LOAD; break;#endif case IMAGE_SCN_MEM_READ: /* Ignored, assume it always to be true. */ break; case IMAGE_SCN_TYPE_NO_PAD: /* Skip. */ break; case IMAGE_SCN_LNK_OTHER: unhandled = "IMAGE_SCN_LNK_OTHER"; break; case IMAGE_SCN_MEM_NOT_CACHED: unhandled = "IMAGE_SCN_MEM_NOT_CACHED"; break; case IMAGE_SCN_MEM_NOT_PAGED: unhandled = "IMAGE_SCN_MEM_NOT_PAGED"; break; case IMAGE_SCN_MEM_EXECUTE: sec_flags |= SEC_CODE; break; case IMAGE_SCN_MEM_WRITE: sec_flags &= ~ SEC_READONLY; break; case IMAGE_SCN_MEM_DISCARDABLE: sec_flags |= SEC_DEBUGGING; break; case IMAGE_SCN_MEM_SHARED: sec_flags |= SEC_SHARED; break; case IMAGE_SCN_LNK_REMOVE: sec_flags |= SEC_EXCLUDE; break; case IMAGE_SCN_CNT_CODE: sec_flags |= SEC_CODE | SEC_ALLOC | SEC_LOAD; break; case IMAGE_SCN_CNT_INITIALIZED_DATA: sec_flags |= SEC_DATA | SEC_ALLOC | SEC_LOAD; break; case IMAGE_SCN_CNT_UNINITIALIZED_DATA: sec_flags |= SEC_ALLOC; break; case IMAGE_SCN_LNK_INFO: /* We mark these as SEC_DEBUGGING, but only if COFF_PAGE_SIZE is defined. coff_compute_section_file_positions uses COFF_PAGE_SIZE to ensure that the low order bits of the section VMA and the file offset match. If we don't know COFF_PAGE_SIZE, we can't ensure the correct correspondence, and demand page loading of the file will fail. */#ifdef COFF_PAGE_SIZE sec_flags |= SEC_DEBUGGING;#endif break; case IMAGE_SCN_LNK_COMDAT: /* COMDAT gets very special treatment. */ sec_flags = handle_COMDAT (abfd, sec_flags, hdr, name, section); break; default: /* Silently ignore for now. */ break; } /* If the section flag was not handled, report it here. This will allow users of the BFD library to report a problem but continue executing. Tools which need to be aware of these problems (such as the linker) can override the default bfd_error_handler to intercept these reports. */ if (unhandled != NULL) (*_bfd_error_handler) (_("%s (%s): Section flag %s (0x%x) ignored"), bfd_get_filename (abfd), name, unhandled, flag); }#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) /* As a GNU extension, if the name begins with .gnu.linkonce, we only link a single copy of the section. This is used to support g++. g++ will emit each template expansion in its own section. The symbols will be defined as weak, so that multiple definitions are permitted. The GNU linker extension is to actually discard all but one of the sections. */ if (strncmp (name, ".gnu.linkonce", sizeof ".gnu.linkonce" - 1) == 0) sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD;#endif return sec_flags;}#endif /* COFF_WITH_PE */#define get_index(symbol) ((symbol)->udata.i)/*INTERNAL_DEFINITION bfd_coff_backend_dataCODE_FRAGMENT.{* COFF symbol classifications. *}..enum coff_symbol_classification.{. {* Global symbol. *}. COFF_SYMBOL_GLOBAL,. {* Common symbol. *}. COFF_SYMBOL_COMMON,. {* Undefined symbol. *}. COFF_SYMBOL_UNDEFINED,. {* Local symbol. *}. COFF_SYMBOL_LOCAL,. {* PE section symbol. *}. COFF_SYMBOL_PE_SECTION.};.Special entry points for gdb to swap in coff symbol table parts:.typedef struct.{. void (*_bfd_coff_swap_aux_in) PARAMS ((. bfd *abfd,. PTR ext,. int type,. int class,. int indaux,. int numaux,. PTR in));.. void (*_bfd_coff_swap_sym_in) PARAMS ((. bfd *abfd ,. PTR ext,. PTR in));.. void (*_bfd_coff_swap_lineno_in) PARAMS ((. bfd *abfd,. PTR ext,. PTR in));.Special entry points for gas to swap out coff parts:. unsigned int (*_bfd_coff_swap_aux_out) PARAMS ((. bfd *abfd,. PTR in,. int type,. int class,. int indaux,. int numaux,. PTR ext));.. unsigned int (*_bfd_coff_swap_sym_out) PARAMS ((. bfd *abfd,. PTR in,. PTR ext));.. unsigned int (*_bfd_coff_swap_lineno_out) PARAMS ((. bfd *abfd,. PTR in,. PTR ext));.. unsigned int (*_bfd_coff_swap_reloc_out) PARAMS ((. bfd *abfd,. PTR src,. PTR dst));.. unsigned int (*_bfd_coff_swap_filehdr_out) PARAMS ((. bfd *abfd,. PTR in,. PTR out));.. unsigned int (*_bfd_coff_swap_aouthdr_out) PARAMS ((. bfd *abfd,. PTR in,. PTR out));.. unsigned int (*_bfd_coff_swap_scnhdr_out) PARAMS ((. bfd *abfd,. PTR in,. PTR out));.Special entry points for generic COFF routines to call targetdependent COFF routines:. unsigned int _bfd_filhsz;. unsigned int _bfd_aoutsz;. unsigned int _bfd_scnhsz;. unsigned int _bfd_symesz;. unsigned int _bfd_auxesz;. unsigned int _bfd_relsz;. unsigned int _bfd_linesz;. unsigned int _bfd_filnmlen;. boolean _bfd_coff_long_filenames;. boolean _bfd_coff_long_section_names;. unsigned int _bfd_coff_default_section_alignment_power;. boolean _bfd_coff_force_symnames_in_strings;. unsigned int _bfd_coff_debug_string_prefix_length;. void (*_bfd_coff_swap_filehdr_in) PARAMS ((. bfd *abfd,. PTR ext,. PTR in));. void (*_bfd_coff_swap_aouthdr_in) PARAMS ((. bfd *abfd,. PTR ext,. PTR in));. void (*_bfd_coff_swap_scnhdr_in) PARAMS ((. bfd *abfd,. PTR ext,. PTR in));. void (*_bfd_coff_swap_reloc_in) PARAMS ((. bfd *abfd,. PTR ext,. PTR in));. boolean (*_bfd_coff_bad_format_hook) PARAMS ((. bfd *abfd,. PTR internal_filehdr));. boolean (*_bfd_coff_set_arch_mach_hook) PARAMS ((. bfd *abfd,. PTR internal_filehdr));. PTR (*_bfd_coff_mkobject_hook) PARAMS ((. bfd *abfd,. PTR internal_filehdr,. PTR internal_aouthdr));. flagword (*_bfd_styp_to_sec_flags_hook) PARAMS ((. bfd *abfd,. PTR internal_scnhdr,. const char *name,. asection *section));. void (*_bfd_set_alignment_hook) PARAMS ((. bfd *abfd,. asection *sec,. PTR internal_scnhdr));. boolean (*_bfd_coff_slurp_symbol_table) PARAMS ((. bfd *abfd));. boolean (*_bfd_coff_symname_in_debug) PARAMS ((. bfd *abfd,. struct internal_syment *sym));. boolean (*_bfd_coff_pointerize_aux_hook) PARAMS ((. bfd *abfd,. combined_entry_type *table_base,. combined_entry_type *symbol,. unsigned int indaux,. combined_entry_type *aux));. boolean (*_bfd_coff_print_aux) PARAMS ((. bfd *abfd,. FILE *file,. combined_entry_type *table_base,. combined_entry_type *symbol,. combined_entry_type *aux,. unsigned int indaux));. void (*_bfd_coff_reloc16_extra_cases) PARAMS ((. bfd *abfd,. struct bfd_link_info *link_info,. struct bfd_link_order *link_order,
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?