1 /* coff object file format
2 Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994
3 Free Software Foundation, Inc.
5 This file is part of GAS.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to
19 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
25 const char *s_get_name PARAMS ((symbolS * s));
26 static symbolS *def_symbol_in_progress;
32 unsigned long chunk_size;
33 unsigned long element_size;
36 unsigned long pointer;
41 stack_init (chunk_size, element_size)
42 unsigned long chunk_size;
43 unsigned long element_size;
47 st = (stack *) malloc (sizeof (stack));
50 st->data = malloc (chunk_size);
57 st->size = chunk_size;
58 st->chunk_size = chunk_size;
59 st->element_size = element_size;
64 /* Not currently used. */
75 stack_push (st, element)
79 if (st->pointer + st->element_size >= st->size)
81 st->size += st->chunk_size;
82 if ((st->data = xrealloc (st->data, st->size)) == (char *) 0)
85 memcpy (st->data + st->pointer, element, st->element_size);
86 st->pointer += st->element_size;
87 return st->data + st->pointer;
94 if (st->pointer < st->element_size)
99 st->pointer -= st->element_size;
100 return st->data + st->pointer;
104 * Maintain a list of the tagnames of the structres.
107 static struct hash_control *tag_hash;
112 tag_hash = hash_new ();
116 tag_insert (name, symbolP)
120 const char *error_string;
122 if ((error_string = hash_jam (tag_hash, name, (char *) symbolP)))
124 as_fatal ("Inserting \"%s\" into structure table failed: %s",
133 #ifdef STRIP_UNDERSCORE
136 #endif /* STRIP_UNDERSCORE */
137 return (symbolS *) hash_find (tag_hash, name);
141 tag_find_or_make (name)
146 if ((symbolP = tag_find (name)) == NULL)
148 symbolP = symbol_new (name, undefined_section,
149 0, &zero_address_frag);
151 tag_insert (S_GET_NAME (symbolP), symbolP);
153 symbol_table_insert (symbolP);
164 static void SA_SET_SYM_TAGNDX PARAMS ((symbolS *, symbolS *));
167 struct line_no *next;
172 #define GET_FILENAME_STRING(X) \
173 ((char*)(&((X)->sy_symbol.ost_auxent->x_file.x_n.x_offset))[1])
177 fetch_coff_debug_section ()
179 static segT debug_section;
183 s = bfd_make_debug_symbol (stdoutput, (char *) 0, 0);
185 debug_section = s->section;
187 return debug_section;
191 SA_SET_SYM_ENDNDX (sym, val)
195 combined_entry_type *entry, *p;
197 entry = &coffsymbol (sym->bsym)->native[1];
198 p = coffsymbol (val->bsym)->native;
199 entry->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p = p;
204 SA_SET_SYM_TAGNDX (sym, val)
208 combined_entry_type *entry, *p;
210 entry = &coffsymbol (sym->bsym)->native[1];
211 p = coffsymbol (val->bsym)->native;
212 entry->u.auxent.x_sym.x_tagndx.p = p;
217 S_GET_DATA_TYPE (sym)
220 return coffsymbol (sym->bsym)->native->u.syment.n_type;
224 S_SET_DATA_TYPE (sym, val)
228 coffsymbol (sym->bsym)->native->u.syment.n_type = val;
233 S_GET_STORAGE_CLASS (sym)
236 return coffsymbol (sym->bsym)->native->u.syment.n_sclass;
240 S_SET_STORAGE_CLASS (sym, val)
244 coffsymbol (sym->bsym)->native->u.syment.n_sclass = val;
248 /* Merge a debug symbol containing debug information into a normal symbol. */
251 c_symbol_merge (debug, normal)
255 S_SET_DATA_TYPE (normal, S_GET_DATA_TYPE (debug));
256 S_SET_STORAGE_CLASS (normal, S_GET_STORAGE_CLASS (debug));
258 if (S_GET_NUMBER_AUXILIARY (debug) > S_GET_NUMBER_AUXILIARY (normal))
259 /* take the most we have */
260 S_SET_NUMBER_AUXILIARY (normal, S_GET_NUMBER_AUXILIARY (debug));
262 if (S_GET_NUMBER_AUXILIARY (debug) > 0)
264 /* Move all the auxiliary information. */
265 /* @@ How many fields do we want to preserve? Would it make more
266 sense to pick and choose those we want to copy? Should look
267 into this further.... [raeburn:19920512.2209EST] */
269 linenos = coffsymbol (normal->bsym)->lineno;
270 memcpy ((char *) &coffsymbol (normal->bsym)->native,
271 (char *) &coffsymbol (debug->bsym)->native,
272 S_GET_NUMBER_AUXILIARY(debug) * AUXESZ);
273 coffsymbol (normal->bsym)->lineno = linenos;
276 /* Move the debug flags. */
277 SF_SET_DEBUG_FIELD (normal, SF_GET_DEBUG_FIELD (debug));
280 static symbolS *previous_file_symbol;
282 c_dot_file_symbol (filename)
287 symbolP = symbol_new (filename, &bfd_abs_section, 0,
290 S_SET_STORAGE_CLASS (symbolP, C_FILE);
291 S_SET_NUMBER_AUXILIARY (symbolP, 1);
293 symbolP->bsym->flags = BSF_DEBUGGING;
300 listing_source_file (filename);
305 S_SET_VALUE (symbolP, (long) previous_file_symbol);
307 previous_file_symbol = symbolP;
309 /* Make sure that the symbol is first on the symbol chain */
310 if (symbol_rootP != symbolP)
312 if (symbolP == symbol_lastP)
314 symbol_lastP = symbol_lastP->sy_previous;
315 } /* if it was the last thing on the list */
317 symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
318 symbol_insert (symbolP, symbol_rootP, &symbol_rootP, &symbol_lastP);
319 symbol_rootP = symbolP;
320 } /* if not first on the list */
324 * Build a 'section static' symbol.
328 c_section_symbol (name, value, length, nreloc, nlnno)
332 unsigned short nreloc;
333 unsigned short nlnno;
337 symbolP = symbol_new (name,
346 S_SET_STORAGE_CLASS (symbolP, C_STAT);
347 S_SET_NUMBER_AUXILIARY (symbolP, 1);
349 SA_SET_SCN_SCNLEN (symbolP, length);
350 SA_SET_SCN_NRELOC (symbolP, nreloc);
351 SA_SET_SCN_NLINNO (symbolP, nlnno);
353 SF_SET_STATICS (symbolP);
355 return (char *) symbolP;
358 /* Line number handling */
362 /* Symbol of last function, which we should hang line#s off of. */
363 static symbolS *line_fsym;
365 #define in_function() (line_fsym != 0)
366 #define clear_function() (line_fsym = 0)
367 #define set_function(F) (line_fsym = (F), coff_add_linesym (F))
371 obj_symbol_new_hook (symbolP)
374 char underscore = 0; /* Symbol has leading _ */
377 long sz = (OBJ_COFF_MAX_AUXENTRIES + 1) * sizeof (combined_entry_type);
378 char *s = (char *) bfd_alloc_by_size_t (stdoutput, sz);
380 coffsymbol (symbolP->bsym)->native = (combined_entry_type *) s;
382 S_SET_DATA_TYPE (symbolP, T_NULL);
383 S_SET_STORAGE_CLASS (symbolP, 0);
384 S_SET_NUMBER_AUXILIARY (symbolP, 0);
386 if (S_IS_STRING (symbolP))
387 SF_SET_STRING (symbolP);
388 if (!underscore && S_IS_LOCAL (symbolP))
389 SF_SET_LOCAL (symbolP);
394 * Handle .ln directives.
397 static symbolS *current_lineno_sym;
398 static struct line_no *line_nos;
401 add_lineno (frag, offset, num)
406 struct line_no *new_line = (struct line_no *) bfd_alloc_by_size_t (stdoutput,
407 sizeof (struct line_no));
408 if (!current_lineno_sym)
412 new_line->next = line_nos;
413 new_line->frag = frag;
414 new_line->l.line_number = num;
415 new_line->l.u.offset = offset;
420 coff_add_linesym (sym)
425 add_lineno (0, 0, 0);
426 coffsymbol (current_lineno_sym->bsym)->lineno = (alent *) line_nos;
429 current_lineno_sym = sym;
433 obj_coff_ln (appline)
438 if (! appline && def_symbol_in_progress != NULL)
440 as_warn (".ln pseudo-op inside .def/.endef: ignored.");
441 demand_empty_rest_of_line ();
445 l = get_absolute_expression ();
448 add_lineno (frag_now, frag_now_fix (), l);
458 l += coff_line_base - 1;
459 listing_source_line (l);
464 demand_empty_rest_of_line ();
470 * Handle .def directives.
472 * One might ask : why can't we symbol_new if the symbol does not
473 * already exist and fill it with debug information. Because of
474 * the C_EFCN special symbol. It would clobber the value of the
475 * function symbol before we have a chance to notice that it is
476 * a C_EFCN. And a second reason is that the code is more clear this
477 * way. (at least I think it is :-).
481 #define SKIP_SEMI_COLON() while (*input_line_pointer++ != ';')
482 #define SKIP_WHITESPACES() while (*input_line_pointer == ' ' || \
483 *input_line_pointer == '\t') \
484 input_line_pointer++;
490 char name_end; /* Char after the end of name */
491 char *symbol_name; /* Name of the debug symbol */
492 char *symbol_name_copy; /* Temporary copy of the name */
493 unsigned int symbol_name_length;
495 if (def_symbol_in_progress != NULL)
497 as_warn (".def pseudo-op used inside of .def/.endef: ignored.");
498 demand_empty_rest_of_line ();
500 } /* if not inside .def/.endef */
504 symbol_name = input_line_pointer;
505 #ifdef STRIP_UNDERSCORE
506 if (symbol_name[0] == '_' && symbol_name[1] != 0)
508 #endif /* STRIP_UNDERSCORE */
510 name_end = get_symbol_end ();
511 symbol_name_length = strlen (symbol_name);
512 symbol_name_copy = xmalloc (symbol_name_length + 1);
513 strcpy (symbol_name_copy, symbol_name);
515 /* Initialize the new symbol */
516 def_symbol_in_progress = symbol_make (symbol_name_copy);
517 def_symbol_in_progress->sy_frag = &zero_address_frag;
518 S_SET_VALUE (def_symbol_in_progress, 0);
520 if (S_IS_STRING (def_symbol_in_progress))
521 SF_SET_STRING (def_symbol_in_progress);
523 *input_line_pointer = name_end;
525 demand_empty_rest_of_line ();
528 unsigned int dim_index;
531 obj_coff_endef (ignore)
535 /* DIM BUG FIX sac@cygnus.com */
537 if (def_symbol_in_progress == NULL)
539 as_warn (".endef pseudo-op used outside of .def/.endef: ignored.");
540 demand_empty_rest_of_line ();
542 } /* if not inside .def/.endef */
544 /* Set the section number according to storage class. */
545 switch (S_GET_STORAGE_CLASS (def_symbol_in_progress))
550 SF_SET_TAG (def_symbol_in_progress);
551 /* intentional fallthrough */
554 SF_SET_DEBUG (def_symbol_in_progress);
555 S_SET_SEGMENT (def_symbol_in_progress, fetch_coff_debug_section ());
559 SF_SET_LOCAL (def_symbol_in_progress); /* Do not emit this symbol. */
560 /* intentional fallthrough */
562 SF_SET_PROCESS (def_symbol_in_progress); /* Will need processing before writing */
563 /* intentional fallthrough */
567 S_SET_SEGMENT (def_symbol_in_progress, text_section);
569 name = bfd_asymbol_name (def_symbol_in_progress->bsym);
570 if (name[1] == 'b' && name[2] == 'f')
572 if (! in_function ())
573 as_warn ("`%s' symbol without preceding function", name);
574 /* SA_SET_SYM_LNNO (def_symbol_in_progress, 12345);*/
575 /* Will need relocating */
576 SF_SET_PROCESS (def_symbol_in_progress);
584 #endif /* C_AUTOARG */
594 SF_SET_DEBUG (def_symbol_in_progress);
595 S_SET_SEGMENT (def_symbol_in_progress, absolute_section);
601 /* Valid but set somewhere else (s_comm, s_lcomm, colon) */
607 as_warn ("unexpected storage class %d",
608 S_GET_STORAGE_CLASS (def_symbol_in_progress));
610 } /* switch on storage class */
612 /* Now that we have built a debug symbol, try to find if we should
613 merge with an existing symbol or not. If a symbol is C_EFCN or
614 SEG_ABSOLUTE or untagged SEG_DEBUG it never merges. */
616 /* Two cases for functions. Either debug followed by definition or
617 definition followed by debug. For definition first, we will
618 merge the debug symbol into the definition. For debug first, the
619 lineno entry MUST point to the definition function or else it
620 will point off into space when obj_crawl_symbol_chain() merges
621 the debug symbol into the real symbol. Therefor, let's presume
622 the debug symbol is a real function reference. */
624 /* FIXME-SOON If for some reason the definition label/symbol is
625 never seen, this will probably leave an undefined symbol at link
628 if (S_GET_STORAGE_CLASS (def_symbol_in_progress) == C_EFCN
629 || (!strcmp (bfd_get_section_name (stdoutput,
630 S_GET_SEGMENT (def_symbol_in_progress)),
632 && !SF_GET_TAG (def_symbol_in_progress))
633 || S_GET_SEGMENT (def_symbol_in_progress) == absolute_section
634 || (symbolP = symbol_find_base (S_GET_NAME (def_symbol_in_progress), DO_NOT_STRIP)) == NULL)
636 if (def_symbol_in_progress != symbol_lastP)
637 symbol_append (def_symbol_in_progress, symbol_lastP, &symbol_rootP,
642 /* This symbol already exists, merge the newly created symbol
643 into the old one. This is not mandatory. The linker can
644 handle duplicate symbols correctly. But I guess that it save
645 a *lot* of space if the assembly file defines a lot of
648 /* The debug entry (def_symbol_in_progress) is merged into the
649 previous definition. */
651 c_symbol_merge (def_symbol_in_progress, symbolP);
652 /* FIXME-SOON Should *def_symbol_in_progress be free'd? xoxorich. */
653 def_symbol_in_progress = symbolP;
655 if (SF_GET_FUNCTION (def_symbol_in_progress)
656 || SF_GET_TAG (def_symbol_in_progress))
658 /* For functions, and tags, the symbol *must* be where the
659 debug symbol appears. Move the existing symbol to the
661 /* If it already is at the end of the symbol list, do nothing */
662 if (def_symbol_in_progress != symbol_lastP)
664 symbol_remove (def_symbol_in_progress, &symbol_rootP, &symbol_lastP);
665 symbol_append (def_symbol_in_progress, symbol_lastP, &symbol_rootP, &symbol_lastP);
670 if (SF_GET_TAG (def_symbol_in_progress)
671 && symbol_find_base (S_GET_NAME (def_symbol_in_progress), DO_NOT_STRIP) == NULL)
673 tag_insert (S_GET_NAME (def_symbol_in_progress), def_symbol_in_progress);
676 if (SF_GET_FUNCTION (def_symbol_in_progress))
678 know (sizeof (def_symbol_in_progress) <= sizeof (long));
679 set_function (def_symbol_in_progress);
680 SF_SET_PROCESS (def_symbol_in_progress);
684 /* That is, if this is the first time we've seen the
686 symbol_table_insert (def_symbol_in_progress);
687 } /* definition follows debug */
688 } /* Create the line number entry pointing to the function being defined */
690 def_symbol_in_progress = NULL;
691 demand_empty_rest_of_line ();
695 obj_coff_dim (ignore)
700 if (def_symbol_in_progress == NULL)
702 as_warn (".dim pseudo-op used outside of .def/.endef: ignored.");
703 demand_empty_rest_of_line ();
705 } /* if not inside .def/.endef */
707 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
709 for (dim_index = 0; dim_index < DIMNUM; dim_index++)
712 SA_SET_SYM_DIMEN (def_symbol_in_progress, dim_index,
713 get_absolute_expression ());
715 switch (*input_line_pointer)
718 input_line_pointer++;
722 as_warn ("badly formed .dim directive ignored");
723 /* intentional fallthrough */
731 demand_empty_rest_of_line ();
735 obj_coff_line (ignore)
740 if (def_symbol_in_progress == NULL)
742 /* Probably stabs-style line? */
747 this_base = get_absolute_expression ();
748 if (this_base > coff_line_base)
749 coff_line_base = this_base;
751 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
752 SA_SET_SYM_LNNO (def_symbol_in_progress, coff_line_base);
754 demand_empty_rest_of_line ();
758 obj_coff_size (ignore)
761 if (def_symbol_in_progress == NULL)
763 as_warn (".size pseudo-op used outside of .def/.endef ignored.");
764 demand_empty_rest_of_line ();
766 } /* if not inside .def/.endef */
768 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
769 SA_SET_SYM_SIZE (def_symbol_in_progress, get_absolute_expression ());
770 demand_empty_rest_of_line ();
774 obj_coff_scl (ignore)
777 if (def_symbol_in_progress == NULL)
779 as_warn (".scl pseudo-op used outside of .def/.endef ignored.");
780 demand_empty_rest_of_line ();
782 } /* if not inside .def/.endef */
784 S_SET_STORAGE_CLASS (def_symbol_in_progress, get_absolute_expression ());
785 demand_empty_rest_of_line ();
789 obj_coff_tag (ignore)
795 if (def_symbol_in_progress == NULL)
797 as_warn (".tag pseudo-op used outside of .def/.endef ignored.");
798 demand_empty_rest_of_line ();
802 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
803 symbol_name = input_line_pointer;
804 name_end = get_symbol_end ();
806 /* Assume that the symbol referred to by .tag is always defined.
807 This was a bad assumption. I've added find_or_make. xoxorich. */
808 SA_SET_SYM_TAGNDX (def_symbol_in_progress,
809 tag_find_or_make (symbol_name));
810 if (SA_GET_SYM_TAGNDX (def_symbol_in_progress) == 0L)
812 as_warn ("tag not found for .tag %s", symbol_name);
815 SF_SET_TAGGED (def_symbol_in_progress);
816 *input_line_pointer = name_end;
818 demand_empty_rest_of_line ();
822 obj_coff_type (ignore)
825 if (def_symbol_in_progress == NULL)
827 as_warn (".type pseudo-op used outside of .def/.endef ignored.");
828 demand_empty_rest_of_line ();
830 } /* if not inside .def/.endef */
832 S_SET_DATA_TYPE (def_symbol_in_progress, get_absolute_expression ());
834 if (ISFCN (S_GET_DATA_TYPE (def_symbol_in_progress)) &&
835 S_GET_STORAGE_CLASS (def_symbol_in_progress) != C_TPDEF)
837 SF_SET_FUNCTION (def_symbol_in_progress);
838 } /* is a function */
840 demand_empty_rest_of_line ();
844 obj_coff_val (ignore)
847 if (def_symbol_in_progress == NULL)
849 as_warn (".val pseudo-op used outside of .def/.endef ignored.");
850 demand_empty_rest_of_line ();
852 } /* if not inside .def/.endef */
854 if (is_name_beginner (*input_line_pointer))
856 char *symbol_name = input_line_pointer;
857 char name_end = get_symbol_end ();
859 if (!strcmp (symbol_name, "."))
861 def_symbol_in_progress->sy_frag = frag_now;
862 S_SET_VALUE (def_symbol_in_progress, (valueT) frag_now_fix ());
863 /* If the .val is != from the .def (e.g. statics) */
865 else if (strcmp (S_GET_NAME (def_symbol_in_progress), symbol_name))
867 def_symbol_in_progress->sy_value.X_op = O_symbol;
868 def_symbol_in_progress->sy_value.X_add_symbol =
869 symbol_find_or_make (symbol_name);
870 def_symbol_in_progress->sy_value.X_op_symbol = NULL;
871 def_symbol_in_progress->sy_value.X_add_number = 0;
873 /* If the segment is undefined when the forward reference is
874 resolved, then copy the segment id from the forward
876 SF_SET_GET_SEGMENT (def_symbol_in_progress);
878 /* Otherwise, it is the name of a non debug symbol and its value will be calculated later. */
879 *input_line_pointer = name_end;
883 S_SET_VALUE (def_symbol_in_progress, get_absolute_expression ());
884 } /* if symbol based */
886 demand_empty_rest_of_line ();
890 obj_read_begin_hook ()
892 /* These had better be the same. Usually 18 bytes. */
894 know (sizeof (SYMENT) == sizeof (AUXENT));
895 know (SYMESZ == AUXESZ);
901 symbolS *coff_last_function;
904 coff_frob_symbol (symp, punt)
908 static symbolS *last_tagP;
909 static stack *block_stack;
910 static symbolS *set_end;
912 if (symp == &abs_symbol)
918 if (current_lineno_sym)
919 coff_add_linesym ((symbolS *) 0);
922 block_stack = stack_init (512, sizeof (symbolS*));
924 if (!S_IS_DEFINED (symp) && S_GET_STORAGE_CLASS (symp) != C_STAT)
925 S_SET_STORAGE_CLASS (symp, C_EXT);
927 if (!SF_GET_DEBUG (symp))
930 if (!SF_GET_LOCAL (symp)
931 && (real = symbol_find_base (S_GET_NAME (symp), DO_NOT_STRIP))
934 c_symbol_merge (symp, real);
937 if (!S_IS_DEFINED (symp) && !SF_GET_LOCAL (symp))
939 assert (S_GET_VALUE (symp) == 0);
940 S_SET_EXTERNAL (symp);
942 else if (S_GET_STORAGE_CLASS (symp) == C_NULL)
944 if (S_GET_SEGMENT (symp) == text_section
945 && symp != seg_info (text_section)->sym)
946 S_SET_STORAGE_CLASS (symp, C_LABEL);
948 S_SET_STORAGE_CLASS (symp, C_STAT);
950 if (SF_GET_PROCESS (symp))
952 if (S_GET_STORAGE_CLASS (symp) == C_BLOCK)
954 if (!strcmp (S_GET_NAME (symp), ".bb"))
955 stack_push (block_stack, (char *) &symp);
959 begin = *(symbolS **) stack_pop (block_stack);
961 as_warn ("mismatched .eb");
966 if (coff_last_function == 0 && SF_GET_FUNCTION (symp))
968 union internal_auxent *auxp;
969 coff_last_function = symp;
970 if (S_GET_NUMBER_AUXILIARY (symp) < 1)
971 S_SET_NUMBER_AUXILIARY (symp, 1);
972 auxp = &coffsymbol (symp->bsym)->native[1].u.auxent;
973 memset (auxp->x_sym.x_fcnary.x_ary.x_dimen, 0,
974 sizeof (auxp->x_sym.x_fcnary.x_ary.x_dimen));
976 if (S_GET_STORAGE_CLASS (symp) == C_EFCN)
978 if (coff_last_function == 0)
979 as_fatal ("C_EFCN symbol out of scope");
980 SA_SET_SYM_FSIZE (coff_last_function,
981 (long) (S_GET_VALUE (symp)
982 - S_GET_VALUE (coff_last_function)));
983 set_end = coff_last_function;
984 coff_last_function = 0;
987 else if (SF_GET_TAG (symp))
989 else if (S_GET_STORAGE_CLASS (symp) == C_EOS)
991 else if (S_GET_STORAGE_CLASS (symp) == C_FILE)
993 if (S_GET_VALUE (symp))
995 S_SET_VALUE ((symbolS *) S_GET_VALUE (symp), 0xdeadbeef);
996 S_SET_VALUE (symp, 0);
999 if (S_IS_EXTERNAL (symp))
1000 S_SET_STORAGE_CLASS (symp, C_EXT);
1001 else if (SF_GET_LOCAL (symp))
1006 if (set_end != (symbolS *) NULL
1009 SA_SET_SYM_ENDNDX (set_end, symp);
1013 if (coffsymbol (symp->bsym)->lineno)
1016 struct line_no *lptr;
1019 lptr = (struct line_no *) coffsymbol (symp->bsym)->lineno;
1020 for (i = 0; lptr; lptr = lptr->next)
1023 lptr = (struct line_no *) coffsymbol (symp->bsym)->lineno;
1024 l = (alent *) bfd_alloc_by_size_t (stdoutput, n * sizeof (alent));
1025 coffsymbol (symp->bsym)->lineno = l;
1026 for (i = n - 1; i > 0; i--)
1029 lptr->l.u.offset += lptr->frag->fr_address;
1037 * implement the .section pseudo op:
1038 * .section name {, "flags"}
1040 * | +--- optional flags: 'b' for bss
1042 * +-- section name 'l' for lib
1046 * 'd' (apparently m88k for data)
1048 * But if the argument is not a quoted string, treat it as a
1049 * subsegment number.
1053 obj_coff_section (ignore)
1056 /* Strip out the section name */
1064 section_name = input_line_pointer;
1065 c = get_symbol_end ();
1067 name = xmalloc (input_line_pointer - section_name + 1);
1068 strcpy (name, section_name);
1070 *input_line_pointer = c;
1075 flags = SEC_NO_FLAGS;
1077 if (*input_line_pointer == ',')
1079 ++input_line_pointer;
1081 if (*input_line_pointer != '"')
1082 exp = get_absolute_expression ();
1085 ++input_line_pointer;
1086 while (*input_line_pointer != '"'
1087 && ! is_end_of_line[(unsigned char) *input_line_pointer])
1089 switch (*input_line_pointer)
1091 case 'b': flags |= SEC_ALLOC; flags &=~ SEC_LOAD; break;
1092 case 'n': flags &=~ SEC_LOAD; break;
1094 case 'w': flags &=~ SEC_READONLY; break;
1095 case 'x': flags |= SEC_CODE; break;
1097 case 'i': /* STYP_INFO */
1098 case 'l': /* STYP_LIB */
1099 case 'o': /* STYP_OVER */
1100 as_warn ("unsupported section attribute '%c'",
1101 *input_line_pointer);
1105 as_warn("unknown section attribute '%c'",
1106 *input_line_pointer);
1109 ++input_line_pointer;
1111 if (*input_line_pointer == '"')
1112 ++input_line_pointer;
1116 sec = subseg_new (name, (subsegT) exp);
1118 if (flags != SEC_NO_FLAGS)
1120 if (! bfd_set_section_flags (stdoutput, sec, flags))
1121 as_warn ("error setting flags for \"%s\": %s",
1122 bfd_section_name (stdoutput, sec),
1123 bfd_errmsg (bfd_get_error ()));
1128 coff_adjust_symtab ()
1130 if (symbol_rootP == NULL
1131 || S_GET_STORAGE_CLASS (symbol_rootP) != C_FILE)
1133 assert (previous_file_symbol == 0);
1134 c_dot_file_symbol ("fake");
1139 coff_frob_section (sec)
1145 bfd_vma size, n_entries, mask;
1147 /* The COFF back end in BFD requires that all section sizes be
1148 rounded up to multiples of the corresponding section alignments.
1149 Seems kinda silly to me, but that's the way it is. */
1150 size = bfd_get_section_size_before_reloc (sec);
1151 assert (sec->alignment_power >= stdoutput->xvec->align_power_min);
1152 mask = ((bfd_vma) 1 << (bfd_vma) sec->alignment_power) - 1;
1154 bfd_set_section_size (stdoutput, sec, (size + mask) & ~mask);
1156 /* @@ these should be in a "stabs.h" file, or maybe as.h */
1157 #ifndef STAB_SECTION_NAME
1158 #define STAB_SECTION_NAME ".stab"
1160 #ifndef STAB_STRING_SECTION_NAME
1161 #define STAB_STRING_SECTION_NAME ".stabstr"
1163 if (strcmp (STAB_STRING_SECTION_NAME, sec->name))
1167 sec = subseg_get (STAB_SECTION_NAME, 0);
1168 /* size is already rounded up, since other section will be listed first */
1169 size = bfd_get_section_size_before_reloc (strsec);
1171 n_entries = bfd_get_section_size_before_reloc (sec) / 12 - 1;
1173 /* Find first non-empty frag. It should be large enough. */
1174 fragp = seg_info (sec)->frchainP->frch_root;
1175 while (fragp && fragp->fr_fix == 0)
1176 fragp = fragp->fr_next;
1177 assert (fragp != 0 && fragp->fr_fix >= 12);
1179 /* Store the values. */
1180 p = fragp->fr_literal;
1181 bfd_h_put_16 (stdoutput, n_entries, (bfd_byte *) p + 6);
1182 bfd_h_put_32 (stdoutput, size, (bfd_byte *) p + 8);
1186 obj_coff_init_stab_section (seg)
1192 unsigned int stroff;
1194 /* Make space for this first symbol. */
1198 as_where (&file, (unsigned int *) NULL);
1199 stabstr_name = (char *) alloca (strlen (seg->name) + 4);
1200 strcpy (stabstr_name, seg->name);
1201 strcat (stabstr_name, "str");
1202 stroff = get_stab_string_offset (file, stabstr_name);
1204 md_number_to_chars (p, stroff, 4);
1213 return ((s == NULL) ? "(NULL)" : S_GET_NAME (s));
1221 for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
1223 printf("0x%lx: \"%s\" type = %ld, class = %d, segment = %d\n",
1224 (unsigned long) symbolP,
1225 S_GET_NAME(symbolP),
1226 (long) S_GET_DATA_TYPE(symbolP),
1227 S_GET_STORAGE_CLASS(symbolP),
1228 (int) S_GET_SEGMENT(symbolP));
1234 #else /* not BFD_ASSEMBLER */
1237 /* This is needed because we include internal bfd things. */
1239 #include "../bfd/libbfd.h"
1240 #include "../bfd/libcoff.h"
1242 /* The NOP_OPCODE is for the alignment fill value. Fill with nop so
1243 that we can stick sections together without causing trouble. */
1245 #define NOP_OPCODE 0x00
1248 /* The zeroes if symbol name is longer than 8 chars */
1249 #define S_SET_ZEROES(s,v) ((s)->sy_symbol.ost_entry.n_zeroes = (v))
1251 #define MIN(a,b) ((a) < (b)? (a) : (b))
1252 /* This vector is used to turn an internal segment into a section #
1253 suitable for insertion into a coff symbol table
1256 const short seg_N_TYPE[] =
1257 { /* in: segT out: N_TYPE bits */
1269 C_UNDEF_SECTION, /* SEG_UNKNOWN */
1270 C_UNDEF_SECTION, /* SEG_GOOF */
1271 C_UNDEF_SECTION, /* SEG_EXPR */
1272 C_DEBUG_SECTION, /* SEG_DEBUG */
1273 C_NTV_SECTION, /* SEG_NTV */
1274 C_PTV_SECTION, /* SEG_PTV */
1275 C_REGISTER_SECTION, /* SEG_REGISTER */
1278 int function_lineoff = -1; /* Offset in line#s where the last function
1279 started (the odd entry for line #0) */
1281 static symbolS *last_line_symbol;
1283 /* Add 4 to the real value to get the index and compensate the
1284 negatives. This vector is used by S_GET_SEGMENT to turn a coff
1285 section number into a segment number
1287 static symbolS *previous_file_symbol;
1288 void c_symbol_merge ();
1289 static int line_base;
1291 symbolS *c_section_symbol ();
1294 static void fixup_segment PARAMS ((segment_info_type *segP,
1295 segT this_segment_type));
1298 static void fixup_mdeps PARAMS ((fragS *,
1303 static void fill_section PARAMS ((bfd * abfd,
1308 static int c_line_new PARAMS ((symbolS * symbol, long paddr,
1313 static void w_symbols PARAMS ((bfd * abfd, char *where,
1314 symbolS * symbol_rootP));
1316 static void adjust_stab_section PARAMS ((bfd *abfd, segT seg));
1318 static void obj_coff_lcomm PARAMS ((int));
1319 static void obj_coff_text PARAMS ((int));
1320 static void obj_coff_data PARAMS ((int));
1321 static void obj_coff_bss PARAMS ((int));
1322 static void obj_coff_ident PARAMS ((int));
1323 void obj_coff_section PARAMS ((int));
1327 We allow more than just the standard 3 sections, infact, we allow
1328 10 sections, (though the usual three have to be there).
1330 This structure performs the mappings for us:
1341 static const seg_info_type seg_info_off_by_4[N_SEG] =
1372 #define SEG_INFO_FROM_SECTION_NUMBER(x) (seg_info_off_by_4[(x)+4])
1374 static relax_addressT
1375 relax_align (address, alignment)
1376 relax_addressT address;
1379 relax_addressT mask;
1380 relax_addressT new_address;
1382 mask = ~((~0) << alignment);
1383 new_address = (address + mask) & (~mask);
1384 return (new_address - address);
1392 return SEG_INFO_FROM_SECTION_NUMBER (x->sy_symbol.ost_entry.n_scnum).seg_t;
1397 /* calculate the size of the frag chain and fill in the section header
1398 to contain all of it, also fill in the addr of the sections */
1400 size_section (abfd, idx)
1405 unsigned int size = 0;
1406 fragS *frag = segment_info[idx].frchainP->frch_root;
1409 size = frag->fr_address;
1410 if (frag->fr_address != size)
1412 fprintf (stderr, "Out of step\n");
1413 size = frag->fr_address;
1416 switch (frag->fr_type)
1418 #ifdef TC_COFF_SIZEMACHDEP
1419 case rs_machine_dependent:
1420 size += TC_COFF_SIZEMACHDEP (frag);
1425 size += frag->fr_fix;
1426 size += frag->fr_offset * frag->fr_var;
1429 size += frag->fr_fix;
1430 size += relax_align (size, frag->fr_offset);
1433 BAD_CASE (frag->fr_type);
1436 frag = frag->fr_next;
1438 segment_info[idx].scnhdr.s_size = size;
1444 count_entries_in_chain (idx)
1447 unsigned int nrelocs;
1450 /* Count the relocations */
1451 fixup_ptr = segment_info[idx].fix_root;
1453 while (fixup_ptr != (fixS *) NULL)
1455 if (TC_COUNT_RELOC (fixup_ptr))
1458 if (fixup_ptr->fx_r_type == RELOC_CONSTH)
1467 fixup_ptr = fixup_ptr->fx_next;
1472 /* output all the relocations for a section */
1474 do_relocs_for (abfd, h, file_cursor)
1477 unsigned long *file_cursor;
1479 unsigned int nrelocs;
1481 unsigned long reloc_start = *file_cursor;
1483 for (idx = SEG_E0; idx < SEG_E9; idx++)
1485 if (segment_info[idx].scnhdr.s_name[0])
1487 struct external_reloc *ext_ptr;
1488 struct external_reloc *external_reloc_vec;
1489 unsigned int external_reloc_size;
1490 unsigned int base = segment_info[idx].scnhdr.s_paddr;
1491 fixS *fix_ptr = segment_info[idx].fix_root;
1492 nrelocs = count_entries_in_chain (idx);
1495 /* Bypass this stuff if no relocs. This also incidentally
1496 avoids a SCO bug, where free(malloc(0)) tends to crash. */
1498 external_reloc_size = nrelocs * RELSZ;
1499 external_reloc_vec =
1500 (struct external_reloc *) malloc (external_reloc_size);
1502 ext_ptr = external_reloc_vec;
1504 /* Fill in the internal coff style reloc struct from the
1505 internal fix list. */
1508 symbolS *symbol_ptr;
1509 struct internal_reloc intr;
1511 /* Only output some of the relocations */
1512 if (TC_COUNT_RELOC (fix_ptr))
1514 #ifdef TC_RELOC_MANGLE
1515 TC_RELOC_MANGLE (fix_ptr, &intr, base);
1519 symbol_ptr = fix_ptr->fx_addsy;
1521 intr.r_type = TC_COFF_FIX2RTYPE (fix_ptr);
1523 base + fix_ptr->fx_frag->fr_address + fix_ptr->fx_where;
1526 intr.r_offset = fix_ptr->fx_offset;
1531 /* Turn the segment of the symbol into an offset. */
1534 dot = segment_info[S_GET_SEGMENT (symbol_ptr)].dot;
1537 intr.r_symndx = dot->sy_number;
1541 intr.r_symndx = symbol_ptr->sy_number;
1551 (void) bfd_coff_swap_reloc_out (abfd, &intr, ext_ptr);
1554 #if defined(TC_A29K)
1556 /* The 29k has a special kludge for the high 16 bit
1557 reloc. Two relocations are emited, R_IHIHALF,
1558 and R_IHCONST. The second one doesn't contain a
1559 symbol, but uses the value for offset. */
1561 if (intr.r_type == R_IHIHALF)
1563 /* now emit the second bit */
1564 intr.r_type = R_IHCONST;
1565 intr.r_symndx = fix_ptr->fx_addnumber;
1566 (void) bfd_coff_swap_reloc_out (abfd, &intr, ext_ptr);
1572 fix_ptr = fix_ptr->fx_next;
1575 /* Write out the reloc table */
1576 bfd_write ((PTR) external_reloc_vec, 1, external_reloc_size,
1578 free (external_reloc_vec);
1580 /* Fill in section header info. */
1581 segment_info[idx].scnhdr.s_relptr = *file_cursor;
1582 *file_cursor += external_reloc_size;
1583 segment_info[idx].scnhdr.s_nreloc = nrelocs;
1588 segment_info[idx].scnhdr.s_relptr = 0;
1592 /* Set relocation_size field in file headers */
1593 H_SET_RELOCATION_SIZE (h, *file_cursor - reloc_start, 0);
1597 /* run through a frag chain and write out the data to go with it, fill
1598 in the scnhdrs with the info on the file postions
1601 fill_section (abfd, h, file_cursor)
1604 unsigned long *file_cursor;
1608 unsigned int paddr = 0;
1610 for (i = SEG_E0; i < SEG_UNKNOWN; i++)
1612 unsigned int offset = 0;
1614 struct internal_scnhdr *s = &(segment_info[i].scnhdr);
1618 fragS *frag = segment_info[i].frchainP->frch_root;
1625 buffer = xmalloc (s->s_size);
1626 s->s_scnptr = *file_cursor;
1628 know (s->s_paddr == paddr);
1630 if (strcmp (s->s_name, ".text") == 0)
1631 s->s_flags |= STYP_TEXT;
1632 else if (strcmp (s->s_name, ".data") == 0)
1633 s->s_flags |= STYP_DATA;
1634 else if (strcmp (s->s_name, ".bss") == 0)
1637 s->s_flags |= STYP_BSS;
1639 /* @@ Should make the i386 and a29k coff targets define
1640 COFF_NOLOAD_PROBLEM, and have only one test here. */
1643 #ifndef COFF_NOLOAD_PROBLEM
1644 /* Apparently the SVR3 linker (and exec syscall) and UDI
1645 mondfe progrem are confused by noload sections. */
1646 s->s_flags |= STYP_NOLOAD;
1651 else if (strcmp (s->s_name, ".lit") == 0)
1652 s->s_flags = STYP_LIT | STYP_TEXT;
1653 else if (strcmp (s->s_name, ".init") == 0)
1654 s->s_flags |= STYP_TEXT;
1655 else if (strcmp (s->s_name, ".fini") == 0)
1656 s->s_flags |= STYP_TEXT;
1657 else if (strncmp (s->s_name, ".comment", 8) == 0)
1658 s->s_flags |= STYP_INFO;
1662 unsigned int fill_size;
1663 switch (frag->fr_type)
1665 case rs_machine_dependent:
1668 memcpy (buffer + frag->fr_address,
1670 (unsigned int) frag->fr_fix);
1671 offset += frag->fr_fix;
1680 memcpy (buffer + frag->fr_address,
1682 (unsigned int) frag->fr_fix);
1683 offset += frag->fr_fix;
1686 fill_size = frag->fr_var;
1687 if (fill_size && frag->fr_offset > 0)
1690 unsigned int off = frag->fr_fix;
1691 for (count = frag->fr_offset; count; count--)
1693 if (fill_size + frag->fr_address + off <= s->s_size)
1695 memcpy (buffer + frag->fr_address + off,
1696 frag->fr_literal + frag->fr_fix,
1699 offset += fill_size;
1704 case rs_broken_word:
1709 frag = frag->fr_next;
1714 if (s->s_scnptr != 0)
1716 bfd_write (buffer, s->s_size, 1, abfd);
1717 *file_cursor += s->s_size;
1726 /* Coff file generation & utilities */
1729 coff_header_append (abfd, h)
1737 bfd_seek (abfd, 0, 0);
1739 #ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER
1740 H_SET_MAGIC_NUMBER (h, COFF_MAGIC);
1741 H_SET_VERSION_STAMP (h, 0);
1742 H_SET_ENTRY_POINT (h, 0);
1743 H_SET_TEXT_START (h, segment_info[SEG_E0].frchainP->frch_root->fr_address);
1744 H_SET_DATA_START (h, segment_info[SEG_E1].frchainP->frch_root->fr_address);
1745 H_SET_SIZEOF_OPTIONAL_HEADER (h, bfd_coff_swap_aouthdr_out(abfd, &h->aouthdr,
1747 #else /* defined (OBJ_COFF_OMIT_OPTIONAL_HEADER) */
1748 H_SET_SIZEOF_OPTIONAL_HEADER (h, 0);
1749 #endif /* defined (OBJ_COFF_OMIT_OPTIONAL_HEADER) */
1751 i = bfd_coff_swap_filehdr_out (abfd, &h->filehdr, buffer);
1753 bfd_write (buffer, i, 1, abfd);
1754 bfd_write (buffero, H_GET_SIZEOF_OPTIONAL_HEADER (h), 1, abfd);
1756 for (i = SEG_E0; i < SEG_E9; i++)
1758 if (segment_info[i].scnhdr.s_name[0])
1761 bfd_coff_swap_scnhdr_out (abfd,
1762 &(segment_info[i].scnhdr),
1764 bfd_write (buffer, size, 1, abfd);
1771 symbol_to_chars (abfd, where, symbolP)
1776 unsigned int numaux = symbolP->sy_symbol.ost_entry.n_numaux;
1780 /* Turn any symbols with register attributes into abs symbols */
1781 if (S_GET_SEGMENT (symbolP) == reg_section)
1783 S_SET_SEGMENT (symbolP, absolute_section);
1785 /* At the same time, relocate all symbols to their output value */
1787 val = (segment_info[S_GET_SEGMENT (symbolP)].scnhdr.s_paddr
1788 + S_GET_VALUE (symbolP));
1790 S_SET_VALUE (symbolP, val);
1792 symbolP->sy_symbol.ost_entry.n_value = val;
1794 where += bfd_coff_swap_sym_out (abfd, &symbolP->sy_symbol.ost_entry,
1797 for (i = 0; i < numaux; i++)
1799 where += bfd_coff_swap_aux_out (abfd,
1800 &symbolP->sy_symbol.ost_auxent[i],
1801 S_GET_DATA_TYPE (symbolP),
1802 S_GET_STORAGE_CLASS (symbolP),
1810 obj_symbol_new_hook (symbolP)
1813 char underscore = 0; /* Symbol has leading _ */
1815 /* Effective symbol */
1816 /* Store the pointer in the offset. */
1817 S_SET_ZEROES (symbolP, 0L);
1818 S_SET_DATA_TYPE (symbolP, T_NULL);
1819 S_SET_STORAGE_CLASS (symbolP, 0);
1820 S_SET_NUMBER_AUXILIARY (symbolP, 0);
1821 /* Additional information */
1822 symbolP->sy_symbol.ost_flags = 0;
1823 /* Auxiliary entries */
1824 memset ((char *) &symbolP->sy_symbol.ost_auxent[0], 0, AUXESZ);
1826 if (S_IS_STRING (symbolP))
1827 SF_SET_STRING (symbolP);
1828 if (!underscore && S_IS_LOCAL (symbolP))
1829 SF_SET_LOCAL (symbolP);
1833 * Handle .ln directives.
1837 obj_coff_ln (appline)
1842 if (! appline && def_symbol_in_progress != NULL)
1844 as_warn (".ln pseudo-op inside .def/.endef: ignored.");
1845 demand_empty_rest_of_line ();
1847 } /* wrong context */
1850 obstack_next_free (&frags) - frag_now->fr_literal,
1851 l = get_absolute_expression (),
1861 listing_source_line ((unsigned int) l);
1866 demand_empty_rest_of_line ();
1872 * Handle .def directives.
1874 * One might ask : why can't we symbol_new if the symbol does not
1875 * already exist and fill it with debug information. Because of
1876 * the C_EFCN special symbol. It would clobber the value of the
1877 * function symbol before we have a chance to notice that it is
1878 * a C_EFCN. And a second reason is that the code is more clear this
1879 * way. (at least I think it is :-).
1883 #define SKIP_SEMI_COLON() while (*input_line_pointer++ != ';')
1884 #define SKIP_WHITESPACES() while (*input_line_pointer == ' ' || \
1885 *input_line_pointer == '\t') \
1886 input_line_pointer++;
1892 char name_end; /* Char after the end of name */
1893 char *symbol_name; /* Name of the debug symbol */
1894 char *symbol_name_copy; /* Temporary copy of the name */
1895 unsigned int symbol_name_length;
1897 if (def_symbol_in_progress != NULL)
1899 as_warn (".def pseudo-op used inside of .def/.endef: ignored.");
1900 demand_empty_rest_of_line ();
1902 } /* if not inside .def/.endef */
1904 SKIP_WHITESPACES ();
1906 def_symbol_in_progress = (symbolS *) obstack_alloc (¬es, sizeof (*def_symbol_in_progress));
1907 memset (def_symbol_in_progress, 0, sizeof (*def_symbol_in_progress));
1909 symbol_name = input_line_pointer;
1910 name_end = get_symbol_end ();
1911 symbol_name_length = strlen (symbol_name);
1912 symbol_name_copy = xmalloc (symbol_name_length + 1);
1913 strcpy (symbol_name_copy, symbol_name);
1915 /* Initialize the new symbol */
1916 #ifdef STRIP_UNDERSCORE
1917 S_SET_NAME (def_symbol_in_progress, (*symbol_name_copy == '_'
1918 ? symbol_name_copy + 1
1919 : symbol_name_copy));
1920 #else /* STRIP_UNDERSCORE */
1921 S_SET_NAME (def_symbol_in_progress, symbol_name_copy);
1922 #endif /* STRIP_UNDERSCORE */
1923 /* free(symbol_name_copy); */
1924 def_symbol_in_progress->sy_name_offset = (unsigned long) ~0;
1925 def_symbol_in_progress->sy_number = ~0;
1926 def_symbol_in_progress->sy_frag = &zero_address_frag;
1927 S_SET_VALUE (def_symbol_in_progress, 0);
1929 if (S_IS_STRING (def_symbol_in_progress))
1930 SF_SET_STRING (def_symbol_in_progress);
1932 *input_line_pointer = name_end;
1934 demand_empty_rest_of_line ();
1937 unsigned int dim_index;
1941 obj_coff_endef (ignore)
1944 symbolS *symbolP = 0;
1945 /* DIM BUG FIX sac@cygnus.com */
1947 if (def_symbol_in_progress == NULL)
1949 as_warn (".endef pseudo-op used outside of .def/.endef: ignored.");
1950 demand_empty_rest_of_line ();
1952 } /* if not inside .def/.endef */
1954 /* Set the section number according to storage class. */
1955 switch (S_GET_STORAGE_CLASS (def_symbol_in_progress))
1960 SF_SET_TAG (def_symbol_in_progress);
1961 /* intentional fallthrough */
1964 SF_SET_DEBUG (def_symbol_in_progress);
1965 S_SET_SEGMENT (def_symbol_in_progress, SEG_DEBUG);
1969 SF_SET_LOCAL (def_symbol_in_progress); /* Do not emit this symbol. */
1970 /* intentional fallthrough */
1972 SF_SET_PROCESS (def_symbol_in_progress); /* Will need processing before writing */
1973 /* intentional fallthrough */
1975 S_SET_SEGMENT (def_symbol_in_progress, SEG_E0);
1977 if (strcmp (S_GET_NAME (def_symbol_in_progress), ".bf") == 0)
1979 if (function_lineoff < 0)
1981 fprintf (stderr, "`.bf' symbol without preceding function\n");
1982 } /* missing function symbol */
1983 SA_GET_SYM_LNNOPTR (last_line_symbol) = function_lineoff;
1985 SF_SET_PROCESS (last_line_symbol);
1986 function_lineoff = -1;
1988 /* Value is always set to . */
1989 def_symbol_in_progress->sy_frag = frag_now;
1990 S_SET_VALUE (def_symbol_in_progress, (valueT) frag_now_fix ());
1995 #endif /* C_AUTOARG */
2005 SF_SET_DEBUG (def_symbol_in_progress);
2006 S_SET_SEGMENT (def_symbol_in_progress, absolute_section);
2012 /* Valid but set somewhere else (s_comm, s_lcomm, colon) */
2018 as_warn ("unexpected storage class %d", S_GET_STORAGE_CLASS (def_symbol_in_progress));
2020 } /* switch on storage class */
2022 /* Now that we have built a debug symbol, try to find if we should
2023 merge with an existing symbol or not. If a symbol is C_EFCN or
2024 absolute_section or untagged SEG_DEBUG it never merges. We also
2025 don't merge labels, which are in a different namespace, nor
2026 symbols which have not yet been defined since they are typically
2027 unique, nor do we merge tags with non-tags. */
2029 /* Two cases for functions. Either debug followed by definition or
2030 definition followed by debug. For definition first, we will
2031 merge the debug symbol into the definition. For debug first, the
2032 lineno entry MUST point to the definition function or else it
2033 will point off into space when crawl_symbols() merges the debug
2034 symbol into the real symbol. Therefor, let's presume the debug
2035 symbol is a real function reference. */
2037 /* FIXME-SOON If for some reason the definition label/symbol is
2038 never seen, this will probably leave an undefined symbol at link
2041 if (S_GET_STORAGE_CLASS (def_symbol_in_progress) == C_EFCN
2042 || S_GET_STORAGE_CLASS (def_symbol_in_progress) == C_LABEL
2043 || (S_GET_SEGMENT (def_symbol_in_progress) == SEG_DEBUG
2044 && !SF_GET_TAG (def_symbol_in_progress))
2045 || S_GET_SEGMENT (def_symbol_in_progress) == absolute_section
2046 || def_symbol_in_progress->sy_value.X_op != O_constant
2047 || (symbolP = symbol_find_base (S_GET_NAME (def_symbol_in_progress), DO_NOT_STRIP)) == NULL
2048 || (SF_GET_TAG (def_symbol_in_progress) != SF_GET_TAG (symbolP)))
2050 symbol_append (def_symbol_in_progress, symbol_lastP, &symbol_rootP,
2055 /* This symbol already exists, merge the newly created symbol
2056 into the old one. This is not mandatory. The linker can
2057 handle duplicate symbols correctly. But I guess that it save
2058 a *lot* of space if the assembly file defines a lot of
2061 /* The debug entry (def_symbol_in_progress) is merged into the
2062 previous definition. */
2064 c_symbol_merge (def_symbol_in_progress, symbolP);
2065 /* FIXME-SOON Should *def_symbol_in_progress be free'd? xoxorich. */
2066 def_symbol_in_progress = symbolP;
2068 if (SF_GET_FUNCTION (def_symbol_in_progress)
2069 || SF_GET_TAG (def_symbol_in_progress))
2071 /* For functions, and tags, the symbol *must* be where the
2072 debug symbol appears. Move the existing symbol to the
2074 /* If it already is at the end of the symbol list, do nothing */
2075 if (def_symbol_in_progress != symbol_lastP)
2077 symbol_remove (def_symbol_in_progress, &symbol_rootP,
2079 symbol_append (def_symbol_in_progress, symbol_lastP,
2080 &symbol_rootP, &symbol_lastP);
2081 } /* if not already in place */
2083 } /* normal or mergable */
2085 if (SF_GET_TAG (def_symbol_in_progress)
2086 && symbol_find_base (S_GET_NAME (def_symbol_in_progress), DO_NOT_STRIP) == NULL)
2088 tag_insert (S_GET_NAME (def_symbol_in_progress), def_symbol_in_progress);
2091 if (SF_GET_FUNCTION (def_symbol_in_progress))
2093 know (sizeof (def_symbol_in_progress) <= sizeof (long));
2095 = c_line_new (def_symbol_in_progress, 0, 0, &zero_address_frag);
2097 SF_SET_PROCESS (def_symbol_in_progress);
2099 if (symbolP == NULL)
2101 /* That is, if this is the first time we've seen the
2103 symbol_table_insert (def_symbol_in_progress);
2104 } /* definition follows debug */
2105 } /* Create the line number entry pointing to the function being defined */
2107 def_symbol_in_progress = NULL;
2108 demand_empty_rest_of_line ();
2112 obj_coff_dim (ignore)
2117 if (def_symbol_in_progress == NULL)
2119 as_warn (".dim pseudo-op used outside of .def/.endef: ignored.");
2120 demand_empty_rest_of_line ();
2122 } /* if not inside .def/.endef */
2124 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
2126 for (dim_index = 0; dim_index < DIMNUM; dim_index++)
2128 SKIP_WHITESPACES ();
2129 SA_SET_SYM_DIMEN (def_symbol_in_progress, dim_index,
2130 get_absolute_expression ());
2132 switch (*input_line_pointer)
2135 input_line_pointer++;
2139 as_warn ("badly formed .dim directive ignored");
2140 /* intentional fallthrough */
2148 demand_empty_rest_of_line ();
2152 obj_coff_line (ignore)
2157 if (def_symbol_in_progress == NULL)
2163 this_base = get_absolute_expression ();
2164 if (this_base > line_base)
2166 line_base = this_base;
2174 listing_source_line ((unsigned int) line_base);
2178 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
2179 SA_SET_SYM_LNNO (def_symbol_in_progress, this_base);
2181 demand_empty_rest_of_line ();
2185 obj_coff_size (ignore)
2188 if (def_symbol_in_progress == NULL)
2190 as_warn (".size pseudo-op used outside of .def/.endef ignored.");
2191 demand_empty_rest_of_line ();
2193 } /* if not inside .def/.endef */
2195 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
2196 SA_SET_SYM_SIZE (def_symbol_in_progress, get_absolute_expression ());
2197 demand_empty_rest_of_line ();
2201 obj_coff_scl (ignore)
2204 if (def_symbol_in_progress == NULL)
2206 as_warn (".scl pseudo-op used outside of .def/.endef ignored.");
2207 demand_empty_rest_of_line ();
2209 } /* if not inside .def/.endef */
2211 S_SET_STORAGE_CLASS (def_symbol_in_progress, get_absolute_expression ());
2212 demand_empty_rest_of_line ();
2216 obj_coff_tag (ignore)
2222 if (def_symbol_in_progress == NULL)
2224 as_warn (".tag pseudo-op used outside of .def/.endef ignored.");
2225 demand_empty_rest_of_line ();
2229 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
2230 symbol_name = input_line_pointer;
2231 name_end = get_symbol_end ();
2233 /* Assume that the symbol referred to by .tag is always defined.
2234 This was a bad assumption. I've added find_or_make. xoxorich. */
2235 SA_SET_SYM_TAGNDX (def_symbol_in_progress,
2236 (long) tag_find_or_make (symbol_name));
2237 if (SA_GET_SYM_TAGNDX (def_symbol_in_progress) == 0L)
2239 as_warn ("tag not found for .tag %s", symbol_name);
2242 SF_SET_TAGGED (def_symbol_in_progress);
2243 *input_line_pointer = name_end;
2245 demand_empty_rest_of_line ();
2249 obj_coff_type (ignore)
2252 if (def_symbol_in_progress == NULL)
2254 as_warn (".type pseudo-op used outside of .def/.endef ignored.");
2255 demand_empty_rest_of_line ();
2257 } /* if not inside .def/.endef */
2259 S_SET_DATA_TYPE (def_symbol_in_progress, get_absolute_expression ());
2261 if (ISFCN (S_GET_DATA_TYPE (def_symbol_in_progress)) &&
2262 S_GET_STORAGE_CLASS (def_symbol_in_progress) != C_TPDEF)
2264 SF_SET_FUNCTION (def_symbol_in_progress);
2265 } /* is a function */
2267 demand_empty_rest_of_line ();
2271 obj_coff_val (ignore)
2274 if (def_symbol_in_progress == NULL)
2276 as_warn (".val pseudo-op used outside of .def/.endef ignored.");
2277 demand_empty_rest_of_line ();
2279 } /* if not inside .def/.endef */
2281 if (is_name_beginner (*input_line_pointer))
2283 char *symbol_name = input_line_pointer;
2284 char name_end = get_symbol_end ();
2286 if (!strcmp (symbol_name, "."))
2288 def_symbol_in_progress->sy_frag = frag_now;
2289 S_SET_VALUE (def_symbol_in_progress, (valueT) frag_now_fix ());
2290 /* If the .val is != from the .def (e.g. statics) */
2292 else if (strcmp (S_GET_NAME (def_symbol_in_progress), symbol_name))
2294 def_symbol_in_progress->sy_value.X_op = O_symbol;
2295 def_symbol_in_progress->sy_value.X_add_symbol =
2296 symbol_find_or_make (symbol_name);
2297 def_symbol_in_progress->sy_value.X_op_symbol = NULL;
2298 def_symbol_in_progress->sy_value.X_add_number = 0;
2300 /* If the segment is undefined when the forward reference is
2301 resolved, then copy the segment id from the forward
2303 SF_SET_GET_SEGMENT (def_symbol_in_progress);
2305 /* FIXME: gcc can generate address expressions
2306 here in unusual cases (search for "obscure"
2307 in sdbout.c). We just ignore the offset
2308 here, thus generating incorrect debugging
2309 information. We ignore the rest of the
2312 /* Otherwise, it is the name of a non debug symbol and
2313 its value will be calculated later. */
2314 *input_line_pointer = name_end;
2316 /* FIXME: this is to avoid an error message in the
2317 FIXME case mentioned just above. */
2318 while (! is_end_of_line[(unsigned char) *input_line_pointer])
2319 ++input_line_pointer;
2323 S_SET_VALUE (def_symbol_in_progress,
2324 (valueT) get_absolute_expression ());
2325 } /* if symbol based */
2327 demand_empty_rest_of_line ();
2331 obj_read_begin_hook ()
2333 /* These had better be the same. Usually 18 bytes. */
2335 know (sizeof (SYMENT) == sizeof (AUXENT));
2336 know (SYMESZ == AUXESZ);
2341 /* This function runs through the symbol table and puts all the
2342 externals onto another chain */
2344 /* The chain of externals */
2345 symbolS *symbol_externP;
2346 symbolS *symbol_extern_lastP;
2349 symbolS *last_functionP;
2356 unsigned int symbol_number = 0;
2357 unsigned int last_file_symno = 0;
2359 for (symbolP = symbol_rootP;
2361 symbolP = symbolP ? symbol_next (symbolP) : symbol_rootP)
2363 if (!SF_GET_DEBUG (symbolP))
2365 /* Debug symbols do not need all this rubbish */
2366 symbolS *real_symbolP;
2368 /* L* and C_EFCN symbols never merge. */
2369 if (!SF_GET_LOCAL (symbolP)
2370 && S_GET_STORAGE_CLASS (symbolP) != C_LABEL
2371 && symbolP->sy_value.X_op == O_constant
2372 && (real_symbolP = symbol_find_base (S_GET_NAME (symbolP), DO_NOT_STRIP))
2373 && real_symbolP != symbolP)
2375 /* FIXME-SOON: where do dups come from?
2376 Maybe tag references before definitions? xoxorich. */
2377 /* Move the debug data from the debug symbol to the
2378 real symbol. Do NOT do the oposite (i.e. move from
2379 real symbol to debug symbol and remove real symbol from the
2380 list.) Because some pointers refer to the real symbol
2381 whereas no pointers refer to the debug symbol. */
2382 c_symbol_merge (symbolP, real_symbolP);
2383 /* Replace the current symbol by the real one */
2384 /* The symbols will never be the last or the first
2385 because : 1st symbol is .file and 3 last symbols are
2386 .text, .data, .bss */
2387 symbol_remove (real_symbolP, &symbol_rootP, &symbol_lastP);
2388 symbol_insert (real_symbolP, symbolP, &symbol_rootP, &symbol_lastP);
2389 symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
2390 symbolP = real_symbolP;
2391 } /* if not local but dup'd */
2393 if (flag_readonly_data_in_text && (S_GET_SEGMENT (symbolP) == SEG_E1))
2395 S_SET_SEGMENT (symbolP, SEG_E0);
2396 } /* push data into text */
2398 resolve_symbol_value (symbolP);
2400 if (S_GET_STORAGE_CLASS (symbolP) == C_NULL)
2402 if (!S_IS_DEFINED (symbolP) && !SF_GET_LOCAL (symbolP))
2404 S_SET_EXTERNAL (symbolP);
2406 else if (S_GET_SEGMENT (symbolP) == SEG_E0)
2408 S_SET_STORAGE_CLASS (symbolP, C_LABEL);
2412 S_SET_STORAGE_CLASS (symbolP, C_STAT);
2416 /* Mainly to speed up if not -g */
2417 if (SF_GET_PROCESS (symbolP))
2419 /* Handle the nested blocks auxiliary info. */
2420 if (S_GET_STORAGE_CLASS (symbolP) == C_BLOCK)
2422 if (!strcmp (S_GET_NAME (symbolP), ".bb"))
2423 stack_push (block_stack, (char *) &symbolP);
2426 register symbolS *begin_symbolP;
2427 begin_symbolP = *(symbolS **) stack_pop (block_stack);
2428 if (begin_symbolP == (symbolS *) 0)
2429 as_warn ("mismatched .eb");
2431 SA_SET_SYM_ENDNDX (begin_symbolP, symbol_number + 2);
2434 /* If we are able to identify the type of a function, and we
2435 are out of a function (last_functionP == 0) then, the
2436 function symbol will be associated with an auxiliary
2438 if (last_functionP == (symbolS *) 0 &&
2439 SF_GET_FUNCTION (symbolP))
2441 last_functionP = symbolP;
2443 if (S_GET_NUMBER_AUXILIARY (symbolP) < 1)
2445 S_SET_NUMBER_AUXILIARY (symbolP, 1);
2446 } /* make it at least 1 */
2448 /* Clobber possible stale .dim information. */
2450 /* Iffed out by steve - this fries the lnnoptr info too */
2451 bzero (symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen,
2452 sizeof (symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen));
2455 /* The C_FCN doesn't need any additional information. I
2456 don't even know if this is needed for sdb. But the
2457 standard assembler generates it, so... */
2458 if (S_GET_STORAGE_CLASS (symbolP) == C_EFCN)
2460 if (last_functionP == (symbolS *) 0)
2461 as_fatal ("C_EFCN symbol out of scope");
2462 SA_SET_SYM_FSIZE (last_functionP,
2463 (long) (S_GET_VALUE (symbolP) -
2464 S_GET_VALUE (last_functionP)));
2465 SA_SET_SYM_ENDNDX (last_functionP, symbol_number);
2466 last_functionP = (symbolS *) 0;
2470 else if (SF_GET_TAG (symbolP))
2472 /* First descriptor of a structure must point to
2473 the first slot after the structure description. */
2474 last_tagP = symbolP;
2477 else if (S_GET_STORAGE_CLASS (symbolP) == C_EOS)
2479 /* +2 take in account the current symbol */
2480 SA_SET_SYM_ENDNDX (last_tagP, symbol_number + 2);
2482 else if (S_GET_STORAGE_CLASS (symbolP) == C_FILE)
2484 if (S_GET_VALUE (symbolP))
2486 S_SET_VALUE (symbolP, last_file_symno);
2487 last_file_symno = symbol_number;
2488 } /* no one points at the first .file symbol */
2489 } /* if debug or tag or eos or file */
2491 /* We must put the external symbols apart. The loader
2492 does not bomb if we do not. But the references in
2493 the endndx field for a .bb symbol are not corrected
2494 if an external symbol is removed between .bb and .be.
2495 I.e in the following case :
2496 [20] .bb endndx = 22
2499 ld will move the symbol 21 to the end of the list but
2500 endndx will still be 22 instead of 21. */
2503 if (SF_GET_LOCAL (symbolP))
2505 /* remove C_EFCN and LOCAL (L...) symbols */
2506 /* next pointer remains valid */
2507 symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
2510 else if (!S_IS_DEFINED (symbolP)
2511 && !S_IS_DEBUG (symbolP)
2512 && !SF_GET_STATICS (symbolP) &&
2513 S_GET_STORAGE_CLASS (symbolP) == C_EXT)
2514 { /* C_EXT && !SF_GET_FUNCTION(symbolP)) */
2515 /* if external, Remove from the list */
2516 symbolS *hold = symbol_previous (symbolP);
2518 symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
2519 symbol_clear_list_pointers (symbolP);
2520 symbol_append (symbolP, symbol_extern_lastP, &symbol_externP, &symbol_extern_lastP);
2525 if (SF_GET_STRING (symbolP))
2527 symbolP->sy_name_offset = string_byte_count;
2528 string_byte_count += strlen (S_GET_NAME (symbolP)) + 1;
2532 symbolP->sy_name_offset = 0;
2533 } /* fix "long" names */
2535 symbolP->sy_number = symbol_number;
2536 symbol_number += 1 + S_GET_NUMBER_AUXILIARY (symbolP);
2537 } /* if local symbol */
2538 } /* traverse the symbol list */
2539 return symbol_number;
2547 unsigned int symbol_number = 0;
2549 for (symbolP = symbol_externP; symbol_externP;)
2551 symbolS *tmp = symbol_externP;
2554 symbol_remove (tmp, &symbol_externP, &symbol_extern_lastP);
2555 symbol_append (tmp, symbol_lastP, &symbol_rootP, &symbol_lastP);
2558 if (SF_GET_STRING (tmp))
2560 tmp->sy_name_offset = string_byte_count;
2561 string_byte_count += strlen (S_GET_NAME (tmp)) + 1;
2565 tmp->sy_name_offset = 0;
2566 } /* fix "long" names */
2568 tmp->sy_number = symbol_number;
2569 symbol_number += 1 + S_GET_NUMBER_AUXILIARY (tmp);
2570 } /* append the entire extern chain */
2571 return symbol_number;
2578 unsigned int symbol_number = 0;
2581 for (symbolP = symbol_rootP; symbolP; symbolP =
2582 symbol_next (symbolP))
2584 symbolP->sy_number = symbol_number;
2588 if (SF_GET_TAGGED (symbolP))
2592 ((symbolS *) SA_GET_SYM_TAGNDX (symbolP))->sy_number);
2595 symbol_number += 1 + S_GET_NUMBER_AUXILIARY (symbolP);
2597 return symbol_number;
2602 crawl_symbols (h, abfd)
2608 /* Initialize the stack used to keep track of the matching .bb .be */
2610 block_stack = stack_init (512, sizeof (symbolS *));
2612 /* The symbol list should be ordered according to the following sequence
2615 * . debug entries for functions
2616 * . fake symbols for the sections, including.text .data and .bss
2618 * . undefined symbols
2619 * But this is not mandatory. The only important point is to put the
2620 * undefined symbols at the end of the list.
2623 if (symbol_rootP == NULL
2624 || S_GET_STORAGE_CLASS (symbol_rootP) != C_FILE)
2626 c_dot_file_symbol ("fake");
2628 /* Is there a .file symbol ? If not insert one at the beginning. */
2631 * Build up static symbols for the sections, they are filled in later
2635 for (i = SEG_E0; i < SEG_E9; i++)
2637 if (segment_info[i].scnhdr.s_name[0])
2641 strncpy (name, segment_info[i].scnhdr.s_name, 8);
2643 segment_info[i].dot = c_section_symbol (name, i - SEG_E0 + 1);
2648 /* Take all the externals out and put them into another chain */
2649 H_SET_SYMBOL_TABLE_SIZE (h, yank_symbols ());
2650 /* Take the externals and glue them onto the end.*/
2651 H_SET_SYMBOL_TABLE_SIZE (h, H_GET_SYMBOL_COUNT (h) + glue_symbols ());
2653 H_SET_SYMBOL_TABLE_SIZE (h, tie_tags ());
2654 know (symbol_externP == NULL);
2655 know (symbol_extern_lastP == NULL);
2659 * Find strings by crawling along symbol table chain.
2668 /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */
2669 md_number_to_chars (where, (valueT) string_byte_count, 4);
2671 for (symbolP = symbol_rootP;
2673 symbolP = symbol_next (symbolP))
2677 if (SF_GET_STRING (symbolP))
2679 size = strlen (S_GET_NAME (symbolP)) + 1;
2681 memcpy (where, S_GET_NAME (symbolP), size);
2689 do_linenos_for (abfd, h, file_cursor)
2692 unsigned long *file_cursor;
2695 unsigned long start = *file_cursor;
2697 for (idx = SEG_E0; idx < SEG_E9; idx++)
2699 segment_info_type *s = segment_info + idx;
2702 if (s->scnhdr.s_nlnno != 0)
2704 struct lineno_list *line_ptr;
2706 struct external_lineno *buffer =
2707 (struct external_lineno *) xmalloc (s->scnhdr.s_nlnno * LINESZ);
2709 struct external_lineno *dst = buffer;
2711 /* Run through the table we've built and turn it into its external
2712 form, take this chance to remove duplicates */
2714 for (line_ptr = s->lineno_list_head;
2715 line_ptr != (struct lineno_list *) NULL;
2716 line_ptr = line_ptr->next)
2719 if (line_ptr->line.l_lnno == 0)
2721 /* Turn a pointer to a symbol into the symbols' index */
2722 line_ptr->line.l_addr.l_symndx =
2723 ((symbolS *) line_ptr->line.l_addr.l_symndx)->sy_number;
2727 line_ptr->line.l_addr.l_paddr += ((struct frag *) (line_ptr->frag))->fr_address;
2731 (void) bfd_coff_swap_lineno_out (abfd, &(line_ptr->line), dst);
2736 s->scnhdr.s_lnnoptr = *file_cursor;
2738 bfd_write (buffer, 1, s->scnhdr.s_nlnno * LINESZ, abfd);
2741 *file_cursor += s->scnhdr.s_nlnno * LINESZ;
2744 H_SET_LINENO_SIZE (h, *file_cursor - start);
2748 /* Now we run through the list of frag chains in a segment and
2749 make all the subsegment frags appear at the end of the
2750 list, as if the seg 0 was extra long */
2757 for (i = SEG_E0; i < SEG_UNKNOWN; i++)
2759 frchainS *head = segment_info[i].frchainP;
2761 fragS *prev_frag = &dummy;
2763 while (head && head->frch_seg == i)
2765 prev_frag->fr_next = head->frch_root;
2766 prev_frag = head->frch_last;
2767 head = head->frch_next;
2769 prev_frag->fr_next = 0;
2773 unsigned long machine;
2776 write_object_file ()
2780 struct frchain *frchain_ptr;
2782 object_headers headers;
2783 unsigned long file_cursor;
2786 abfd = bfd_openw (out_file_name, TARGET_FORMAT);
2791 as_perror ("FATAL: Can't create %s", out_file_name);
2794 bfd_set_format (abfd, bfd_object);
2795 bfd_set_arch_mach (abfd, BFD_ARCH, machine);
2797 string_byte_count = 4;
2799 for (frchain_ptr = frchain_root;
2800 frchain_ptr != (struct frchain *) NULL;
2801 frchain_ptr = frchain_ptr->frch_next)
2803 /* Run through all the sub-segments and align them up. Also
2804 close any open frags. We tack a .fill onto the end of the
2805 frag chain so that any .align's size can be worked by looking
2806 at the next frag. */
2808 subseg_set (frchain_ptr->frch_seg, frchain_ptr->frch_subseg);
2809 #ifndef SUB_SEGMENT_ALIGN
2810 #define SUB_SEGMENT_ALIGN(SEG) 1
2812 frag_align (SUB_SEGMENT_ALIGN (now_seg), NOP_OPCODE);
2813 frag_wane (frag_now);
2814 frag_now->fr_fix = 0;
2815 know (frag_now->fr_next == NULL);
2822 for (i = SEG_E0; i < SEG_UNKNOWN; i++)
2824 relax_segment (segment_info[i].frchainP->frch_root, i);
2827 H_SET_NUMBER_OF_SECTIONS (&headers, 0);
2829 /* Find out how big the sections are, and set the addresses. */
2831 for (i = SEG_E0; i < SEG_UNKNOWN; i++)
2835 segment_info[i].scnhdr.s_paddr = addr;
2836 segment_info[i].scnhdr.s_vaddr = addr;
2838 if (segment_info[i].scnhdr.s_name[0])
2840 H_SET_NUMBER_OF_SECTIONS (&headers,
2841 H_GET_NUMBER_OF_SECTIONS (&headers) + 1);
2844 size = size_section (abfd, (unsigned int) i);
2847 /* I think the section alignment is only used on the i960; the
2848 i960 needs it, and it should do no harm on other targets. */
2849 segment_info[i].scnhdr.s_align = section_alignment[i];
2852 H_SET_TEXT_SIZE (&headers, size);
2853 else if (i == SEG_E1)
2854 H_SET_DATA_SIZE (&headers, size);
2855 else if (i == SEG_E2)
2856 H_SET_BSS_SIZE (&headers, size);
2859 /* Turn the gas native symbol table shape into a coff symbol table */
2860 crawl_symbols (&headers, abfd);
2862 if (string_byte_count == 4)
2863 string_byte_count = 0;
2865 H_SET_STRING_SIZE (&headers, string_byte_count);
2867 #if !defined(TC_H8300) && !defined(TC_Z8K)
2868 for (i = SEG_E0; i < SEG_UNKNOWN; i++)
2870 fixup_mdeps (segment_info[i].frchainP->frch_root, &headers, i);
2871 fixup_segment (&segment_info[i], i);
2875 /* Look for ".stab" segments and fill in their initial symbols
2877 for (i = SEG_E0; i < SEG_UNKNOWN; i++)
2879 name = segment_info[i].scnhdr.s_name;
2882 && strncmp (".stab", name, 5) == 0
2883 && strncmp (".stabstr", name, 8) != 0)
2884 adjust_stab_section (abfd, i);
2887 file_cursor = H_GET_TEXT_FILE_OFFSET (&headers);
2889 bfd_seek (abfd, (file_ptr) file_cursor, 0);
2891 /* Plant the data */
2893 fill_section (abfd, &headers, &file_cursor);
2895 do_relocs_for (abfd, &headers, &file_cursor);
2897 do_linenos_for (abfd, &headers, &file_cursor);
2899 H_SET_FILE_MAGIC_NUMBER (&headers, COFF_MAGIC);
2900 #ifndef OBJ_COFF_OMIT_TIMESTAMP
2901 H_SET_TIME_STAMP (&headers, (long)time((long*)0));
2903 H_SET_TIME_STAMP (&headers, 0);
2905 #ifdef TC_COFF_SET_MACHINE
2906 TC_COFF_SET_MACHINE (&headers);
2909 #ifdef KEEP_RELOC_INFO
2910 H_SET_FLAGS (&headers, ((H_GET_LINENO_SIZE(&headers) ? 0 : F_LNNO) |
2911 COFF_FLAGS | coff_flags));
2913 H_SET_FLAGS (&headers, ((H_GET_LINENO_SIZE(&headers) ? 0 : F_LNNO) |
2914 (H_GET_RELOCATION_SIZE(&headers) ? 0 : F_RELFLG) |
2915 COFF_FLAGS | coff_flags));
2919 unsigned int symtable_size = H_GET_SYMBOL_TABLE_SIZE (&headers);
2920 char *buffer1 = xmalloc (symtable_size + string_byte_count + 1);
2922 H_SET_SYMBOL_TABLE_POINTER (&headers, bfd_tell (abfd));
2923 w_symbols (abfd, buffer1, symbol_rootP);
2924 if (string_byte_count > 0)
2925 w_strings (buffer1 + symtable_size);
2926 bfd_write (buffer1, 1, symtable_size + string_byte_count, abfd);
2930 coff_header_append (abfd, &headers);
2932 /* Recent changes to write need this, but where it should
2933 go is up to Ken.. */
2934 if (bfd_close_all_done (abfd) == false)
2935 as_fatal ("Can't close %s: %s", out_file_name,
2936 bfd_errmsg (bfd_get_error ()));
2939 extern bfd *stdoutput;
2946 /* Add a new segment. This is called from subseg_new via the
2947 obj_new_segment macro. */
2950 obj_coff_add_segment (name)
2956 /* Find out if we've already got a section of this name. */
2957 len = strlen (name);
2958 if (len < sizeof (segment_info[i].scnhdr.s_name))
2961 len = sizeof (segment_info[i].scnhdr.s_name);
2962 for (i = SEG_E0; i < SEG_E9 && segment_info[i].scnhdr.s_name[0]; i++)
2963 if (strncmp (segment_info[i].scnhdr.s_name, name, len) == 0
2964 && (len == sizeof (segment_info[i].scnhdr.s_name)
2965 || segment_info[i].scnhdr.s_name[len] == '\0'))
2970 as_bad ("Too many new sections; can't add \"%s\"", name);
2974 /* Add a new section. */
2975 strncpy (segment_info[i].scnhdr.s_name, name,
2976 sizeof (segment_info[i].scnhdr.s_name));
2977 segment_info[i].scnhdr.s_flags = STYP_REG;
2983 * implement the .section pseudo op:
2984 * .section name {, "flags"}
2986 * | +--- optional flags: 'b' for bss
2988 * +-- section name 'l' for lib
2992 * 'd' (apparently m88k for data)
2994 * But if the argument is not a quoted string, treat it as a
2995 * subsegment number.
2999 obj_coff_section (ignore)
3002 /* Strip out the section name */
3004 char *section_name_end;
3011 section_name = input_line_pointer;
3012 c = get_symbol_end ();
3013 section_name_end = input_line_pointer;
3015 len = section_name_end - section_name;
3016 input_line_pointer++;
3022 else if (*input_line_pointer == ',')
3025 ++input_line_pointer;
3033 if (*input_line_pointer != '"')
3034 exp = get_absolute_expression ();
3037 ++input_line_pointer;
3038 while (*input_line_pointer != '"'
3039 && ! is_end_of_line[(unsigned char) *input_line_pointer])
3041 switch (*input_line_pointer)
3043 case 'b': flags |= STYP_BSS; break;
3044 case 'i': flags |= STYP_INFO; break;
3045 case 'l': flags |= STYP_LIB; break;
3046 case 'n': flags |= STYP_NOLOAD; break;
3047 case 'o': flags |= STYP_OVER; break;
3049 case 'w': flags |= STYP_DATA; break;
3050 case 'x': flags |= STYP_TEXT; break;
3052 as_warn("unknown section attribute '%c'",
3053 *input_line_pointer);
3056 ++input_line_pointer;
3058 if (*input_line_pointer == '"')
3059 ++input_line_pointer;
3063 subseg_new (section_name, (subsegT) exp);
3065 segment_info[now_seg].scnhdr.s_flags |= flags;
3067 *section_name_end = c;
3072 obj_coff_text (ignore)
3075 subseg_new (".text", get_absolute_expression ());
3080 obj_coff_data (ignore)
3083 if (flag_readonly_data_in_text)
3084 subseg_new (".text", get_absolute_expression () + 1000);
3086 subseg_new (".data", get_absolute_expression ());
3090 obj_coff_bss (ignore)
3093 if (*input_line_pointer == '\n') /* .bss */
3094 subseg_new(".bss", get_absolute_expression());
3095 else /* .bss id,expr */
3100 obj_coff_ident (ignore)
3103 segT current_seg = now_seg; /* save current seg */
3104 subsegT current_subseg = now_subseg;
3105 subseg_new (".comment", 0); /* .comment seg */
3106 stringer (1); /* read string */
3107 subseg_set (current_seg, current_subseg); /* restore current seg */
3111 c_symbol_merge (debug, normal)
3115 S_SET_DATA_TYPE (normal, S_GET_DATA_TYPE (debug));
3116 S_SET_STORAGE_CLASS (normal, S_GET_STORAGE_CLASS (debug));
3118 if (S_GET_NUMBER_AUXILIARY (debug) > S_GET_NUMBER_AUXILIARY (normal))
3120 S_SET_NUMBER_AUXILIARY (normal, S_GET_NUMBER_AUXILIARY (debug));
3121 } /* take the most we have */
3123 if (S_GET_NUMBER_AUXILIARY (debug) > 0)
3125 memcpy ((char *) &normal->sy_symbol.ost_auxent[0],
3126 (char *) &debug->sy_symbol.ost_auxent[0],
3127 (unsigned int) (S_GET_NUMBER_AUXILIARY (debug) * AUXESZ));
3128 } /* Move all the auxiliary information */
3130 /* Move the debug flags. */
3131 SF_SET_DEBUG_FIELD (normal, SF_GET_DEBUG_FIELD (debug));
3132 } /* c_symbol_merge() */
3135 c_line_new (symbol, paddr, line_number, frag)
3141 struct lineno_list *new_line =
3142 (struct lineno_list *) xmalloc (sizeof (struct lineno_list));
3144 segment_info_type *s = segment_info + now_seg;
3145 new_line->line.l_lnno = line_number;
3147 if (line_number == 0)
3149 last_line_symbol = symbol;
3150 new_line->line.l_addr.l_symndx = (long) symbol;
3154 new_line->line.l_addr.l_paddr = paddr;
3157 new_line->frag = (char *) frag;
3158 new_line->next = (struct lineno_list *) NULL;
3161 if (s->lineno_list_head == (struct lineno_list *) NULL)
3163 s->lineno_list_head = new_line;
3167 s->lineno_list_tail->next = new_line;
3169 s->lineno_list_tail = new_line;
3170 return LINESZ * s->scnhdr.s_nlnno++;
3174 c_dot_file_symbol (filename)
3179 symbolP = symbol_new (".file",
3182 &zero_address_frag);
3184 S_SET_STORAGE_CLASS (symbolP, C_FILE);
3185 S_SET_NUMBER_AUXILIARY (symbolP, 1);
3186 SA_SET_FILE_FNAME (symbolP, filename);
3192 listing_source_file (filename);
3198 SF_SET_DEBUG (symbolP);
3199 S_SET_VALUE (symbolP, (valueT) previous_file_symbol);
3201 previous_file_symbol = symbolP;
3203 /* Make sure that the symbol is first on the symbol chain */
3204 if (symbol_rootP != symbolP)
3206 if (symbolP == symbol_lastP)
3208 symbol_lastP = symbol_lastP->sy_previous;
3209 } /* if it was the last thing on the list */
3211 symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
3212 symbol_insert (symbolP, symbol_rootP, &symbol_rootP, &symbol_lastP);
3213 symbol_rootP = symbolP;
3214 } /* if not first on the list */
3216 } /* c_dot_file_symbol() */
3219 * Build a 'section static' symbol.
3223 c_section_symbol (name, idx)
3229 symbolP = symbol_new (name, idx,
3231 &zero_address_frag);
3233 S_SET_STORAGE_CLASS (symbolP, C_STAT);
3234 S_SET_NUMBER_AUXILIARY (symbolP, 1);
3236 SF_SET_STATICS (symbolP);
3239 } /* c_section_symbol() */
3242 w_symbols (abfd, where, symbol_rootP)
3245 symbolS * symbol_rootP;
3250 /* First fill in those values we have only just worked out */
3251 for (i = SEG_E0; i < SEG_E9; i++)
3253 symbolP = segment_info[i].dot;
3257 SA_SET_SCN_SCNLEN (symbolP, segment_info[i].scnhdr.s_size);
3258 SA_SET_SCN_NRELOC (symbolP, segment_info[i].scnhdr.s_nreloc);
3259 SA_SET_SCN_NLINNO (symbolP, segment_info[i].scnhdr.s_nlnno);
3265 * Emit all symbols left in the symbol chain.
3267 for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
3269 /* Used to save the offset of the name. It is used to point
3270 to the string in memory but must be a file offset. */
3271 register char *temp;
3273 tc_coff_symbol_emit_hook (symbolP);
3275 temp = S_GET_NAME (symbolP);
3276 if (SF_GET_STRING (symbolP))
3278 S_SET_OFFSET (symbolP, symbolP->sy_name_offset);
3279 S_SET_ZEROES (symbolP, 0);
3283 memset (symbolP->sy_symbol.ost_entry.n_name, 0, SYMNMLEN);
3284 strncpy (symbolP->sy_symbol.ost_entry.n_name, temp, SYMNMLEN);
3286 where = symbol_to_chars (abfd, where, symbolP);
3287 S_SET_NAME (symbolP, temp);
3293 obj_coff_lcomm (ignore)
3306 name = input_line_pointer;
3308 c = get_symbol_end ();
3309 p = input_line_pointer;
3312 if (*input_line_pointer != ',')
3314 as_bad ("Expected comma after name");
3315 ignore_rest_of_line ();
3318 if (*input_line_pointer == '\n')
3320 as_bad ("Missing size expression");
3323 input_line_pointer++;
3324 if ((temp = get_absolute_expression ()) < 0)
3326 as_warn ("lcomm length (%d.) <0! Ignored.", temp);
3327 ignore_rest_of_line ();
3332 symbolP = symbol_find_or_make(name);
3334 if (S_GET_SEGMENT(symbolP) == SEG_UNKNOWN &&
3335 S_GET_VALUE(symbolP) == 0)
3340 segT current_seg = now_seg; /* save current seg */
3341 subsegT current_subseg = now_subseg;
3343 subseg_set (SEG_E2, 1);
3344 symbolP->sy_frag = frag_now;
3345 p = frag_var(rs_org, 1, 1, (relax_substateT)0, symbolP,
3348 subseg_set (current_seg, current_subseg); /* restore current seg */
3349 S_SET_SEGMENT(symbolP, SEG_E2);
3350 S_SET_STORAGE_CLASS(symbolP, C_STAT);
3354 as_bad("Symbol %s already defined", name);
3356 demand_empty_rest_of_line();
3361 fixup_mdeps (frags, h, this_segment)
3366 subseg_change (this_segment, 0);
3369 switch (frags->fr_type)
3373 frags->fr_type = rs_fill;
3375 (frags->fr_next->fr_address - frags->fr_address - frags->fr_fix);
3377 case rs_machine_dependent:
3378 md_convert_frag (h, frags);
3384 frags = frags->fr_next;
3390 fixup_segment (segP, this_segment_type)
3391 segment_info_type * segP;
3392 segT this_segment_type;
3394 register fixS * fixP;
3395 register symbolS *add_symbolP;
3396 register symbolS *sub_symbolP;
3397 register long add_number;
3399 register char *place;
3400 register long where;
3401 register char pcrel;
3402 register fragS *fragP;
3403 register segT add_symbol_segment = absolute_section;
3406 for (fixP = segP->fix_root; fixP; fixP = fixP->fx_next)
3408 fragP = fixP->fx_frag;
3410 where = fixP->fx_where;
3411 place = fragP->fr_literal + where;
3412 size = fixP->fx_size;
3413 add_symbolP = fixP->fx_addsy;
3415 if (fixP->fx_tcbit && SF_GET_CALLNAME (add_symbolP))
3417 /* Relocation should be done via the associated 'bal' entry
3420 if (!SF_GET_BALNAME (tc_get_bal_of_call (add_symbolP)))
3422 as_bad_where (fixP->fx_file, fixP->fx_line,
3423 "No 'bal' entry point for leafproc %s",
3424 S_GET_NAME (add_symbolP));
3427 fixP->fx_addsy = add_symbolP = tc_get_bal_of_call (add_symbolP);
3430 sub_symbolP = fixP->fx_subsy;
3431 add_number = fixP->fx_offset;
3432 pcrel = fixP->fx_pcrel;
3436 add_symbol_segment = S_GET_SEGMENT (add_symbolP);
3437 } /* if there is an addend */
3444 if (S_GET_SEGMENT (sub_symbolP) != absolute_section)
3446 as_bad_where (fixP->fx_file, fixP->fx_line,
3447 "Negative of non-absolute symbol %s",
3448 S_GET_NAME (sub_symbolP));
3449 } /* not absolute */
3451 add_number -= S_GET_VALUE (sub_symbolP);
3454 /* if sub_symbol is in the same segment that add_symbol
3455 and add_symbol is either in DATA, TEXT, BSS or ABSOLUTE */
3457 else if ((S_GET_SEGMENT (sub_symbolP) == add_symbol_segment)
3458 && (SEG_NORMAL (add_symbol_segment)
3459 || (add_symbol_segment == absolute_section)))
3461 /* Difference of 2 symbols from same segment. Can't
3462 make difference of 2 undefineds: 'value' means
3463 something different for N_UNDF. */
3465 /* Makes no sense to use the difference of 2 arbitrary symbols
3466 as the target of a call instruction. */
3469 as_bad_where (fixP->fx_file, fixP->fx_line,
3470 "callj to difference of 2 symbols");
3472 #endif /* TC_I960 */
3473 add_number += S_GET_VALUE (add_symbolP) -
3474 S_GET_VALUE (sub_symbolP);
3477 fixP->fx_addsy = NULL;
3478 fixP->fx_subsy = NULL;
3483 /* Different segments in subtraction. */
3484 know (!(S_IS_EXTERNAL (sub_symbolP) && (S_GET_SEGMENT (sub_symbolP) == absolute_section)));
3486 if ((S_GET_SEGMENT (sub_symbolP) == absolute_section))
3488 add_number -= S_GET_VALUE (sub_symbolP);
3491 else if (S_GET_SEGMENT (sub_symbolP) == this_segment_type
3492 #if 0 /* Okay for 68k, at least... */
3497 /* Make it pc-relative. */
3498 add_number += (md_pcrel_from (fixP)
3499 - S_GET_VALUE (sub_symbolP));
3508 as_bad_where (fixP->fx_file, fixP->fx_line,
3509 "Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %ld.",
3510 segment_name (S_GET_SEGMENT (sub_symbolP)),
3511 S_GET_NAME (sub_symbolP),
3512 (long) (fragP->fr_address + where));
3515 } /* if sub_symbolP */
3519 if (add_symbol_segment == this_segment_type && pcrel)
3522 * This fixup was made when the symbol's segment was
3523 * SEG_UNKNOWN, but it is now in the local segment.
3524 * So we know how to do the address without relocation.
3527 /* reloc_callj() may replace a 'call' with a 'calls' or a 'bal',
3528 * in which cases it modifies *fixP as appropriate. In the case
3529 * of a 'calls', no further work is required, and *fixP has been
3530 * set up to make the rest of the code below a no-op.
3533 #endif /* TC_I960 */
3535 add_number += S_GET_VALUE (add_symbolP);
3536 add_number -= md_pcrel_from (fixP);
3537 #if defined (TC_I386) || defined (TE_LYNX)
3538 /* On the 386 we must adjust by the segment
3539 vaddr as well. Ian Taylor. */
3540 add_number -= segP->scnhdr.s_vaddr;
3542 pcrel = 0; /* Lie. Don't want further pcrel processing. */
3543 fixP->fx_addsy = NULL;
3548 switch (add_symbol_segment)
3550 case absolute_section:
3552 reloc_callj (fixP); /* See comment about reloc_callj() above*/
3553 #endif /* TC_I960 */
3554 add_number += S_GET_VALUE (add_symbolP);
3555 fixP->fx_addsy = NULL;
3562 /* This really should be handled in the linker, but
3563 backward compatibility forbids. */
3564 add_number += S_GET_VALUE (add_symbolP);
3566 add_number += S_GET_VALUE (add_symbolP) +
3567 segment_info[S_GET_SEGMENT (add_symbolP)].scnhdr.s_paddr;
3573 if ((int) fixP->fx_bit_fixP == 13)
3575 /* This is a COBR instruction. They have only a
3576 * 13-bit displacement and are only to be used
3577 * for local branches: flag as error, don't generate
3580 as_bad_where (fixP->fx_file, fixP->fx_line,
3581 "can't use COBR format with external label");
3582 fixP->fx_addsy = NULL;
3586 #endif /* TC_I960 */
3587 #if defined (TC_I386) || defined (TE_LYNX)
3588 /* 386 COFF uses a peculiar format in
3589 which the value of a common symbol is
3590 stored in the .text segment (I've
3591 checked this on SVR3.2 and SCO 3.2.2)
3592 Ian Taylor <ian@cygnus.com>. */
3593 if (S_IS_COMMON (add_symbolP))
3594 add_number += S_GET_VALUE (add_symbolP);
3599 } /* switch on symbol seg */
3600 } /* if not in local seg */
3601 } /* if there was a + symbol */
3606 /* This adjustment is not correct on the m88k, for which the
3607 linker does all the computation. */
3608 add_number -= md_pcrel_from (fixP);
3610 if (add_symbolP == 0)
3612 fixP->fx_addsy = &abs_symbol;
3613 } /* if there's an add_symbol */
3614 #if defined (TC_I386) || defined (TE_LYNX)
3615 /* On the 386 we must adjust by the segment vaddr
3616 as well. Ian Taylor. */
3617 add_number -= segP->scnhdr.s_vaddr;
3621 if (!fixP->fx_bit_fixP)
3624 /* The m88k uses the offset field of the reloc to get around
3627 (add_number & ~0xFF) && ((add_number & ~0xFF) != (-1 & ~0xFF))) ||
3629 (add_number & ~0xFFFF) && ((add_number & ~0xFFFF) != (-1 & ~0xFFFF))))
3631 as_bad_where (fixP->fx_file, fixP->fx_line,
3632 "Value of %ld too large for field of %d bytes at 0x%lx",
3633 (long) add_number, size,
3634 (unsigned long) (fragP->fr_address + where));
3635 } /* generic error checking */
3637 #ifdef WARN_SIGNED_OVERFLOW_WORD
3638 /* Warn if a .word value is too large when treated as
3639 a signed number. We already know it is not too
3640 negative. This is to catch over-large switches
3641 generated by gcc on the 68k. */
3642 if (!flag_signed_overflow_ok
3644 && add_number > 0x7fff)
3645 as_bad_where (fixP->fx_file, fixP->fx_line,
3646 "Signed .word overflow; switch may be too large; %ld at 0x%lx",
3648 (unsigned long) (fragP->fr_address + where));
3650 } /* not a bit fix */
3651 /* once this fix has been applied, we don't have to output anything
3652 nothing more need be done -*/
3653 md_apply_fix (fixP, add_number);
3654 } /* For each fixS in this segment. */
3655 } /* fixup_segment() */
3659 /* The first entry in a .stab section is special. */
3662 obj_coff_init_stab_section (seg)
3668 unsigned int stroff;
3670 /* Make space for this first symbol. */
3674 as_where (&file, (unsigned int *) NULL);
3675 stabstr_name = (char *) alloca (strlen (segment_info[seg].scnhdr.s_name) + 4);
3676 strcpy (stabstr_name, segment_info[seg].scnhdr.s_name);
3677 strcat (stabstr_name, "str");
3678 stroff = get_stab_string_offset (file, stabstr_name);
3680 md_number_to_chars (p, stroff, 4);
3683 /* Fill in the counts in the first entry in a .stab section. */
3686 adjust_stab_section(abfd, seg)
3690 segT stabstrseg = SEG_UNKNOWN;
3691 char *secname, *name, *name2;
3693 int i, strsz = 0, nsyms;
3694 fragS *frag = segment_info[seg].frchainP->frch_root;
3696 /* Look for the associated string table section. */
3698 secname = segment_info[seg].scnhdr.s_name;
3699 name = (char *) alloca (strlen (secname) + 4);
3700 strcpy (name, secname);
3701 strcat (name, "str");
3703 for (i = SEG_E0; i < SEG_UNKNOWN; i++)
3705 name2 = segment_info[i].scnhdr.s_name;
3706 if (name2 != NULL && strncmp(name2, name, 8) == 0)
3713 /* If we found the section, get its size. */
3714 if (stabstrseg != SEG_UNKNOWN)
3715 strsz = size_section (abfd, stabstrseg);
3717 nsyms = size_section (abfd, seg) / 12 - 1;
3719 /* Look for the first frag of sufficient size for the initial stab
3720 symbol, and collect a pointer to it. */
3721 while (frag && frag->fr_fix < 12)
3722 frag = frag->fr_next;
3724 p = frag->fr_literal;
3727 /* Write in the number of stab symbols and the size of the string
3729 bfd_h_put_16 (abfd, (bfd_vma) nsyms, (bfd_byte *) p + 6);
3730 bfd_h_put_32 (abfd, (bfd_vma) strsz, (bfd_byte *) p + 8);
3733 #endif /* not BFD_ASSEMBLER */
3735 const pseudo_typeS obj_pseudo_table[] =
3737 {"def", obj_coff_def, 0},
3738 {"dim", obj_coff_dim, 0},
3739 {"endef", obj_coff_endef, 0},
3740 {"line", obj_coff_line, 0},
3741 {"ln", obj_coff_ln, 0},
3742 {"appline", obj_coff_ln, 1},
3743 {"scl", obj_coff_scl, 0},
3744 {"size", obj_coff_size, 0},
3745 {"tag", obj_coff_tag, 0},
3746 {"type", obj_coff_type, 0},
3747 {"val", obj_coff_val, 0},
3748 {"section", obj_coff_section, 0},
3749 #ifndef BFD_ASSEMBLER
3750 {"use", obj_coff_section, 0},
3751 {"sect", obj_coff_section, 0},
3752 {"text", obj_coff_text, 0},
3753 {"data", obj_coff_data, 0},
3754 {"bss", obj_coff_bss, 0},
3755 {"lcomm", obj_coff_lcomm, 0},
3756 {"ident", obj_coff_ident, 0},
3758 {"optim", s_ignore, 0}, /* For sun386i cc (?) */
3759 {"ident", s_ignore, 0}, /* we don't yet handle this. */
3761 {"ABORT", s_abort, 0},
3763 /* The m88k uses sdef instead of def. */
3764 {"sdef", obj_coff_def, 0},
3766 {NULL} /* end sentinel */
3767 }; /* obj_pseudo_table */