ecoff.c
来自「基于4个mips核的noc设计」· C语言 代码 · 共 2,282 行 · 第 1/5 页
C
2,282 行
bitsize = ecoff_backend (abfd)->constructor_bitsize; section->alignment_power = 1; while ((1 << section->alignment_power) < bitsize / 8) ++section->alignment_power; reloc_chain->next = section->constructor_chain; section->constructor_chain = reloc_chain; section->_raw_size += bitsize / 8;#endif /* 0 */ /* Mark the symbol as a constructor. */ asym->flags |= BSF_CONSTRUCTOR; } break; } } return true;}/* Read an ECOFF symbol table. */boolean_bfd_ecoff_slurp_symbol_table (abfd) bfd *abfd;{ const struct ecoff_backend_data * const backend = ecoff_backend (abfd); const bfd_size_type external_ext_size = backend->debug_swap.external_ext_size; const bfd_size_type external_sym_size = backend->debug_swap.external_sym_size; void (* const swap_ext_in) PARAMS ((bfd *, PTR, EXTR *)) = backend->debug_swap.swap_ext_in; void (* const swap_sym_in) PARAMS ((bfd *, PTR, SYMR *)) = backend->debug_swap.swap_sym_in; bfd_size_type internal_size; ecoff_symbol_type *internal; ecoff_symbol_type *internal_ptr; char *eraw_src; char *eraw_end; FDR *fdr_ptr; FDR *fdr_end; /* If we've already read in the symbol table, do nothing. */ if (ecoff_data (abfd)->canonical_symbols != NULL) return true; /* Get the symbolic information. */ if (! _bfd_ecoff_slurp_symbolic_info (abfd, (asection *) NULL, &ecoff_data (abfd)->debug_info)) return false; if (bfd_get_symcount (abfd) == 0) return true; internal_size = bfd_get_symcount (abfd) * sizeof (ecoff_symbol_type); internal = (ecoff_symbol_type *) bfd_alloc (abfd, internal_size); if (internal == NULL) return false; internal_ptr = internal; eraw_src = (char *) ecoff_data (abfd)->debug_info.external_ext; eraw_end = (eraw_src + (ecoff_data (abfd)->debug_info.symbolic_header.iextMax * external_ext_size)); for (; eraw_src < eraw_end; eraw_src += external_ext_size, internal_ptr++) { EXTR internal_esym; (*swap_ext_in) (abfd, (PTR) eraw_src, &internal_esym); internal_ptr->symbol.name = (ecoff_data (abfd)->debug_info.ssext + internal_esym.asym.iss); if (!ecoff_set_symbol_info (abfd, &internal_esym.asym, &internal_ptr->symbol, 1, internal_esym.weakext)) return false; /* The alpha uses a negative ifd field for section symbols. */ if (internal_esym.ifd >= 0) internal_ptr->fdr = (ecoff_data (abfd)->debug_info.fdr + internal_esym.ifd); else internal_ptr->fdr = NULL; internal_ptr->local = false; internal_ptr->native = (PTR) eraw_src; } /* The local symbols must be accessed via the fdr's, because the string and aux indices are relative to the fdr information. */ fdr_ptr = ecoff_data (abfd)->debug_info.fdr; fdr_end = fdr_ptr + ecoff_data (abfd)->debug_info.symbolic_header.ifdMax; for (; fdr_ptr < fdr_end; fdr_ptr++) { char *lraw_src; char *lraw_end; lraw_src = ((char *) ecoff_data (abfd)->debug_info.external_sym + fdr_ptr->isymBase * external_sym_size); lraw_end = lraw_src + fdr_ptr->csym * external_sym_size; for (; lraw_src < lraw_end; lraw_src += external_sym_size, internal_ptr++) { SYMR internal_sym; (*swap_sym_in) (abfd, (PTR) lraw_src, &internal_sym); internal_ptr->symbol.name = (ecoff_data (abfd)->debug_info.ss + fdr_ptr->issBase + internal_sym.iss); if (!ecoff_set_symbol_info (abfd, &internal_sym, &internal_ptr->symbol, 0, 0)) return false; internal_ptr->fdr = fdr_ptr; internal_ptr->local = true; internal_ptr->native = (PTR) lraw_src; } } ecoff_data (abfd)->canonical_symbols = internal; return true;}/* Return the amount of space needed for the canonical symbols. */long_bfd_ecoff_get_symtab_upper_bound (abfd) bfd *abfd;{ if (! _bfd_ecoff_slurp_symbolic_info (abfd, (asection *) NULL, &ecoff_data (abfd)->debug_info)) return -1; if (bfd_get_symcount (abfd) == 0) return 0; return (bfd_get_symcount (abfd) + 1) * (sizeof (ecoff_symbol_type *));}/* Get the canonical symbols. */long_bfd_ecoff_get_symtab (abfd, alocation) bfd *abfd; asymbol **alocation;{ unsigned int counter = 0; ecoff_symbol_type *symbase; ecoff_symbol_type **location = (ecoff_symbol_type **) alocation; if (_bfd_ecoff_slurp_symbol_table (abfd) == false) return -1; if (bfd_get_symcount (abfd) == 0) return 0; symbase = ecoff_data (abfd)->canonical_symbols; while (counter < bfd_get_symcount (abfd)) { *(location++) = symbase++; counter++; } *location++ = (ecoff_symbol_type *) NULL; return bfd_get_symcount (abfd);}/* Turn ECOFF type information into a printable string. ecoff_emit_aggregate and ecoff_type_to_string are from gcc/mips-tdump.c, with swapping added and used_ptr removed. *//* Write aggregate information to a string. */static voidecoff_emit_aggregate (abfd, fdr, string, rndx, isym, which) bfd *abfd; FDR *fdr; char *string; RNDXR *rndx; long isym; const char *which;{ const struct ecoff_debug_swap * const debug_swap = &ecoff_backend (abfd)->debug_swap; struct ecoff_debug_info * const debug_info = &ecoff_data (abfd)->debug_info; unsigned int ifd = rndx->rfd; unsigned int indx = rndx->index; const char *name; if (ifd == 0xfff) ifd = isym; /* An ifd of -1 is an opaque type. An escaped index of 0 is a struct return type of a procedure compiled without -g. */ if (ifd == 0xffffffff || (rndx->rfd == 0xfff && indx == 0)) name = "<undefined>"; else if (indx == indexNil) name = "<no name>"; else { SYMR sym; if (debug_info->external_rfd == NULL) fdr = debug_info->fdr + ifd; else { RFDT rfd; (*debug_swap->swap_rfd_in) (abfd, ((char *) debug_info->external_rfd + ((fdr->rfdBase + ifd) * debug_swap->external_rfd_size)), &rfd); fdr = debug_info->fdr + rfd; } indx += fdr->isymBase; (*debug_swap->swap_sym_in) (abfd, ((char *) debug_info->external_sym + indx * debug_swap->external_sym_size), &sym); name = debug_info->ss + fdr->issBase + sym.iss; } sprintf (string, "%s %s { ifd = %u, index = %lu }", which, name, ifd, ((long) indx + debug_info->symbolic_header.iextMax));}/* Convert the type information to string format. */static char *ecoff_type_to_string (abfd, fdr, indx) bfd *abfd; FDR *fdr; unsigned int indx;{ union aux_ext *aux_ptr; int bigendian; AUXU u; struct qual { unsigned int type; int low_bound; int high_bound; int stride; } qualifiers[7]; unsigned int basic_type; int i; char buffer1[1024]; static char buffer2[1024]; char *p1 = buffer1; char *p2 = buffer2; RNDXR rndx; aux_ptr = ecoff_data (abfd)->debug_info.external_aux + fdr->iauxBase; bigendian = fdr->fBigendian; for (i = 0; i < 7; i++) { qualifiers[i].low_bound = 0; qualifiers[i].high_bound = 0; qualifiers[i].stride = 0; } if (AUX_GET_ISYM (bigendian, &aux_ptr[indx]) == (bfd_vma) -1) return "-1 (no type)"; _bfd_ecoff_swap_tir_in (bigendian, &aux_ptr[indx++].a_ti, &u.ti); basic_type = u.ti.bt; qualifiers[0].type = u.ti.tq0; qualifiers[1].type = u.ti.tq1; qualifiers[2].type = u.ti.tq2; qualifiers[3].type = u.ti.tq3; qualifiers[4].type = u.ti.tq4; qualifiers[5].type = u.ti.tq5; qualifiers[6].type = tqNil; /* * Go get the basic type. */ switch (basic_type) { case btNil: /* undefined */ strcpy (p1, "nil"); break; case btAdr: /* address - integer same size as pointer */ strcpy (p1, "address"); break; case btChar: /* character */ strcpy (p1, "char"); break; case btUChar: /* unsigned character */ strcpy (p1, "unsigned char"); break; case btShort: /* short */ strcpy (p1, "short"); break; case btUShort: /* unsigned short */ strcpy (p1, "unsigned short"); break; case btInt: /* int */ strcpy (p1, "int"); break; case btUInt: /* unsigned int */ strcpy (p1, "unsigned int"); break; case btLong: /* long */ strcpy (p1, "long"); break; case btULong: /* unsigned long */ strcpy (p1, "unsigned long"); break; case btFloat: /* float (real) */ strcpy (p1, "float"); break; case btDouble: /* Double (real) */ strcpy (p1, "double"); break; /* Structures add 1-2 aux words: 1st word is [ST_RFDESCAPE, offset] pointer to struct def; 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */ case btStruct: /* Structure (Record) */ _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx); ecoff_emit_aggregate (abfd, fdr, p1, &rndx, (long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]), "struct"); indx++; /* skip aux words */ break; /* Unions add 1-2 aux words: 1st word is [ST_RFDESCAPE, offset] pointer to union def; 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */ case btUnion: /* Union */ _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx); ecoff_emit_aggregate (abfd, fdr, p1, &rndx, (long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]), "union"); indx++; /* skip aux words */ break; /* Enumerations add 1-2 aux words: 1st word is [ST_RFDESCAPE, offset] pointer to enum def; 2nd word is file index if 1st word rfd is ST_RFDESCAPE. */ case btEnum: /* Enumeration */ _bfd_ecoff_swap_rndx_in (bigendian, &aux_ptr[indx].a_rndx, &rndx); ecoff_emit_aggregate (abfd, fdr, p1, &rndx, (long) AUX_GET_ISYM (bigendian, &aux_ptr[indx+1]), "enum"); indx++; /* skip aux words */ break; case btTypedef: /* defined via a typedef, isymRef points */ strcpy (p1, "typedef"); break; case btRange: /* subrange of int */ strcpy (p1, "subrange"); break; case btSet: /* pascal sets */ strcpy (p1, "set"); break; case btComplex: /* fortran complex */ strcpy (p1, "complex"); break; case btDComplex: /* fortran double complex */ strcpy (p1, "double complex"); break; case btIndirect: /* forward or unnamed typedef */ strcpy (p1, "forward/unamed typedef"); break; case btFixedDec: /* Fixed Decimal */ strcpy (p1, "fixed decimal"); break; case btFloatDec: /* Float Decimal */ strcpy (p1, "float decimal"); break; case btString: /* Varying Length Character String */ strcpy (p1, "string"); break; case btBit: /* Aligned Bit String */ strcpy (p1, "bit"); break; case btPicture: /* Picture */ strcpy (p1, "picture"); break; case btVoid: /* Void */ strcpy (p1, "void"); break; default: sprintf (p1, _("Unknown basic type %d"), (int) basic_type); break; } p1 += strlen (buffer1); /* * If this is a bitfield, get the bitsize. */ if (u.ti.fBitfield) { int bitsize; bitsize = AUX_GET_WIDTH (bigendian, &aux_ptr[indx++]); sprintf (p1, " : %d", bitsize); p1 += strlen (buffer1); } /* * Deal with any qualifiers. */ if (qualifiers[0].type != tqNil) { /* * Snarf up any array bounds in the correct order. Arrays * store 5 successive words in the aux. table: * word 0 RNDXR to type of the bounds (ie, int) * word 1 Current file descriptor index * word 2 low bound * word 3 high bound (or -1 if []) * word 4 stride size in bits */ for (i = 0; i < 7; i++) { if (qualifiers[i].type == tqArray) { qualifiers[i].low_bound = AUX_GET_DNLOW (bigendian, &aux_ptr[indx+2]); qualifiers[i].high_bound = AUX_GET_DNHIGH (bigendian, &aux_ptr[indx+3]); qualifiers[i].stride =
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?