subsegs.c
来自「基于4个mips核的noc设计」· C语言 代码 · 共 661 行 · 第 1/2 页
C
661 行
* sub-segment. * Frchain_root updated if needed. */#ifndef BFD_ASSEMBLERsegTsubseg_new (segname, subseg) const char *segname; subsegT subseg;{ int i; for (i = 0; i < (int) SEG_MAXIMUM_ORDINAL; i++) { const char *s; s = segment_name ((segT) i); if (strcmp (segname, s) == 0 || (segname[0] == '.' && strcmp (segname + 1, s) == 0)) { subseg_set ((segT) i, subseg); return (segT) i; }#ifdef obj_segment_name s = obj_segment_name ((segT) i); if (strcmp (segname, s) == 0 || (segname[0] == '.' && strcmp (segname + 1, s) == 0)) { subseg_set ((segT) i, subseg); return (segT) i; }#endif }#ifdef obj_add_segment { segT new_seg; new_seg = obj_add_segment (segname); subseg_set (new_seg, subseg); return new_seg; }#else as_bad (_("Attempt to switch to nonexistent segment \"%s\""), segname); return now_seg;#endif}voidsubseg_set (seg, subseg) /* begin assembly for a new sub-segment */ register segT seg; /* SEG_DATA or SEG_TEXT */ register subsegT subseg;{#ifndef MANY_SEGMENTS know (seg == SEG_DATA || seg == SEG_TEXT || seg == SEG_BSS || seg == SEG_ABSOLUTE);#endif if (seg != now_seg || subseg != now_subseg) { /* we just changed sub-segments */ subseg_set_rest (seg, subseg); } mri_common_symbol = NULL;}#else /* BFD_ASSEMBLER */segTsubseg_get (segname, force_new) const char *segname; int force_new;{ segT secptr; segment_info_type *seginfo; const char *now_seg_name = (now_seg ? bfd_get_section_name (stdoutput, now_seg) : 0); if (!force_new && now_seg_name && (now_seg_name == segname || !strcmp (now_seg_name, segname))) return now_seg; if (!force_new) secptr = bfd_make_section_old_way (stdoutput, segname); else secptr = bfd_make_section_anyway (stdoutput, segname); seginfo = seg_info (secptr); if (! seginfo) { /* Check whether output_section is set first because secptr may be bfd_abs_section_ptr. */ if (secptr->output_section != secptr) secptr->output_section = secptr; seginfo = (segment_info_type *) xmalloc (sizeof (*seginfo)); memset ((PTR) seginfo, 0, sizeof (*seginfo)); seginfo->fix_root = NULL; seginfo->fix_tail = NULL; seginfo->bfd_section = secptr; if (secptr == bfd_abs_section_ptr) abs_seg_info = seginfo; else if (secptr == bfd_und_section_ptr) und_seg_info = seginfo; else bfd_set_section_userdata (stdoutput, secptr, (PTR) seginfo); seginfo->frchainP = NULL; seginfo->lineno_list_head = seginfo->lineno_list_tail = NULL; seginfo->sym = NULL; seginfo->dot = NULL; } return secptr;}segTsubseg_new (segname, subseg) const char *segname; subsegT subseg;{ segT secptr; segment_info_type *seginfo; secptr = subseg_get (segname, 0); subseg_set_rest (secptr, subseg); seginfo = seg_info (secptr); if (! seginfo->frchainP) seginfo->frchainP = frchain_now; return secptr;}/* Like subseg_new, except a new section is always created, even if a section with that name already exists. */segTsubseg_force_new (segname, subseg) const char *segname; subsegT subseg;{ segT secptr; segment_info_type *seginfo; secptr = subseg_get (segname, 1); subseg_set_rest (secptr, subseg); seginfo = seg_info (secptr); if (! seginfo->frchainP) seginfo->frchainP = frchain_now; return secptr;}voidsubseg_set (secptr, subseg) segT secptr; subsegT subseg;{ if (! (secptr == now_seg && subseg == now_subseg)) subseg_set_rest (secptr, subseg); mri_common_symbol = NULL;}#ifndef obj_sec_sym_ok_for_reloc#define obj_sec_sym_ok_for_reloc(SEC) 0#endif/* Get the gas information we are storing for a section. */segment_info_type *seg_info (sec) segT sec;{ if (sec == bfd_abs_section_ptr) return abs_seg_info; else if (sec == bfd_und_section_ptr) return und_seg_info; else return (segment_info_type *) bfd_get_section_userdata (stdoutput, sec);}symbolS *section_symbol (sec) segT sec;{ segment_info_type *seginfo = seg_info (sec); symbolS *s; if (seginfo == 0) abort (); if (seginfo->sym) return seginfo->sym;#ifndef EMIT_SECTION_SYMBOLS#define EMIT_SECTION_SYMBOLS 1#endif if (! EMIT_SECTION_SYMBOLS#ifdef BFD_ASSEMBLER || symbol_table_frozen#endif ) { /* Here we know it won't be going into the symbol table. */ s = symbol_create (sec->name, sec, 0, &zero_address_frag); } else { s = symbol_find_base (sec->name, 0); if (s == NULL) s = symbol_new (sec->name, sec, 0, &zero_address_frag); else { if (S_GET_SEGMENT (s) == undefined_section) { S_SET_SEGMENT (s, sec); symbol_set_frag (s, &zero_address_frag); } } } S_CLEAR_EXTERNAL (s); /* Use the BFD section symbol, if possible. */ if (obj_sec_sym_ok_for_reloc (sec)) symbol_set_bfdsym (s, sec->symbol); seginfo->sym = s; return s;}#endif /* BFD_ASSEMBLER *//* Return whether the specified segment is thought to hold text. */#ifndef BFD_ASSEMBLERconst char * const nontext_section_names[] = { ".eh_frame", ".gcc_except_table",#ifdef OBJ_COFF#ifndef COFF_LONG_SECTION_NAMES ".eh_fram", ".gcc_exc",#endif#endif NULL};#endif /* ! BFD_ASSEMBLER */intsubseg_text_p (sec) segT sec;{#ifdef BFD_ASSEMBLER return (bfd_get_section_flags (stdoutput, sec) & SEC_CODE) != 0;#else /* ! BFD_ASSEMBLER */ const char * const *p; if (sec == data_section || sec == bss_section) return 0; for (p = nontext_section_names; *p != NULL; ++p) { if (strcmp (segment_name (sec), *p) == 0) return 0;#ifdef obj_segment_name if (strcmp (obj_segment_name (sec), *p) == 0) return 0;#endif } return 1;#endif /* ! BFD_ASSEMBLER */}voidsubsegs_print_statistics (file) FILE *file;{ frchainS *frchp; fprintf (file, "frag chains:\n"); for (frchp = frchain_root; frchp; frchp = frchp->frch_next) { int count = 0; fragS *fragp; /* If frch_subseg is non-zero, it's probably been chained onto the end of a previous subsection. Don't count it again. */ if (frchp->frch_subseg != 0) continue; /* Skip gas-internal sections. */ if (segment_name (frchp->frch_seg)[0] == '*') continue; for (fragp = frchp->frch_root; fragp; fragp = fragp->fr_next) {#if 0 switch (fragp->fr_type) { case rs_fill: fprintf (file, "f"); break; case rs_align: fprintf (file, "a"); break; case rs_align_code: fprintf (file, "c"); break; case rs_org: fprintf (file, "o"); break; case rs_machine_dependent: fprintf (file, "m"); break; case rs_space: fprintf (file, "s"); break; case 0: fprintf (file, "0"); break; default: fprintf (file, "?"); break; }#endif count++; } fprintf (file, "\n"); fprintf (file, "\t%p %-10s\t%10d frags\n", frchp, segment_name (frchp->frch_seg), count); }}/* end of subsegs.c */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?