aoutx.h
来自「基于4个mips核的noc设计」· C头文件 代码 · 共 2,130 行 · 第 1/5 页
H
2,130 行
} if ((cache_ptr->flags & BSF_WEAK) != 0) { int type; switch (sym_pointer->e_type[0] & N_TYPE) { default: case N_ABS: type = N_WEAKA; break; case N_TEXT: type = N_WEAKT; break; case N_DATA: type = N_WEAKD; break; case N_BSS: type = N_WEAKB; break; case N_UNDF: type = N_WEAKU; break; } sym_pointer->e_type[0] = type; } PUT_WORD(abfd, value, sym_pointer->e_value); return true;}/* Native-level interface to symbols. */asymbol *NAME(aout,make_empty_symbol) (abfd) bfd *abfd;{ aout_symbol_type *new = (aout_symbol_type *)bfd_zalloc (abfd, sizeof (aout_symbol_type)); if (!new) return NULL; new->symbol.the_bfd = abfd; return &new->symbol;}/* Translate a set of internal symbols into external symbols. */booleanNAME(aout,translate_symbol_table) (abfd, in, ext, count, str, strsize, dynamic) bfd *abfd; aout_symbol_type *in; struct external_nlist *ext; bfd_size_type count; char *str; bfd_size_type strsize; boolean dynamic;{ struct external_nlist *ext_end; ext_end = ext + count; for (; ext < ext_end; ext++, in++) { bfd_vma x; x = GET_WORD (abfd, ext->e_strx); in->symbol.the_bfd = abfd; /* For the normal symbols, the zero index points at the number of bytes in the string table but is to be interpreted as the null string. For the dynamic symbols, the number of bytes in the string table is stored in the __DYNAMIC structure and the zero index points at an actual string. */ if (x == 0 && ! dynamic) in->symbol.name = ""; else if (x < strsize) in->symbol.name = str + x; else return false; in->symbol.value = GET_SWORD (abfd, ext->e_value); in->desc = bfd_h_get_16 (abfd, ext->e_desc); in->other = bfd_h_get_8 (abfd, ext->e_other); in->type = bfd_h_get_8 (abfd, ext->e_type); in->symbol.udata.p = NULL; if (! translate_from_native_sym_flags (abfd, in)) return false; if (dynamic) in->symbol.flags |= BSF_DYNAMIC; } return true;}/* We read the symbols into a buffer, which is discarded when this function exits. We read the strings into a buffer large enough to hold them all plus all the cached symbol entries. */booleanNAME(aout,slurp_symbol_table) (abfd) bfd *abfd;{ struct external_nlist *old_external_syms; aout_symbol_type *cached; size_t cached_size; /* If there's no work to be done, don't do any */ if (obj_aout_symbols (abfd) != (aout_symbol_type *) NULL) return true; old_external_syms = obj_aout_external_syms (abfd); if (! aout_get_external_symbols (abfd)) return false; cached_size = (obj_aout_external_sym_count (abfd) * sizeof (aout_symbol_type)); cached = (aout_symbol_type *) bfd_malloc (cached_size); if (cached == NULL && cached_size != 0) return false; if (cached_size != 0) memset (cached, 0, cached_size); /* Convert from external symbol information to internal. */ if (! (NAME(aout,translate_symbol_table) (abfd, cached, obj_aout_external_syms (abfd), obj_aout_external_sym_count (abfd), obj_aout_external_strings (abfd), obj_aout_external_string_size (abfd), false))) { free (cached); return false; } bfd_get_symcount (abfd) = obj_aout_external_sym_count (abfd); obj_aout_symbols (abfd) = cached; /* It is very likely that anybody who calls this function will not want the external symbol information, so if it was allocated because of our call to aout_get_external_symbols, we free it up right away to save space. */ if (old_external_syms == (struct external_nlist *) NULL && obj_aout_external_syms (abfd) != (struct external_nlist *) NULL) {#ifdef USE_MMAP bfd_free_window (&obj_aout_sym_window (abfd));#else free (obj_aout_external_syms (abfd));#endif obj_aout_external_syms (abfd) = NULL; } return true;}/* We use a hash table when writing out symbols so that we only write out a particular string once. This helps particularly when the linker writes out stabs debugging entries, because each different contributing object file tends to have many duplicate stabs strings. This hash table code breaks dbx on SunOS 4.1.3, so we don't do it if BFD_TRADITIONAL_FORMAT is set. */static bfd_size_type add_to_stringtab PARAMS ((bfd *, struct bfd_strtab_hash *, const char *, boolean));static boolean emit_stringtab PARAMS ((bfd *, struct bfd_strtab_hash *));/* Get the index of a string in a strtab, adding it if it is not already present. */static INLINE bfd_size_typeadd_to_stringtab (abfd, tab, str, copy) bfd *abfd; struct bfd_strtab_hash *tab; const char *str; boolean copy;{ boolean hash; bfd_size_type index; /* An index of 0 always means the empty string. */ if (str == 0 || *str == '\0') return 0; /* Don't hash if BFD_TRADITIONAL_FORMAT is set, because SunOS dbx doesn't understand a hashed string table. */ hash = true; if ((abfd->flags & BFD_TRADITIONAL_FORMAT) != 0) hash = false; index = _bfd_stringtab_add (tab, str, hash, copy); if (index != (bfd_size_type) -1) { /* Add BYTES_IN_WORD to the return value to account for the space taken up by the string table size. */ index += BYTES_IN_WORD; } return index;}/* Write out a strtab. ABFD is already at the right location in the file. */static booleanemit_stringtab (abfd, tab) register bfd *abfd; struct bfd_strtab_hash *tab;{ bfd_byte buffer[BYTES_IN_WORD]; /* The string table starts with the size. */ PUT_WORD (abfd, _bfd_stringtab_size (tab) + BYTES_IN_WORD, buffer); if (bfd_write ((PTR) buffer, 1, BYTES_IN_WORD, abfd) != BYTES_IN_WORD) return false; return _bfd_stringtab_emit (abfd, tab);}booleanNAME(aout,write_syms) (abfd) bfd *abfd;{ unsigned int count ; asymbol **generic = bfd_get_outsymbols (abfd); struct bfd_strtab_hash *strtab; strtab = _bfd_stringtab_init (); if (strtab == NULL) return false; for (count = 0; count < bfd_get_symcount (abfd); count++) { asymbol *g = generic[count]; bfd_size_type indx; struct external_nlist nsp; indx = add_to_stringtab (abfd, strtab, g->name, false); if (indx == (bfd_size_type) -1) goto error_return; PUT_WORD (abfd, indx, (bfd_byte *) nsp.e_strx); if (bfd_asymbol_flavour(g) == abfd->xvec->flavour) { bfd_h_put_16(abfd, aout_symbol(g)->desc, nsp.e_desc); bfd_h_put_8(abfd, aout_symbol(g)->other, nsp.e_other); bfd_h_put_8(abfd, aout_symbol(g)->type, nsp.e_type); } else { bfd_h_put_16(abfd,0, nsp.e_desc); bfd_h_put_8(abfd, 0, nsp.e_other); bfd_h_put_8(abfd, 0, nsp.e_type); } if (! translate_to_native_sym_flags (abfd, g, &nsp)) goto error_return; if (bfd_write((PTR)&nsp,1,EXTERNAL_NLIST_SIZE, abfd) != EXTERNAL_NLIST_SIZE) goto error_return; /* NB: `KEEPIT' currently overlays `udata.p', so set this only here, at the end. */ g->KEEPIT = count; } if (! emit_stringtab (abfd, strtab)) goto error_return; _bfd_stringtab_free (strtab); return true;error_return: _bfd_stringtab_free (strtab); return false;}longNAME(aout,get_symtab) (abfd, location) bfd *abfd; asymbol **location;{ unsigned int counter = 0; aout_symbol_type *symbase; if (!NAME(aout,slurp_symbol_table) (abfd)) return -1; for (symbase = obj_aout_symbols(abfd); counter++ < bfd_get_symcount (abfd);) *(location++) = (asymbol *) ( symbase++); *location++ =0; return bfd_get_symcount (abfd);}/* Standard reloc stuff *//* Output standard relocation information to a file in target byte order. */extern void NAME(aout,swap_std_reloc_out) PARAMS ((bfd *, arelent *, struct reloc_std_external *));voidNAME(aout,swap_std_reloc_out) (abfd, g, natptr) bfd *abfd; arelent *g; struct reloc_std_external *natptr;{ int r_index; asymbol *sym = *(g->sym_ptr_ptr); int r_extern; unsigned int r_length; int r_pcrel; int r_baserel, r_jmptable, r_relative; asection *output_section = sym->section->output_section; PUT_WORD(abfd, g->address, natptr->r_address); r_length = g->howto->size ; /* Size as a power of two */ r_pcrel = (int) g->howto->pc_relative; /* Relative to PC? */ /* XXX This relies on relocs coming from a.out files. */ r_baserel = (g->howto->type & 8) != 0; r_jmptable = (g->howto->type & 16) != 0; r_relative = (g->howto->type & 32) != 0;#if 0 /* For a standard reloc, the addend is in the object file. */ r_addend = g->addend + (*(g->sym_ptr_ptr))->section->output_section->vma;#endif /* name was clobbered by aout_write_syms to be symbol index */ /* If this relocation is relative to a symbol then set the r_index to the symbols index, and the r_extern bit. Absolute symbols can come in in two ways, either as an offset from the abs section, or as a symbol which has an abs value. check for that here */ if (bfd_is_com_section (output_section) || bfd_is_abs_section (output_section) || bfd_is_und_section (output_section)) { if (bfd_abs_section_ptr->symbol == sym) { /* Whoops, looked like an abs symbol, but is really an offset from the abs section */ r_index = N_ABS; r_extern = 0; } else { /* Fill in symbol */ r_extern = 1; r_index = (*(g->sym_ptr_ptr))->KEEPIT; } } else { /* Just an ordinary section */ r_extern = 0; r_index = output_section->target_index; } /* now the fun stuff */ if (bfd_header_big_endian (abfd)) { natptr->r_index[0] = r_index >> 16; natptr->r_index[1] = r_index >> 8; natptr->r_index[2] = r_index; natptr->r_type[0] = (r_extern? RELOC_STD_BITS_EXTERN_BIG: 0) | (r_pcrel? RELOC_STD_BITS_PCREL_BIG: 0) | (r_baserel? RELOC_STD_BITS_BASEREL_BIG: 0) | (r_jmptable? RELOC_STD_BITS_JMPTABLE_BIG: 0) | (r_relative? RELOC_STD_BITS_RELATIVE_BIG: 0) | (r_length << RELOC_STD_BITS_LENGTH_SH_BIG); } else { natptr->r_index[2] = r_index >> 16; natptr->r_index[1] = r_index >> 8; natptr->r_index[0] = r_index; natptr->r_type[0] = (r_extern? RELOC_STD_BITS_EXTERN_LITTLE: 0) | (r_pcrel? RELOC_STD_BITS_PCREL_LITTLE: 0) | (r_baserel? RELOC_STD_BITS_BASEREL_LITTLE: 0) | (r_jmptable? RELOC_STD_BITS_JMPTABLE_LITTLE: 0) | (r_relative? RELOC_STD_BITS_RELATIVE_LITTLE: 0) | (r_length << RELOC_STD_BITS_LENGTH_SH_LITTLE); }}/* Extended stuff *//* Output extended relocation information to a file in target byte order. */extern void NAME(aout,swap_ext_reloc_out) PARAMS ((bfd *, arelent *, struct reloc_ext_external *));voidNAME(aout,swap_ext_reloc_out) (abfd, g, natptr) bfd *abfd; arelent *g; register struct reloc_ext_external *natptr;{ int r_index; int r_extern; unsigned int r_type; unsigned int r_addend; asymbol *sym = *(g->sym_ptr_ptr); asection *output_section = sym->section->output_section; PUT_WORD (abfd, g->address, natptr->r_address); r_type = (unsigned int) g->howto->type; r_addend = g->addend; if ((sym->flags & BSF_SECTION_SYM) != 0) r_addend += (*(g->sym_ptr_ptr))->section->output_section->vma; /* If this relocation is relative to a symbol then set the r_index to the symbols index, and the r_extern bit. Absolute symbols can come in in two ways, either as an offset from the abs section, or as a symbol which has an abs value. check for that here. */ if (bfd_is_ab
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?