1 /* Support for Intel 960 COFF and Motorola 88k BCS COFF (and maybe others) */
3 /* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
5 This file is part of BFD, the Binary File Diddler.
7 BFD is free software; you can redistribute it and/or modify it under the
8 terms of the GNU General Public License as published by the Free Software
9 Foundation; either version 1, or (at your option) any later version.
11 BFD is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 You should have received a copy of the GNU General Public License along with
17 BFD; see the file COPYING. If not, write to the Free Software Foundation,
18 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "archures.h" /* Machine architectures and types */
31 /* Align an address upward to a boundary, expressed as a number of bytes.
32 E.g. align to an 8-byte boundary with argument of 8. */
33 #define ALIGN(this, boundary) \
34 ((( (this) + ((boundary) -1)) & (~((boundary)-1))))
36 /* Align an address upward to a power of two. Argument is the power
37 of two, e.g. 8-byte alignment uses argument of 3 (8 == 2^3). */
38 #define i960_align(addr, align) \
39 ( ((addr) + ((1<<(align))-1)) & (-1 << (align)))
41 #define sp(x) bfd_h_put_x(abfd, x, &x)
44 #define GDB_EXPORT static
46 #define GDB_EXPORT /* nothing */
49 PROTO(static void,force_indices_file_symbol_relative,(bfd *abfd,
50 struct internal_syment *symtab));
54 extern asection abs_section;
57 DEFUN(get_index,(symbol),
60 return (int) symbol->value;
64 DEFUN(set_index,(symbol, idx),
75 /* All the swapping routines:
81 DEFUN(bfd_swap_reloc_in,(abfd, reloc_src, reloc_dst),
84 struct internal_reloc *reloc_dst)
86 reloc_dst->r_vaddr = bfd_h_getlong(abfd, reloc_src->r_vaddr);
87 reloc_dst->r_symndx = bfd_h_getlong(abfd, reloc_src->r_symndx);
88 reloc_dst->r_type = bfd_h_getshort(abfd, reloc_src->r_type);
90 reloc_dst->r_offset = bfd_h_getshort(abfd, reloc_src->r_offset);
96 DEFUN(bfd_swap_reloc_out,(abfd, reloc_src, reloc_dst),
98 struct internal_reloc *reloc_src AND
99 struct external_reloc *reloc_dst)
101 bfd_h_putlong(abfd, reloc_src->r_vaddr, reloc_dst->r_vaddr);
102 bfd_h_putlong(abfd, reloc_src->r_symndx, reloc_dst->r_symndx);
103 bfd_h_putshort(abfd, reloc_src->r_type, reloc_dst->r_type);
105 bfd_h_putshort(abfd, reloc_src->r_offset, reloc_dst->r_offset);
111 DEFUN(bfd_swap_filehdr_in,(abfd, filehdr_src, filehdr_dst),
113 FILHDR *filehdr_src AND
114 struct internal_filehdr *filehdr_dst)
116 filehdr_dst->f_magic = bfd_h_get_x(abfd, filehdr_src->f_magic);
117 filehdr_dst->f_nscns = bfd_h_get_x(abfd,filehdr_src-> f_nscns);
118 filehdr_dst->f_timdat = bfd_h_get_x(abfd,filehdr_src-> f_timdat);
119 filehdr_dst->f_symptr = bfd_h_get_x(abfd,filehdr_src-> f_symptr);
120 filehdr_dst->f_nsyms = bfd_h_get_x(abfd,filehdr_src-> f_nsyms);
121 filehdr_dst->f_opthdr = bfd_h_get_x(abfd,filehdr_src-> f_opthdr);
122 filehdr_dst->f_flags = bfd_h_get_x(abfd,filehdr_src-> f_flags);
126 DEFUN(bfd_swap_filehdr_out,(abfd, filehdr_in, filehdr_out),
128 struct internal_filehdr *filehdr_in AND
131 bfd_h_put_x(abfd, filehdr_in->f_magic, filehdr_out->f_magic);
132 bfd_h_put_x(abfd, filehdr_in->f_nscns, filehdr_out->f_nscns);
133 bfd_h_put_x(abfd, filehdr_in->f_timdat, filehdr_out->f_timdat);
134 bfd_h_put_x(abfd, filehdr_in->f_symptr, filehdr_out->f_symptr);
135 bfd_h_put_x(abfd, filehdr_in->f_nsyms, filehdr_out->f_nsyms);
136 bfd_h_put_x(abfd, filehdr_in->f_opthdr, filehdr_out->f_opthdr);
137 bfd_h_put_x(abfd, filehdr_in->f_flags, filehdr_out->f_flags);
143 DEFUN(bfd_coff_swap_sym_in,(abfd, ext, in),
146 struct internal_syment *in)
148 if( ext->e.e_name[0] == 0) {
149 in->_n._n_n._n_zeroes = 0;
150 in->_n._n_n._n_offset = bfd_h_getlong(abfd, ext->e.e.e_offset);
153 memcpy(in->_n._n_name, ext->e.e_name, SYMNMLEN);
155 in->n_value = bfd_h_get_x(abfd, ext->e_value);
156 in->n_scnum = bfd_h_get_x(abfd, ext->e_scnum);
157 in->n_type = bfd_h_get_x(abfd, ext->e_type);
158 in->n_sclass = bfd_h_get_x(abfd, ext->e_sclass);
159 in->n_numaux = bfd_h_get_x(abfd, ext->e_numaux);
163 DEFUN(bfd_coff_swap_sym_out,(abfd,in, ext),
165 struct internal_syment *in AND
168 if(in->_n._n_name[0] == 0) {
169 bfd_h_putlong(abfd, 0, ext->e.e.e_zeroes);
170 bfd_h_putlong(abfd, in->_n._n_n._n_offset, ext->e.e.e_offset);
173 memcpy(ext->e.e_name, in->_n._n_name, SYMNMLEN);
175 bfd_h_put_x(abfd, in->n_value , ext->e_value);
176 bfd_h_put_x(abfd, in->n_scnum , ext->e_scnum);
177 bfd_h_put_x(abfd, in->n_type , ext->e_type);
178 bfd_h_put_x(abfd, in->n_sclass , ext->e_sclass);
179 bfd_h_put_x(abfd, in->n_numaux , ext->e_numaux);
183 DEFUN(bfd_coff_swap_aux_in,(abfd, ext, type, class, in),
188 union internal_auxent *in)
192 if (ext->x_file.x_fname[0] == 0) {
193 in->x_file.x_n.x_zeroes = 0;
194 in->x_file.x_n.x_offset = bfd_h_getlong(abfd, ext->x_file.x_n.x_offset);
203 if (type == T_NULL) {
204 in->x_scn.x_scnlen = bfd_h_get_x(abfd, ext->x_scn.x_scnlen);
205 in->x_scn.x_nreloc = bfd_h_get_x(abfd, ext->x_scn.x_nreloc);
206 in->x_scn.x_nlinno = bfd_h_get_x(abfd, ext->x_scn.x_nlinno);
210 in->x_sym.x_tagndx = bfd_h_get_x(abfd, ext->x_sym.x_tagndx);
211 in->x_sym.x_tvndx = bfd_h_get_x(abfd, ext->x_sym.x_tvndx);
213 if (ISARY(type) || class == C_BLOCK) {
214 in->x_sym.x_fcnary.x_ary.x_dimen[0] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
215 in->x_sym.x_fcnary.x_ary.x_dimen[1] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
216 in->x_sym.x_fcnary.x_ary.x_dimen[2] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
217 in->x_sym.x_fcnary.x_ary.x_dimen[3] = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
220 in->x_sym.x_fcnary.x_fcn.x_lnnoptr = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
221 in->x_sym.x_fcnary.x_fcn.x_endndx = bfd_h_get_x(abfd, ext->x_sym.x_fcnary.x_fcn.x_endndx);
224 in->x_sym.x_misc.x_fsize = bfd_h_get_x(abfd, ext->x_sym.x_misc.x_fsize);
227 in->x_sym.x_misc.x_lnsz.x_lnno = bfd_h_get_x(abfd, ext->x_sym.x_misc.x_lnsz.x_lnno);
228 in->x_sym.x_misc.x_lnsz.x_size = bfd_h_get_x(abfd, ext->x_sym.x_misc.x_lnsz.x_size);
234 DEFUN(bfd_coff_swap_aux_out,(abfd, in, type, class, ext),
236 union internal_auxent *in AND
243 if (in->x_file.x_fname[0] == 0) {
244 bfd_h_put_x(abfd, 0, ext->x_file.x_n.x_zeroes );
245 bfd_h_put_x(abfd, in->x_file.x_n.x_offset, ext->x_file.x_n.x_offset);
254 if (type == T_NULL) {
255 bfd_h_put_x(abfd, in->x_scn.x_scnlen, ext->x_scn.x_scnlen);
256 bfd_h_put_x(abfd, in->x_scn.x_nreloc, ext->x_scn.x_nreloc);
257 bfd_h_put_x(abfd, in->x_scn.x_nlinno, ext->x_scn.x_nlinno);
261 bfd_h_put_x(abfd, in->x_sym.x_tagndx, ext->x_sym.x_tagndx);
262 bfd_h_put_x(abfd, in->x_sym.x_tvndx , ext->x_sym.x_tvndx);
264 if (ISARY(type) || class == C_BLOCK) {
265 bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[0],ext->x_sym.x_fcnary.x_ary.x_dimen[0]);
266 bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[1],ext->x_sym.x_fcnary.x_ary.x_dimen[1]);
267 bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[2],ext->x_sym.x_fcnary.x_ary.x_dimen[2]);
268 bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_ary.x_dimen[3],ext->x_sym.x_fcnary.x_ary.x_dimen[3]);
271 bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_fcn.x_lnnoptr, ext->x_sym.x_fcnary.x_fcn.x_lnnoptr);
272 bfd_h_put_x(abfd, in->x_sym.x_fcnary.x_fcn.x_endndx, ext->x_sym.x_fcnary.x_fcn.x_endndx);
275 bfd_h_put_x(abfd, in->x_sym.x_misc.x_fsize, ext->x_sym.x_misc.x_fsize);
278 bfd_h_put_x(abfd, in->x_sym.x_misc.x_lnsz.x_lnno, ext->x_sym.x_misc.x_lnsz.x_lnno);
279 bfd_h_put_x(abfd, in->x_sym.x_misc.x_lnsz.x_size, ext->x_sym.x_misc.x_lnsz.x_size);
285 DEFUN(bfd_coff_swap_lineno_in,(abfd, ext, in),
288 struct internal_lineno *in)
290 in->l_addr.l_symndx = bfd_h_get_x(abfd, ext->l_addr.l_symndx);
291 in->l_lnno = bfd_h_get_x(abfd, ext->l_lnno);
295 DEFUN(bfd_coff_swap_lineno_out,(abfd, in, ext),
297 struct internal_lineno *in AND
298 struct external_lineno *ext)
300 bfd_h_put_x(abfd, in->l_addr.l_symndx, ext->l_addr.l_symndx);
301 bfd_h_put_x(abfd, in->l_lnno, ext->l_lnno);
308 DEFUN(bfd_swap_aouthdr_in,(abfd, aouthdr_ext, aouthdr_int),
310 AOUTHDR *aouthdr_ext AND
311 struct internal_aouthdr *aouthdr_int)
313 aouthdr_int->magic = bfd_h_get_x(abfd, aouthdr_ext->magic);
314 aouthdr_int->vstamp = bfd_h_get_x(abfd, aouthdr_ext->vstamp);
315 aouthdr_int->tsize = bfd_h_get_x(abfd, aouthdr_ext->tsize);
316 aouthdr_int->dsize = bfd_h_get_x(abfd, aouthdr_ext->dsize);
317 aouthdr_int->bsize = bfd_h_get_x(abfd, aouthdr_ext->bsize);
318 aouthdr_int->entry = bfd_h_get_x(abfd, aouthdr_ext->entry);
319 aouthdr_int->text_start = bfd_h_get_x(abfd, aouthdr_ext->text_start);
320 aouthdr_int->data_start = bfd_h_get_x(abfd, aouthdr_ext->data_start);
322 aouthdr_int->tagentries = bfd_h_get_x(abfd, aouthdr_ext->tagentries);
327 DEFUN(bfd_swap_aouthdr_out,(abfd, aouthdr_in, aouthdr_out),
329 struct internal_aouthdr *aouthdr_in AND
330 AOUTHDR *aouthdr_out)
332 bfd_h_put_x(abfd, aouthdr_in->magic, aouthdr_out->magic);
333 bfd_h_put_x(abfd, aouthdr_in->vstamp, aouthdr_out->vstamp);
334 bfd_h_put_x(abfd, aouthdr_in->tsize, aouthdr_out->tsize);
335 bfd_h_put_x(abfd, aouthdr_in->dsize, aouthdr_out->dsize);
336 bfd_h_put_x(abfd, aouthdr_in->bsize, aouthdr_out->bsize);
337 bfd_h_put_x(abfd, aouthdr_in->entry, aouthdr_out->entry);
338 bfd_h_put_x(abfd, aouthdr_in->text_start, aouthdr_out->text_start);
339 bfd_h_put_x(abfd, aouthdr_in->data_start, aouthdr_out->data_start);
341 bfd_h_put_x(abfd, aouthdr_in->tagentries, aouthdr_out->tagentries);
346 DEFUN(bfd_coff_swap_scnhdr_in,(abfd, scnhdr_ext, scnhdr_int),
348 SCNHDR *scnhdr_ext AND
349 struct internal_scnhdr *scnhdr_int)
351 memcpy(scnhdr_int->s_name, scnhdr_ext->s_name, sizeof(scnhdr_int->s_name));
352 scnhdr_int->s_vaddr = bfd_h_get_x(abfd, scnhdr_ext->s_vaddr);
353 scnhdr_int->s_paddr = bfd_h_get_x(abfd, scnhdr_ext->s_paddr);
354 scnhdr_int->s_size = bfd_h_get_x(abfd, scnhdr_ext->s_size);
355 scnhdr_int->s_scnptr = bfd_h_get_x(abfd, scnhdr_ext->s_scnptr);
356 scnhdr_int->s_relptr = bfd_h_get_x(abfd, scnhdr_ext->s_relptr);
357 scnhdr_int->s_lnnoptr = bfd_h_get_x(abfd, scnhdr_ext->s_lnnoptr);
358 scnhdr_int->s_nreloc = bfd_h_get_x(abfd, scnhdr_ext->s_nreloc);
359 scnhdr_int->s_nlnno = bfd_h_get_x(abfd, scnhdr_ext->s_nlnno);
360 scnhdr_int->s_flags = bfd_h_get_x(abfd, scnhdr_ext->s_flags);
362 scnhdr_int->s_align = bfd_h_get_x(abfd, scnhdr_ext->s_align);
367 DEFUN(swap_scnhdr_out,(abfd, scnhdr_int, scnhdr_ext),
369 struct internal_scnhdr *scnhdr_int AND
372 memcpy(scnhdr_ext->s_name, scnhdr_int->s_name, sizeof(scnhdr_int->s_name));
373 bfd_h_put_x(abfd, scnhdr_int->s_vaddr, scnhdr_ext->s_vaddr);
374 bfd_h_put_x(abfd, scnhdr_int->s_paddr, scnhdr_ext->s_paddr);
375 bfd_h_put_x(abfd, scnhdr_int->s_size, scnhdr_ext->s_size);
376 bfd_h_put_x(abfd, scnhdr_int->s_scnptr, scnhdr_ext->s_scnptr);
377 bfd_h_put_x(abfd, scnhdr_int->s_relptr, scnhdr_ext->s_relptr);
378 bfd_h_put_x(abfd, scnhdr_int->s_lnnoptr, scnhdr_ext->s_lnnoptr);
379 bfd_h_put_x(abfd, scnhdr_int->s_nreloc, scnhdr_ext->s_nreloc);
380 bfd_h_put_x(abfd, scnhdr_int->s_nlnno, scnhdr_ext->s_nlnno);
381 bfd_h_put_x(abfd, scnhdr_int->s_flags, scnhdr_ext->s_flags);
383 bfd_h_put_x(abfd, scnhdr_int->s_align, scnhdr_ext->s_align);
388 initialize a section structure with information peculiar to this
389 particular implementation of coff
393 DEFUN(coff_new_section_hook,(abfd_ignore, section_ignore),
395 asection *section_ignore)
398 /* FIXME, shouldn't this ifdef be on something that says we are
399 actually COMPILING FOR an 88K coff file, rather than simply
400 knowing its magic number? */
401 /* Align to at least 16 bytes */
402 section_ignore->alignment_power = 4;
405 section_ignore->alignment_power = 3;
410 /* Take a section header read from a coff file (in HOST byte order),
411 and make a BFD "section" out of it. */
413 DEFUN(make_a_section_from_file,(abfd, hdr),
415 struct internal_scnhdr *hdr)
417 asection *return_section;
420 /* Assorted wastage to null-terminate the name, thanks AT&T! */
421 char *name = bfd_alloc(abfd, sizeof (hdr->s_name)+1);
423 bfd_error = no_memory;
426 strncpy(name, (char *) &hdr->s_name[0], sizeof (hdr->s_name));
427 name[sizeof (hdr->s_name)] = 0;
429 return_section = bfd_make_section(abfd, name);
432 /* s_paddr is presumed to be = to s_vaddr */
433 #define assign(to, from) return_section->to = hdr->from
434 assign(vma, s_vaddr);
435 /* assign (vma, s_vaddr); */
436 assign(size, s_size);
437 assign(filepos, s_scnptr);
438 assign(rel_filepos, s_relptr);
439 assign(reloc_count, s_nreloc);
442 /* FIXME, use a temp var rather than alignment_power */
443 assign(alignment_power, s_align);
446 for (i = 0; i < 32; i++) {
447 if ((1 << i) >= (int) (return_section->alignment_power)) {
448 return_section->alignment_power = i;
455 assign(line_filepos, s_lnnoptr);
457 return_section->linesize = hdr->s_nlnno * sizeof (struct lineno);
461 return_section->lineno_count = hdr->s_nlnno;
462 return_section->userdata = NULL;
463 return_section->next = (asection *) NULL;
464 return_section->flags = 0;
465 if ((hdr->s_flags & STYP_TEXT) || (hdr->s_flags & STYP_DATA))
466 return_section->flags = (SEC_LOAD | SEC_ALLOC);
467 else if (hdr->s_flags & STYP_BSS)
468 return_section->flags = SEC_ALLOC;
470 if (hdr->s_nreloc != 0)
471 return_section->flags |= SEC_RELOC;
472 if (hdr->s_scnptr != 0)
473 return_section->flags |= SEC_HAS_CONTENTS;
477 DEFUN(coff_mkobject,(abfd),
480 set_tdata (abfd, bfd_zalloc (abfd,sizeof(coff_data_type)));
481 if (coff_data(abfd) == 0) {
482 bfd_error = no_memory;
485 coff_data(abfd)->relocbase = 0;
491 DEFUN(coff_real_object_p,(abfd, nscns, internal_f, internal_a),
494 struct internal_filehdr *internal_f AND
495 struct internal_aouthdr *internal_a)
497 coff_data_type *coff;
499 size_t readsize; /* length of file_info */
500 SCNHDR *external_sections;
502 /* Build a play area */
503 if (coff_mkobject(abfd) != true)
505 coff = coff_data(abfd);
508 external_sections = (SCNHDR *)bfd_alloc(abfd, readsize = (nscns * SCNHSZ));
509 if (bfd_read((PTR)external_sections, 1, readsize, abfd) != readsize) {
515 /* Now copy data as required; construct all asections etc */
516 coff->symbol_index_slew = 0;
518 coff->raw_syment_count = 0;
519 coff->raw_linenos = 0;
520 coff->raw_syments = 0;
521 coff->sym_filepos =0;
522 coff->flags = internal_f->f_flags;
525 for (i = 0; i < nscns; i++) {
526 struct internal_scnhdr tmp;
527 bfd_coff_swap_scnhdr_in(abfd, external_sections + i, &tmp);
528 make_a_section_from_file(abfd,&tmp);
531 /* Determine the machine architecture and type. */
532 abfd->obj_machine = 0;
533 switch (internal_f->f_magic) {
538 abfd->obj_arch = bfd_arch_mips;
539 abfd->obj_machine = 0;
546 abfd->obj_arch = bfd_arch_m68k;
547 abfd->obj_machine = 68020;
554 abfd->obj_arch = bfd_arch_m88k;
555 abfd->obj_machine = 88100;
562 abfd->obj_arch = bfd_arch_i960;
563 switch (F_I960TYPE & internal_f->f_flags)
567 abfd->obj_machine = bfd_mach_i960_core;
570 abfd->obj_machine = bfd_mach_i960_kb_sb;
573 abfd->obj_machine = bfd_mach_i960_mc;
576 abfd->obj_machine = bfd_mach_i960_xa;
579 abfd->obj_machine = bfd_mach_i960_ca;
582 abfd->obj_machine = bfd_mach_i960_ka_sa;
590 default: /* Unreadable input file type */
591 abfd->obj_arch = bfd_arch_obscure;
595 if (!(internal_f->f_flags & F_RELFLG))
596 abfd->flags |= HAS_RELOC;
597 if ((internal_f->f_flags & F_EXEC))
598 abfd->flags |= EXEC_P;
599 if (!(internal_f->f_flags & F_LNNO))
600 abfd->flags |= HAS_LINENO;
601 if (!(internal_f->f_flags & F_LSYMS))
602 abfd->flags |= HAS_LOCALS;
605 bfd_get_symcount(abfd) = internal_f->f_nsyms;
606 if (internal_f->f_nsyms)
607 abfd->flags |= HAS_SYMS;
609 coff->sym_filepos = internal_f->f_symptr;
613 coff->symbols = (coff_symbol_type *) NULL;
614 bfd_get_start_address(abfd) = internal_f->f_opthdr ? internal_a->entry : 0;
618 bfd_release(abfd, coff);
619 return (bfd_target *)NULL;
623 DEFUN(coff_object_p,(abfd),
629 struct internal_filehdr internal_f;
630 struct internal_aouthdr internal_a;
632 bfd_error = system_call_error;
634 /* figure out how much to read */
635 if (bfd_read((PTR) &filehdr, 1, FILHSZ, abfd) != FILHSZ)
638 bfd_swap_filehdr_in(abfd, &filehdr, &internal_f);
640 if (BADMAG(internal_f)) {
641 bfd_error = wrong_format;
644 nscns =internal_f.f_nscns;
646 if (internal_f.f_opthdr) {
647 if (bfd_read((PTR) &opthdr, 1,AOUTSZ, abfd) != AOUTSZ) {
650 bfd_swap_aouthdr_in(abfd, &opthdr, &internal_a);
653 /* Seek past the opt hdr stuff */
654 bfd_seek(abfd, internal_f.f_opthdr + FILHSZ, SEEK_SET);
656 /* if the optional header is NULL or not the correct size then
657 quit; the only difference I can see between m88k dgux headers (MC88DMAGIC)
658 and Intel 960 readwrite headers (I960WRMAGIC) is that the
659 optional header is of a different size.
661 But the mips keeps extra stuff in it's opthdr, so dont check
666 if (internal_f.f_opthdr != 0 && AOUTSZ != internal_f.f_opthdr)
667 return (bfd_target *)NULL;
670 return coff_real_object_p(abfd, nscns, &internal_f, &internal_a);
677 Takes a bfd and a symbol, returns a pointer to the coff specific area
678 of the symbol if there is one.
680 static coff_symbol_type *
681 DEFUN(coff_symbol_from,(abfd, symbol),
685 if (symbol->the_bfd->xvec->flavour != bfd_target_coff_flavour_enum)
686 return (coff_symbol_type *)NULL;
688 if (symbol->the_bfd->tdata == (PTR)NULL)
689 return (coff_symbol_type *)NULL;
691 return (coff_symbol_type *) symbol;
701 DEFUN(coff_count_linenumbers,(abfd),
704 unsigned int limit = bfd_get_symcount(abfd);
708 asection *s = abfd->sections->output_section;
710 BFD_ASSERT(s->lineno_count == 0);
716 for (p = abfd->outsymbols, i = 0; i < limit; i++, p++) {
717 asymbol *q_maybe = *p;
718 if (q_maybe->the_bfd->xvec->flavour == bfd_target_coff_flavour_enum) {
719 coff_symbol_type *q = coffsymbol(q_maybe);
722 This symbol has a linenumber, increment the owning
723 section's linenumber count
725 alent *l = q->lineno;
726 q->symbol.section->output_section->lineno_count++;
728 while (l->line_number) {
729 q->symbol.section->output_section->lineno_count++;
738 This function returns true if the supplied SYMENT has an AUXENT with
739 a tagndx field which should be relocated.
741 The coff book says that all auxents have this and should be moved,
742 but all the actual implementations I've looked at do this ..
747 DEFUN(uses_x_sym_x_tagndx_p,(abfd, native),
749 struct internal_syment *native)
751 if (BTYPE(native->n_type) == T_STRUCT) return true;
752 if (BTYPE(native->n_type) == T_UNION) return true;
753 if (BTYPE(native->n_type) == T_ENUM) return true;
759 This procedure runs through the native entries in a coff symbol table
760 and links up all the elements which should point to one another, in
761 particular these are:
763 strtag, entag and untags have an auxent endindex which points to the
764 first syment after the .eos. This is simple to do, we just keep a
765 pointer to the symbol with the most recent pending strtag and patch it
766 when we see the eos. This works since coff structs are never nested.
768 ISFCN type entries have an endindex which points to the next static or
769 extern in the table, thereby skipping the function contents.
770 The coff book says that an ISFCN's tagindex
771 points to the first .bf for the function, so far I havn't seen it
772 used. We do this using the same mechanism as strtags.
774 Each file entry has a value which points to the next file entry,
775 the last file entry points to the first extern symbol in the table
776 which is not an ISFCN.
778 Each .bb entry points to the matching .eb entry, but these are nested
779 so we keep a stack of them.
781 The tagndx of .eos items points to the strtag attached to them, this
782 is simply the last_tagndx again.
784 The tagndx of items with type strtag point to the defining struct.
785 This bit is complicated; We know that a struct ref and def must be
786 within the same file, so all the natives will be in the same vector.
787 This means that we can subtracts two pointers and get the index
788 differences between to items, used to work out the true index of the
791 We store in the name field of each syment the actual native index
792 applied so we can dig it out through a pointer. */
795 DEFUN(coff_mangle_symbols,(bfd_ptr),
798 unsigned int symbol_count = bfd_get_symcount(bfd_ptr);
799 asymbol **symbol_ptr_ptr = bfd_ptr->outsymbols;
800 struct internal_syment *last_tagndx = (struct internal_syment *)NULL;
801 struct internal_syment *last_file = (struct internal_syment *)NULL;
802 struct internal_syment *last_fcn = (struct internal_syment *)NULL;
803 struct internal_syment *block_stack[50];
804 struct internal_syment **last_block = &block_stack[0];
805 boolean first_time = true;
806 unsigned int symbol_index;
807 unsigned int native_index = 0;
809 for (symbol_index = 0; symbol_index < symbol_count; symbol_index++) {
810 coff_symbol_type *coff_symbol_ptr =
811 coff_symbol_from(bfd_ptr, symbol_ptr_ptr[symbol_index]);
812 if (coff_symbol_ptr == (coff_symbol_type *)NULL) {
814 This symbol has no coff information in it, it will take up
815 only one slot in the output symbol table
820 struct internal_syment *syment = coff_symbol_ptr->native;
821 if (syment == (struct internal_syment *)NULL) {
825 /* Normalize the symbol flags */
826 if (coff_symbol_ptr->symbol.flags & BSF_FORT_COMM) {
827 /* a common symbol is undefined with a value */
828 syment->n_scnum = N_UNDEF;
829 syment->n_value = coff_symbol_ptr->symbol.value;
831 else if (coff_symbol_ptr->symbol.flags & BSF_DEBUGGING) {
832 syment->n_value = coff_symbol_ptr->symbol.value;
834 else if (coff_symbol_ptr->symbol.flags & BSF_UNDEFINED) {
835 syment->n_scnum = N_UNDEF;
838 else if (coff_symbol_ptr->symbol.flags & BSF_ABSOLUTE) {
839 syment->n_scnum = N_ABS;
840 syment->n_value = coff_symbol_ptr->symbol.value;
844 coff_symbol_ptr->symbol.section->output_section->index+1;
847 coff_symbol_ptr->symbol.value +
848 coff_symbol_ptr->symbol.section->output_offset +
849 coff_symbol_ptr->symbol.section->output_section->vma;
853 /* If this symbol ties up something then do it */
855 if (syment->n_sclass == C_FILE && last_file != (struct internal_syment *)NULL)
857 last_file->n_value = native_index;
859 else if ((syment->n_sclass == C_EXT
860 || syment->n_sclass == C_STAT
862 || syment->n_sclass == C_LEAFEXT
863 || syment->n_sclass == C_LEAFSTAT
866 && last_fcn != (struct internal_syment *)NULL)
868 union internal_auxent *auxent = (union internal_auxent *)(last_fcn+1);
869 auxent->x_sym.x_fcnary.x_fcn.x_endndx = native_index;
870 last_fcn = (struct internal_syment *)NULL;
873 else if (syment->n_sclass == C_EOS && last_tagndx != (struct internal_syment*)NULL)
875 union internal_auxent *auxent = (union internal_auxent *)(last_tagndx+1);
876 /* Remember that we keep the native index in the offset
877 so patch the beginning of the struct to point to this
879 auxent->x_sym.x_tagndx = last_tagndx->_n._n_n._n_offset;
880 auxent->x_sym.x_fcnary.x_fcn.x_endndx = syment->n_numaux + 1 + native_index;
881 /* Now point the eos to the structure */
882 auxent = (union internal_auxent *)(syment+1);
883 auxent->x_sym.x_tagndx = last_tagndx->_n._n_n._n_offset;
885 else if (syment->n_sclass == C_BLOCK
886 && coff_symbol_ptr->symbol.name[1] == 'e')
888 union internal_auxent *auxent = (union internal_auxent *)((*(--last_block))+1);
889 auxent->x_sym.x_fcnary.x_fcn.x_endndx = native_index + syment->n_numaux + 1;
891 if (syment->n_sclass == C_EXT
892 && !ISFCN(syment->n_type)
893 && first_time == true
894 && last_file != (struct internal_syment *)NULL) {
895 /* This is the first external symbol seen which isn't a
896 function place it in the last .file entry */
897 last_file->n_value = native_index;
901 if (syment->n_sclass == C_LEAFPROC &&
902 syment->n_numaux == 2) {
903 union internal_auxent *auxent = (union internal_auxent *)(syment+2);
904 /* This is the definition of a leaf proc, we'll relocate the
906 auxent->x_bal.x_balntry =
907 coff_symbol_ptr->symbol.section->output_offset +
908 coff_symbol_ptr->symbol.section->output_section->vma +
909 auxent->x_bal.x_balntry ;
912 /* If this symbol needs to be tied up then remember some facts */
913 if (syment->n_sclass == C_FILE)
917 if (syment->n_numaux != 0) {
919 If this symbol would like to point to something in the
920 future then remember where it is
922 if (uses_x_sym_x_tagndx_p(bfd_ptr, syment)) {
924 If this is a ref to a structure then we'll tie it up
925 now - there are never any forward refs for one
927 if (syment->n_sclass == C_STRTAG ||
928 syment->n_sclass == C_ENTAG ||
929 syment->n_sclass == C_UNTAG) {
930 last_tagndx = syment;
934 This is a ref to a structure - the structure must
935 have been defined within the same file, and previous
936 to this point, so we can deduce the new tagndx
939 union internal_auxent *auxent = (union internal_auxent *)(syment+1);
940 bfd *bfd_ptr = coff_symbol_ptr->symbol.the_bfd;
941 struct internal_syment *base = obj_raw_syments(bfd_ptr);
942 auxent->x_sym.x_tagndx = base[auxent->x_sym.x_tagndx]._n._n_n._n_offset;
947 if (ISFCN(syment->n_type)) {
950 if (syment->n_sclass == C_BLOCK
951 && coff_symbol_ptr->symbol.name[1] == 'b')
953 *last_block++ = syment;
956 syment->_n._n_n._n_offset = native_index;
957 native_index = native_index + 1 + syment->n_numaux;
965 DEFUN(coff_write_symbols,(abfd),
969 unsigned int limit = bfd_get_symcount(abfd);
970 unsigned int written = 0;
971 struct internal_syment dummy;
973 unsigned int string_size = 0;
976 /* Seek to the right place */
977 bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET);
979 /* Output all the symbols we have */
982 for (p = abfd->outsymbols, i = 0; i < limit; i++, p++) {
983 asymbol *symbol = *p;
984 coff_symbol_type *c_symbol = coff_symbol_from(abfd, symbol);
987 struct internal_syment *native;
988 if (c_symbol == (coff_symbol_type *) NULL ||
989 c_symbol->native == (struct internal_syment *) NULL) {
991 This symbol has been created by the loader, or come from a non
992 coff format. It has no native element to inherit, make our
997 native->n_type = T_NULL;
1001 if (symbol->flags & BSF_ABSOLUTE) {
1002 native->n_scnum = N_ABS;
1003 native->n_value = symbol->value;
1005 else if (symbol->flags & (BSF_UNDEFINED | BSF_FORT_COMM)) {
1006 native->n_scnum = N_UNDEF;
1007 native->n_value = symbol->value;
1009 else if (symbol->flags & BSF_DEBUGGING) {
1011 remove name so it doesn't take up any space
1017 native->n_scnum = symbol->section->output_section->index +
1019 native->n_value = symbol->value +
1020 symbol->section->output_section->vma +
1021 symbol->section->output_offset;
1023 /* Copy the any flags from the the file hdr into the symbol */
1025 coff_symbol_type *c = coff_symbol_from(abfd, symbol);
1026 if (c != (coff_symbol_type *)NULL) {
1027 native->n_flags = c->symbol.the_bfd->flags;
1034 native->pad1[0] = 0;
1035 native->pad1[0] = 0;
1039 if (symbol->flags & BSF_LOCAL)
1040 native->n_sclass = C_STAT;
1042 native->n_sclass = C_EXT;
1043 native->n_numaux = 0;
1047 Does this symbol have an ascociated line number - if so then
1048 make it remember this symbol index. Also tag the auxent of
1049 this symbol to point to the right place in the lineno table
1052 alent *lineno = c_symbol->lineno;
1053 native = c_symbol->native;
1055 unsigned int count = 0;
1056 lineno[count].u.offset = written;
1057 if (native->n_numaux) {
1058 union internal_auxent *a = (union internal_auxent *) (native + 1);
1060 a->x_sym.x_fcnary.x_fcn.x_lnnoptr =
1061 c_symbol->symbol.section->output_section->moving_line_filepos;
1064 And count and relocate all other linenumbers
1067 while (lineno[count].line_number) {
1068 lineno[count].u.offset +=
1069 c_symbol->symbol.section->output_section->vma +
1070 c_symbol->symbol.section->output_offset;
1073 c_symbol->symbol.section->output_section->moving_line_filepos +=
1077 } /* if symbol new to coff */
1079 /* Fix the symbol names */
1081 unsigned int name_length;
1082 if (symbol->name == (char *) NULL) {
1084 coff symbols always have names, so we'll make one up
1086 symbol->name = "strange";
1088 name_length = strlen(symbol->name);
1089 if (name_length <= SYMNMLEN) {
1090 /* This name will fit into the symbol neatly */
1091 strncpy(native->_n._n_name, symbol->name, SYMNMLEN);
1094 native->_n._n_n._n_offset = string_size + 4;
1095 native->_n._n_n._n_zeroes = 0;
1096 string_size += name_length + 1;
1099 unsigned int numaux = native->n_numaux;
1100 int type = native->n_type;
1101 int class = native->n_sclass;
1103 bfd_coff_swap_sym_out(abfd, native, &buf);
1104 bfd_write((PTR)& buf, 1, SYMESZ, abfd);
1105 for (j = 0; j != native->n_numaux;
1108 bfd_coff_swap_aux_out(abfd,
1109 (union internal_auxent *)(native + j + 1), type, class, &buf1);
1110 bfd_write((PTR) (native + j + 1), 1, AUXESZ, abfd);
1113 Reuse somewhere in the symbol to keep the index
1115 set_index(symbol, written);
1116 written += 1 + numaux;
1119 } /* for each out symbol */
1121 bfd_get_symcount(abfd) = written;
1122 /* Now write out strings */
1125 unsigned int size = string_size + 4;
1127 bfd_write((PTR) &size, 1, sizeof(size), abfd);
1128 for (p = abfd->outsymbols, i = 0; i < limit; i++, p++) {
1130 size_t name_length = strlen(q->name);
1131 if (name_length > SYMNMLEN) {
1132 bfd_write((PTR) (q->name), 1, name_length + 1, abfd);
1137 /* We would normally not write anything here, but we'll write
1138 out 4 so that any stupid coff reader which tries to read
1139 the string table even when there isn't one won't croak.
1142 uint32e_type size = 4;
1144 bfd_write((PTR)&size, 1, sizeof(size), abfd);
1151 coff_write_relocs(abfd)
1155 for (s = abfd->sections; s != (asection *) NULL; s = s->next) {
1157 struct external_reloc dst;
1159 arelent **p = s->orelocation;
1160 bfd_seek(abfd, s->rel_filepos, SEEK_SET);
1161 for (i = 0; i < s->reloc_count; i++) {
1162 struct internal_reloc n;
1164 memset((PTR)&n, 0, sizeof(n));
1165 n.r_vaddr = q->address + s->vma;
1166 if (q->sym_ptr_ptr) {
1167 n.r_symndx = get_index((*(q->sym_ptr_ptr)));
1170 /* Work out reloc type from what is required */
1171 SELECT_RELOC(n.r_type, q->howto);
1173 n.r_type = q->howto->type;
1175 bfd_swap_reloc_out(abfd, &n, &dst);
1176 bfd_write((PTR) &n, 1, RELSZ, abfd);
1182 DEFUN(coff_write_linenumbers,(abfd),
1186 for (s = abfd->sections; s != (asection *) NULL; s = s->next) {
1187 if (s->lineno_count) {
1188 asymbol **q = abfd->outsymbols;
1189 bfd_seek(abfd, s->line_filepos, SEEK_SET);
1190 /* Find all the linenumbers in this section */
1193 alent *l = BFD_SEND(p->the_bfd, _get_lineno, (p->the_bfd, p));
1195 /* Found a linenumber entry, output */
1196 struct internal_lineno out;
1198 bzero( (PTR)&out, sizeof(out));
1200 out.l_addr.l_symndx = l->u.offset;
1201 bfd_coff_swap_lineno_out(abfd, &out, &buff);
1202 bfd_write((PTR) &buff, 1, LINESZ, abfd);
1204 while (l->line_number) {
1205 out.l_lnno = l->line_number;
1206 out.l_addr.l_symndx = l->u.offset;
1207 bfd_coff_swap_lineno_out(abfd, &out, &buff);
1208 bfd_write((PTR) &buff, 1, LINESZ, abfd);
1220 coff_make_empty_symbol(abfd)
1223 coff_symbol_type *new = (coff_symbol_type *) bfd_alloc(abfd, sizeof(coff_symbol_type));
1225 bfd_error = no_memory;
1229 new->lineno = (alent *) NULL;
1230 new->symbol.the_bfd = abfd;
1231 return &new->symbol;
1235 coff_print_symbol(ignore_abfd, file, symbol, how)
1239 bfd_print_symbol_enum_type how;
1242 case bfd_print_symbol_name_enum:
1243 fprintf(file, "%s", symbol->name);
1245 case bfd_print_symbol_type_enum:
1246 fprintf(file, "coff %lx %lx", (unsigned long) coffsymbol(symbol)->native,
1247 (unsigned long) coffsymbol(symbol)->lineno);
1249 case bfd_print_symbol_all_enum:
1251 CONST char *section_name = symbol->section == (asection *) NULL ?
1252 "*abs" : symbol->section->name;
1253 bfd_print_symbol_vandf((PTR) file, symbol);
1255 fprintf(file, " %-5s %s %s %s",
1257 coffsymbol(symbol)->native ? "n" : "g",
1258 coffsymbol(symbol)->lineno ? "l" : " ",
1268 coff_get_lineno(ignore_abfd, symbol)
1272 return coffsymbol(symbol)->lineno;
1276 Set flags and magic number of a coff file from architecture and machine
1277 type. Result is true if we can represent the arch&type, false if not.
1280 coff_set_flags(abfd, magicp, flagsp)
1286 switch (abfd->obj_arch) {
1294 *magicp = I960ROMAGIC;
1296 ((bfd_get_file_flags(abfd) & WP_TEXT) ? I960ROMAGIC :
1297 I960RWMAGIC); FIXME???
1299 switch (abfd->obj_machine) {
1300 case bfd_mach_i960_core:
1303 case bfd_mach_i960_kb_sb:
1306 case bfd_mach_i960_mc:
1309 case bfd_mach_i960_xa:
1312 case bfd_mach_i960_ca:
1315 case bfd_mach_i960_ka_sa:
1328 *magicp = MIPS_MAGIC_2;
1334 *magicp = MC68MAGIC;
1340 *magicp = MC88OMAGIC;
1345 default: /* Unknown architecture */
1354 coff_set_arch_mach(abfd, arch, machine)
1356 enum bfd_architecture arch;
1357 unsigned long machine;
1361 abfd->obj_arch = arch;
1362 abfd->obj_machine = machine;
1363 if (arch != bfd_arch_unknown &&
1364 coff_set_flags(abfd, &dummy1, &dummy2) != true)
1365 return false; /* We can't represent this type */
1366 return true; /* We're easy ... */
1370 /* Calculate the file position for each section. */
1373 coff_compute_section_file_positions(abfd)
1377 file_ptr sofar = FILHSZ;
1378 if (bfd_get_start_address(abfd)) {
1380 A start address may have been added to the original file. In this
1381 case it will need an optional header to record it.
1383 abfd->flags |= EXEC_P;
1385 if (abfd->flags & EXEC_P)
1389 sofar += abfd->section_count * SCNHSZ;
1391 for (current = abfd->sections; current != NULL; current =
1393 /* Only deal with sections which have contents */
1394 if (!(current->flags & SEC_HAS_CONTENTS))
1397 /* Align the sections in the file to the same boundary on
1398 which they are aligned in virtual memory. I960 doesn't
1399 do this (FIXME) so we can stay in sync with Intel. 960
1400 doesn't yet page from files... */
1402 sofar = ALIGN(sofar, 1 << current->alignment_power);
1404 /* FIXME, in demand paged files, the low order bits of the file
1405 offset must match the low order bits of the virtual address.
1406 "Low order" is apparently implementation defined. Add code
1407 here to round sofar up to match the virtual address. */
1409 current->filepos = sofar;
1410 sofar += current->size;
1412 obj_relocbase(abfd) = sofar;
1421 DEFUN(coff_write_object_contents,(abfd),
1425 boolean hasrelocs = false;
1426 boolean haslinno = false;
1427 file_ptr reloc_base;
1428 file_ptr lineno_base;
1432 unsigned long reloc_size = 0;
1433 unsigned long lnno_size = 0;
1434 asection *text_sec = NULL;
1435 asection *data_sec = NULL;
1436 asection *bss_sec = NULL;
1438 struct internal_filehdr internal_f;
1439 struct internal_aouthdr internal_a;
1441 struct icofdata *coff = obj_icof(abfd);
1444 bfd_error = system_call_error;
1447 if(abfd->output_has_begun == false) {
1448 coff_compute_section_file_positions(abfd);
1451 if (abfd->sections != (asection *)NULL) {
1452 scn_base = abfd->sections->filepos;
1457 if (bfd_seek(abfd, scn_base, SEEK_SET) != 0)
1459 reloc_base = obj_relocbase(abfd);
1461 /* Make a pass through the symbol table to count line number entries and
1462 put them into the correct asections */
1464 coff_count_linenumbers(abfd);
1465 data_base = scn_base;
1467 /* Work out the size of the reloc and linno areas */
1469 for (current = abfd->sections; current != NULL; current = current->next) {
1470 reloc_size += current->reloc_count * RELSZ;
1471 lnno_size += current->lineno_count * LINESZ;
1472 data_base += SCNHSZ;
1475 lineno_base = reloc_base + reloc_size;
1476 sym_base = lineno_base + lnno_size;
1478 /* Indicate in each section->line_filepos its actual file address */
1479 for (current = abfd->sections; current != NULL; current = current->next) {
1480 if (current->lineno_count) {
1481 current->line_filepos = lineno_base;
1482 current->moving_line_filepos = lineno_base;
1483 lineno_base += current->lineno_count * LINESZ;
1486 current->line_filepos = 0;
1488 if (current->reloc_count) {
1489 current->rel_filepos = reloc_base;
1490 reloc_base += current->reloc_count * sizeof(struct internal_reloc);
1493 current->rel_filepos = 0;
1497 /* Write section headers to the file. */
1500 (file_ptr) ((abfd->flags & EXEC_P) ?
1501 (FILHSZ + AOUTSZ) : FILHSZ),
1506 unsigned int pad = abfd->flags & D_PAGED ? data_base : 0;
1508 unsigned int pad = 0;
1510 for (current = abfd->sections; current != NULL; current = current->next) {
1511 struct internal_scnhdr section;
1512 strncpy(&(section.s_name[0]), current->name, 8);
1513 section.s_vaddr = current->vma + pad;
1514 section.s_paddr = current->vma + pad;
1515 section.s_size = current->size - pad;
1517 If this section has no size or is unloadable then the scnptr
1520 if (current->size - pad == 0 ||
1521 (current->flags & SEC_LOAD) == 0) {
1522 section.s_scnptr = 0;
1526 section.s_scnptr = current->filepos;
1528 section.s_relptr = current->rel_filepos;
1529 section.s_lnnoptr = current->line_filepos;
1530 section.s_nreloc = current->reloc_count;
1531 section.s_nlnno = current->lineno_count;
1532 if (current->reloc_count != 0)
1534 if (current->lineno_count != 0)
1537 if (!strcmp(current->name, _TEXT)) {
1539 section.s_flags = STYP_TEXT; /* kinda stupid */
1541 else if (!strcmp(current->name, _DATA)) {
1543 section.s_flags = STYP_DATA; /* kinda stupid */
1545 else if (!strcmp(current->name, _BSS)) {
1547 section.s_flags = STYP_BSS; /* kinda stupid */
1552 section.s_align = (current->alignment_power
1553 ? 1 << current->alignment_power
1560 swap_scnhdr_out(abfd, §ion, &buff);
1561 bfd_write((PTR) (&buff), 1, SCNHSZ, abfd);
1568 /* OK, now set up the filehdr... */
1569 internal_f.f_nscns = abfd->section_count;
1571 We will NOT put a fucking timestamp in the header here. Every time you
1572 put it back, I will come in and take it out again. I'm sorry. This
1573 field does not belong here. We fill it with a 0 so it compares the
1577 Well, I like it, so I'm conditionally compiling it in.
1580 #ifdef COFF_TIMESTAMP
1581 internal_f.f_timdat = time(0);
1583 internal_f.f_timdat = 0;
1586 if (bfd_get_symcount(abfd) != 0)
1587 internal_f.f_symptr = sym_base;
1589 internal_f.f_symptr = 0;
1591 internal_f.f_flags = 0;
1593 if (abfd->flags & EXEC_P)
1594 internal_f.f_opthdr = AOUTSZ;
1596 internal_f.f_opthdr = 0;
1599 internal_f.f_flags |= F_RELFLG;
1601 internal_f.f_flags |= F_LNNO;
1602 if (0 == bfd_get_symcount(abfd))
1603 internal_f.f_flags |= F_LSYMS;
1604 if (abfd->flags & EXEC_P)
1605 internal_f.f_flags |= F_EXEC;
1607 internal_f.f_flags |= F_AR32W;
1609 if (!abfd->xvec->byteorder_big_p)
1610 internal_f.f_flags |= F_AR32WR;
1613 FIXME, should do something about the other byte orders and
1617 /* Set up architecture-dependent stuff */
1621 coff_set_flags(abfd, &magic, &flags);
1622 internal_f.f_magic = magic;
1623 internal_f.f_flags = flags;
1625 /* ...and the "opt"hdr... */
1628 internal_a.magic = (magic == I960ROMAGIC ? NMAGIC : OMAGIC);
1631 internal_a.magic = PAGEMAGICBCS;
1634 /* Now should write relocs, strings, syms */
1635 obj_sym_filepos(abfd) = sym_base;
1637 if (bfd_get_symcount(abfd) != 0) {
1638 coff_mangle_symbols(abfd);
1639 coff_write_symbols(abfd);
1640 coff_write_linenumbers(abfd);
1641 coff_write_relocs(abfd);
1644 internal_a.tsize = text_sec->size;
1645 internal_a.text_start =text_sec->size ? text_sec->vma : 0;
1648 internal_a.dsize = data_sec->size;
1649 internal_a.data_start = data_sec->size ? data_sec->vma : 0;
1652 internal_a.bsize = bss_sec->size;
1655 internal_a.entry = bfd_get_start_address(abfd);
1656 internal_f.f_nsyms = bfd_get_symcount(abfd);
1658 /* now write them */
1659 if (bfd_seek(abfd, 0L, SEEK_SET) != 0)
1663 bfd_swap_filehdr_out(abfd, &internal_f, &buff);
1664 bfd_write((PTR) &buff, 1, FILHSZ, abfd);
1666 if (abfd->flags & EXEC_P) {
1668 bfd_swap_aouthdr_out(abfd, &internal_a, &buff);
1669 bfd_write((PTR) &buff, 1, AOUTSZ, abfd);
1675 coff_set_section_contents(abfd, section, location, offset, count)
1682 if (abfd->output_has_begun == false) /* set by bfd.c handler */
1683 coff_compute_section_file_positions(abfd);
1685 bfd_seek(abfd, (file_ptr) (section->filepos + offset), SEEK_SET);
1688 return (bfd_write(location, 1, count, abfd) == count) ? true : false;
1694 coff_close_and_cleanup(abfd)
1697 if (!bfd_read_p(abfd))
1698 switch (abfd->format) {
1700 if (!_bfd_write_archive_contents(abfd))
1704 if (!coff_write_object_contents(abfd))
1708 bfd_error = invalid_operation;
1712 /* We depend on bfd_close to free all the memory on the obstack. */
1713 /* FIXME if bfd_release is not using obstacks! */
1719 buy_and_read(abfd, where, seek_direction, size)
1725 PTR area = (PTR) bfd_alloc(abfd, size);
1727 bfd_error = no_memory;
1730 bfd_seek(abfd, where, seek_direction);
1731 if (bfd_read(area, 1, size, abfd) != size) {
1732 bfd_error = system_call_error;
1736 } /* buy_and_read() */
1739 DEFUN(offset_symbol_indices,(abfd, symtab, count, offset),
1741 struct internal_syment *symtab AND
1742 unsigned long count AND
1745 struct internal_syment *end = symtab + count;
1746 for (; symtab < end; ++symtab) {
1747 if (symtab->n_sclass == C_FILE) {
1748 symtab->n_value = 0;
1750 else if (symtab->n_sclass == C_ALIAS) {
1752 These guys have indices in their values.
1754 symtab->n_value = symtab->n_value + offset;
1756 else if (symtab->n_numaux) {
1758 anybody else without an aux, has no indices.
1761 if (symtab->n_sclass == C_EOS
1762 || (BTYPE(symtab->n_type) == T_STRUCT
1763 && symtab->n_sclass != C_STRTAG)
1764 || BTYPE(symtab->n_type) == T_UNION
1765 || BTYPE(symtab->n_type) == T_ENUM) {
1766 /* If the tagndx is 0 then the struct hasn't really been
1767 defined, so leave it alone */
1769 if(((union internal_auxent *) (symtab + 1))->x_sym.x_tagndx != 0) {
1770 ((union internal_auxent *) (symtab + 1))->x_sym.x_tagndx += offset;
1773 } /* These guys have a tagndx */
1774 if (symtab->n_sclass == C_STRTAG
1775 || symtab->n_sclass == C_UNTAG
1776 || symtab->n_sclass == C_ENTAG
1777 || symtab->n_sclass == C_BLOCK
1778 || symtab->n_sclass == C_FCN
1779 || ISFCN(symtab->n_type)) {
1781 ((union internal_auxent *) (symtab +
1782 1))->x_sym.x_fcnary.x_fcn.x_endndx
1785 } /* These guys have an endndx */
1787 if (ISFCN(symtab->n_type)) {
1788 ((union internal_auxent *) (symtab + 1))->x_sym.x_tvndx += offset;
1789 } /* These guys have a tvndx. I think...
1791 #endif /* Not I960 */
1793 } /* if value, else if aux */
1794 symtab += symtab->n_numaux;
1795 } /* walk the symtab */
1798 } /* offset_symbol_indices() */
1801 /* swap the entire symbol table - we c*/
1803 swap_raw_symtab(abfd, raw_symtab)
1808 SYMENT *end = raw_symtab + bfd_get_symcount(abfd);
1809 for (; raw_symtab < end; ++raw_symtab) {
1810 bfd_coff_swap_sym(abfd, raw_symtab);
1812 for (i = raw_symtab->n_numaux; i; --i, ++raw_symtab) {
1813 bfd_coff_swap_aux(abfd,
1814 (AUXENT *)(raw_symtab + 1),
1816 raw_symtab->n_sclass);
1817 } /* swap all the aux entries */
1818 } /* walk the symbol table */
1821 } /* swap_raw_symtab() */
1824 read a symbol table into freshly mallocated memory, swap it, and knit the
1825 symbol names into a normalized form. By normalized here I mean that all
1826 symbols have an n_offset pointer that points to a NULL terminated string.
1827 Oh, and the first symbol MUST be a C_FILE. If there wasn't one there
1828 before, put one there.
1831 static struct internal_syment *
1832 DEFUN(get_normalized_symtab,(abfd),
1836 struct internal_syment *internal;
1837 struct internal_syment *internal_ptr;
1838 struct internal_syment *internal_end;
1842 char *string_table = NULL;
1844 char string_table_size_buffer[4];
1845 unsigned long string_table_size = 0;
1846 unsigned int raw_size;
1847 if (obj_raw_syments(abfd) != (struct internal_syment *)NULL) {
1848 return obj_raw_syments(abfd);
1850 if ((size = bfd_get_symcount(abfd) * sizeof(struct internal_syment)) == 0) {
1851 bfd_error = no_symbols;
1855 internal = (struct internal_syment *)bfd_alloc(abfd, size);
1856 internal_end = internal + bfd_get_symcount(abfd);
1858 raw_size = bfd_get_symcount(abfd) * SYMESZ;
1859 raw = (SYMENT *)bfd_alloc(abfd,raw_size);
1861 if (bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET) == -1
1862 || bfd_read((PTR)raw, raw_size, 1, abfd) != raw_size) {
1863 bfd_error = system_call_error;
1866 /* mark the end of the symbols */
1867 raw_end = raw + bfd_get_symcount(abfd);
1869 FIXME SOMEDAY. A string table size of zero is very weird, but
1870 probably possible. If one shows up, it will probably kill us.
1873 /* Swap all the raw entries */
1874 for (raw_src = raw, internal_ptr = internal; raw_src < raw_end; raw_src++, internal_ptr++) {
1876 bfd_coff_swap_sym_in(abfd, raw_src,internal_ptr);
1877 for (i = internal_ptr->n_numaux; i; --i, raw_src++, internal_ptr++) {
1878 bfd_coff_swap_aux_in(abfd, (AUXENT *)(raw_src +1), internal_ptr->n_type,
1879 internal_ptr->n_sclass, (union
1880 internal_auxent *)(internal_ptr +1));
1884 /* Free all the raw stuff */
1885 bfd_release(abfd, raw_src);
1887 for (internal_ptr = internal; internal_ptr < internal_end; internal_ptr ++) {
1889 if (internal_ptr->_n._n_n._n_zeroes != 0) {
1891 This is a "short" name. Make it long.
1893 unsigned long i = 0;
1894 char *newstring = NULL;
1896 find the length of this string without walking into memory
1900 for (i = 0; i < 8; ++i) {
1901 if (internal_ptr->_n._n_name[i] == '\0') {
1903 } /* if end of string */
1904 } /* possible lengths of this string. */
1906 if ((newstring = (PTR) bfd_alloc(abfd, ++i)) == NULL) {
1907 bfd_error = no_memory;
1910 bzero(newstring, i);
1911 strncpy(newstring, internal_ptr->_n._n_name, i-1);
1912 internal_ptr->_n._n_n._n_offset = (int) newstring;
1913 internal_ptr->_n._n_n._n_zeroes = 0;
1917 if (string_table == NULL) {
1919 NOTE: we don't read the string table until now because we
1920 don't necessarily know that we have one until now.
1923 At this point we should be "seek"'d to the end of the
1924 symbols === the symbol table size.
1927 if (bfd_read((char *) string_table_size_buffer,
1928 sizeof(string_table_size_buffer),
1929 1, abfd) != sizeof(string_table_size)) {
1930 bfd_error = system_call_error;
1934 string_table_size = bfd_h_getlong(abfd, string_table_size_buffer);
1936 if ((string_table = (PTR) bfd_alloc(abfd, string_table_size -= 4)) == NULL) {
1937 bfd_error = no_memory;
1939 } /* on mallocation error */
1940 if (bfd_read(string_table, string_table_size, 1, abfd) != string_table_size) {
1941 bfd_error = system_call_error;
1944 } /* have not yet read the string table. */
1946 This is a long name already. Just point it at the string in
1949 internal_ptr->_n._n_n._n_offset = (int) (string_table - 4 + internal_ptr->_n._n_n._n_offset);
1951 } /* switch on type of symbol name */
1953 internal_ptr += internal_ptr->n_numaux;
1954 } /* for each symbol */
1957 /* I'm not sure of the repercussions of this, so the Intel
1958 folks will always do the force
1960 if (obj_symbol_slew(abfd) > 0)
1961 force_indices_file_symbol_relative(abfd, internal);
1963 force_indices_file_symbol_relative(abfd, internal);
1966 obj_raw_syments(abfd) = internal;
1967 obj_string_table(abfd) = string_table;
1970 } /* get_normalized_symtab() */
1974 DEFUN(section_from_bfd_index,(abfd, index),
1979 struct sec *answer = abfd->sections;
1981 answer = answer->next;
1992 coff_slurp_line_table(abfd, asect)
1996 LINENO *native_lineno;
1997 alent *lineno_cache;
1999 BFD_ASSERT(asect->lineno == (alent *) NULL);
2001 native_lineno = (LINENO *) buy_and_read(abfd,
2002 asect->line_filepos,
2005 asect->lineno_count));
2007 (alent *) bfd_alloc(abfd, (size_t) ((asect->lineno_count + 1) * sizeof(alent)));
2008 if (lineno_cache == NULL) {
2009 bfd_error = no_memory;
2012 unsigned int counter = 0;
2013 alent *cache_ptr = lineno_cache;
2014 LINENO *src = native_lineno;
2016 while (counter < asect->lineno_count) {
2017 struct internal_lineno dst;
2018 bfd_coff_swap_lineno_in(abfd, src, &dst);
2019 cache_ptr->line_number = dst.l_lnno;
2021 if (cache_ptr->line_number == 0) {
2022 coff_symbol_type *sym =
2023 (coff_symbol_type *) (dst.l_addr.l_symndx
2024 + obj_symbol_slew(abfd)
2025 + obj_raw_syments(abfd))->_n._n_n._n_zeroes;
2026 cache_ptr->u.sym = (asymbol *) sym;
2027 sym->lineno = cache_ptr;
2030 cache_ptr->u.offset = dst.l_addr.l_paddr
2031 - bfd_section_vma(abfd, asect);
2032 } /* If no linenumber expect a symbol index */
2038 cache_ptr->line_number = 0;
2041 asect->lineno = lineno_cache;
2042 /* FIXME, free native_lineno here, or use alloca or something. */
2044 } /* coff_slurp_line_table() */
2046 static struct internal_syment *
2047 DEFUN(find_next_file_symbol,(abfd, current, end),
2049 struct internal_syment *current AND
2050 struct internal_syment *end)
2052 current += current->n_numaux + 1;
2054 while (current < end) {
2055 if (current->n_sclass== C_FILE) {
2058 current += current->n_numaux + 1;
2065 Note that C_FILE symbols can, and some do, have more than 1 aux entry.
2069 DEFUN(force_indices_file_symbol_relative,(abfd, symtab),
2071 struct internal_syment *symtab)
2073 struct internal_syment *end = symtab + bfd_get_symcount(abfd);
2074 struct internal_syment *current;
2075 struct internal_syment *next;
2076 /* the first symbol had damn well better be a C_FILE. */
2077 BFD_ASSERT(symtab->n_sclass == C_FILE);
2079 for (current = find_next_file_symbol(abfd, symtab, end);
2082 offset_symbol_indices(abfd, current,
2084 find_next_file_symbol(abfd, current,
2092 DEFUN(coff_slurp_symbol_table,(abfd),
2095 struct internal_syment *native_symbols;
2096 coff_symbol_type *cached_area;
2097 unsigned int *table_ptr;
2099 unsigned int number_of_symbols = 0;
2100 if (obj_symbols(abfd))
2102 bfd_seek(abfd, obj_sym_filepos(abfd), SEEK_SET);
2104 /* Read in the symbol table */
2105 if ((native_symbols = get_normalized_symtab(abfd)) == NULL) {
2110 /* Allocate enough room for all the symbols in cached form */
2112 (coff_symbol_type *)
2113 bfd_alloc(abfd, (size_t) (bfd_get_symcount(abfd) * sizeof(coff_symbol_type)));
2115 if (cached_area == NULL) {
2116 bfd_error = no_memory;
2121 bfd_alloc(abfd, (size_t) (bfd_get_symcount(abfd) * sizeof(unsigned int)));
2123 if (table_ptr == NULL) {
2124 bfd_error = no_memory;
2127 coff_symbol_type *dst = cached_area;
2128 unsigned int last_native_index = bfd_get_symcount(abfd);
2129 unsigned int this_index = 0;
2130 while (this_index < last_native_index) {
2131 struct internal_syment *src = native_symbols + this_index;
2132 table_ptr[this_index] = number_of_symbols;
2133 dst->symbol.the_bfd = abfd;
2135 dst->symbol.name = (char *)(src->_n._n_n._n_offset);
2137 We use the native name field to point to the cached field
2139 src->_n._n_n._n_zeroes = (int) dst;
2140 dst->symbol.section = section_from_bfd_index(abfd,
2142 switch (src->n_sclass) {
2146 dst->symbol.value = src->n_value - dst->symbol.section->vma;
2147 dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
2148 dst->symbol.flags |= BSF_NOT_AT_END;
2150 /* Fall through to next case */
2155 if ((src->n_scnum) == 0) {
2156 if ((src->n_value) == 0) {
2157 dst->symbol.flags = BSF_UNDEFINED;
2158 dst->symbol.value= 0;
2161 dst->symbol.flags = BSF_FORT_COMM;
2162 dst->symbol.value = (src->n_value);
2167 Base the value as an index from the base of the
2170 if (dst->symbol.section == (asection *) NULL) {
2171 dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL | BSF_ABSOLUTE;
2172 dst->symbol.value = src->n_value;
2175 dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
2176 dst->symbol.value = src->n_value - dst->symbol.section->vma;
2178 if (ISFCN((src->n_type))) {
2180 A function ext does not go at the end of a file
2182 dst->symbol.flags |= BSF_NOT_AT_END;
2187 case C_STAT: /* static */
2189 case C_LEAFSTAT: /* static leaf procedure */
2191 case C_LABEL: /* label */
2192 dst->symbol.flags = BSF_LOCAL;
2194 Base the value as an index from the base of the section
2196 dst->symbol.value = (src->n_value) - dst->symbol.section->vma;
2199 case C_MOS: /* member of structure */
2200 case C_EOS: /* end of structure */
2201 case C_REGPARM: /* register parameter */
2202 case C_REG: /* register variable */
2204 case C_AUTOARG: /* 960-specific storage class */
2206 case C_TPDEF: /* type definition */
2209 case C_AUTO: /* automatic variable */
2210 case C_FIELD: /* bit field */
2211 case C_ENTAG: /* enumeration tag */
2212 case C_MOE: /* member of enumeration */
2213 case C_MOU: /* member of union */
2214 case C_UNTAG: /* union tag */
2216 dst->symbol.flags = BSF_DEBUGGING;
2217 dst->symbol.value = (src->n_value);
2220 case C_FILE: /* file name */
2221 case C_STRTAG: /* structure tag */
2222 dst->symbol.flags = BSF_DEBUGGING;
2223 dst->symbol.value = (src->n_value);
2226 case C_BLOCK: /* ".bb" or ".eb" */
2227 case C_FCN: /* ".bf" or ".ef" */
2228 dst->symbol.flags = BSF_LOCAL;
2230 Base the value as an index from the base of the section
2232 dst->symbol.value = (src->n_value) - dst->symbol.section->vma;
2235 case C_EFCN: /* physical end of function */
2237 case C_EXTDEF: /* external definition */
2238 case C_ULABEL: /* undefined label */
2239 case C_USTATIC: /* undefined static */
2240 case C_LINE: /* line # reformatted as symbol table entry */
2241 case C_ALIAS: /* duplicate tag */
2242 case C_HIDDEN: /* ext symbol in dmert public lib */
2247 dst->symbol.flags = BSF_DEBUGGING;
2248 dst->symbol.value = (src->n_value);
2253 BFD_ASSERT(dst->symbol.flags != 0);
2257 dst->symbol.udata = 0;
2258 dst->lineno = (alent *) NULL;
2259 this_index += (src->n_numaux) + 1;
2261 number_of_symbols++;
2262 } /* walk the native symtab */
2263 } /* bfdize the native symtab */
2265 obj_symbols(abfd) = cached_area;
2266 obj_raw_syments(abfd) = native_symbols;
2268 bfd_get_symcount(abfd) = number_of_symbols;
2269 obj_convert(abfd) = table_ptr;
2270 /* Slurp the line tables for each section too */
2275 coff_slurp_line_table(abfd, p);
2280 } /* coff_slurp_symbol_table() */
2283 coff_get_symtab_upper_bound(abfd)
2286 if (!coff_slurp_symbol_table(abfd))
2289 return (bfd_get_symcount(abfd) + 1) * (sizeof(coff_symbol_type *));
2294 coff_get_symtab(abfd, alocation)
2296 asymbol **alocation;
2298 unsigned int counter = 0;
2299 coff_symbol_type *symbase;
2300 coff_symbol_type **location = (coff_symbol_type **) (alocation);
2301 if (!coff_slurp_symbol_table(abfd))
2304 for (symbase = obj_symbols(abfd); counter++ < bfd_get_symcount(abfd);)
2305 *(location++) = symbase++;
2307 return bfd_get_symcount(abfd);
2311 coff_get_reloc_upper_bound(abfd, asect)
2315 if (bfd_get_format(abfd) != bfd_object) {
2316 bfd_error = invalid_operation;
2319 return (asect->reloc_count + 1) * sizeof(arelent *);
2323 DEFUN(coff_slurp_reloc_table,(abfd, asect, symbols),
2328 RELOC *native_relocs;
2329 arelent *reloc_cache;
2330 if (asect->relocation)
2332 if (asect->reloc_count == 0)
2334 if (!coff_slurp_symbol_table(abfd))
2337 (RELOC *) buy_and_read(abfd,
2341 asect->reloc_count));
2342 reloc_cache = (arelent *)
2343 bfd_alloc(abfd, (size_t) (asect->reloc_count * sizeof(arelent)));
2345 if (reloc_cache == NULL) {
2346 bfd_error = no_memory;
2351 for (cache_ptr = reloc_cache,
2352 src = native_relocs;
2353 cache_ptr < reloc_cache + asect->reloc_count;
2356 struct internal_reloc dst;
2358 bfd_swap_reloc_in(abfd, src, &dst);
2359 dst.r_symndx += obj_symbol_slew(abfd);
2360 cache_ptr->sym_ptr_ptr = symbols + obj_convert(abfd)[dst.r_symndx];
2362 ptr = *(cache_ptr->sym_ptr_ptr);
2363 cache_ptr->address = dst.r_vaddr;
2365 The symbols definitions that we have read in have been
2366 relocated as if their sections started at 0. But the offsets
2367 refering to the symbols in the raw data have not been
2368 modified, so we have to have a negative addend to compensate.
2370 Note that symbols which used to be common must be left alone
2373 if (ptr->the_bfd == abfd
2374 && ptr->section != (asection *) NULL
2375 && ((ptr->flags & BSF_OLD_COMMON)== 0))
2377 cache_ptr->addend = -(ptr->section->vma + ptr->value);
2380 cache_ptr->addend = 0;
2383 cache_ptr->address -= asect->vma;
2385 cache_ptr->section = (asection *) NULL;
2388 cache_ptr->howto = howto_table + dst.r_type;
2391 cache_ptr->howto = howto_table + dst.r_type - R_RELBYTE;
2394 if (dst.r_type >= R_PCR16L && dst.r_type <= R_VRT32) {
2395 cache_ptr->howto = howto_table + dst.r_type - R_PCR16L;
2396 cache_ptr->addend += dst.r_offset << 16;
2407 asect->relocation = reloc_cache;
2412 /* This is stupid. This function should be a boolean predicate */
2414 coff_canonicalize_reloc(abfd, section, relptr, symbols)
2420 arelent *tblptr = section->relocation;
2421 unsigned int count = 0;
2422 if (!(tblptr || coff_slurp_reloc_table(abfd, section, symbols)))
2424 tblptr = section->relocation;
2428 for (; count++ < section->reloc_count;)
2429 *relptr++ = tblptr++;
2433 return section->reloc_count;
2438 provided a bfd, a section and an offset into the section, calculate and
2439 return the name of the source file and the line nearest to the wanted
2444 DEFUN(coff_find_nearest_line,(abfd,
2452 asection *section AND
2453 asymbol **symbols AND
2455 CONST char **filename_ptr AND
2456 CONST char **functionname_ptr AND
2457 unsigned int *line_ptr)
2459 static bfd *cache_abfd;
2460 static asection *cache_section;
2461 static bfd_vma cache_offset;
2462 static unsigned int cache_i;
2463 static alent *cache_l;
2466 struct icofdata *cof = obj_icof(abfd);
2467 /* Run through the raw syments if available */
2468 struct internal_syment *p;
2470 unsigned int line_base = 0;
2474 *functionname_ptr = 0;
2477 /* Don't try and find line numbers in a non coff file */
2478 if (abfd->xvec->flavour != bfd_target_coff_flavour_enum)
2481 if (cof == (struct icofdata *)NULL)
2484 p = cof->raw_syments;
2486 I don't know for sure what's right, but this isn't it. First off, an
2487 object file may not have any C_FILE's in it. After
2488 get_normalized_symtab(), it should have at least 1, the one I put
2489 there, but otherwise, all bets are off. Point #2, the first C_FILE
2490 isn't necessarily the right C_FILE because any given object may have
2491 many. I think you'll have to track sections as they coelesce in order
2492 to find the C_STAT symbol for this section. Then you'll have to work
2493 backwards to find the previous C_FILE, or choke if you get to a C_STAT
2494 for the same kind of section. That will mean that the original object
2495 file didn't have a C_FILE. xoxorich.
2498 #ifdef WEREBEINGPEDANTIC
2502 for (i = 0; i < cof->raw_syment_count; i++) {
2503 if (p->n_sclass == C_FILE) {
2504 /* File name is embeded in auxent */
2506 This isn't right. The fname should probably be normalized
2507 during get_normalized_symtab(). In any case, what was here
2508 wasn't right because a SYMENT.n_name isn't an
2509 AUXENT.x_file.x_fname. xoxorich.
2512 *filename_ptr = ((AUXENT *) (p + 1))->x_file.x_fname;
2515 p += 1 + p->n_numaux;
2517 /* Now wander though the raw linenumbers of the section */
2519 If this is the same bfd as we were previously called with and this is
2520 the same section, and the offset we want is further down then we can
2521 prime the lookup loop
2523 if (abfd == cache_abfd &&
2524 section == cache_section &&
2525 offset >= cache_offset) {
2531 l = section->lineno;
2534 for (; i < section->lineno_count; i++) {
2535 if (l->line_number == 0) {
2536 /* Get the symbol this line number points at */
2537 coff_symbol_type *coff = (coff_symbol_type *) (l->u.sym);
2538 *functionname_ptr = coff->symbol.name;
2540 struct internal_syment *s = coff->native;
2541 s = s + 1 + s->n_numaux;
2543 S should now point to the .bf of the function
2547 The linenumber is stored in the auxent
2549 union internal_auxent *a = (union internal_auxent *) (s + 1);
2550 line_base = a->x_sym.x_misc.x_lnsz.x_lnno;
2555 if (l->u.offset > offset)
2557 *line_ptr = l->line_number + line_base + 1;
2563 cache_section = section;
2564 cache_offset = offset;
2572 coff_sym_filepos(abfd)
2575 return obj_sym_filepos(abfd);
2581 DEFUN(coff_sizeof_headers,(abfd, reloc),
2587 if (reloc == false) {
2588 size = FILHSZ + AOUTSZ;
2594 size += abfd->section_count * SCNHSZ;
2599 #define coff_core_file_failing_command _bfd_dummy_core_file_failing_command
2600 #define coff_core_file_failing_signal _bfd_dummy_core_file_failing_signal
2601 #define coff_core_file_matches_executable_p _bfd_dummy_core_file_matches_executable_p
2602 #define coff_slurp_armap bfd_slurp_coff_armap
2603 #define coff_slurp_extended_name_table _bfd_slurp_extended_name_table
2604 #define coff_truncate_arname bfd_dont_truncate_arname
2605 #define coff_openr_next_archived_file bfd_generic_openr_next_archived_file
2606 #define coff_generic_stat_arch_elt bfd_generic_stat_arch_elt
2607 #define coff_get_section_contents bfd_generic_get_section_contents
2608 #define coff_close_and_cleanup bfd_generic_close_and_cleanup