diff options
author | Ian Lance Taylor <ian@airs.com> | 1994-09-06 19:28:55 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1994-09-06 19:28:55 +0000 |
commit | 69645d10fb4647f6855c76ae54a1acf60f28fc94 (patch) | |
tree | 61e36c9f73fda03557d67fda9f185ea6a7828b5f /bfd/coffgen.c | |
parent | de733a0edf37f2e2f4a7733da66b55a07ef1f804 (diff) | |
download | gdb-69645d10fb4647f6855c76ae54a1acf60f28fc94.zip gdb-69645d10fb4647f6855c76ae54a1acf60f28fc94.tar.gz gdb-69645d10fb4647f6855c76ae54a1acf60f28fc94.tar.bz2 |
Add new style linker support to COFF backend. a29k only for now.
* cofflink.c: New file.
* libcoff-in.h: Include bfdlink.h.
(obj_coff_external_syms, obj_coff_strings): Define accessor macro.
(obj_coff_sym_hashes): Define accessor macro.
(struct coff_tdata): Add fields external_syms, strings, and
sym_hashes.
(struct coff_link_hash_entry): Define.
(struct coff_link_hash_table): Define.
(coff_link_hash_lookup, coff_link_hash_traverse): Define.
(coff_hash_table): Define.
(_bfd_coff_link_hash_table_create): Declare.
(_bfd_coff_link_add_symbols, _bfd_coff_final_link): Declare.
* coffcode.h (bfd_coff_backend_data): Add fields _bfd_relsz,
_bfd_coff_swap_reloc_in, _bfd_coff_sym_is_global,
_bfd_coff_compute_section_file_positions,
_bfd_coff_relocate_section.
(bfd_coff_relsz, bfd_coff_swap_reloc_in): Define.
(bfd_coff_sym_is_global): Define.
(bfd_coff_compute_section_file_positions): Define.
(bfd_coff_relocate_section): Define.
(coff_mkobject_hook): Initialize obj_raw_syment_count and
obj_conv_table_size.
(coff_compute_section_file_positions): Set target_index of all
sections. Set output_has_begun field.
(coff_write_object_contents): Don't set target_index; now done by
coff_compute_section_file_positions. Remove obsolete handling of
scn_base and data_base. Don't bother to check that target_index
is positive, since it always is. Remove use of pad, which is
always zero. Check obj_raw_syment_count, not bfd_get_symcount,
for the number of symbols, but only write them out if
bfd_get_symcount is non-zero.
(coff_slurp_symbol_table): Use obj_raw_syment_count, not
bfd_get_symcount for the number of symbols. Don't set
obj_conv_table_size.
(coff_sym_is_global): New static function or macro.
(coff_slurp_reloc_table): Call coff_swap_reloc_in, not
bfd_swap_reloc_in.
(coff_bfd_link_hash_table_create): If coff_relocate_section is
defined, define as _bfd_coff_link_hash_table_create.
(coff_bfd_link_add_symbols): Similar change.
(coff_bfd_final_link): Similar change.
(coff_relocate_section): Define as NULL if not defined.
(bfd_coff_std_swap_table): Initialize new fields.
* coffgen.c (coff_real_object_p): Don't set obj_raw_syment_count
and obj_conv_table_size here.
(coff_count_linenumbers): Reindent. If bfd_get_symcount is zero,
add up the line numbers from the sections.
(coff_write_symbols): Don't set bfd_get_symcount.
(coff_pointerize_aux): Don't pointerize a nonpositive x_endndx
field.
(coff_get_normalized_symtab): Use obj_raw_syment_count, not
bfd_get_symcount.
(coff_print_symbol): If auxp->fix_end, print x_endndx value.
* coffswap.h (coff_swap_reloc_in): Rename from bfd_swap_reloc_in.
Reindent. Change argument type to PTR.
* coff-a29k.c (coff_a29k_relocate_section): New static function.
(coff_relocate_section): Define.
* configure.in (a29kcoff_big_vec): Compile cofflink.o.
* coff-alpha.c (alpha_ecoff_backend_data): Initialize new fields.
* coff-mips.c (mips_ecoff_backend_data): Likewise.
* libcoff.h: Rebuilt.
* Makefile.in: Rebuilt dependencies.
(BFD32_BACKENDS): Add cofflink.o.
(CFILES): Add cofflink.c.
Diffstat (limited to 'bfd/coffgen.c')
-rw-r--r-- | bfd/coffgen.c | 102 |
1 files changed, 59 insertions, 43 deletions
diff --git a/bfd/coffgen.c b/bfd/coffgen.c index fe72cc3..8e91d1c 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -180,10 +180,7 @@ coff_real_object_p (abfd, nscns, internal_f, internal_a) if ((internal_f->f_flags & F_EXEC) != 0) abfd->flags |= D_PAGED; - obj_raw_syment_count (abfd) = - obj_conv_table_size (abfd) = - bfd_get_symcount(abfd) = - internal_f->f_nsyms; + bfd_get_symcount(abfd) = internal_f->f_nsyms; if (internal_f->f_nsyms) abfd->flags |= HAS_SYMS; @@ -343,42 +340,53 @@ coff_get_symtab (abfd, alocation) int coff_count_linenumbers (abfd) - bfd *abfd; + bfd *abfd; { - unsigned int limit = bfd_get_symcount(abfd); - unsigned int i; + unsigned int limit = bfd_get_symcount(abfd); + unsigned int i; int total = 0; - asymbol **p; - { - asection *s = abfd->sections->output_section; - while (s) { - BFD_ASSERT(s->lineno_count == 0); - s = s->next; - } - } + asymbol **p; + asection *s; + if (limit == 0) + { + /* This may be from the backend linker, in which case the + lineno_count in the sections is correct. */ + for (s = abfd->sections; s != NULL; s = s->next) + total += s->lineno_count; + return total; + } - for (p = abfd->outsymbols, i = 0; i < limit; i++, p++) { - asymbol *q_maybe = *p; - if (bfd_asymbol_flavour(q_maybe) == bfd_target_coff_flavour) { - coff_symbol_type *q = coffsymbol(q_maybe); - if (q->lineno) { - /* - This symbol has a linenumber, increment the owning - section's linenumber count - */ - alent *l = q->lineno; - q->symbol.section->output_section->lineno_count++; - total ++; - l++; - while (l->line_number) { - total ++; - q->symbol.section->output_section->lineno_count++; - l++; + for (s = abfd->sections; s != NULL; s = s->next) + BFD_ASSERT (s->lineno_count == 0); + + for (p = abfd->outsymbols, i = 0; i < limit; i++, p++) + { + asymbol *q_maybe = *p; + + if (bfd_asymbol_flavour (q_maybe) == bfd_target_coff_flavour) + { + coff_symbol_type *q = coffsymbol (q_maybe); + + if (q->lineno != NULL) + { + /* This symbol has line numbers. Increment the owning + section's linenumber count. */ + alent *l = q->lineno; + + ++q->symbol.section->output_section->lineno_count; + ++total; + ++l; + while (l->line_number != 0) + { + ++total; + ++q->symbol.section->output_section->lineno_count; + ++l; + } + } } - } } - } + return total; } @@ -920,8 +928,6 @@ coff_write_symbols (abfd) } } - bfd_get_symcount (abfd) = written; - /* Now write out strings */ if (string_size != 0) @@ -1137,9 +1143,12 @@ coff_pointerize_aux (abfd, table_base, type, class, auxent) /* Otherwise patch up */ #define N_TMASK coff_data (abfd)->local_n_tmask #define N_BTSHFT coff_data (abfd)->local_n_btshft - if (ISFCN(type) || ISTAG(class) || class == C_BLOCK) { - auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p = table_base + - auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l; + if ((ISFCN(type) || ISTAG(class) || class == C_BLOCK) + && auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l > 0) + { + auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p = + (table_base + + auxent->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.l); auxent->fix_end = 1; } /* A negative tagndx is meaningless, but the SCO 3.2v4 cc can @@ -1276,7 +1285,9 @@ coff_get_normalized_symtab (abfd) if (obj_raw_syments(abfd) != (combined_entry_type *)NULL) { return obj_raw_syments(abfd); } - if ((size = bfd_get_symcount(abfd) * sizeof(combined_entry_type)) == 0) { + size = obj_raw_syment_count (abfd) * sizeof (combined_entry_type); + if (size == 0) + { bfd_set_error (bfd_error_no_symbols); return (NULL); } @@ -1287,10 +1298,10 @@ coff_get_normalized_symtab (abfd) bfd_set_error (bfd_error_no_memory); return NULL; } - internal_end = internal + bfd_get_symcount(abfd); + internal_end = internal + obj_raw_syment_count (abfd); symesz = bfd_coff_symesz (abfd); - raw_size = bfd_get_symcount(abfd) * symesz; + raw_size = obj_raw_syment_count (abfd) * symesz; raw = bfd_alloc(abfd,raw_size); if (!raw) { @@ -1302,7 +1313,7 @@ coff_get_normalized_symtab (abfd) || bfd_read(raw, raw_size, 1, abfd) != raw_size) return (NULL); /* mark the end of the symbols */ - raw_end = (char *) raw + bfd_get_symcount(abfd) * symesz; + raw_end = (char *) raw + obj_raw_syment_count (abfd) * symesz; /* FIXME SOMEDAY. A string table size of zero is very weird, but probably possible. If one shows up, it will probably kill us. @@ -1575,6 +1586,11 @@ coff_print_symbol (abfd, filep, symbol, how) auxp->u.auxent.x_sym.x_misc.x_lnsz.x_lnno, auxp->u.auxent.x_sym.x_misc.x_lnsz.x_size, tagndx); + if (auxp->fix_end) + fprintf (file, " endndx %ld", + ((long) + (auxp->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p + - root))); break; } } |