From 27f524a3179dd8c37801de0ddce64326095775b4 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Mon, 25 Jan 1993 23:32:26 +0000 Subject: [PATCH] Mon Jan 25 15:27:36 1993 Ian Lance Taylor (ian@cygnus.com) * coffcode.h (_bfd_coff_mkobject_hook): Pass aouthdr argument. (coff_mkobject_hook): Accept aouthdr argument. * coffgen.c (coff_real_object_p): Pass aouthdr to mkobject_hook. Handle NULL aouthdr argument. (coff_object_p): If there is no aouthdr, pass it as NULL to coff_real_object_p. * libcoff.h: Rebuilt for mkobject_hook changes. --- bfd/coffcode.h | 17 +++++++++-------- bfd/coffgen.c | 60 +++++++++++++++++++++++++++++++++++----------------------- 2 files changed, 45 insertions(+), 32 deletions(-) diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 3c79081..bcb93c5 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -341,7 +341,7 @@ DEFUN(sec_to_styp_flags, (sec_name, sec_flags), } /* Try and figure out what it should be */ - else if (sec_flags & SEC_CODE) + else if (sec_flags & SEC_CODE) { styp_flags = STYP_TEXT; } @@ -539,7 +539,8 @@ dependent COFF routines . PTR internal_filehdr)); . PTR (*_bfd_coff_mkobject_hook) PARAMS (( . bfd *abfd, -. PTR internal_filehdr)); +. PTR internal_filehdr, +. PTR internal_aouthdr)); . flagword (*_bfd_styp_to_sec_flags_hook) PARAMS (( . bfd *abfd, . PTR internal_scnhdr)); @@ -617,8 +618,8 @@ dependent COFF routines . .#define bfd_coff_set_arch_mach_hook(abfd, filehdr)\ . ((coff_backend_info (abfd)->_bfd_coff_set_arch_mach_hook) (abfd, filehdr)) -.#define bfd_coff_mkobject_hook(abfd, filehdr)\ -. ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr)) +.#define bfd_coff_mkobject_hook(abfd, filehdr, aouthdr)\ +. ((coff_backend_info (abfd)->_bfd_coff_mkobject_hook) (abfd, filehdr, aouthdr)) . .#define bfd_coff_styp_to_sec_flags_hook(abfd, scnhdr)\ . ((coff_backend_info (abfd)->_bfd_styp_to_sec_flags_hook) (abfd, scnhdr)) @@ -756,9 +757,10 @@ DEFUN(coff_mkobject,(abfd), /* Create the COFF backend specific information. */ static PTR -DEFUN(coff_mkobject_hook,(abfd, filehdr), +DEFUN(coff_mkobject_hook,(abfd, filehdr, aouthdr), bfd *abfd AND - PTR filehdr) + PTR filehdr AND + PTR aouthdr) { struct internal_filehdr *internal_f = (struct internal_filehdr *) filehdr; coff_data_type *coff; @@ -1344,7 +1346,7 @@ DEFUN(coff_write_object_contents,(abfd), /* Make a pass through the symbol table to count line number entries and put them into the correct asections */ - coff_count_linenumbers(abfd); + lnno_size = coff_count_linenumbers(abfd) * LINESZ; data_base = scn_base; /* Work out the size of the reloc and linno areas */ @@ -1357,7 +1359,6 @@ DEFUN(coff_write_object_contents,(abfd), { reloc_size += current->reloc_count * RELSZ; - lnno_size += current->lineno_count * LINESZ; data_base += SCNHSZ; } diff --git a/bfd/coffgen.c b/bfd/coffgen.c index fc87b4d..4e410fd 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -114,7 +114,7 @@ DEFUN(coff_real_object_p,(abfd, nscns, internal_f, internal_a), char *external_sections; /* Build a play area */ - tdata = bfd_coff_mkobject_hook (abfd, (PTR) internal_f); + tdata = bfd_coff_mkobject_hook (abfd, (PTR) internal_f, (PTR) internal_a); if (tdata == NULL) return 0; @@ -156,7 +156,10 @@ DEFUN(coff_real_object_p,(abfd, nscns, internal_f, internal_a), if (internal_f->f_nsyms) abfd->flags |= HAS_SYMS; - bfd_get_start_address(abfd) = internal_f->f_opthdr ? internal_a->entry : 0; + if (internal_a != (struct internal_aouthdr *) NULL) + bfd_get_start_address (abfd) = internal_a->entry; + else + bfd_get_start_address (abfd) = 0; return abfd->xvec; fail: @@ -213,7 +216,10 @@ DEFUN(coff_object_p,(abfd), /* Seek past the opt hdr stuff */ bfd_seek(abfd, (file_ptr) (internal_f.f_opthdr + filhsz), SEEK_SET); - return coff_real_object_p(abfd, nscns, &internal_f, &internal_a); + return coff_real_object_p(abfd, nscns, &internal_f, + (internal_f.f_opthdr != 0 + ? &internal_a + : (struct internal_aouthdr *) NULL)); } /* Get the BFD section from a COFF symbol section number. */ @@ -298,20 +304,21 @@ DEFUN(coff_get_symtab, (abfd, alocation), /* Set lineno_count for the output sections of a COFF file. */ -void +int DEFUN(coff_count_linenumbers,(abfd), bfd *abfd) { 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; - } - } + { + asection *s = abfd->sections->output_section; + while (s) { + BFD_ASSERT(s->lineno_count == 0); + s = s->next; + } + } for (p = abfd->outsymbols, i = 0; i < limit; i++, p++) { @@ -325,14 +332,17 @@ DEFUN(coff_count_linenumbers,(abfd), */ 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++; } } } } + return total; } /* Takes a bfd and a symbol, returns a pointer to the coff specific @@ -844,23 +854,25 @@ DEFUN(coff_write_linenumbers,(abfd), /* Find all the linenumbers in this section */ while (*q) { asymbol *p = *q; - alent *l = - BFD_SEND(bfd_asymbol_bfd(p), _get_lineno, (bfd_asymbol_bfd(p), p)); - if (l) { - /* Found a linenumber entry, output */ - struct internal_lineno out; - memset( (PTR)&out, 0, sizeof(out)); - out.l_lnno = 0; - out.l_addr.l_symndx = l->u.offset; - bfd_coff_swap_lineno_out(abfd, &out, buff); - bfd_write(buff, 1, linesz, abfd); - l++; - while (l->line_number) { - out.l_lnno = l->line_number; + if (p->section->output_section == s) { + alent *l = + BFD_SEND(bfd_asymbol_bfd(p), _get_lineno, (bfd_asymbol_bfd(p), p)); + if (l) { + /* Found a linenumber entry, output */ + struct internal_lineno out; + memset( (PTR)&out, 0, sizeof(out)); + out.l_lnno = 0; out.l_addr.l_symndx = l->u.offset; bfd_coff_swap_lineno_out(abfd, &out, buff); bfd_write(buff, 1, linesz, abfd); l++; + while (l->line_number) { + out.l_lnno = l->line_number; + out.l_addr.l_symndx = l->u.offset; + bfd_coff_swap_lineno_out(abfd, &out, buff); + bfd_write(buff, 1, linesz, abfd); + l++; + } } } q++; -- 2.7.4