* config/obj-coff.c (struct filename_list): Only define if not
[deliverable/binutils-gdb.git] / gas / config / obj-coff.c
1 /* coff object file format
2 Copyright (C) 1989, 90, 91, 92, 93, 94, 95, 1996
3 Free Software Foundation, Inc.
4
5 This file is part of GAS.
6
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)
10 any later version.
11
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.
16
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 the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20 02111-1307, USA. */
21
22 #include "as.h"
23 #include "obstack.h"
24 #include "subsegs.h"
25 #include "libiberty.h"
26
27 /* I think this is probably always correct. */
28 #ifndef KEEP_RELOC_INFO
29 #define KEEP_RELOC_INFO
30 #endif
31
32 const char *s_get_name PARAMS ((symbolS * s));
33 static symbolS *def_symbol_in_progress;
34
35 \f
36 /* stack stuff */
37 typedef struct
38 {
39 unsigned long chunk_size;
40 unsigned long element_size;
41 unsigned long size;
42 char *data;
43 unsigned long pointer;
44 }
45 stack;
46
47 static stack *
48 stack_init (chunk_size, element_size)
49 unsigned long chunk_size;
50 unsigned long element_size;
51 {
52 stack *st;
53
54 st = (stack *) malloc (sizeof (stack));
55 if (!st)
56 return 0;
57 st->data = malloc (chunk_size);
58 if (!st->data)
59 {
60 free (st);
61 return 0;
62 }
63 st->pointer = 0;
64 st->size = chunk_size;
65 st->chunk_size = chunk_size;
66 st->element_size = element_size;
67 return st;
68 }
69
70 #if 0
71 /* Not currently used. */
72 static void
73 stack_delete (st)
74 stack *st;
75 {
76 free (st->data);
77 free (st);
78 }
79 #endif
80
81 static char *
82 stack_push (st, element)
83 stack *st;
84 char *element;
85 {
86 if (st->pointer + st->element_size >= st->size)
87 {
88 st->size += st->chunk_size;
89 if ((st->data = xrealloc (st->data, st->size)) == (char *) 0)
90 return (char *) 0;
91 }
92 memcpy (st->data + st->pointer, element, st->element_size);
93 st->pointer += st->element_size;
94 return st->data + st->pointer;
95 }
96
97 static char *
98 stack_pop (st)
99 stack *st;
100 {
101 if (st->pointer < st->element_size)
102 {
103 st->pointer = 0;
104 return (char *) 0;
105 }
106 st->pointer -= st->element_size;
107 return st->data + st->pointer;
108 }
109 \f
110 /*
111 * Maintain a list of the tagnames of the structres.
112 */
113
114 static struct hash_control *tag_hash;
115
116 static void
117 tag_init ()
118 {
119 tag_hash = hash_new ();
120 }
121
122 static void
123 tag_insert (name, symbolP)
124 const char *name;
125 symbolS *symbolP;
126 {
127 const char *error_string;
128
129 if ((error_string = hash_jam (tag_hash, name, (char *) symbolP)))
130 {
131 as_fatal ("Inserting \"%s\" into structure table failed: %s",
132 name, error_string);
133 }
134 }
135
136 static symbolS *
137 tag_find (name)
138 char *name;
139 {
140 #ifdef STRIP_UNDERSCORE
141 if (*name == '_')
142 name++;
143 #endif /* STRIP_UNDERSCORE */
144 return (symbolS *) hash_find (tag_hash, name);
145 }
146
147 static symbolS *
148 tag_find_or_make (name)
149 char *name;
150 {
151 symbolS *symbolP;
152
153 if ((symbolP = tag_find (name)) == NULL)
154 {
155 symbolP = symbol_new (name, undefined_section,
156 0, &zero_address_frag);
157
158 tag_insert (S_GET_NAME (symbolP), symbolP);
159 #ifdef BFD_ASSEMBLER
160 symbol_table_insert (symbolP);
161 #endif
162 } /* not found */
163
164 return symbolP;
165 }
166
167
168
169 #ifdef BFD_ASSEMBLER
170
171 static void SA_SET_SYM_TAGNDX PARAMS ((symbolS *, symbolS *));
172
173 #define GET_FILENAME_STRING(X) \
174 ((char*)(&((X)->sy_symbol.ost_auxent->x_file.x_n.x_offset))[1])
175
176 /* @@ Ick. */
177 static segT
178 fetch_coff_debug_section ()
179 {
180 static segT debug_section;
181 if (!debug_section)
182 {
183 CONST asymbol *s;
184 s = bfd_make_debug_symbol (stdoutput, (char *) 0, 0);
185 assert (s != 0);
186 debug_section = s->section;
187 }
188 return debug_section;
189 }
190
191 void
192 SA_SET_SYM_ENDNDX (sym, val)
193 symbolS *sym;
194 symbolS *val;
195 {
196 combined_entry_type *entry, *p;
197
198 entry = &coffsymbol (sym->bsym)->native[1];
199 p = coffsymbol (val->bsym)->native;
200 entry->u.auxent.x_sym.x_fcnary.x_fcn.x_endndx.p = p;
201 entry->fix_end = 1;
202 }
203
204 static void
205 SA_SET_SYM_TAGNDX (sym, val)
206 symbolS *sym;
207 symbolS *val;
208 {
209 combined_entry_type *entry, *p;
210
211 entry = &coffsymbol (sym->bsym)->native[1];
212 p = coffsymbol (val->bsym)->native;
213 entry->u.auxent.x_sym.x_tagndx.p = p;
214 entry->fix_tag = 1;
215 }
216
217 static int
218 S_GET_DATA_TYPE (sym)
219 symbolS *sym;
220 {
221 return coffsymbol (sym->bsym)->native->u.syment.n_type;
222 }
223
224 int
225 S_SET_DATA_TYPE (sym, val)
226 symbolS *sym;
227 int val;
228 {
229 coffsymbol (sym->bsym)->native->u.syment.n_type = val;
230 return val;
231 }
232
233 int
234 S_GET_STORAGE_CLASS (sym)
235 symbolS *sym;
236 {
237 return coffsymbol (sym->bsym)->native->u.syment.n_sclass;
238 }
239
240 int
241 S_SET_STORAGE_CLASS (sym, val)
242 symbolS *sym;
243 int val;
244 {
245 coffsymbol (sym->bsym)->native->u.syment.n_sclass = val;
246 return val;
247 }
248
249 /* Merge a debug symbol containing debug information into a normal symbol. */
250
251 void
252 c_symbol_merge (debug, normal)
253 symbolS *debug;
254 symbolS *normal;
255 {
256 S_SET_DATA_TYPE (normal, S_GET_DATA_TYPE (debug));
257 S_SET_STORAGE_CLASS (normal, S_GET_STORAGE_CLASS (debug));
258
259 if (S_GET_NUMBER_AUXILIARY (debug) > S_GET_NUMBER_AUXILIARY (normal))
260 /* take the most we have */
261 S_SET_NUMBER_AUXILIARY (normal, S_GET_NUMBER_AUXILIARY (debug));
262
263 if (S_GET_NUMBER_AUXILIARY (debug) > 0)
264 {
265 /* Move all the auxiliary information. */
266 /* @@ How many fields do we want to preserve? Would it make more
267 sense to pick and choose those we want to copy? Should look
268 into this further.... [raeburn:19920512.2209EST] */
269 alent *linenos;
270 linenos = coffsymbol (normal->bsym)->lineno;
271 memcpy ((char *) &coffsymbol (normal->bsym)->native,
272 (char *) &coffsymbol (debug->bsym)->native,
273 S_GET_NUMBER_AUXILIARY(debug) * AUXESZ);
274 coffsymbol (normal->bsym)->lineno = linenos;
275 }
276
277 /* Move the debug flags. */
278 SF_SET_DEBUG_FIELD (normal, SF_GET_DEBUG_FIELD (debug));
279 }
280
281 static symbolS *previous_file_symbol;
282 void
283 c_dot_file_symbol (filename)
284 char *filename;
285 {
286 symbolS *symbolP;
287
288 symbolP = symbol_new (filename, bfd_abs_section_ptr, 0, &zero_address_frag);
289
290 S_SET_STORAGE_CLASS (symbolP, C_FILE);
291 S_SET_NUMBER_AUXILIARY (symbolP, 1);
292
293 symbolP->bsym->flags = BSF_DEBUGGING;
294
295 #ifndef NO_LISTING
296 {
297 extern int listing;
298 if (listing)
299 {
300 listing_source_file (filename);
301 }
302 }
303 #endif
304
305 S_SET_VALUE (symbolP, (long) previous_file_symbol);
306
307 previous_file_symbol = symbolP;
308
309 /* Make sure that the symbol is first on the symbol chain */
310 if (symbol_rootP != symbolP)
311 {
312 if (symbolP == symbol_lastP)
313 {
314 symbol_lastP = symbol_lastP->sy_previous;
315 } /* if it was the last thing on the list */
316
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 */
321 }
322
323 /* Line number handling */
324
325 struct line_no {
326 struct line_no *next;
327 fragS *frag;
328 alent l;
329 };
330
331 int coff_line_base;
332
333 /* Symbol of last function, which we should hang line#s off of. */
334 static symbolS *line_fsym;
335
336 #define in_function() (line_fsym != 0)
337 #define clear_function() (line_fsym = 0)
338 #define set_function(F) (line_fsym = (F), coff_add_linesym (F))
339
340 \f
341 void
342 obj_symbol_new_hook (symbolP)
343 symbolS *symbolP;
344 {
345 char underscore = 0; /* Symbol has leading _ */
346
347 {
348 long sz = (OBJ_COFF_MAX_AUXENTRIES + 1) * sizeof (combined_entry_type);
349 char *s = (char *) bfd_alloc_by_size_t (stdoutput, sz);
350 memset (s, 0, sz);
351 coffsymbol (symbolP->bsym)->native = (combined_entry_type *) s;
352 }
353 S_SET_DATA_TYPE (symbolP, T_NULL);
354 S_SET_STORAGE_CLASS (symbolP, 0);
355 S_SET_NUMBER_AUXILIARY (symbolP, 0);
356
357 if (S_IS_STRING (symbolP))
358 SF_SET_STRING (symbolP);
359 if (!underscore && S_IS_LOCAL (symbolP))
360 SF_SET_LOCAL (symbolP);
361 }
362
363 \f
364 /*
365 * Handle .ln directives.
366 */
367
368 static symbolS *current_lineno_sym;
369 static struct line_no *line_nos;
370 /* @@ Blindly assume all .ln directives will be in the .text section... */
371 int coff_n_line_nos;
372
373 static void
374 add_lineno (frag, offset, num)
375 fragS *frag;
376 int offset;
377 int num;
378 {
379 struct line_no *new_line = (struct line_no *) bfd_alloc_by_size_t (stdoutput,
380 sizeof (struct line_no));
381 if (!current_lineno_sym)
382 {
383 abort ();
384 }
385 new_line->next = line_nos;
386 new_line->frag = frag;
387 new_line->l.line_number = num;
388 new_line->l.u.offset = offset;
389 line_nos = new_line;
390 coff_n_line_nos++;
391 }
392
393 void
394 coff_add_linesym (sym)
395 symbolS *sym;
396 {
397 if (line_nos)
398 {
399 coffsymbol (current_lineno_sym->bsym)->lineno = (alent *) line_nos;
400 coff_n_line_nos++;
401 line_nos = 0;
402 }
403 current_lineno_sym = sym;
404 }
405
406 static void
407 obj_coff_ln (appline)
408 int appline;
409 {
410 int l;
411
412 if (! appline && def_symbol_in_progress != NULL)
413 {
414 as_warn (".ln pseudo-op inside .def/.endef: ignored.");
415 demand_empty_rest_of_line ();
416 return;
417 }
418
419 l = get_absolute_expression ();
420 if (!appline)
421 {
422 add_lineno (frag_now, frag_now_fix (), l);
423 }
424
425 #ifndef NO_LISTING
426 {
427 extern int listing;
428
429 if (listing)
430 {
431 if (! appline)
432 l += coff_line_base - 1;
433 listing_source_line (l);
434 }
435 }
436 #endif
437
438 demand_empty_rest_of_line ();
439 }
440
441 /*
442 * def()
443 *
444 * Handle .def directives.
445 *
446 * One might ask : why can't we symbol_new if the symbol does not
447 * already exist and fill it with debug information. Because of
448 * the C_EFCN special symbol. It would clobber the value of the
449 * function symbol before we have a chance to notice that it is
450 * a C_EFCN. And a second reason is that the code is more clear this
451 * way. (at least I think it is :-).
452 *
453 */
454
455 #define SKIP_SEMI_COLON() while (*input_line_pointer++ != ';')
456 #define SKIP_WHITESPACES() while (*input_line_pointer == ' ' || \
457 *input_line_pointer == '\t') \
458 input_line_pointer++;
459
460 static void
461 obj_coff_def (what)
462 int what;
463 {
464 char name_end; /* Char after the end of name */
465 char *symbol_name; /* Name of the debug symbol */
466 char *symbol_name_copy; /* Temporary copy of the name */
467 unsigned int symbol_name_length;
468
469 if (def_symbol_in_progress != NULL)
470 {
471 as_warn (".def pseudo-op used inside of .def/.endef: ignored.");
472 demand_empty_rest_of_line ();
473 return;
474 } /* if not inside .def/.endef */
475
476 SKIP_WHITESPACES ();
477
478 symbol_name = input_line_pointer;
479 #ifdef STRIP_UNDERSCORE
480 if (symbol_name[0] == '_' && symbol_name[1] != 0)
481 symbol_name++;
482 #endif /* STRIP_UNDERSCORE */
483
484 name_end = get_symbol_end ();
485 symbol_name_length = strlen (symbol_name);
486 symbol_name_copy = xmalloc (symbol_name_length + 1);
487 strcpy (symbol_name_copy, symbol_name);
488
489 /* Initialize the new symbol */
490 def_symbol_in_progress = symbol_make (symbol_name_copy);
491 def_symbol_in_progress->sy_frag = &zero_address_frag;
492 S_SET_VALUE (def_symbol_in_progress, 0);
493
494 if (S_IS_STRING (def_symbol_in_progress))
495 SF_SET_STRING (def_symbol_in_progress);
496
497 *input_line_pointer = name_end;
498
499 demand_empty_rest_of_line ();
500 }
501
502 unsigned int dim_index;
503
504 static void
505 obj_coff_endef (ignore)
506 int ignore;
507 {
508 symbolS *symbolP;
509 /* DIM BUG FIX sac@cygnus.com */
510 dim_index = 0;
511 if (def_symbol_in_progress == NULL)
512 {
513 as_warn (".endef pseudo-op used outside of .def/.endef: ignored.");
514 demand_empty_rest_of_line ();
515 return;
516 } /* if not inside .def/.endef */
517
518 /* Set the section number according to storage class. */
519 switch (S_GET_STORAGE_CLASS (def_symbol_in_progress))
520 {
521 case C_STRTAG:
522 case C_ENTAG:
523 case C_UNTAG:
524 SF_SET_TAG (def_symbol_in_progress);
525 /* intentional fallthrough */
526 case C_FILE:
527 case C_TPDEF:
528 SF_SET_DEBUG (def_symbol_in_progress);
529 S_SET_SEGMENT (def_symbol_in_progress, fetch_coff_debug_section ());
530 break;
531
532 case C_EFCN:
533 SF_SET_LOCAL (def_symbol_in_progress); /* Do not emit this symbol. */
534 /* intentional fallthrough */
535 case C_BLOCK:
536 SF_SET_PROCESS (def_symbol_in_progress); /* Will need processing before writing */
537 /* intentional fallthrough */
538 case C_FCN:
539 {
540 CONST char *name;
541 S_SET_SEGMENT (def_symbol_in_progress, text_section);
542
543 name = bfd_asymbol_name (def_symbol_in_progress->bsym);
544 if (name[1] == 'b' && name[2] == 'f')
545 {
546 if (! in_function ())
547 as_warn ("`%s' symbol without preceding function", name);
548 /* SA_SET_SYM_LNNO (def_symbol_in_progress, 12345);*/
549 /* Will need relocating */
550 SF_SET_PROCESS (def_symbol_in_progress);
551 clear_function ();
552 }
553 }
554 break;
555
556 #ifdef C_AUTOARG
557 case C_AUTOARG:
558 #endif /* C_AUTOARG */
559 case C_AUTO:
560 case C_REG:
561 case C_ARG:
562 case C_REGPARM:
563 case C_FIELD:
564 SF_SET_DEBUG (def_symbol_in_progress);
565 S_SET_SEGMENT (def_symbol_in_progress, absolute_section);
566 break;
567
568 case C_MOS:
569 case C_MOE:
570 case C_MOU:
571 case C_EOS:
572 S_SET_SEGMENT (def_symbol_in_progress, absolute_section);
573 break;
574
575 case C_EXT:
576 case C_STAT:
577 case C_LABEL:
578 /* Valid but set somewhere else (s_comm, s_lcomm, colon) */
579 break;
580
581 case C_USTATIC:
582 case C_EXTDEF:
583 case C_ULABEL:
584 as_warn ("unexpected storage class %d",
585 S_GET_STORAGE_CLASS (def_symbol_in_progress));
586 break;
587 } /* switch on storage class */
588
589 /* Now that we have built a debug symbol, try to find if we should
590 merge with an existing symbol or not. If a symbol is C_EFCN or
591 SEG_ABSOLUTE or untagged SEG_DEBUG it never merges. */
592
593 /* Two cases for functions. Either debug followed by definition or
594 definition followed by debug. For definition first, we will
595 merge the debug symbol into the definition. For debug first, the
596 lineno entry MUST point to the definition function or else it
597 will point off into space when obj_crawl_symbol_chain() merges
598 the debug symbol into the real symbol. Therefor, let's presume
599 the debug symbol is a real function reference. */
600
601 /* FIXME-SOON If for some reason the definition label/symbol is
602 never seen, this will probably leave an undefined symbol at link
603 time. */
604
605 if (S_GET_STORAGE_CLASS (def_symbol_in_progress) == C_EFCN
606 || (!strcmp (bfd_get_section_name (stdoutput,
607 S_GET_SEGMENT (def_symbol_in_progress)),
608 "*DEBUG*")
609 && !SF_GET_TAG (def_symbol_in_progress))
610 || S_GET_SEGMENT (def_symbol_in_progress) == absolute_section
611 || (symbolP = symbol_find_base (S_GET_NAME (def_symbol_in_progress), DO_NOT_STRIP)) == NULL)
612 {
613 if (def_symbol_in_progress != symbol_lastP)
614 symbol_append (def_symbol_in_progress, symbol_lastP, &symbol_rootP,
615 &symbol_lastP);
616 }
617 else
618 {
619 /* This symbol already exists, merge the newly created symbol
620 into the old one. This is not mandatory. The linker can
621 handle duplicate symbols correctly. But I guess that it save
622 a *lot* of space if the assembly file defines a lot of
623 symbols. [loic] */
624
625 /* The debug entry (def_symbol_in_progress) is merged into the
626 previous definition. */
627
628 c_symbol_merge (def_symbol_in_progress, symbolP);
629 symbol_remove (def_symbol_in_progress, &symbol_rootP, &symbol_lastP);
630
631 def_symbol_in_progress = symbolP;
632
633 if (SF_GET_FUNCTION (def_symbol_in_progress)
634 || SF_GET_TAG (def_symbol_in_progress))
635 {
636 /* For functions, and tags, the symbol *must* be where the
637 debug symbol appears. Move the existing symbol to the
638 current place. */
639 /* If it already is at the end of the symbol list, do nothing */
640 if (def_symbol_in_progress != symbol_lastP)
641 {
642 symbol_remove (def_symbol_in_progress, &symbol_rootP, &symbol_lastP);
643 symbol_append (def_symbol_in_progress, symbol_lastP, &symbol_rootP, &symbol_lastP);
644 }
645 }
646 }
647
648 if (SF_GET_TAG (def_symbol_in_progress))
649 {
650 symbolS *oldtag;
651
652 oldtag = symbol_find_base (S_GET_NAME (def_symbol_in_progress),
653 DO_NOT_STRIP);
654 if (oldtag == NULL || ! SF_GET_TAG (oldtag))
655 tag_insert (S_GET_NAME (def_symbol_in_progress),
656 def_symbol_in_progress);
657 }
658
659 if (SF_GET_FUNCTION (def_symbol_in_progress))
660 {
661 know (sizeof (def_symbol_in_progress) <= sizeof (long));
662 set_function (def_symbol_in_progress);
663 SF_SET_PROCESS (def_symbol_in_progress);
664
665 if (symbolP == NULL)
666 {
667 /* That is, if this is the first time we've seen the
668 function... */
669 symbol_table_insert (def_symbol_in_progress);
670 } /* definition follows debug */
671 } /* Create the line number entry pointing to the function being defined */
672
673 def_symbol_in_progress = NULL;
674 demand_empty_rest_of_line ();
675 }
676
677 static void
678 obj_coff_dim (ignore)
679 int ignore;
680 {
681 int dim_index;
682
683 if (def_symbol_in_progress == NULL)
684 {
685 as_warn (".dim pseudo-op used outside of .def/.endef: ignored.");
686 demand_empty_rest_of_line ();
687 return;
688 } /* if not inside .def/.endef */
689
690 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
691
692 for (dim_index = 0; dim_index < DIMNUM; dim_index++)
693 {
694 SKIP_WHITESPACES ();
695 SA_SET_SYM_DIMEN (def_symbol_in_progress, dim_index,
696 get_absolute_expression ());
697
698 switch (*input_line_pointer)
699 {
700 case ',':
701 input_line_pointer++;
702 break;
703
704 default:
705 as_warn ("badly formed .dim directive ignored");
706 /* intentional fallthrough */
707 case '\n':
708 case ';':
709 dim_index = DIMNUM;
710 break;
711 }
712 }
713
714 demand_empty_rest_of_line ();
715 }
716
717 static void
718 obj_coff_line (ignore)
719 int ignore;
720 {
721 int this_base;
722
723 if (def_symbol_in_progress == NULL)
724 {
725 /* Probably stabs-style line? */
726 obj_coff_ln (0);
727 return;
728 }
729
730 this_base = get_absolute_expression ();
731 if (!strcmp (".bf", S_GET_NAME (def_symbol_in_progress)))
732 coff_line_base = this_base;
733
734 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
735 SA_SET_SYM_LNNO (def_symbol_in_progress, coff_line_base);
736
737 demand_empty_rest_of_line ();
738
739 #ifndef NO_LISTING
740 if (strcmp (".bf", S_GET_NAME (def_symbol_in_progress)) == 0)
741 {
742 extern int listing;
743
744 if (listing)
745 listing_source_line ((unsigned int) coff_line_base);
746 }
747 #endif
748 }
749
750 static void
751 obj_coff_size (ignore)
752 int ignore;
753 {
754 if (def_symbol_in_progress == NULL)
755 {
756 as_warn (".size pseudo-op used outside of .def/.endef ignored.");
757 demand_empty_rest_of_line ();
758 return;
759 } /* if not inside .def/.endef */
760
761 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
762 SA_SET_SYM_SIZE (def_symbol_in_progress, get_absolute_expression ());
763 demand_empty_rest_of_line ();
764 }
765
766 static void
767 obj_coff_scl (ignore)
768 int ignore;
769 {
770 if (def_symbol_in_progress == NULL)
771 {
772 as_warn (".scl pseudo-op used outside of .def/.endef ignored.");
773 demand_empty_rest_of_line ();
774 return;
775 } /* if not inside .def/.endef */
776
777 S_SET_STORAGE_CLASS (def_symbol_in_progress, get_absolute_expression ());
778 demand_empty_rest_of_line ();
779 }
780
781 static void
782 obj_coff_tag (ignore)
783 int ignore;
784 {
785 char *symbol_name;
786 char name_end;
787
788 if (def_symbol_in_progress == NULL)
789 {
790 as_warn (".tag pseudo-op used outside of .def/.endef ignored.");
791 demand_empty_rest_of_line ();
792 return;
793 }
794
795 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
796 symbol_name = input_line_pointer;
797 name_end = get_symbol_end ();
798
799 /* Assume that the symbol referred to by .tag is always defined.
800 This was a bad assumption. I've added find_or_make. xoxorich. */
801 SA_SET_SYM_TAGNDX (def_symbol_in_progress,
802 tag_find_or_make (symbol_name));
803 if (SA_GET_SYM_TAGNDX (def_symbol_in_progress) == 0L)
804 {
805 as_warn ("tag not found for .tag %s", symbol_name);
806 } /* not defined */
807
808 SF_SET_TAGGED (def_symbol_in_progress);
809 *input_line_pointer = name_end;
810
811 demand_empty_rest_of_line ();
812 }
813
814 static void
815 obj_coff_type (ignore)
816 int ignore;
817 {
818 if (def_symbol_in_progress == NULL)
819 {
820 as_warn (".type pseudo-op used outside of .def/.endef ignored.");
821 demand_empty_rest_of_line ();
822 return;
823 } /* if not inside .def/.endef */
824
825 S_SET_DATA_TYPE (def_symbol_in_progress, get_absolute_expression ());
826
827 if (ISFCN (S_GET_DATA_TYPE (def_symbol_in_progress)) &&
828 S_GET_STORAGE_CLASS (def_symbol_in_progress) != C_TPDEF)
829 {
830 SF_SET_FUNCTION (def_symbol_in_progress);
831 } /* is a function */
832
833 demand_empty_rest_of_line ();
834 }
835
836 static void
837 obj_coff_val (ignore)
838 int ignore;
839 {
840 if (def_symbol_in_progress == NULL)
841 {
842 as_warn (".val pseudo-op used outside of .def/.endef ignored.");
843 demand_empty_rest_of_line ();
844 return;
845 } /* if not inside .def/.endef */
846
847 if (is_name_beginner (*input_line_pointer))
848 {
849 char *symbol_name = input_line_pointer;
850 char name_end = get_symbol_end ();
851
852 if (!strcmp (symbol_name, "."))
853 {
854 def_symbol_in_progress->sy_frag = frag_now;
855 S_SET_VALUE (def_symbol_in_progress, (valueT) frag_now_fix ());
856 /* If the .val is != from the .def (e.g. statics) */
857 }
858 else if (strcmp (S_GET_NAME (def_symbol_in_progress), symbol_name))
859 {
860 def_symbol_in_progress->sy_value.X_op = O_symbol;
861 def_symbol_in_progress->sy_value.X_add_symbol =
862 symbol_find_or_make (symbol_name);
863 def_symbol_in_progress->sy_value.X_op_symbol = NULL;
864 def_symbol_in_progress->sy_value.X_add_number = 0;
865
866 /* If the segment is undefined when the forward reference is
867 resolved, then copy the segment id from the forward
868 symbol. */
869 SF_SET_GET_SEGMENT (def_symbol_in_progress);
870 }
871 /* Otherwise, it is the name of a non debug symbol and its value will be calculated later. */
872 *input_line_pointer = name_end;
873 }
874 else
875 {
876 S_SET_VALUE (def_symbol_in_progress, get_absolute_expression ());
877 } /* if symbol based */
878
879 demand_empty_rest_of_line ();
880 }
881
882 void
883 obj_read_begin_hook ()
884 {
885 /* These had better be the same. Usually 18 bytes. */
886 #ifndef BFD_HEADERS
887 know (sizeof (SYMENT) == sizeof (AUXENT));
888 know (SYMESZ == AUXESZ);
889 #endif
890 tag_init ();
891 }
892
893
894 symbolS *coff_last_function;
895 static symbolS *coff_last_bf;
896
897 void
898 coff_frob_symbol (symp, punt)
899 symbolS *symp;
900 int *punt;
901 {
902 static symbolS *last_tagP;
903 static stack *block_stack;
904 static symbolS *set_end;
905 symbolS *next_set_end = NULL;
906
907 if (symp == &abs_symbol)
908 {
909 *punt = 1;
910 return;
911 }
912
913 if (current_lineno_sym)
914 coff_add_linesym ((symbolS *) 0);
915
916 if (!block_stack)
917 block_stack = stack_init (512, sizeof (symbolS*));
918
919 if (!S_IS_DEFINED (symp) && S_GET_STORAGE_CLASS (symp) != C_STAT)
920 S_SET_STORAGE_CLASS (symp, C_EXT);
921
922 if (!SF_GET_DEBUG (symp))
923 {
924 symbolS *real;
925 if (!SF_GET_LOCAL (symp)
926 && !SF_GET_STATICS (symp)
927 && (real = symbol_find_base (S_GET_NAME (symp), DO_NOT_STRIP))
928 && real != symp)
929 {
930 c_symbol_merge (symp, real);
931 *punt = 1;
932 }
933 if (!S_IS_DEFINED (symp) && !SF_GET_LOCAL (symp))
934 {
935 assert (S_GET_VALUE (symp) == 0);
936 S_SET_EXTERNAL (symp);
937 }
938 else if (S_GET_STORAGE_CLASS (symp) == C_NULL)
939 {
940 if (S_GET_SEGMENT (symp) == text_section
941 && symp != seg_info (text_section)->sym)
942 S_SET_STORAGE_CLASS (symp, C_LABEL);
943 else
944 S_SET_STORAGE_CLASS (symp, C_STAT);
945 }
946 if (SF_GET_PROCESS (symp))
947 {
948 if (S_GET_STORAGE_CLASS (symp) == C_BLOCK)
949 {
950 if (!strcmp (S_GET_NAME (symp), ".bb"))
951 stack_push (block_stack, (char *) &symp);
952 else
953 {
954 symbolS *begin;
955 begin = *(symbolS **) stack_pop (block_stack);
956 if (begin == 0)
957 as_warn ("mismatched .eb");
958 else
959 next_set_end = begin;
960 }
961 }
962 if (coff_last_function == 0 && SF_GET_FUNCTION (symp))
963 {
964 union internal_auxent *auxp;
965 coff_last_function = symp;
966 if (S_GET_NUMBER_AUXILIARY (symp) < 1)
967 S_SET_NUMBER_AUXILIARY (symp, 1);
968 auxp = &coffsymbol (symp->bsym)->native[1].u.auxent;
969 memset (auxp->x_sym.x_fcnary.x_ary.x_dimen, 0,
970 sizeof (auxp->x_sym.x_fcnary.x_ary.x_dimen));
971 }
972 if (S_GET_STORAGE_CLASS (symp) == C_EFCN)
973 {
974 if (coff_last_function == 0)
975 as_fatal ("C_EFCN symbol out of scope");
976 SA_SET_SYM_FSIZE (coff_last_function,
977 (long) (S_GET_VALUE (symp)
978 - S_GET_VALUE (coff_last_function)));
979 next_set_end = coff_last_function;
980 coff_last_function = 0;
981 }
982 }
983 if (S_IS_EXTERNAL (symp))
984 S_SET_STORAGE_CLASS (symp, C_EXT);
985 else if (SF_GET_LOCAL (symp))
986 *punt = 1;
987
988 if (SF_GET_FUNCTION (symp))
989 symp->bsym->flags |= BSF_FUNCTION;
990
991 /* more ... */
992 }
993
994 if (SF_GET_TAG (symp))
995 last_tagP = symp;
996 else if (S_GET_STORAGE_CLASS (symp) == C_EOS)
997 next_set_end = last_tagP;
998 else if (S_GET_STORAGE_CLASS (symp) == C_FILE)
999 {
1000 if (S_GET_VALUE (symp))
1001 {
1002 S_SET_VALUE ((symbolS *) S_GET_VALUE (symp), 0xdeadbeef);
1003 S_SET_VALUE (symp, 0);
1004 }
1005 }
1006
1007 #ifdef OBJ_XCOFF
1008 /* This is pretty horrible, but we have to set *punt correctly in
1009 order to call SA_SET_SYM_ENDNDX correctly. */
1010 if (! symp->sy_used_in_reloc
1011 && ((symp->bsym->flags & BSF_SECTION_SYM) != 0
1012 || (! S_IS_EXTERNAL (symp)
1013 && ! symp->sy_tc.output
1014 && S_GET_STORAGE_CLASS (symp) != C_FILE)))
1015 *punt = 1;
1016 #endif
1017
1018 if (set_end != (symbolS *) NULL
1019 && ! *punt
1020 && ((symp->bsym->flags & BSF_NOT_AT_END) != 0
1021 || (S_IS_DEFINED (symp)
1022 && ! S_IS_COMMON (symp)
1023 && (! S_IS_EXTERNAL (symp) || SF_GET_FUNCTION (symp)))))
1024 {
1025 SA_SET_SYM_ENDNDX (set_end, symp);
1026 set_end = NULL;
1027 }
1028
1029 if (next_set_end != NULL
1030 && ! *punt)
1031 set_end = next_set_end;
1032
1033 if (! *punt
1034 && S_GET_STORAGE_CLASS (symp) == C_FCN
1035 && strcmp (S_GET_NAME (symp), ".bf") == 0)
1036 {
1037 if (coff_last_bf != NULL)
1038 SA_SET_SYM_ENDNDX (coff_last_bf, symp);
1039 coff_last_bf = symp;
1040 }
1041
1042 if (coffsymbol (symp->bsym)->lineno)
1043 {
1044 int i;
1045 struct line_no *lptr;
1046 alent *l;
1047
1048 lptr = (struct line_no *) coffsymbol (symp->bsym)->lineno;
1049 for (i = 0; lptr; lptr = lptr->next)
1050 i++;
1051 lptr = (struct line_no *) coffsymbol (symp->bsym)->lineno;
1052
1053 /* We need i entries for line numbers, plus 1 for the first
1054 entry which BFD will override, plus 1 for the last zero
1055 entry (a marker for BFD). */
1056 l = (alent *) bfd_alloc_by_size_t (stdoutput, (i + 2) * sizeof (alent));
1057 coffsymbol (symp->bsym)->lineno = l;
1058 l[i + 1].line_number = 0;
1059 l[i + 1].u.sym = NULL;
1060 for (; i > 0; i--)
1061 {
1062 if (lptr->frag)
1063 lptr->l.u.offset += lptr->frag->fr_address;
1064 l[i] = lptr->l;
1065 lptr = lptr->next;
1066 }
1067 }
1068 }
1069
1070 void
1071 coff_adjust_section_syms (abfd, sec, x)
1072 bfd *abfd;
1073 asection *sec;
1074 PTR x;
1075 {
1076 symbolS *secsym;
1077 segment_info_type *seginfo = seg_info (sec);
1078 int nlnno, nrelocs = 0;
1079
1080 /* RS/6000 gas creates a .debug section manually in ppc_frob_file in
1081 tc-ppc.c. Do not get confused by it. */
1082 if (seginfo == NULL)
1083 return;
1084
1085 if (!strcmp (sec->name, ".text"))
1086 nlnno = coff_n_line_nos;
1087 else
1088 nlnno = 0;
1089 {
1090 /* @@ Hope that none of the fixups expand to more than one reloc
1091 entry... */
1092 fixS *fixp = seginfo->fix_root;
1093 while (fixp)
1094 {
1095 fixp = fixp->fx_next;
1096 nrelocs++;
1097 }
1098 }
1099 if (bfd_get_section_size_before_reloc (sec) == 0
1100 && nrelocs == 0
1101 && nlnno == 0
1102 && sec != text_section
1103 && sec != data_section
1104 && sec != bss_section)
1105 return;
1106 secsym = section_symbol (sec);
1107 SA_SET_SCN_NRELOC (secsym, nrelocs);
1108 SA_SET_SCN_NLINNO (secsym, nlnno);
1109 }
1110
1111 void
1112 coff_frob_file ()
1113 {
1114 bfd_map_over_sections (stdoutput, coff_adjust_section_syms, (char*) 0);
1115 }
1116
1117 /*
1118 * implement the .section pseudo op:
1119 * .section name {, "flags"}
1120 * ^ ^
1121 * | +--- optional flags: 'b' for bss
1122 * | 'i' for info
1123 * +-- section name 'l' for lib
1124 * 'n' for noload
1125 * 'o' for over
1126 * 'w' for data
1127 * 'd' (apparently m88k for data)
1128 * 'x' for text
1129 * But if the argument is not a quoted string, treat it as a
1130 * subsegment number.
1131 */
1132
1133 void
1134 obj_coff_section (ignore)
1135 int ignore;
1136 {
1137 /* Strip out the section name */
1138 char *section_name;
1139 char c;
1140 char *name;
1141 unsigned int exp;
1142 flagword flags;
1143 asection *sec;
1144
1145 if (flag_mri)
1146 {
1147 char type;
1148
1149 s_mri_sect (&type);
1150 return;
1151 }
1152
1153 section_name = input_line_pointer;
1154 c = get_symbol_end ();
1155
1156 name = xmalloc (input_line_pointer - section_name + 1);
1157 strcpy (name, section_name);
1158
1159 *input_line_pointer = c;
1160
1161 SKIP_WHITESPACE ();
1162
1163 exp = 0;
1164 flags = SEC_NO_FLAGS;
1165
1166 if (*input_line_pointer == ',')
1167 {
1168 ++input_line_pointer;
1169 SKIP_WHITESPACE ();
1170 if (*input_line_pointer != '"')
1171 exp = get_absolute_expression ();
1172 else
1173 {
1174 ++input_line_pointer;
1175 while (*input_line_pointer != '"'
1176 && ! is_end_of_line[(unsigned char) *input_line_pointer])
1177 {
1178 switch (*input_line_pointer)
1179 {
1180 case 'b': flags |= SEC_ALLOC; flags &=~ SEC_LOAD; break;
1181 case 'n': flags &=~ SEC_LOAD; break;
1182 case 'd':
1183 case 'w': flags &=~ SEC_READONLY; break;
1184 case 'x': flags |= SEC_CODE; break;
1185
1186 case 'i': /* STYP_INFO */
1187 case 'l': /* STYP_LIB */
1188 case 'o': /* STYP_OVER */
1189 as_warn ("unsupported section attribute '%c'",
1190 *input_line_pointer);
1191 break;
1192
1193 default:
1194 as_warn("unknown section attribute '%c'",
1195 *input_line_pointer);
1196 break;
1197 }
1198 ++input_line_pointer;
1199 }
1200 if (*input_line_pointer == '"')
1201 ++input_line_pointer;
1202 }
1203 }
1204
1205 sec = subseg_new (name, (subsegT) exp);
1206
1207 if (flags != SEC_NO_FLAGS)
1208 {
1209 if (! bfd_set_section_flags (stdoutput, sec, flags))
1210 as_warn ("error setting flags for \"%s\": %s",
1211 bfd_section_name (stdoutput, sec),
1212 bfd_errmsg (bfd_get_error ()));
1213 }
1214
1215 demand_empty_rest_of_line ();
1216 }
1217
1218 void
1219 coff_adjust_symtab ()
1220 {
1221 if (symbol_rootP == NULL
1222 || S_GET_STORAGE_CLASS (symbol_rootP) != C_FILE)
1223 {
1224 assert (previous_file_symbol == 0);
1225 c_dot_file_symbol ("fake");
1226 }
1227 }
1228
1229 void
1230 coff_frob_section (sec)
1231 segT sec;
1232 {
1233 segT strsec;
1234 char *p;
1235 fragS *fragp;
1236 bfd_vma size, n_entries, mask;
1237
1238 /* The COFF back end in BFD requires that all section sizes be
1239 rounded up to multiples of the corresponding section alignments.
1240 Seems kinda silly to me, but that's the way it is. */
1241 size = bfd_get_section_size_before_reloc (sec);
1242 mask = ((bfd_vma) 1 << (bfd_vma) sec->alignment_power) - 1;
1243 if (size & mask)
1244 {
1245 size = (size + mask) & ~mask;
1246 bfd_set_section_size (stdoutput, sec, size);
1247 }
1248
1249 /* If the section size is non-zero, the section symbol needs an aux
1250 entry associated with it, indicating the size. We don't know
1251 all the values yet; coff_frob_symbol will fill them in later. */
1252 if (size != 0
1253 || sec == text_section
1254 || sec == data_section
1255 || sec == bss_section)
1256 {
1257 symbolS *secsym = section_symbol (sec);
1258
1259 S_SET_STORAGE_CLASS (secsym, C_STAT);
1260 S_SET_NUMBER_AUXILIARY (secsym, 1);
1261 SF_SET_STATICS (secsym);
1262 SA_SET_SCN_SCNLEN (secsym, size);
1263 }
1264
1265 /* @@ these should be in a "stabs.h" file, or maybe as.h */
1266 #ifndef STAB_SECTION_NAME
1267 #define STAB_SECTION_NAME ".stab"
1268 #endif
1269 #ifndef STAB_STRING_SECTION_NAME
1270 #define STAB_STRING_SECTION_NAME ".stabstr"
1271 #endif
1272 if (strcmp (STAB_STRING_SECTION_NAME, sec->name))
1273 return;
1274
1275 strsec = sec;
1276 sec = subseg_get (STAB_SECTION_NAME, 0);
1277 /* size is already rounded up, since other section will be listed first */
1278 size = bfd_get_section_size_before_reloc (strsec);
1279
1280 n_entries = bfd_get_section_size_before_reloc (sec) / 12 - 1;
1281
1282 /* Find first non-empty frag. It should be large enough. */
1283 fragp = seg_info (sec)->frchainP->frch_root;
1284 while (fragp && fragp->fr_fix == 0)
1285 fragp = fragp->fr_next;
1286 assert (fragp != 0 && fragp->fr_fix >= 12);
1287
1288 /* Store the values. */
1289 p = fragp->fr_literal;
1290 bfd_h_put_16 (stdoutput, n_entries, (bfd_byte *) p + 6);
1291 bfd_h_put_32 (stdoutput, size, (bfd_byte *) p + 8);
1292 }
1293
1294 void
1295 obj_coff_init_stab_section (seg)
1296 segT seg;
1297 {
1298 char *file;
1299 char *p;
1300 char *stabstr_name;
1301 unsigned int stroff;
1302
1303 /* Make space for this first symbol. */
1304 p = frag_more (12);
1305 /* Zero it out. */
1306 memset (p, 0, 12);
1307 as_where (&file, (unsigned int *) NULL);
1308 stabstr_name = (char *) alloca (strlen (seg->name) + 4);
1309 strcpy (stabstr_name, seg->name);
1310 strcat (stabstr_name, "str");
1311 stroff = get_stab_string_offset (file, stabstr_name);
1312 know (stroff == 1);
1313 md_number_to_chars (p, stroff, 4);
1314 }
1315
1316 #ifdef DEBUG
1317 /* for debugging */
1318 const char *
1319 s_get_name (s)
1320 symbolS *s;
1321 {
1322 return ((s == NULL) ? "(NULL)" : S_GET_NAME (s));
1323 }
1324
1325 void
1326 symbol_dump ()
1327 {
1328 symbolS *symbolP;
1329
1330 for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
1331 {
1332 printf("0x%lx: \"%s\" type = %ld, class = %d, segment = %d\n",
1333 (unsigned long) symbolP,
1334 S_GET_NAME(symbolP),
1335 (long) S_GET_DATA_TYPE(symbolP),
1336 S_GET_STORAGE_CLASS(symbolP),
1337 (int) S_GET_SEGMENT(symbolP));
1338 }
1339 }
1340
1341 #endif /* DEBUG */
1342
1343 #else /* not BFD_ASSEMBLER */
1344
1345 #include "frags.h"
1346 /* This is needed because we include internal bfd things. */
1347 #include <time.h>
1348
1349 #include "libbfd.h"
1350 #include "libcoff.h"
1351
1352 #ifdef TE_PE
1353 #include "coff/pe.h"
1354 #endif
1355
1356 /* The NOP_OPCODE is for the alignment fill value. Fill with nop so
1357 that we can stick sections together without causing trouble. */
1358 #ifndef NOP_OPCODE
1359 #define NOP_OPCODE 0x00
1360 #endif
1361
1362 /* The zeroes if symbol name is longer than 8 chars */
1363 #define S_SET_ZEROES(s,v) ((s)->sy_symbol.ost_entry.n_zeroes = (v))
1364
1365 #define MIN(a,b) ((a) < (b)? (a) : (b))
1366 /* This vector is used to turn an internal segment into a section #
1367 suitable for insertion into a coff symbol table
1368 */
1369
1370 const short seg_N_TYPE[] =
1371 { /* in: segT out: N_TYPE bits */
1372 C_ABS_SECTION,
1373 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
1374 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
1375 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
1376 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
1377 C_UNDEF_SECTION, /* SEG_UNKNOWN */
1378 C_UNDEF_SECTION, /* SEG_GOOF */
1379 C_UNDEF_SECTION, /* SEG_EXPR */
1380 C_DEBUG_SECTION, /* SEG_DEBUG */
1381 C_NTV_SECTION, /* SEG_NTV */
1382 C_PTV_SECTION, /* SEG_PTV */
1383 C_REGISTER_SECTION, /* SEG_REGISTER */
1384 };
1385
1386 int function_lineoff = -1; /* Offset in line#s where the last function
1387 started (the odd entry for line #0) */
1388
1389 /* structure used to keep the filenames which
1390 are too long around so that we can stick them
1391 into the string table */
1392 struct filename_list
1393 {
1394 char *filename;
1395 struct filename_list *next;
1396 };
1397
1398 static struct filename_list *filename_list_head;
1399 static struct filename_list *filename_list_tail;
1400
1401 static symbolS *last_line_symbol;
1402
1403 /* Add 4 to the real value to get the index and compensate the
1404 negatives. This vector is used by S_GET_SEGMENT to turn a coff
1405 section number into a segment number
1406 */
1407 static symbolS *previous_file_symbol;
1408 void c_symbol_merge ();
1409 static int line_base;
1410
1411 symbolS *c_section_symbol ();
1412 bfd *abfd;
1413
1414 static void fixup_segment PARAMS ((segment_info_type *segP,
1415 segT this_segment_type));
1416
1417
1418 static void fixup_mdeps PARAMS ((fragS *,
1419 object_headers *,
1420 segT));
1421
1422
1423 static void fill_section PARAMS ((bfd * abfd,
1424 object_headers *,
1425 unsigned long *));
1426
1427
1428 static int c_line_new PARAMS ((symbolS * symbol, long paddr,
1429 int line_number,
1430 fragS * frag));
1431
1432
1433 static void w_symbols PARAMS ((bfd * abfd, char *where,
1434 symbolS * symbol_rootP));
1435
1436 static void adjust_stab_section PARAMS ((bfd *abfd, segT seg));
1437
1438 static void obj_coff_lcomm PARAMS ((int));
1439 static void obj_coff_text PARAMS ((int));
1440 static void obj_coff_data PARAMS ((int));
1441 static void obj_coff_bss PARAMS ((int));
1442 static void obj_coff_ident PARAMS ((int));
1443 void obj_coff_section PARAMS ((int));
1444
1445 /* Section stuff
1446
1447 We allow more than just the standard 3 sections, infact, we allow
1448 40 sections, (though the usual three have to be there).
1449
1450 This structure performs the mappings for us:
1451 */
1452
1453
1454 typedef struct
1455 {
1456 segT seg_t;
1457 int i;
1458 } seg_info_type;
1459
1460 static const seg_info_type seg_info_off_by_4[] =
1461 {
1462 {SEG_PTV, },
1463 {SEG_NTV, },
1464 {SEG_DEBUG, },
1465 {SEG_ABSOLUTE, },
1466 {SEG_UNKNOWN, },
1467 {SEG_E0}, {SEG_E1}, {SEG_E2}, {SEG_E3}, {SEG_E4},
1468 {SEG_E5}, {SEG_E6}, {SEG_E7}, {SEG_E8}, {SEG_E9},
1469 {SEG_E10},{SEG_E11},{SEG_E12},{SEG_E13},{SEG_E14},
1470 {SEG_E15},{SEG_E16},{SEG_E17},{SEG_E18},{SEG_E19},
1471 {SEG_E20},{SEG_E21},{SEG_E22},{SEG_E23},{SEG_E24},
1472 {SEG_E25},{SEG_E26},{SEG_E27},{SEG_E28},{SEG_E29},
1473 {SEG_E30},{SEG_E31},{SEG_E32},{SEG_E33},{SEG_E34},
1474 {SEG_E35},{SEG_E36},{SEG_E37},{SEG_E38},{SEG_E39},
1475 {(segT)40},
1476 {(segT)41},
1477 {(segT)42},
1478 {(segT)43},
1479 {(segT)44},
1480 {(segT)45},
1481 {(segT)0},
1482 {(segT)0},
1483 {(segT)0},
1484 {SEG_REGISTER}
1485 };
1486
1487
1488
1489 #define SEG_INFO_FROM_SECTION_NUMBER(x) (seg_info_off_by_4[(x)+4])
1490
1491 static relax_addressT
1492 relax_align (address, alignment)
1493 relax_addressT address;
1494 long alignment;
1495 {
1496 relax_addressT mask;
1497 relax_addressT new_address;
1498
1499 mask = ~((~0) << alignment);
1500 new_address = (address + mask) & (~mask);
1501 return (new_address - address);
1502 }
1503
1504
1505 segT
1506 s_get_segment (x)
1507 symbolS * x;
1508 {
1509 return SEG_INFO_FROM_SECTION_NUMBER (x->sy_symbol.ost_entry.n_scnum).seg_t;
1510 }
1511
1512
1513
1514 /* calculate the size of the frag chain and fill in the section header
1515 to contain all of it, also fill in the addr of the sections */
1516 static unsigned int
1517 size_section (abfd, idx)
1518 bfd * abfd;
1519 unsigned int idx;
1520 {
1521
1522 unsigned int size = 0;
1523 fragS *frag = segment_info[idx].frchainP->frch_root;
1524 while (frag)
1525 {
1526 size = frag->fr_address;
1527 if (frag->fr_address != size)
1528 {
1529 fprintf (stderr, "Out of step\n");
1530 size = frag->fr_address;
1531 }
1532
1533 switch (frag->fr_type)
1534 {
1535 #ifdef TC_COFF_SIZEMACHDEP
1536 case rs_machine_dependent:
1537 size += TC_COFF_SIZEMACHDEP (frag);
1538 break;
1539 #endif
1540 case rs_space:
1541 assert (frag->fr_symbol == 0);
1542 case rs_fill:
1543 case rs_org:
1544 size += frag->fr_fix;
1545 size += frag->fr_offset * frag->fr_var;
1546 break;
1547 case rs_align:
1548 case rs_align_code:
1549 size += frag->fr_fix;
1550 size += relax_align (size, frag->fr_offset);
1551 break;
1552 default:
1553 BAD_CASE (frag->fr_type);
1554 break;
1555 }
1556 frag = frag->fr_next;
1557 }
1558 segment_info[idx].scnhdr.s_size = size;
1559 return size;
1560 }
1561
1562
1563 static unsigned int
1564 count_entries_in_chain (idx)
1565 unsigned int idx;
1566 {
1567 unsigned int nrelocs;
1568 fixS *fixup_ptr;
1569
1570 /* Count the relocations */
1571 fixup_ptr = segment_info[idx].fix_root;
1572 nrelocs = 0;
1573 while (fixup_ptr != (fixS *) NULL)
1574 {
1575 if (fixup_ptr->fx_done == 0 && TC_COUNT_RELOC (fixup_ptr))
1576 {
1577 #ifdef TC_A29K
1578 if (fixup_ptr->fx_r_type == RELOC_CONSTH)
1579 nrelocs += 2;
1580 else
1581 nrelocs++;
1582 #else
1583 nrelocs++;
1584 #endif
1585 }
1586
1587 fixup_ptr = fixup_ptr->fx_next;
1588 }
1589 return nrelocs;
1590 }
1591
1592 #ifdef TE_AUX
1593
1594 static int compare_external_relocs PARAMS ((const PTR, const PTR));
1595
1596 /* AUX's ld expects relocations to be sorted */
1597 static int
1598 compare_external_relocs (x, y)
1599 const PTR x;
1600 const PTR y;
1601 {
1602 struct external_reloc *a = (struct external_reloc *) x;
1603 struct external_reloc *b = (struct external_reloc *) y;
1604 bfd_vma aadr = bfd_getb32 (a->r_vaddr);
1605 bfd_vma badr = bfd_getb32 (b->r_vaddr);
1606 return (aadr < badr ? -1 : badr < aadr ? 1 : 0);
1607 }
1608
1609 #endif
1610
1611 /* output all the relocations for a section */
1612 void
1613 do_relocs_for (abfd, h, file_cursor)
1614 bfd * abfd;
1615 object_headers * h;
1616 unsigned long *file_cursor;
1617 {
1618 unsigned int nrelocs;
1619 unsigned int idx;
1620 unsigned long reloc_start = *file_cursor;
1621
1622 for (idx = SEG_E0; idx < SEG_LAST; idx++)
1623 {
1624 if (segment_info[idx].scnhdr.s_name[0])
1625 {
1626 struct external_reloc *ext_ptr;
1627 struct external_reloc *external_reloc_vec;
1628 unsigned int external_reloc_size;
1629 unsigned int base = segment_info[idx].scnhdr.s_paddr;
1630 fixS *fix_ptr = segment_info[idx].fix_root;
1631 nrelocs = count_entries_in_chain (idx);
1632
1633 if (nrelocs)
1634 /* Bypass this stuff if no relocs. This also incidentally
1635 avoids a SCO bug, where free(malloc(0)) tends to crash. */
1636 {
1637 external_reloc_size = nrelocs * RELSZ;
1638 external_reloc_vec =
1639 (struct external_reloc *) malloc (external_reloc_size);
1640
1641 ext_ptr = external_reloc_vec;
1642
1643 /* Fill in the internal coff style reloc struct from the
1644 internal fix list. */
1645 while (fix_ptr)
1646 {
1647 struct internal_reloc intr;
1648
1649 /* Only output some of the relocations */
1650 if (fix_ptr->fx_done == 0 && TC_COUNT_RELOC (fix_ptr))
1651 {
1652 #ifdef TC_RELOC_MANGLE
1653 TC_RELOC_MANGLE (&segment_info[idx], fix_ptr, &intr,
1654 base);
1655
1656 #else
1657 symbolS *dot;
1658 symbolS *symbol_ptr = fix_ptr->fx_addsy;
1659
1660 intr.r_type = TC_COFF_FIX2RTYPE (fix_ptr);
1661 intr.r_vaddr =
1662 base + fix_ptr->fx_frag->fr_address + fix_ptr->fx_where;
1663
1664 #ifdef TC_KEEP_FX_OFFSET
1665 intr.r_offset = fix_ptr->fx_offset;
1666 #else
1667 intr.r_offset = 0;
1668 #endif
1669
1670 while (symbol_ptr->sy_value.X_op == O_symbol
1671 && (! S_IS_DEFINED (symbol_ptr)
1672 || S_IS_COMMON (symbol_ptr)))
1673 symbol_ptr = symbol_ptr->sy_value.X_add_symbol;
1674
1675 /* Turn the segment of the symbol into an offset. */
1676 if (symbol_ptr)
1677 {
1678 dot = segment_info[S_GET_SEGMENT (symbol_ptr)].dot;
1679 if (dot)
1680 {
1681 intr.r_symndx = dot->sy_number;
1682 }
1683 else
1684 {
1685 intr.r_symndx = symbol_ptr->sy_number;
1686 }
1687
1688 }
1689 else
1690 {
1691 intr.r_symndx = -1;
1692 }
1693 #endif
1694
1695 (void) bfd_coff_swap_reloc_out (abfd, &intr, ext_ptr);
1696 ext_ptr++;
1697
1698 #if defined(TC_A29K)
1699
1700 /* The 29k has a special kludge for the high 16 bit
1701 reloc. Two relocations are emited, R_IHIHALF,
1702 and R_IHCONST. The second one doesn't contain a
1703 symbol, but uses the value for offset. */
1704
1705 if (intr.r_type == R_IHIHALF)
1706 {
1707 /* now emit the second bit */
1708 intr.r_type = R_IHCONST;
1709 intr.r_symndx = fix_ptr->fx_addnumber;
1710 (void) bfd_coff_swap_reloc_out (abfd, &intr, ext_ptr);
1711 ext_ptr++;
1712 }
1713 #endif
1714 }
1715
1716 fix_ptr = fix_ptr->fx_next;
1717 }
1718
1719 #ifdef TE_AUX
1720 /* Sort the reloc table */
1721 qsort ((PTR) external_reloc_vec, nrelocs,
1722 sizeof (struct external_reloc), compare_external_relocs);
1723 #endif
1724
1725 /* Write out the reloc table */
1726 bfd_write ((PTR) external_reloc_vec, 1, external_reloc_size,
1727 abfd);
1728 free (external_reloc_vec);
1729
1730 /* Fill in section header info. */
1731 segment_info[idx].scnhdr.s_relptr = *file_cursor;
1732 *file_cursor += external_reloc_size;
1733 segment_info[idx].scnhdr.s_nreloc = nrelocs;
1734 }
1735 else
1736 {
1737 /* No relocs */
1738 segment_info[idx].scnhdr.s_relptr = 0;
1739 }
1740 }
1741 }
1742 /* Set relocation_size field in file headers */
1743 H_SET_RELOCATION_SIZE (h, *file_cursor - reloc_start, 0);
1744 }
1745
1746
1747 /* run through a frag chain and write out the data to go with it, fill
1748 in the scnhdrs with the info on the file postions
1749 */
1750 static void
1751 fill_section (abfd, h, file_cursor)
1752 bfd * abfd;
1753 object_headers *h;
1754 unsigned long *file_cursor;
1755 {
1756
1757 unsigned int i;
1758 unsigned int paddr = 0;
1759
1760 for (i = SEG_E0; i < SEG_UNKNOWN; i++)
1761 {
1762 unsigned int offset = 0;
1763 struct internal_scnhdr *s = &(segment_info[i].scnhdr);
1764
1765 PROGRESS (1);
1766
1767 if (s->s_name[0])
1768 {
1769 fragS *frag = segment_info[i].frchainP->frch_root;
1770 char *buffer;
1771
1772 if (s->s_size == 0)
1773 s->s_scnptr = 0;
1774 else
1775 {
1776 buffer = xmalloc (s->s_size);
1777 s->s_scnptr = *file_cursor;
1778 }
1779 know (s->s_paddr == paddr);
1780
1781 if (strcmp (s->s_name, ".text") == 0)
1782 s->s_flags |= STYP_TEXT;
1783 else if (strcmp (s->s_name, ".data") == 0)
1784 s->s_flags |= STYP_DATA;
1785 else if (strcmp (s->s_name, ".bss") == 0)
1786 {
1787 s->s_scnptr = 0;
1788 s->s_flags |= STYP_BSS;
1789
1790 /* @@ Should make the i386 and a29k coff targets define
1791 COFF_NOLOAD_PROBLEM, and have only one test here. */
1792 #ifndef TC_I386
1793 #ifndef TC_A29K
1794 #ifndef COFF_NOLOAD_PROBLEM
1795 /* Apparently the SVR3 linker (and exec syscall) and UDI
1796 mondfe progrem are confused by noload sections. */
1797 s->s_flags |= STYP_NOLOAD;
1798 #endif
1799 #endif
1800 #endif
1801 }
1802 else if (strcmp (s->s_name, ".lit") == 0)
1803 s->s_flags = STYP_LIT | STYP_TEXT;
1804 else if (strcmp (s->s_name, ".init") == 0)
1805 s->s_flags |= STYP_TEXT;
1806 else if (strcmp (s->s_name, ".fini") == 0)
1807 s->s_flags |= STYP_TEXT;
1808 else if (strncmp (s->s_name, ".comment", 8) == 0)
1809 s->s_flags |= STYP_INFO;
1810
1811 while (frag)
1812 {
1813 unsigned int fill_size;
1814 switch (frag->fr_type)
1815 {
1816 case rs_machine_dependent:
1817 if (frag->fr_fix)
1818 {
1819 memcpy (buffer + frag->fr_address,
1820 frag->fr_literal,
1821 (unsigned int) frag->fr_fix);
1822 offset += frag->fr_fix;
1823 }
1824
1825 break;
1826 case rs_space:
1827 assert (frag->fr_symbol == 0);
1828 case rs_fill:
1829 case rs_align:
1830 case rs_align_code:
1831 case rs_org:
1832 if (frag->fr_fix)
1833 {
1834 memcpy (buffer + frag->fr_address,
1835 frag->fr_literal,
1836 (unsigned int) frag->fr_fix);
1837 offset += frag->fr_fix;
1838 }
1839
1840 fill_size = frag->fr_var;
1841 if (fill_size && frag->fr_offset > 0)
1842 {
1843 unsigned int count;
1844 unsigned int off = frag->fr_fix;
1845 for (count = frag->fr_offset; count; count--)
1846 {
1847 if (fill_size + frag->fr_address + off <= s->s_size)
1848 {
1849 memcpy (buffer + frag->fr_address + off,
1850 frag->fr_literal + frag->fr_fix,
1851 fill_size);
1852 off += fill_size;
1853 offset += fill_size;
1854 }
1855 }
1856 }
1857 break;
1858 case rs_broken_word:
1859 break;
1860 default:
1861 abort ();
1862 }
1863 frag = frag->fr_next;
1864 }
1865
1866 if (s->s_size != 0)
1867 {
1868 if (s->s_scnptr != 0)
1869 {
1870 bfd_write (buffer, s->s_size, 1, abfd);
1871 *file_cursor += s->s_size;
1872 }
1873 free (buffer);
1874 }
1875 paddr += s->s_size;
1876 }
1877 }
1878 }
1879
1880 /* Coff file generation & utilities */
1881
1882 static void
1883 coff_header_append (abfd, h)
1884 bfd * abfd;
1885 object_headers * h;
1886 {
1887 unsigned int i;
1888 char buffer[1000];
1889 char buffero[1000];
1890
1891 bfd_seek (abfd, 0, 0);
1892
1893 #ifndef OBJ_COFF_OMIT_OPTIONAL_HEADER
1894 H_SET_MAGIC_NUMBER (h, COFF_MAGIC);
1895 H_SET_VERSION_STAMP (h, 0);
1896 H_SET_ENTRY_POINT (h, 0);
1897 H_SET_TEXT_START (h, segment_info[SEG_E0].frchainP->frch_root->fr_address);
1898 H_SET_DATA_START (h, segment_info[SEG_E1].frchainP->frch_root->fr_address);
1899 H_SET_SIZEOF_OPTIONAL_HEADER (h, bfd_coff_swap_aouthdr_out(abfd, &h->aouthdr,
1900 buffero));
1901 #else /* defined (OBJ_COFF_OMIT_OPTIONAL_HEADER) */
1902 H_SET_SIZEOF_OPTIONAL_HEADER (h, 0);
1903 #endif /* defined (OBJ_COFF_OMIT_OPTIONAL_HEADER) */
1904
1905 i = bfd_coff_swap_filehdr_out (abfd, &h->filehdr, buffer);
1906
1907 bfd_write (buffer, i, 1, abfd);
1908 bfd_write (buffero, H_GET_SIZEOF_OPTIONAL_HEADER (h), 1, abfd);
1909
1910 for (i = SEG_E0; i < SEG_LAST; i++)
1911 {
1912 #ifdef COFF_LONG_SECTION_NAMES
1913 unsigned long string_size = 4;
1914 #endif
1915
1916 if (segment_info[i].scnhdr.s_name[0])
1917 {
1918 unsigned int size;
1919
1920 #ifdef COFF_LONG_SECTION_NAMES
1921 /* Support long section names as found in PE. This code
1922 must coordinate with that in write_object_file and
1923 w_strings. */
1924 if (strlen (segment_info[i].name) > SCNNMLEN)
1925 {
1926 memset (segment_info[i].scnhdr.s_name, 0, SCNNMLEN);
1927 sprintf (segment_info[i].scnhdr.s_name, "/%lu", string_size);
1928 string_size += strlen (segment_info[i].name) + 1;
1929 }
1930 #endif
1931
1932 size = bfd_coff_swap_scnhdr_out (abfd,
1933 &(segment_info[i].scnhdr),
1934 buffer);
1935 if (size == 0)
1936 as_bad ("bfd_coff_swap_scnhdr_out failed");
1937 bfd_write (buffer, size, 1, abfd);
1938 }
1939 }
1940 }
1941
1942
1943 char *
1944 symbol_to_chars (abfd, where, symbolP)
1945 bfd * abfd;
1946 char *where;
1947 symbolS * symbolP;
1948 {
1949 unsigned int numaux = symbolP->sy_symbol.ost_entry.n_numaux;
1950 unsigned int i;
1951 valueT val;
1952
1953 /* Turn any symbols with register attributes into abs symbols */
1954 if (S_GET_SEGMENT (symbolP) == reg_section)
1955 {
1956 S_SET_SEGMENT (symbolP, absolute_section);
1957 }
1958 /* At the same time, relocate all symbols to their output value */
1959
1960 val = (segment_info[S_GET_SEGMENT (symbolP)].scnhdr.s_paddr
1961 + S_GET_VALUE (symbolP));
1962
1963 S_SET_VALUE (symbolP, val);
1964
1965 symbolP->sy_symbol.ost_entry.n_value = val;
1966
1967 where += bfd_coff_swap_sym_out (abfd, &symbolP->sy_symbol.ost_entry,
1968 where);
1969
1970 for (i = 0; i < numaux; i++)
1971 {
1972 where += bfd_coff_swap_aux_out (abfd,
1973 &symbolP->sy_symbol.ost_auxent[i],
1974 S_GET_DATA_TYPE (symbolP),
1975 S_GET_STORAGE_CLASS (symbolP),
1976 i, numaux, where);
1977 }
1978 return where;
1979
1980 }
1981
1982 void
1983 obj_symbol_new_hook (symbolP)
1984 symbolS *symbolP;
1985 {
1986 char underscore = 0; /* Symbol has leading _ */
1987
1988 /* Effective symbol */
1989 /* Store the pointer in the offset. */
1990 S_SET_ZEROES (symbolP, 0L);
1991 S_SET_DATA_TYPE (symbolP, T_NULL);
1992 S_SET_STORAGE_CLASS (symbolP, 0);
1993 S_SET_NUMBER_AUXILIARY (symbolP, 0);
1994 /* Additional information */
1995 symbolP->sy_symbol.ost_flags = 0;
1996 /* Auxiliary entries */
1997 memset ((char *) &symbolP->sy_symbol.ost_auxent[0], 0, AUXESZ);
1998
1999 if (S_IS_STRING (symbolP))
2000 SF_SET_STRING (symbolP);
2001 if (!underscore && S_IS_LOCAL (symbolP))
2002 SF_SET_LOCAL (symbolP);
2003 }
2004
2005 /*
2006 * Handle .ln directives.
2007 */
2008
2009 static void
2010 obj_coff_ln (appline)
2011 int appline;
2012 {
2013 int l;
2014
2015 if (! appline && def_symbol_in_progress != NULL)
2016 {
2017 as_warn (".ln pseudo-op inside .def/.endef: ignored.");
2018 demand_empty_rest_of_line ();
2019 return;
2020 } /* wrong context */
2021
2022 l = get_absolute_expression ();
2023 c_line_new (0, frag_now_fix (), l, frag_now);
2024 #ifndef NO_LISTING
2025 {
2026 extern int listing;
2027
2028 if (listing)
2029 {
2030 if (! appline)
2031 l += line_base - 1;
2032 listing_source_line ((unsigned int) l);
2033 }
2034
2035 }
2036 #endif
2037 demand_empty_rest_of_line ();
2038 }
2039
2040 /*
2041 * def()
2042 *
2043 * Handle .def directives.
2044 *
2045 * One might ask : why can't we symbol_new if the symbol does not
2046 * already exist and fill it with debug information. Because of
2047 * the C_EFCN special symbol. It would clobber the value of the
2048 * function symbol before we have a chance to notice that it is
2049 * a C_EFCN. And a second reason is that the code is more clear this
2050 * way. (at least I think it is :-).
2051 *
2052 */
2053
2054 #define SKIP_SEMI_COLON() while (*input_line_pointer++ != ';')
2055 #define SKIP_WHITESPACES() while (*input_line_pointer == ' ' || \
2056 *input_line_pointer == '\t') \
2057 input_line_pointer++;
2058
2059 static void
2060 obj_coff_def (what)
2061 int what;
2062 {
2063 char name_end; /* Char after the end of name */
2064 char *symbol_name; /* Name of the debug symbol */
2065 char *symbol_name_copy; /* Temporary copy of the name */
2066 unsigned int symbol_name_length;
2067
2068 if (def_symbol_in_progress != NULL)
2069 {
2070 as_warn (".def pseudo-op used inside of .def/.endef: ignored.");
2071 demand_empty_rest_of_line ();
2072 return;
2073 } /* if not inside .def/.endef */
2074
2075 SKIP_WHITESPACES ();
2076
2077 def_symbol_in_progress = (symbolS *) obstack_alloc (&notes, sizeof (*def_symbol_in_progress));
2078 memset (def_symbol_in_progress, 0, sizeof (*def_symbol_in_progress));
2079
2080 symbol_name = input_line_pointer;
2081 name_end = get_symbol_end ();
2082 symbol_name_length = strlen (symbol_name);
2083 symbol_name_copy = xmalloc (symbol_name_length + 1);
2084 strcpy (symbol_name_copy, symbol_name);
2085
2086 /* Initialize the new symbol */
2087 #ifdef STRIP_UNDERSCORE
2088 S_SET_NAME (def_symbol_in_progress, (*symbol_name_copy == '_'
2089 ? symbol_name_copy + 1
2090 : symbol_name_copy));
2091 #else /* STRIP_UNDERSCORE */
2092 S_SET_NAME (def_symbol_in_progress, symbol_name_copy);
2093 #endif /* STRIP_UNDERSCORE */
2094 /* free(symbol_name_copy); */
2095 def_symbol_in_progress->sy_name_offset = (unsigned long) ~0;
2096 def_symbol_in_progress->sy_number = ~0;
2097 def_symbol_in_progress->sy_frag = &zero_address_frag;
2098 S_SET_VALUE (def_symbol_in_progress, 0);
2099
2100 if (S_IS_STRING (def_symbol_in_progress))
2101 SF_SET_STRING (def_symbol_in_progress);
2102
2103 *input_line_pointer = name_end;
2104
2105 demand_empty_rest_of_line ();
2106 }
2107
2108 unsigned int dim_index;
2109
2110
2111 static void
2112 obj_coff_endef (ignore)
2113 int ignore;
2114 {
2115 symbolS *symbolP = 0;
2116 /* DIM BUG FIX sac@cygnus.com */
2117 dim_index = 0;
2118 if (def_symbol_in_progress == NULL)
2119 {
2120 as_warn (".endef pseudo-op used outside of .def/.endef: ignored.");
2121 demand_empty_rest_of_line ();
2122 return;
2123 } /* if not inside .def/.endef */
2124
2125 /* Set the section number according to storage class. */
2126 switch (S_GET_STORAGE_CLASS (def_symbol_in_progress))
2127 {
2128 case C_STRTAG:
2129 case C_ENTAG:
2130 case C_UNTAG:
2131 SF_SET_TAG (def_symbol_in_progress);
2132 /* intentional fallthrough */
2133 case C_FILE:
2134 case C_TPDEF:
2135 SF_SET_DEBUG (def_symbol_in_progress);
2136 S_SET_SEGMENT (def_symbol_in_progress, SEG_DEBUG);
2137 break;
2138
2139 case C_EFCN:
2140 SF_SET_LOCAL (def_symbol_in_progress); /* Do not emit this symbol. */
2141 /* intentional fallthrough */
2142 case C_BLOCK:
2143 SF_SET_PROCESS (def_symbol_in_progress); /* Will need processing before writing */
2144 /* intentional fallthrough */
2145 case C_FCN:
2146 S_SET_SEGMENT (def_symbol_in_progress, SEG_E0);
2147
2148 if (strcmp (S_GET_NAME (def_symbol_in_progress), ".bf") == 0)
2149 { /* .bf */
2150 if (function_lineoff < 0)
2151 {
2152 fprintf (stderr, "`.bf' symbol without preceding function\n");
2153 } /* missing function symbol */
2154 SA_GET_SYM_LNNOPTR (last_line_symbol) = function_lineoff;
2155
2156 SF_SET_PROCESS (last_line_symbol);
2157 SF_SET_ADJ_LNNOPTR (last_line_symbol);
2158 SF_SET_PROCESS (def_symbol_in_progress);
2159 function_lineoff = -1;
2160 }
2161 /* Value is always set to . */
2162 def_symbol_in_progress->sy_frag = frag_now;
2163 S_SET_VALUE (def_symbol_in_progress, (valueT) frag_now_fix ());
2164 break;
2165
2166 #ifdef C_AUTOARG
2167 case C_AUTOARG:
2168 #endif /* C_AUTOARG */
2169 case C_AUTO:
2170 case C_REG:
2171 case C_MOS:
2172 case C_MOE:
2173 case C_MOU:
2174 case C_ARG:
2175 case C_REGPARM:
2176 case C_FIELD:
2177 case C_EOS:
2178 SF_SET_DEBUG (def_symbol_in_progress);
2179 S_SET_SEGMENT (def_symbol_in_progress, absolute_section);
2180 break;
2181
2182 case C_EXT:
2183 case C_STAT:
2184 case C_LABEL:
2185 /* Valid but set somewhere else (s_comm, s_lcomm, colon) */
2186 break;
2187
2188 case C_USTATIC:
2189 case C_EXTDEF:
2190 case C_ULABEL:
2191 as_warn ("unexpected storage class %d", S_GET_STORAGE_CLASS (def_symbol_in_progress));
2192 break;
2193 } /* switch on storage class */
2194
2195 /* Now that we have built a debug symbol, try to find if we should
2196 merge with an existing symbol or not. If a symbol is C_EFCN or
2197 absolute_section or untagged SEG_DEBUG it never merges. We also
2198 don't merge labels, which are in a different namespace, nor
2199 symbols which have not yet been defined since they are typically
2200 unique, nor do we merge tags with non-tags. */
2201
2202 /* Two cases for functions. Either debug followed by definition or
2203 definition followed by debug. For definition first, we will
2204 merge the debug symbol into the definition. For debug first, the
2205 lineno entry MUST point to the definition function or else it
2206 will point off into space when crawl_symbols() merges the debug
2207 symbol into the real symbol. Therefor, let's presume the debug
2208 symbol is a real function reference. */
2209
2210 /* FIXME-SOON If for some reason the definition label/symbol is
2211 never seen, this will probably leave an undefined symbol at link
2212 time. */
2213
2214 if (S_GET_STORAGE_CLASS (def_symbol_in_progress) == C_EFCN
2215 || S_GET_STORAGE_CLASS (def_symbol_in_progress) == C_LABEL
2216 || (S_GET_SEGMENT (def_symbol_in_progress) == SEG_DEBUG
2217 && !SF_GET_TAG (def_symbol_in_progress))
2218 || S_GET_SEGMENT (def_symbol_in_progress) == absolute_section
2219 || def_symbol_in_progress->sy_value.X_op != O_constant
2220 || (symbolP = symbol_find_base (S_GET_NAME (def_symbol_in_progress), DO_NOT_STRIP)) == NULL
2221 || (SF_GET_TAG (def_symbol_in_progress) != SF_GET_TAG (symbolP)))
2222 {
2223 symbol_append (def_symbol_in_progress, symbol_lastP, &symbol_rootP,
2224 &symbol_lastP);
2225 }
2226 else
2227 {
2228 /* This symbol already exists, merge the newly created symbol
2229 into the old one. This is not mandatory. The linker can
2230 handle duplicate symbols correctly. But I guess that it save
2231 a *lot* of space if the assembly file defines a lot of
2232 symbols. [loic] */
2233
2234 /* The debug entry (def_symbol_in_progress) is merged into the
2235 previous definition. */
2236
2237 c_symbol_merge (def_symbol_in_progress, symbolP);
2238 /* FIXME-SOON Should *def_symbol_in_progress be free'd? xoxorich. */
2239 def_symbol_in_progress = symbolP;
2240
2241 if (SF_GET_FUNCTION (def_symbol_in_progress)
2242 || SF_GET_TAG (def_symbol_in_progress))
2243 {
2244 /* For functions, and tags, the symbol *must* be where the
2245 debug symbol appears. Move the existing symbol to the
2246 current place. */
2247 /* If it already is at the end of the symbol list, do nothing */
2248 if (def_symbol_in_progress != symbol_lastP)
2249 {
2250 symbol_remove (def_symbol_in_progress, &symbol_rootP,
2251 &symbol_lastP);
2252 symbol_append (def_symbol_in_progress, symbol_lastP,
2253 &symbol_rootP, &symbol_lastP);
2254 } /* if not already in place */
2255 } /* if function */
2256 } /* normal or mergable */
2257
2258 if (SF_GET_TAG (def_symbol_in_progress))
2259 {
2260 symbolS *oldtag;
2261
2262 oldtag = symbol_find_base (S_GET_NAME (def_symbol_in_progress),
2263 DO_NOT_STRIP);
2264 if (oldtag == NULL || ! SF_GET_TAG (oldtag))
2265 tag_insert (S_GET_NAME (def_symbol_in_progress),
2266 def_symbol_in_progress);
2267 }
2268
2269 if (SF_GET_FUNCTION (def_symbol_in_progress))
2270 {
2271 know (sizeof (def_symbol_in_progress) <= sizeof (long));
2272 function_lineoff
2273 = c_line_new (def_symbol_in_progress, 0, 0, &zero_address_frag);
2274
2275 SF_SET_PROCESS (def_symbol_in_progress);
2276
2277 if (symbolP == NULL)
2278 {
2279 /* That is, if this is the first time we've seen the
2280 function... */
2281 symbol_table_insert (def_symbol_in_progress);
2282 } /* definition follows debug */
2283 } /* Create the line number entry pointing to the function being defined */
2284
2285 def_symbol_in_progress = NULL;
2286 demand_empty_rest_of_line ();
2287 }
2288
2289 static void
2290 obj_coff_dim (ignore)
2291 int ignore;
2292 {
2293 int dim_index;
2294
2295 if (def_symbol_in_progress == NULL)
2296 {
2297 as_warn (".dim pseudo-op used outside of .def/.endef: ignored.");
2298 demand_empty_rest_of_line ();
2299 return;
2300 } /* if not inside .def/.endef */
2301
2302 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
2303
2304 for (dim_index = 0; dim_index < DIMNUM; dim_index++)
2305 {
2306 SKIP_WHITESPACES ();
2307 SA_SET_SYM_DIMEN (def_symbol_in_progress, dim_index,
2308 get_absolute_expression ());
2309
2310 switch (*input_line_pointer)
2311 {
2312 case ',':
2313 input_line_pointer++;
2314 break;
2315
2316 default:
2317 as_warn ("badly formed .dim directive ignored");
2318 /* intentional fallthrough */
2319 case '\n':
2320 case ';':
2321 dim_index = DIMNUM;
2322 break;
2323 }
2324 }
2325
2326 demand_empty_rest_of_line ();
2327 }
2328
2329 static void
2330 obj_coff_line (ignore)
2331 int ignore;
2332 {
2333 int this_base;
2334 const char *name;
2335
2336 if (def_symbol_in_progress == NULL)
2337 {
2338 obj_coff_ln (0);
2339 return;
2340 }
2341
2342 name = S_GET_NAME (def_symbol_in_progress);
2343 this_base = get_absolute_expression ();
2344
2345 /* Only .bf symbols indicate the use of a new base line number; the
2346 line numbers associated with .ef, .bb, .eb are relative to the
2347 start of the containing function. */
2348 if (!strcmp (".bf", name))
2349 {
2350 #if 0 /* XXX Can we ever have line numbers going backwards? */
2351 if (this_base > line_base)
2352 #endif
2353 {
2354 line_base = this_base;
2355 }
2356
2357 #ifndef NO_LISTING
2358 {
2359 extern int listing;
2360 if (listing)
2361 {
2362 listing_source_line ((unsigned int) line_base);
2363 }
2364 }
2365 #endif
2366 }
2367
2368 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
2369 SA_SET_SYM_LNNO (def_symbol_in_progress, this_base);
2370
2371 demand_empty_rest_of_line ();
2372 }
2373
2374 static void
2375 obj_coff_size (ignore)
2376 int ignore;
2377 {
2378 if (def_symbol_in_progress == NULL)
2379 {
2380 as_warn (".size pseudo-op used outside of .def/.endef ignored.");
2381 demand_empty_rest_of_line ();
2382 return;
2383 } /* if not inside .def/.endef */
2384
2385 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
2386 SA_SET_SYM_SIZE (def_symbol_in_progress, get_absolute_expression ());
2387 demand_empty_rest_of_line ();
2388 }
2389
2390 static void
2391 obj_coff_scl (ignore)
2392 int ignore;
2393 {
2394 if (def_symbol_in_progress == NULL)
2395 {
2396 as_warn (".scl pseudo-op used outside of .def/.endef ignored.");
2397 demand_empty_rest_of_line ();
2398 return;
2399 } /* if not inside .def/.endef */
2400
2401 S_SET_STORAGE_CLASS (def_symbol_in_progress, get_absolute_expression ());
2402 demand_empty_rest_of_line ();
2403 }
2404
2405 static void
2406 obj_coff_tag (ignore)
2407 int ignore;
2408 {
2409 char *symbol_name;
2410 char name_end;
2411
2412 if (def_symbol_in_progress == NULL)
2413 {
2414 as_warn (".tag pseudo-op used outside of .def/.endef ignored.");
2415 demand_empty_rest_of_line ();
2416 return;
2417 }
2418
2419 S_SET_NUMBER_AUXILIARY (def_symbol_in_progress, 1);
2420 symbol_name = input_line_pointer;
2421 name_end = get_symbol_end ();
2422
2423 /* Assume that the symbol referred to by .tag is always defined.
2424 This was a bad assumption. I've added find_or_make. xoxorich. */
2425 SA_SET_SYM_TAGNDX (def_symbol_in_progress,
2426 (long) tag_find_or_make (symbol_name));
2427 if (SA_GET_SYM_TAGNDX (def_symbol_in_progress) == 0L)
2428 {
2429 as_warn ("tag not found for .tag %s", symbol_name);
2430 } /* not defined */
2431
2432 SF_SET_TAGGED (def_symbol_in_progress);
2433 *input_line_pointer = name_end;
2434
2435 demand_empty_rest_of_line ();
2436 }
2437
2438 static void
2439 obj_coff_type (ignore)
2440 int ignore;
2441 {
2442 if (def_symbol_in_progress == NULL)
2443 {
2444 as_warn (".type pseudo-op used outside of .def/.endef ignored.");
2445 demand_empty_rest_of_line ();
2446 return;
2447 } /* if not inside .def/.endef */
2448
2449 S_SET_DATA_TYPE (def_symbol_in_progress, get_absolute_expression ());
2450
2451 if (ISFCN (S_GET_DATA_TYPE (def_symbol_in_progress)) &&
2452 S_GET_STORAGE_CLASS (def_symbol_in_progress) != C_TPDEF)
2453 {
2454 SF_SET_FUNCTION (def_symbol_in_progress);
2455 } /* is a function */
2456
2457 demand_empty_rest_of_line ();
2458 }
2459
2460 static void
2461 obj_coff_val (ignore)
2462 int ignore;
2463 {
2464 if (def_symbol_in_progress == NULL)
2465 {
2466 as_warn (".val pseudo-op used outside of .def/.endef ignored.");
2467 demand_empty_rest_of_line ();
2468 return;
2469 } /* if not inside .def/.endef */
2470
2471 if (is_name_beginner (*input_line_pointer))
2472 {
2473 char *symbol_name = input_line_pointer;
2474 char name_end = get_symbol_end ();
2475
2476 if (!strcmp (symbol_name, "."))
2477 {
2478 def_symbol_in_progress->sy_frag = frag_now;
2479 S_SET_VALUE (def_symbol_in_progress, (valueT) frag_now_fix ());
2480 /* If the .val is != from the .def (e.g. statics) */
2481 }
2482 else if (strcmp (S_GET_NAME (def_symbol_in_progress), symbol_name))
2483 {
2484 def_symbol_in_progress->sy_value.X_op = O_symbol;
2485 def_symbol_in_progress->sy_value.X_add_symbol =
2486 symbol_find_or_make (symbol_name);
2487 def_symbol_in_progress->sy_value.X_op_symbol = NULL;
2488 def_symbol_in_progress->sy_value.X_add_number = 0;
2489
2490 /* If the segment is undefined when the forward reference is
2491 resolved, then copy the segment id from the forward
2492 symbol. */
2493 SF_SET_GET_SEGMENT (def_symbol_in_progress);
2494
2495 /* FIXME: gcc can generate address expressions
2496 here in unusual cases (search for "obscure"
2497 in sdbout.c). We just ignore the offset
2498 here, thus generating incorrect debugging
2499 information. We ignore the rest of the
2500 line just below. */
2501 }
2502 /* Otherwise, it is the name of a non debug symbol and
2503 its value will be calculated later. */
2504 *input_line_pointer = name_end;
2505
2506 /* FIXME: this is to avoid an error message in the
2507 FIXME case mentioned just above. */
2508 while (! is_end_of_line[(unsigned char) *input_line_pointer])
2509 ++input_line_pointer;
2510 }
2511 else
2512 {
2513 S_SET_VALUE (def_symbol_in_progress,
2514 (valueT) get_absolute_expression ());
2515 } /* if symbol based */
2516
2517 demand_empty_rest_of_line ();
2518 }
2519
2520 #ifdef TE_PE
2521
2522 /* Handle the .linkonce pseudo-op. This is parsed by s_linkonce in
2523 read.c, which then calls this object file format specific routine. */
2524
2525 void
2526 obj_coff_pe_handle_link_once (type)
2527 enum linkonce_type type;
2528 {
2529 seg_info (now_seg)->scnhdr.s_flags |= IMAGE_SCN_LNK_COMDAT;
2530
2531 /* We store the type in the seg_info structure, and use it to set up
2532 the auxiliary entry for the section symbol in c_section_symbol. */
2533 seg_info (now_seg)->linkonce = type;
2534 }
2535
2536 #endif /* TE_PE */
2537
2538 void
2539 obj_read_begin_hook ()
2540 {
2541 /* These had better be the same. Usually 18 bytes. */
2542 #ifndef BFD_HEADERS
2543 know (sizeof (SYMENT) == sizeof (AUXENT));
2544 know (SYMESZ == AUXESZ);
2545 #endif
2546 tag_init ();
2547 }
2548
2549 /* This function runs through the symbol table and puts all the
2550 externals onto another chain */
2551
2552 /* The chain of globals. */
2553 symbolS *symbol_globalP;
2554 symbolS *symbol_global_lastP;
2555
2556 /* The chain of externals */
2557 symbolS *symbol_externP;
2558 symbolS *symbol_extern_lastP;
2559
2560 stack *block_stack;
2561 symbolS *last_functionP;
2562 static symbolS *last_bfP;
2563 symbolS *last_tagP;
2564
2565 static unsigned int
2566 yank_symbols ()
2567 {
2568 symbolS *symbolP;
2569 unsigned int symbol_number = 0;
2570 unsigned int last_file_symno = 0;
2571
2572 struct filename_list *filename_list_scan = filename_list_head;
2573
2574 for (symbolP = symbol_rootP;
2575 symbolP;
2576 symbolP = symbolP ? symbol_next (symbolP) : symbol_rootP)
2577 {
2578 if (symbolP->sy_mri_common)
2579 {
2580 if (S_GET_STORAGE_CLASS (symbolP) == C_EXT)
2581 as_bad ("%s: global symbols not supported in common sections",
2582 S_GET_NAME (symbolP));
2583 symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
2584 continue;
2585 }
2586
2587 if (!SF_GET_DEBUG (symbolP))
2588 {
2589 /* Debug symbols do not need all this rubbish */
2590 symbolS *real_symbolP;
2591
2592 /* L* and C_EFCN symbols never merge. */
2593 if (!SF_GET_LOCAL (symbolP)
2594 && !SF_GET_STATICS (symbolP)
2595 && S_GET_STORAGE_CLASS (symbolP) != C_LABEL
2596 && symbolP->sy_value.X_op == O_constant
2597 && (real_symbolP = symbol_find_base (S_GET_NAME (symbolP), DO_NOT_STRIP))
2598 && real_symbolP != symbolP)
2599 {
2600 /* FIXME-SOON: where do dups come from?
2601 Maybe tag references before definitions? xoxorich. */
2602 /* Move the debug data from the debug symbol to the
2603 real symbol. Do NOT do the oposite (i.e. move from
2604 real symbol to debug symbol and remove real symbol from the
2605 list.) Because some pointers refer to the real symbol
2606 whereas no pointers refer to the debug symbol. */
2607 c_symbol_merge (symbolP, real_symbolP);
2608 /* Replace the current symbol by the real one */
2609 /* The symbols will never be the last or the first
2610 because : 1st symbol is .file and 3 last symbols are
2611 .text, .data, .bss */
2612 symbol_remove (real_symbolP, &symbol_rootP, &symbol_lastP);
2613 symbol_insert (real_symbolP, symbolP, &symbol_rootP, &symbol_lastP);
2614 symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
2615 symbolP = real_symbolP;
2616 } /* if not local but dup'd */
2617
2618 if (flag_readonly_data_in_text && (S_GET_SEGMENT (symbolP) == SEG_E1))
2619 {
2620 S_SET_SEGMENT (symbolP, SEG_E0);
2621 } /* push data into text */
2622
2623 resolve_symbol_value (symbolP);
2624
2625 if (S_GET_STORAGE_CLASS (symbolP) == C_NULL)
2626 {
2627 if (!S_IS_DEFINED (symbolP) && !SF_GET_LOCAL (symbolP))
2628 {
2629 S_SET_EXTERNAL (symbolP);
2630 }
2631 else if (S_GET_SEGMENT (symbolP) == SEG_E0)
2632 {
2633 S_SET_STORAGE_CLASS (symbolP, C_LABEL);
2634 }
2635 else
2636 {
2637 S_SET_STORAGE_CLASS (symbolP, C_STAT);
2638 }
2639 }
2640
2641 /* Mainly to speed up if not -g */
2642 if (SF_GET_PROCESS (symbolP))
2643 {
2644 /* Handle the nested blocks auxiliary info. */
2645 if (S_GET_STORAGE_CLASS (symbolP) == C_BLOCK)
2646 {
2647 if (!strcmp (S_GET_NAME (symbolP), ".bb"))
2648 stack_push (block_stack, (char *) &symbolP);
2649 else
2650 { /* .eb */
2651 register symbolS *begin_symbolP;
2652 begin_symbolP = *(symbolS **) stack_pop (block_stack);
2653 if (begin_symbolP == (symbolS *) 0)
2654 as_warn ("mismatched .eb");
2655 else
2656 SA_SET_SYM_ENDNDX (begin_symbolP, symbol_number + 2);
2657 }
2658 }
2659 /* If we are able to identify the type of a function, and we
2660 are out of a function (last_functionP == 0) then, the
2661 function symbol will be associated with an auxiliary
2662 entry. */
2663 if (last_functionP == (symbolS *) 0 &&
2664 SF_GET_FUNCTION (symbolP))
2665 {
2666 last_functionP = symbolP;
2667
2668 if (S_GET_NUMBER_AUXILIARY (symbolP) < 1)
2669 {
2670 S_SET_NUMBER_AUXILIARY (symbolP, 1);
2671 } /* make it at least 1 */
2672
2673 /* Clobber possible stale .dim information. */
2674 #if 0
2675 /* Iffed out by steve - this fries the lnnoptr info too */
2676 bzero (symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen,
2677 sizeof (symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen));
2678 #endif
2679 }
2680 if (S_GET_STORAGE_CLASS (symbolP) == C_FCN)
2681 {
2682 if (strcmp (S_GET_NAME (symbolP), ".bf") == 0)
2683 {
2684 if (last_bfP != NULL)
2685 SA_SET_SYM_ENDNDX (last_bfP, symbol_number);
2686 last_bfP = symbolP;
2687 }
2688 }
2689 else if (S_GET_STORAGE_CLASS (symbolP) == C_EFCN)
2690 {
2691 /* I don't even know if this is needed for sdb. But
2692 the standard assembler generates it, so... */
2693 if (last_functionP == (symbolS *) 0)
2694 as_fatal ("C_EFCN symbol out of scope");
2695 SA_SET_SYM_FSIZE (last_functionP,
2696 (long) (S_GET_VALUE (symbolP) -
2697 S_GET_VALUE (last_functionP)));
2698 SA_SET_SYM_ENDNDX (last_functionP, symbol_number);
2699 last_functionP = (symbolS *) 0;
2700 }
2701 }
2702 }
2703 else if (SF_GET_TAG (symbolP))
2704 {
2705 /* First descriptor of a structure must point to
2706 the first slot after the structure description. */
2707 last_tagP = symbolP;
2708
2709 }
2710 else if (S_GET_STORAGE_CLASS (symbolP) == C_EOS)
2711 {
2712 /* +2 take in account the current symbol */
2713 SA_SET_SYM_ENDNDX (last_tagP, symbol_number + 2);
2714 }
2715 else if (S_GET_STORAGE_CLASS (symbolP) == C_FILE)
2716 {
2717 /* If the filename was too long to fit in the
2718 auxent, put it in the string table */
2719 if (SA_GET_FILE_FNAME_ZEROS (symbolP) == 0
2720 && SA_GET_FILE_FNAME_OFFSET (symbolP) != 0)
2721 {
2722 SA_SET_FILE_FNAME_OFFSET (symbolP, string_byte_count);
2723 string_byte_count += strlen (filename_list_scan->filename) + 1;
2724 filename_list_scan = filename_list_scan->next;
2725 }
2726 if (S_GET_VALUE (symbolP))
2727 {
2728 S_SET_VALUE (symbolP, last_file_symno);
2729 last_file_symno = symbol_number;
2730 } /* no one points at the first .file symbol */
2731 } /* if debug or tag or eos or file */
2732
2733 /* We must put the external symbols apart. The loader
2734 does not bomb if we do not. But the references in
2735 the endndx field for a .bb symbol are not corrected
2736 if an external symbol is removed between .bb and .be.
2737 I.e in the following case :
2738 [20] .bb endndx = 22
2739 [21] foo external
2740 [22] .be
2741 ld will move the symbol 21 to the end of the list but
2742 endndx will still be 22 instead of 21. */
2743
2744
2745 if (SF_GET_LOCAL (symbolP))
2746 {
2747 /* remove C_EFCN and LOCAL (L...) symbols */
2748 /* next pointer remains valid */
2749 symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
2750
2751 }
2752 else if (symbolP->sy_value.X_op == O_symbol
2753 && (! S_IS_DEFINED (symbolP) || S_IS_COMMON (symbolP)))
2754 {
2755 /* Skip symbols which were equated to undefined or common
2756 symbols. */
2757 symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
2758 }
2759 else if (!S_IS_DEFINED (symbolP)
2760 && !S_IS_DEBUG (symbolP)
2761 && !SF_GET_STATICS (symbolP) &&
2762 S_GET_STORAGE_CLASS (symbolP) == C_EXT)
2763 { /* C_EXT && !SF_GET_FUNCTION(symbolP)) */
2764 /* if external, Remove from the list */
2765 symbolS *hold = symbol_previous (symbolP);
2766
2767 symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
2768 symbol_clear_list_pointers (symbolP);
2769 symbol_append (symbolP, symbol_extern_lastP, &symbol_externP, &symbol_extern_lastP);
2770 symbolP = hold;
2771 }
2772 else if (! S_IS_DEBUG (symbolP)
2773 && ! SF_GET_STATICS (symbolP)
2774 && ! SF_GET_FUNCTION (symbolP)
2775 && S_GET_STORAGE_CLASS (symbolP) == C_EXT)
2776 {
2777 symbolS *hold = symbol_previous (symbolP);
2778
2779 /* The O'Reilly COFF book says that defined global symbols
2780 come at the end of the symbol table, just before
2781 undefined global symbols. */
2782
2783 symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
2784 symbol_clear_list_pointers (symbolP);
2785 symbol_append (symbolP, symbol_global_lastP, &symbol_globalP,
2786 &symbol_global_lastP);
2787 symbolP = hold;
2788 }
2789 else
2790 {
2791 if (SF_GET_STRING (symbolP))
2792 {
2793 symbolP->sy_name_offset = string_byte_count;
2794 string_byte_count += strlen (S_GET_NAME (symbolP)) + 1;
2795 }
2796 else
2797 {
2798 symbolP->sy_name_offset = 0;
2799 } /* fix "long" names */
2800
2801 symbolP->sy_number = symbol_number;
2802 symbol_number += 1 + S_GET_NUMBER_AUXILIARY (symbolP);
2803 } /* if local symbol */
2804 } /* traverse the symbol list */
2805 return symbol_number;
2806
2807 }
2808
2809
2810 static unsigned int
2811 glue_symbols (head, tail)
2812 symbolS **head;
2813 symbolS **tail;
2814 {
2815 unsigned int symbol_number = 0;
2816 symbolS *symbolP;
2817
2818 for (symbolP = *head; *head != NULL;)
2819 {
2820 symbolS *tmp = *head;
2821
2822 /* append */
2823 symbol_remove (tmp, head, tail);
2824 symbol_append (tmp, symbol_lastP, &symbol_rootP, &symbol_lastP);
2825
2826 /* and process */
2827 if (SF_GET_STRING (tmp))
2828 {
2829 tmp->sy_name_offset = string_byte_count;
2830 string_byte_count += strlen (S_GET_NAME (tmp)) + 1;
2831 }
2832 else
2833 {
2834 tmp->sy_name_offset = 0;
2835 } /* fix "long" names */
2836
2837 tmp->sy_number = symbol_number;
2838 symbol_number += 1 + S_GET_NUMBER_AUXILIARY (tmp);
2839 } /* append the entire extern chain */
2840
2841 return symbol_number;
2842 }
2843
2844 static unsigned int
2845 tie_tags ()
2846 {
2847 unsigned int symbol_number = 0;
2848
2849 symbolS *symbolP;
2850 for (symbolP = symbol_rootP; symbolP; symbolP =
2851 symbol_next (symbolP))
2852 {
2853 symbolP->sy_number = symbol_number;
2854
2855
2856
2857 if (SF_GET_TAGGED (symbolP))
2858 {
2859 SA_SET_SYM_TAGNDX
2860 (symbolP,
2861 ((symbolS *) SA_GET_SYM_TAGNDX (symbolP))->sy_number);
2862 }
2863
2864 symbol_number += 1 + S_GET_NUMBER_AUXILIARY (symbolP);
2865 }
2866 return symbol_number;
2867
2868 }
2869
2870 static void
2871 crawl_symbols (h, abfd)
2872 object_headers *h;
2873 bfd * abfd;
2874 {
2875 unsigned int i;
2876
2877 /* Initialize the stack used to keep track of the matching .bb .be */
2878
2879 block_stack = stack_init (512, sizeof (symbolS *));
2880
2881 /* The symbol list should be ordered according to the following sequence
2882 * order :
2883 * . .file symbol
2884 * . debug entries for functions
2885 * . fake symbols for the sections, including.text .data and .bss
2886 * . defined symbols
2887 * . undefined symbols
2888 * But this is not mandatory. The only important point is to put the
2889 * undefined symbols at the end of the list.
2890 */
2891
2892 if (symbol_rootP == NULL
2893 || S_GET_STORAGE_CLASS (symbol_rootP) != C_FILE)
2894 {
2895 c_dot_file_symbol ("fake");
2896 }
2897 /* Is there a .file symbol ? If not insert one at the beginning. */
2898
2899 /*
2900 * Build up static symbols for the sections, they are filled in later
2901 */
2902
2903
2904 for (i = SEG_E0; i < SEG_LAST; i++)
2905 if (segment_info[i].scnhdr.s_name[0])
2906 segment_info[i].dot = c_section_symbol (segment_info[i].name,
2907 i - SEG_E0 + 1);
2908
2909 /* Take all the externals out and put them into another chain */
2910 H_SET_SYMBOL_TABLE_SIZE (h, yank_symbols ());
2911 /* Take the externals and glue them onto the end.*/
2912 H_SET_SYMBOL_TABLE_SIZE (h,
2913 (H_GET_SYMBOL_COUNT (h)
2914 + glue_symbols (&symbol_globalP,
2915 &symbol_global_lastP)
2916 + glue_symbols (&symbol_externP,
2917 &symbol_extern_lastP)));
2918
2919 H_SET_SYMBOL_TABLE_SIZE (h, tie_tags ());
2920 know (symbol_globalP == NULL);
2921 know (symbol_global_lastP == NULL);
2922 know (symbol_externP == NULL);
2923 know (symbol_extern_lastP == NULL);
2924 }
2925
2926 /*
2927 * Find strings by crawling along symbol table chain.
2928 */
2929
2930 void
2931 w_strings (where)
2932 char *where;
2933 {
2934 symbolS *symbolP;
2935 struct filename_list *filename_list_scan = filename_list_head;
2936
2937 /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */
2938 md_number_to_chars (where, (valueT) string_byte_count, 4);
2939 where += 4;
2940
2941 #ifdef COFF_LONG_SECTION_NAMES
2942 /* Support long section names as found in PE. This code must
2943 coordinate with that in coff_header_append and write_object_file. */
2944 {
2945 unsigned int i;
2946
2947 for (i = SEG_E0; i < SEG_LAST; i++)
2948 {
2949 if (segment_info[i].scnhdr.s_name[0]
2950 && strlen (segment_info[i].name) > SCNNMLEN)
2951 {
2952 unsigned int size;
2953
2954 size = strlen (segment_info[i].name) + 1;
2955 memcpy (where, segment_info[i].name, size);
2956 where += size;
2957 }
2958 }
2959 }
2960 #endif /* COFF_LONG_SECTION_NAMES */
2961
2962 for (symbolP = symbol_rootP;
2963 symbolP;
2964 symbolP = symbol_next (symbolP))
2965 {
2966 unsigned int size;
2967
2968 if (SF_GET_STRING (symbolP))
2969 {
2970 size = strlen (S_GET_NAME (symbolP)) + 1;
2971 memcpy (where, S_GET_NAME (symbolP), size);
2972 where += size;
2973 }
2974 if (S_GET_STORAGE_CLASS (symbolP) == C_FILE
2975 && SA_GET_FILE_FNAME_ZEROS (symbolP) == 0
2976 && SA_GET_FILE_FNAME_OFFSET (symbolP) != 0)
2977 {
2978 size = strlen (filename_list_scan->filename) + 1;
2979 memcpy (where, filename_list_scan->filename, size);
2980 filename_list_scan = filename_list_scan ->next;
2981 where += size;
2982 }
2983 }
2984 }
2985
2986 static void
2987 do_linenos_for (abfd, h, file_cursor)
2988 bfd * abfd;
2989 object_headers * h;
2990 unsigned long *file_cursor;
2991 {
2992 unsigned int idx;
2993 unsigned long start = *file_cursor;
2994
2995 for (idx = SEG_E0; idx < SEG_LAST; idx++)
2996 {
2997 segment_info_type *s = segment_info + idx;
2998
2999
3000 if (s->scnhdr.s_nlnno != 0)
3001 {
3002 struct lineno_list *line_ptr;
3003
3004 struct external_lineno *buffer =
3005 (struct external_lineno *) xmalloc (s->scnhdr.s_nlnno * LINESZ);
3006
3007 struct external_lineno *dst = buffer;
3008
3009 /* Run through the table we've built and turn it into its external
3010 form, take this chance to remove duplicates */
3011
3012 for (line_ptr = s->lineno_list_head;
3013 line_ptr != (struct lineno_list *) NULL;
3014 line_ptr = line_ptr->next)
3015 {
3016
3017 if (line_ptr->line.l_lnno == 0)
3018 {
3019 /* Turn a pointer to a symbol into the symbols' index */
3020 line_ptr->line.l_addr.l_symndx =
3021 ((symbolS *) line_ptr->line.l_addr.l_symndx)->sy_number;
3022 }
3023 else
3024 {
3025 line_ptr->line.l_addr.l_paddr += ((struct frag *) (line_ptr->frag))->fr_address;
3026 }
3027
3028
3029 (void) bfd_coff_swap_lineno_out (abfd, &(line_ptr->line), dst);
3030 dst++;
3031
3032 }
3033
3034 s->scnhdr.s_lnnoptr = *file_cursor;
3035
3036 bfd_write (buffer, 1, s->scnhdr.s_nlnno * LINESZ, abfd);
3037 free (buffer);
3038
3039 *file_cursor += s->scnhdr.s_nlnno * LINESZ;
3040 }
3041 }
3042 H_SET_LINENO_SIZE (h, *file_cursor - start);
3043 }
3044
3045
3046 /* Now we run through the list of frag chains in a segment and
3047 make all the subsegment frags appear at the end of the
3048 list, as if the seg 0 was extra long */
3049
3050 static void
3051 remove_subsegs ()
3052 {
3053 unsigned int i;
3054
3055 for (i = SEG_E0; i < SEG_UNKNOWN; i++)
3056 {
3057 frchainS *head = segment_info[i].frchainP;
3058 fragS dummy;
3059 fragS *prev_frag = &dummy;
3060
3061 while (head && head->frch_seg == i)
3062 {
3063 prev_frag->fr_next = head->frch_root;
3064 prev_frag = head->frch_last;
3065 head = head->frch_next;
3066 }
3067 prev_frag->fr_next = 0;
3068 }
3069 }
3070
3071 unsigned long machine;
3072 int coff_flags;
3073 extern void
3074 write_object_file ()
3075 {
3076 int i;
3077 const char *name;
3078 struct frchain *frchain_ptr;
3079
3080 object_headers headers;
3081 unsigned long file_cursor;
3082 bfd *abfd;
3083 unsigned int addr;
3084 abfd = bfd_openw (out_file_name, TARGET_FORMAT);
3085
3086
3087 if (abfd == 0)
3088 {
3089 as_perror ("FATAL: Can't create %s", out_file_name);
3090 exit (EXIT_FAILURE);
3091 }
3092 bfd_set_format (abfd, bfd_object);
3093 bfd_set_arch_mach (abfd, BFD_ARCH, machine);
3094
3095 string_byte_count = 4;
3096
3097 for (frchain_ptr = frchain_root;
3098 frchain_ptr != (struct frchain *) NULL;
3099 frchain_ptr = frchain_ptr->frch_next)
3100 {
3101 /* Run through all the sub-segments and align them up. Also
3102 close any open frags. We tack a .fill onto the end of the
3103 frag chain so that any .align's size can be worked by looking
3104 at the next frag. */
3105
3106 subseg_set (frchain_ptr->frch_seg, frchain_ptr->frch_subseg);
3107 #ifndef SUB_SEGMENT_ALIGN
3108 #define SUB_SEGMENT_ALIGN(SEG) 1
3109 #endif
3110 #ifdef md_do_align
3111 {
3112 static char nop = NOP_OPCODE;
3113 md_do_align (SUB_SEGMENT_ALIGN (now_seg), &nop, 1, alignment_done);
3114 }
3115 #endif
3116 frag_align (SUB_SEGMENT_ALIGN (now_seg), NOP_OPCODE);
3117 #ifdef md_do_align
3118 alignment_done:
3119 #endif
3120 frag_wane (frag_now);
3121 frag_now->fr_fix = 0;
3122 know (frag_now->fr_next == NULL);
3123 }
3124
3125
3126 remove_subsegs ();
3127
3128
3129 for (i = SEG_E0; i < SEG_UNKNOWN; i++)
3130 {
3131 relax_segment (segment_info[i].frchainP->frch_root, i);
3132 }
3133
3134 H_SET_NUMBER_OF_SECTIONS (&headers, 0);
3135
3136 /* Find out how big the sections are, and set the addresses. */
3137 addr = 0;
3138 for (i = SEG_E0; i < SEG_UNKNOWN; i++)
3139 {
3140 long size;
3141
3142 segment_info[i].scnhdr.s_paddr = addr;
3143 segment_info[i].scnhdr.s_vaddr = addr;
3144
3145 if (segment_info[i].scnhdr.s_name[0])
3146 {
3147 H_SET_NUMBER_OF_SECTIONS (&headers,
3148 H_GET_NUMBER_OF_SECTIONS (&headers) + 1);
3149
3150 #ifdef COFF_LONG_SECTION_NAMES
3151 /* Support long section names as found in PE. This code
3152 must coordinate with that in coff_header_append and
3153 w_strings. */
3154 {
3155 unsigned int len;
3156
3157 len = strlen (segment_info[i].name);
3158 if (len > SCNNMLEN)
3159 string_byte_count += len + 1;
3160 }
3161 #endif /* COFF_LONG_SECTION_NAMES */
3162 }
3163
3164 size = size_section (abfd, (unsigned int) i);
3165 addr += size;
3166
3167 /* I think the section alignment is only used on the i960; the
3168 i960 needs it, and it should do no harm on other targets. */
3169 segment_info[i].scnhdr.s_align = 1 << section_alignment[i];
3170
3171 if (i == SEG_E0)
3172 H_SET_TEXT_SIZE (&headers, size);
3173 else if (i == SEG_E1)
3174 H_SET_DATA_SIZE (&headers, size);
3175 else if (i == SEG_E2)
3176 H_SET_BSS_SIZE (&headers, size);
3177 }
3178
3179 /* Turn the gas native symbol table shape into a coff symbol table */
3180 crawl_symbols (&headers, abfd);
3181
3182 if (string_byte_count == 4)
3183 string_byte_count = 0;
3184
3185 H_SET_STRING_SIZE (&headers, string_byte_count);
3186
3187 #ifdef tc_frob_file
3188 tc_frob_file ();
3189 #endif
3190
3191 for (i = SEG_E0; i < SEG_UNKNOWN; i++)
3192 {
3193 fixup_mdeps (segment_info[i].frchainP->frch_root, &headers, i);
3194 fixup_segment (&segment_info[i], i);
3195 }
3196
3197 /* Look for ".stab" segments and fill in their initial symbols
3198 correctly. */
3199 for (i = SEG_E0; i < SEG_UNKNOWN; i++)
3200 {
3201 name = segment_info[i].name;
3202
3203 if (name != NULL
3204 && strncmp (".stab", name, 5) == 0
3205 && strncmp (".stabstr", name, 8) != 0)
3206 adjust_stab_section (abfd, i);
3207 }
3208
3209 file_cursor = H_GET_TEXT_FILE_OFFSET (&headers);
3210
3211 bfd_seek (abfd, (file_ptr) file_cursor, 0);
3212
3213 /* Plant the data */
3214
3215 fill_section (abfd, &headers, &file_cursor);
3216
3217 do_relocs_for (abfd, &headers, &file_cursor);
3218
3219 do_linenos_for (abfd, &headers, &file_cursor);
3220
3221 H_SET_FILE_MAGIC_NUMBER (&headers, COFF_MAGIC);
3222 #ifndef OBJ_COFF_OMIT_TIMESTAMP
3223 H_SET_TIME_STAMP (&headers, (long)time((time_t *)0));
3224 #else
3225 H_SET_TIME_STAMP (&headers, 0);
3226 #endif
3227 #ifdef TC_COFF_SET_MACHINE
3228 TC_COFF_SET_MACHINE (&headers);
3229 #endif
3230
3231 #ifndef COFF_FLAGS
3232 #define COFF_FLAGS 0
3233 #endif
3234
3235 #ifdef KEEP_RELOC_INFO
3236 H_SET_FLAGS (&headers, ((H_GET_LINENO_SIZE(&headers) ? 0 : F_LNNO) |
3237 COFF_FLAGS | coff_flags));
3238 #else
3239 H_SET_FLAGS (&headers, ((H_GET_LINENO_SIZE(&headers) ? 0 : F_LNNO) |
3240 (H_GET_RELOCATION_SIZE(&headers) ? 0 : F_RELFLG) |
3241 COFF_FLAGS | coff_flags));
3242 #endif
3243
3244 {
3245 unsigned int symtable_size = H_GET_SYMBOL_TABLE_SIZE (&headers);
3246 char *buffer1 = xmalloc (symtable_size + string_byte_count + 1);
3247
3248 H_SET_SYMBOL_TABLE_POINTER (&headers, bfd_tell (abfd));
3249 w_symbols (abfd, buffer1, symbol_rootP);
3250 if (string_byte_count > 0)
3251 w_strings (buffer1 + symtable_size);
3252 bfd_write (buffer1, 1, symtable_size + string_byte_count, abfd);
3253 free (buffer1);
3254 }
3255
3256 coff_header_append (abfd, &headers);
3257 #if 0
3258 /* Recent changes to write need this, but where it should
3259 go is up to Ken.. */
3260 if (bfd_close_all_done (abfd) == false)
3261 as_fatal ("Can't close %s: %s", out_file_name,
3262 bfd_errmsg (bfd_get_error ()));
3263 #else
3264 {
3265 extern bfd *stdoutput;
3266 stdoutput = abfd;
3267 }
3268 #endif
3269
3270 }
3271
3272 /* Add a new segment. This is called from subseg_new via the
3273 obj_new_segment macro. */
3274
3275 segT
3276 obj_coff_add_segment (name)
3277 const char *name;
3278 {
3279 unsigned int i;
3280
3281 #ifndef COFF_LONG_SECTION_NAMES
3282 char buf[SCNNMLEN + 1];
3283
3284 strncpy (buf, name, SCNNMLEN);
3285 buf[SCNNMLEN] = '\0';
3286 name = buf;
3287 #endif
3288
3289 for (i = SEG_E0; i < SEG_LAST && segment_info[i].scnhdr.s_name[0]; i++)
3290 if (strcmp (name, segment_info[i].name) == 0)
3291 return (segT) i;
3292
3293 if (i == SEG_LAST)
3294 {
3295 as_bad ("Too many new sections; can't add \"%s\"", name);
3296 return now_seg;
3297 }
3298
3299 /* Add a new section. */
3300 strncpy (segment_info[i].scnhdr.s_name, name,
3301 sizeof (segment_info[i].scnhdr.s_name));
3302 segment_info[i].scnhdr.s_flags = STYP_REG;
3303 segment_info[i].name = xstrdup (name);
3304
3305 return (segT) i;
3306 }
3307
3308 /*
3309 * implement the .section pseudo op:
3310 * .section name {, "flags"}
3311 * ^ ^
3312 * | +--- optional flags: 'b' for bss
3313 * | 'i' for info
3314 * +-- section name 'l' for lib
3315 * 'n' for noload
3316 * 'o' for over
3317 * 'w' for data
3318 * 'd' (apparently m88k for data)
3319 * 'x' for text
3320 * But if the argument is not a quoted string, treat it as a
3321 * subsegment number.
3322 */
3323
3324 void
3325 obj_coff_section (ignore)
3326 int ignore;
3327 {
3328 /* Strip out the section name */
3329 char *section_name, *name;
3330 char c;
3331 unsigned int exp;
3332 long flags;
3333
3334 if (flag_mri)
3335 {
3336 char type;
3337
3338 s_mri_sect (&type);
3339 flags = 0;
3340 if (type == 'C')
3341 flags = STYP_TEXT;
3342 else if (type == 'D')
3343 flags = STYP_DATA;
3344 segment_info[now_seg].scnhdr.s_flags |= flags;
3345
3346 return;
3347 }
3348
3349 section_name = input_line_pointer;
3350 c = get_symbol_end ();
3351
3352 name = xmalloc (input_line_pointer - section_name + 1);
3353 strcpy (name, section_name);
3354
3355 *input_line_pointer = c;
3356
3357 exp = 0;
3358 flags = 0;
3359
3360 SKIP_WHITESPACE ();
3361 if (*input_line_pointer == ',')
3362 {
3363 ++input_line_pointer;
3364 SKIP_WHITESPACE ();
3365
3366 if (*input_line_pointer != '"')
3367 exp = get_absolute_expression ();
3368 else
3369 {
3370 ++input_line_pointer;
3371 while (*input_line_pointer != '"'
3372 && ! is_end_of_line[(unsigned char) *input_line_pointer])
3373 {
3374 switch (*input_line_pointer)
3375 {
3376 case 'b': flags |= STYP_BSS; break;
3377 case 'i': flags |= STYP_INFO; break;
3378 case 'l': flags |= STYP_LIB; break;
3379 case 'n': flags |= STYP_NOLOAD; break;
3380 case 'o': flags |= STYP_OVER; break;
3381 case 'd':
3382 case 'w': flags |= STYP_DATA; break;
3383 case 'x': flags |= STYP_TEXT; break;
3384 default:
3385 as_warn("unknown section attribute '%c'",
3386 *input_line_pointer);
3387 break;
3388 }
3389 ++input_line_pointer;
3390 }
3391 if (*input_line_pointer == '"')
3392 ++input_line_pointer;
3393 }
3394 }
3395
3396 subseg_new (name, (subsegT) exp);
3397
3398 segment_info[now_seg].scnhdr.s_flags |= flags;
3399
3400 demand_empty_rest_of_line ();
3401 }
3402
3403
3404 static void
3405 obj_coff_text (ignore)
3406 int ignore;
3407 {
3408 subseg_new (".text", get_absolute_expression ());
3409 }
3410
3411
3412 static void
3413 obj_coff_data (ignore)
3414 int ignore;
3415 {
3416 if (flag_readonly_data_in_text)
3417 subseg_new (".text", get_absolute_expression () + 1000);
3418 else
3419 subseg_new (".data", get_absolute_expression ());
3420 }
3421
3422 static void
3423 obj_coff_bss (ignore)
3424 int ignore;
3425 {
3426 if (*input_line_pointer == '\n') /* .bss */
3427 subseg_new(".bss", get_absolute_expression());
3428 else /* .bss id,expr */
3429 obj_coff_lcomm(0);
3430 }
3431
3432 static void
3433 obj_coff_ident (ignore)
3434 int ignore;
3435 {
3436 segT current_seg = now_seg; /* save current seg */
3437 subsegT current_subseg = now_subseg;
3438 subseg_new (".comment", 0); /* .comment seg */
3439 stringer (1); /* read string */
3440 subseg_set (current_seg, current_subseg); /* restore current seg */
3441 }
3442
3443 void
3444 c_symbol_merge (debug, normal)
3445 symbolS *debug;
3446 symbolS *normal;
3447 {
3448 S_SET_DATA_TYPE (normal, S_GET_DATA_TYPE (debug));
3449 S_SET_STORAGE_CLASS (normal, S_GET_STORAGE_CLASS (debug));
3450
3451 if (S_GET_NUMBER_AUXILIARY (debug) > S_GET_NUMBER_AUXILIARY (normal))
3452 {
3453 S_SET_NUMBER_AUXILIARY (normal, S_GET_NUMBER_AUXILIARY (debug));
3454 } /* take the most we have */
3455
3456 if (S_GET_NUMBER_AUXILIARY (debug) > 0)
3457 {
3458 memcpy ((char *) &normal->sy_symbol.ost_auxent[0],
3459 (char *) &debug->sy_symbol.ost_auxent[0],
3460 (unsigned int) (S_GET_NUMBER_AUXILIARY (debug) * AUXESZ));
3461 } /* Move all the auxiliary information */
3462
3463 /* Move the debug flags. */
3464 SF_SET_DEBUG_FIELD (normal, SF_GET_DEBUG_FIELD (debug));
3465 } /* c_symbol_merge() */
3466
3467 static int
3468 c_line_new (symbol, paddr, line_number, frag)
3469 symbolS * symbol;
3470 long paddr;
3471 int line_number;
3472 fragS * frag;
3473 {
3474 struct lineno_list *new_line =
3475 (struct lineno_list *) xmalloc (sizeof (struct lineno_list));
3476
3477 segment_info_type *s = segment_info + now_seg;
3478 new_line->line.l_lnno = line_number;
3479
3480 if (line_number == 0)
3481 {
3482 last_line_symbol = symbol;
3483 new_line->line.l_addr.l_symndx = (long) symbol;
3484 }
3485 else
3486 {
3487 new_line->line.l_addr.l_paddr = paddr;
3488 }
3489
3490 new_line->frag = (char *) frag;
3491 new_line->next = (struct lineno_list *) NULL;
3492
3493
3494 if (s->lineno_list_head == (struct lineno_list *) NULL)
3495 {
3496 s->lineno_list_head = new_line;
3497 }
3498 else
3499 {
3500 s->lineno_list_tail->next = new_line;
3501 }
3502 s->lineno_list_tail = new_line;
3503 return LINESZ * s->scnhdr.s_nlnno++;
3504 }
3505
3506 void
3507 c_dot_file_symbol (filename)
3508 char *filename;
3509 {
3510 symbolS *symbolP;
3511
3512 symbolP = symbol_new (".file",
3513 SEG_DEBUG,
3514 0,
3515 &zero_address_frag);
3516
3517 S_SET_STORAGE_CLASS (symbolP, C_FILE);
3518 S_SET_NUMBER_AUXILIARY (symbolP, 1);
3519
3520 if (strlen (filename) > FILNMLEN)
3521 {
3522 /* Filename is too long to fit into an auxent,
3523 we stick it into the string table instead. We keep
3524 a linked list of the filenames we find so we can emit
3525 them later.*/
3526 struct filename_list *f = ((struct filename_list *)
3527 xmalloc (sizeof (struct filename_list)));
3528
3529 f->filename = filename;
3530 f->next = 0;
3531
3532 SA_SET_FILE_FNAME_ZEROS (symbolP, 0);
3533 SA_SET_FILE_FNAME_OFFSET (symbolP, 1);
3534
3535 if (filename_list_tail)
3536 filename_list_tail->next = f;
3537 else
3538 filename_list_head = f;
3539 filename_list_tail = f;
3540 }
3541 else
3542 {
3543 SA_SET_FILE_FNAME (symbolP, filename);
3544 }
3545 #ifndef NO_LISTING
3546 {
3547 extern int listing;
3548 if (listing)
3549 {
3550 listing_source_file (filename);
3551 }
3552
3553 }
3554
3555 #endif
3556 SF_SET_DEBUG (symbolP);
3557 S_SET_VALUE (symbolP, (valueT) previous_file_symbol);
3558
3559 previous_file_symbol = symbolP;
3560
3561 /* Make sure that the symbol is first on the symbol chain */
3562 if (symbol_rootP != symbolP)
3563 {
3564 if (symbolP == symbol_lastP)
3565 {
3566 symbol_lastP = symbol_lastP->sy_previous;
3567 } /* if it was the last thing on the list */
3568
3569 symbol_remove (symbolP, &symbol_rootP, &symbol_lastP);
3570 symbol_insert (symbolP, symbol_rootP, &symbol_rootP, &symbol_lastP);
3571 symbol_rootP = symbolP;
3572 } /* if not first on the list */
3573
3574 } /* c_dot_file_symbol() */
3575
3576 /*
3577 * Build a 'section static' symbol.
3578 */
3579
3580 symbolS *
3581 c_section_symbol (name, idx)
3582 char *name;
3583 int idx;
3584 {
3585 symbolS *symbolP;
3586
3587 symbolP = symbol_new (name, idx,
3588 0,
3589 &zero_address_frag);
3590
3591 S_SET_STORAGE_CLASS (symbolP, C_STAT);
3592 S_SET_NUMBER_AUXILIARY (symbolP, 1);
3593
3594 SF_SET_STATICS (symbolP);
3595
3596 #ifdef TE_PE
3597 /* If the .linkonce pseudo-op was used for this section, we must
3598 store the information in the auxiliary entry for the section
3599 symbol. */
3600 if (segment_info[idx].linkonce != LINKONCE_UNSET)
3601 {
3602 int type;
3603
3604 switch (segment_info[idx].linkonce)
3605 {
3606 default:
3607 abort ();
3608 case LINKONCE_DISCARD:
3609 type = IMAGE_COMDAT_SELECT_ANY;
3610 break;
3611 case LINKONCE_ONE_ONLY:
3612 type = IMAGE_COMDAT_SELECT_NODUPLICATES;
3613 break;
3614 case LINKONCE_SAME_SIZE:
3615 type = IMAGE_COMDAT_SELECT_SAME_SIZE;
3616 break;
3617 case LINKONCE_SAME_CONTENTS:
3618 type = IMAGE_COMDAT_SELECT_EXACT_MATCH;
3619 break;
3620 }
3621
3622 SYM_AUXENT (symbolP)->x_scn.x_comdat = type;
3623 }
3624 #endif /* TE_PE */
3625
3626 return symbolP;
3627 } /* c_section_symbol() */
3628
3629 static void
3630 w_symbols (abfd, where, symbol_rootP)
3631 bfd * abfd;
3632 char *where;
3633 symbolS * symbol_rootP;
3634 {
3635 symbolS *symbolP;
3636 unsigned int i;
3637
3638 /* First fill in those values we have only just worked out */
3639 for (i = SEG_E0; i < SEG_LAST; i++)
3640 {
3641 symbolP = segment_info[i].dot;
3642 if (symbolP)
3643 {
3644 SA_SET_SCN_SCNLEN (symbolP, segment_info[i].scnhdr.s_size);
3645 SA_SET_SCN_NRELOC (symbolP, segment_info[i].scnhdr.s_nreloc);
3646 SA_SET_SCN_NLINNO (symbolP, segment_info[i].scnhdr.s_nlnno);
3647 }
3648 }
3649
3650 /*
3651 * Emit all symbols left in the symbol chain.
3652 */
3653 for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next (symbolP))
3654 {
3655 /* Used to save the offset of the name. It is used to point
3656 to the string in memory but must be a file offset. */
3657 register char *temp;
3658
3659 /* We can't fix the lnnoptr field in yank_symbols with the other
3660 adjustments, because we have to wait until we know where they
3661 go in the file. */
3662 if (SF_GET_ADJ_LNNOPTR (symbolP))
3663 {
3664 SA_GET_SYM_LNNOPTR (symbolP) +=
3665 segment_info[S_GET_SEGMENT (symbolP)].scnhdr.s_lnnoptr;
3666 }
3667
3668 tc_coff_symbol_emit_hook (symbolP);
3669
3670 temp = S_GET_NAME (symbolP);
3671 if (SF_GET_STRING (symbolP))
3672 {
3673 S_SET_OFFSET (symbolP, symbolP->sy_name_offset);
3674 S_SET_ZEROES (symbolP, 0);
3675 }
3676 else
3677 {
3678 memset (symbolP->sy_symbol.ost_entry.n_name, 0, SYMNMLEN);
3679 strncpy (symbolP->sy_symbol.ost_entry.n_name, temp, SYMNMLEN);
3680 }
3681 where = symbol_to_chars (abfd, where, symbolP);
3682 S_SET_NAME (symbolP, temp);
3683 }
3684
3685 } /* w_symbols() */
3686
3687 static void
3688 obj_coff_lcomm (ignore)
3689 int ignore;
3690 {
3691 s_lcomm(0);
3692 return;
3693 #if 0
3694 char *name;
3695 char c;
3696 int temp;
3697 char *p;
3698
3699 symbolS *symbolP;
3700
3701 name = input_line_pointer;
3702
3703 c = get_symbol_end ();
3704 p = input_line_pointer;
3705 *p = c;
3706 SKIP_WHITESPACE ();
3707 if (*input_line_pointer != ',')
3708 {
3709 as_bad ("Expected comma after name");
3710 ignore_rest_of_line ();
3711 return;
3712 }
3713 if (*input_line_pointer == '\n')
3714 {
3715 as_bad ("Missing size expression");
3716 return;
3717 }
3718 input_line_pointer++;
3719 if ((temp = get_absolute_expression ()) < 0)
3720 {
3721 as_warn ("lcomm length (%d.) <0! Ignored.", temp);
3722 ignore_rest_of_line ();
3723 return;
3724 }
3725 *p = 0;
3726
3727 symbolP = symbol_find_or_make(name);
3728
3729 if (S_GET_SEGMENT(symbolP) == SEG_UNKNOWN &&
3730 S_GET_VALUE(symbolP) == 0)
3731 {
3732 if (! need_pass_2)
3733 {
3734 char *p;
3735 segT current_seg = now_seg; /* save current seg */
3736 subsegT current_subseg = now_subseg;
3737
3738 subseg_set (SEG_E2, 1);
3739 symbolP->sy_frag = frag_now;
3740 p = frag_var(rs_org, 1, 1, (relax_substateT)0, symbolP,
3741 temp, (char *)0);
3742 *p = 0;
3743 subseg_set (current_seg, current_subseg); /* restore current seg */
3744 S_SET_SEGMENT(symbolP, SEG_E2);
3745 S_SET_STORAGE_CLASS(symbolP, C_STAT);
3746 }
3747 }
3748 else
3749 as_bad("Symbol %s already defined", name);
3750
3751 demand_empty_rest_of_line();
3752 #endif
3753 }
3754
3755 static void
3756 fixup_mdeps (frags, h, this_segment)
3757 fragS * frags;
3758 object_headers * h;
3759 segT this_segment;
3760 {
3761 subseg_change (this_segment, 0);
3762 while (frags)
3763 {
3764 switch (frags->fr_type)
3765 {
3766 case rs_align:
3767 case rs_align_code:
3768 case rs_org:
3769 #ifdef HANDLE_ALIGN
3770 HANDLE_ALIGN (frags);
3771 #endif
3772 frags->fr_type = rs_fill;
3773 frags->fr_offset =
3774 ((frags->fr_next->fr_address - frags->fr_address - frags->fr_fix)
3775 / frags->fr_var);
3776 break;
3777 case rs_machine_dependent:
3778 md_convert_frag (h, this_segment, frags);
3779 frag_wane (frags);
3780 break;
3781 default:
3782 ;
3783 }
3784 frags = frags->fr_next;
3785 }
3786 }
3787
3788 #if 1
3789
3790 #ifndef TC_FORCE_RELOCATION
3791 #define TC_FORCE_RELOCATION(fix) 0
3792 #endif
3793
3794 static void
3795 fixup_segment (segP, this_segment_type)
3796 segment_info_type * segP;
3797 segT this_segment_type;
3798 {
3799 register fixS * fixP;
3800 register symbolS *add_symbolP;
3801 register symbolS *sub_symbolP;
3802 long add_number;
3803 register int size;
3804 register char *place;
3805 register long where;
3806 register char pcrel;
3807 register fragS *fragP;
3808 register segT add_symbol_segment = absolute_section;
3809
3810 for (fixP = segP->fix_root; fixP; fixP = fixP->fx_next)
3811 {
3812 fragP = fixP->fx_frag;
3813 know (fragP);
3814 where = fixP->fx_where;
3815 place = fragP->fr_literal + where;
3816 size = fixP->fx_size;
3817 add_symbolP = fixP->fx_addsy;
3818 sub_symbolP = fixP->fx_subsy;
3819 add_number = fixP->fx_offset;
3820 pcrel = fixP->fx_pcrel;
3821
3822 /* We want function-relative stabs to work on systems which
3823 may use a relaxing linker; thus we must handle the sym1-sym2
3824 fixups function-relative stabs generates.
3825
3826 Of course, if you actually enable relaxing in the linker, the
3827 line and block scoping information is going to be incorrect
3828 in some cases. The only way to really fix this is to support
3829 a reloc involving the difference of two symbols. */
3830 if (linkrelax
3831 && (!sub_symbolP || pcrel))
3832 continue;
3833
3834 #ifdef TC_I960
3835 if (fixP->fx_tcbit && SF_GET_CALLNAME (add_symbolP))
3836 {
3837 /* Relocation should be done via the associated 'bal' entry
3838 point symbol. */
3839
3840 if (!SF_GET_BALNAME (tc_get_bal_of_call (add_symbolP)))
3841 {
3842 as_bad_where (fixP->fx_file, fixP->fx_line,
3843 "No 'bal' entry point for leafproc %s",
3844 S_GET_NAME (add_symbolP));
3845 continue;
3846 }
3847 fixP->fx_addsy = add_symbolP = tc_get_bal_of_call (add_symbolP);
3848 }
3849 #endif
3850
3851 if (add_symbolP != NULL
3852 && add_symbolP->sy_mri_common)
3853 {
3854 know (add_symbolP->sy_value.X_op == O_symbol);
3855 add_number += S_GET_VALUE (add_symbolP);
3856 fixP->fx_offset = add_number;
3857 add_symbolP = fixP->fx_addsy = add_symbolP->sy_value.X_add_symbol;
3858 }
3859
3860 if (add_symbolP)
3861 {
3862 add_symbol_segment = S_GET_SEGMENT (add_symbolP);
3863 } /* if there is an addend */
3864
3865 if (sub_symbolP)
3866 {
3867 if (add_symbolP == NULL || add_symbol_segment == absolute_section)
3868 {
3869 if (add_symbolP != NULL)
3870 {
3871 add_number += S_GET_VALUE (add_symbolP);
3872 add_symbolP = NULL;
3873 fixP->fx_addsy = NULL;
3874 }
3875
3876 /* It's just -sym. */
3877 if (S_GET_SEGMENT (sub_symbolP) == absolute_section)
3878 {
3879 add_number -= S_GET_VALUE (sub_symbolP);
3880 fixP->fx_subsy = 0;
3881 fixP->fx_done = 1;
3882 }
3883 else
3884 {
3885 #ifndef TC_M68K
3886 as_bad_where (fixP->fx_file, fixP->fx_line,
3887 "Negative of non-absolute symbol %s",
3888 S_GET_NAME (sub_symbolP));
3889 #endif
3890 add_number -= S_GET_VALUE (sub_symbolP);
3891 } /* not absolute */
3892
3893 /* if sub_symbol is in the same segment that add_symbol
3894 and add_symbol is either in DATA, TEXT, BSS or ABSOLUTE */
3895 }
3896 else if (S_GET_SEGMENT (sub_symbolP) == add_symbol_segment
3897 && SEG_NORMAL (add_symbol_segment))
3898 {
3899 /* Difference of 2 symbols from same segment. Can't
3900 make difference of 2 undefineds: 'value' means
3901 something different for N_UNDF. */
3902 #ifdef TC_I960
3903 /* Makes no sense to use the difference of 2 arbitrary symbols
3904 as the target of a call instruction. */
3905 if (fixP->fx_tcbit)
3906 {
3907 as_bad_where (fixP->fx_file, fixP->fx_line,
3908 "callj to difference of 2 symbols");
3909 }
3910 #endif /* TC_I960 */
3911 add_number += S_GET_VALUE (add_symbolP) -
3912 S_GET_VALUE (sub_symbolP);
3913 add_symbolP = NULL;
3914
3915 if (!TC_FORCE_RELOCATION (fixP))
3916 {
3917 fixP->fx_addsy = NULL;
3918 fixP->fx_subsy = NULL;
3919 fixP->fx_done = 1;
3920 #ifdef TC_M68K /* is this right? */
3921 pcrel = 0;
3922 fixP->fx_pcrel = 0;
3923 #endif
3924 }
3925 }
3926 else
3927 {
3928 /* Different segments in subtraction. */
3929 know (!(S_IS_EXTERNAL (sub_symbolP) && (S_GET_SEGMENT (sub_symbolP) == absolute_section)));
3930
3931 if ((S_GET_SEGMENT (sub_symbolP) == absolute_section))
3932 {
3933 add_number -= S_GET_VALUE (sub_symbolP);
3934 }
3935 #ifdef DIFF_EXPR_OK
3936 else if (S_GET_SEGMENT (sub_symbolP) == this_segment_type
3937 #if 0 /* Okay for 68k, at least... */
3938 && !pcrel
3939 #endif
3940 )
3941 {
3942 /* Make it pc-relative. */
3943 add_number += (md_pcrel_from (fixP)
3944 - S_GET_VALUE (sub_symbolP));
3945 pcrel = 1;
3946 fixP->fx_pcrel = 1;
3947 sub_symbolP = 0;
3948 fixP->fx_subsy = 0;
3949 }
3950 #endif
3951 else
3952 {
3953 as_bad_where (fixP->fx_file, fixP->fx_line,
3954 "Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %ld.",
3955 segment_name (S_GET_SEGMENT (sub_symbolP)),
3956 S_GET_NAME (sub_symbolP),
3957 (long) (fragP->fr_address + where));
3958 } /* if absolute */
3959 }
3960 } /* if sub_symbolP */
3961
3962 if (add_symbolP)
3963 {
3964 if (add_symbol_segment == this_segment_type && pcrel)
3965 {
3966 /*
3967 * This fixup was made when the symbol's segment was
3968 * SEG_UNKNOWN, but it is now in the local segment.
3969 * So we know how to do the address without relocation.
3970 */
3971 #ifdef TC_I960
3972 /* reloc_callj() may replace a 'call' with a 'calls' or a 'bal',
3973 * in which cases it modifies *fixP as appropriate. In the case
3974 * of a 'calls', no further work is required, and *fixP has been
3975 * set up to make the rest of the code below a no-op.
3976 */
3977 reloc_callj (fixP);
3978 #endif /* TC_I960 */
3979
3980 add_number += S_GET_VALUE (add_symbolP);
3981 add_number -= md_pcrel_from (fixP);
3982 #if defined (TC_I386) || defined (TE_LYNX)
3983 /* On the 386 we must adjust by the segment
3984 vaddr as well. Ian Taylor. */
3985 add_number -= segP->scnhdr.s_vaddr;
3986 #endif
3987 pcrel = 0; /* Lie. Don't want further pcrel processing. */
3988 if (!TC_FORCE_RELOCATION (fixP))
3989 {
3990 fixP->fx_addsy = NULL;
3991 fixP->fx_done = 1;
3992 }
3993 }
3994 else
3995 {
3996 switch (add_symbol_segment)
3997 {
3998 case absolute_section:
3999 #ifdef TC_I960
4000 reloc_callj (fixP); /* See comment about reloc_callj() above*/
4001 #endif /* TC_I960 */
4002 add_number += S_GET_VALUE (add_symbolP);
4003 add_symbolP = NULL;
4004
4005 if (!TC_FORCE_RELOCATION (fixP))
4006 {
4007 fixP->fx_addsy = NULL;
4008 fixP->fx_done = 1;
4009 }
4010 break;
4011 default:
4012
4013
4014 #if defined(TC_A29K) || (defined(TE_PE) && defined(TC_I386)) || defined(TC_M88K)
4015 /* This really should be handled in the linker, but
4016 backward compatibility forbids. */
4017 add_number += S_GET_VALUE (add_symbolP);
4018 #else
4019 add_number += S_GET_VALUE (add_symbolP) +
4020 segment_info[S_GET_SEGMENT (add_symbolP)].scnhdr.s_paddr;
4021 #endif
4022 break;
4023
4024 case SEG_UNKNOWN:
4025 #ifdef TC_I960
4026 if ((int) fixP->fx_bit_fixP == 13)
4027 {
4028 /* This is a COBR instruction. They have only a
4029 * 13-bit displacement and are only to be used
4030 * for local branches: flag as error, don't generate
4031 * relocation.
4032 */
4033 as_bad_where (fixP->fx_file, fixP->fx_line,
4034 "can't use COBR format with external label");
4035 fixP->fx_addsy = NULL;
4036 fixP->fx_done = 1;
4037 continue;
4038 } /* COBR */
4039 #endif /* TC_I960 */
4040 #if (defined (TC_I386) || defined (TE_LYNX) || defined (TE_AUX)) && !defined(TE_PE)
4041 /* 386 COFF uses a peculiar format in which the
4042 value of a common symbol is stored in the .text
4043 segment (I've checked this on SVR3.2 and SCO
4044 3.2.2) Ian Taylor <ian@cygnus.com>. */
4045 if (S_IS_COMMON (add_symbolP))
4046 add_number += S_GET_VALUE (add_symbolP);
4047 #endif
4048 break;
4049
4050
4051 } /* switch on symbol seg */
4052 } /* if not in local seg */
4053 } /* if there was a + symbol */
4054
4055 if (pcrel)
4056 {
4057 #if !defined(TC_M88K) && !(defined(TE_PE) && defined(TC_I386)) && !defined(TC_A29K)
4058 /* This adjustment is not correct on the m88k, for which the
4059 linker does all the computation. */
4060 add_number -= md_pcrel_from (fixP);
4061 #endif
4062 if (add_symbolP == 0)
4063 {
4064 fixP->fx_addsy = &abs_symbol;
4065 } /* if there's an add_symbol */
4066 #if defined (TC_I386) || defined (TE_LYNX)
4067 /* On the 386 we must adjust by the segment vaddr
4068 as well. Ian Taylor. */
4069 add_number -= segP->scnhdr.s_vaddr;
4070 #endif
4071 } /* if pcrel */
4072
4073 if (!fixP->fx_bit_fixP)
4074 {
4075 #ifndef TC_M88K
4076 /* The m88k uses the offset field of the reloc to get around
4077 this problem. */
4078 if ((size == 1
4079 && (add_number & ~0xFF)
4080 && ((add_number & ~0xFF) != (-1 & ~0xFF)))
4081 || (size == 2
4082 && (add_number & ~0xFFFF)
4083 && ((add_number & ~0xFFFF) != (-1 & ~0xFFFF))))
4084 {
4085 as_bad_where (fixP->fx_file, fixP->fx_line,
4086 "Value of %ld too large for field of %d bytes at 0x%lx",
4087 (long) add_number, size,
4088 (unsigned long) (fragP->fr_address + where));
4089 }
4090 #endif
4091 #ifdef WARN_SIGNED_OVERFLOW_WORD
4092 /* Warn if a .word value is too large when treated as a
4093 signed number. We already know it is not too negative.
4094 This is to catch over-large switches generated by gcc on
4095 the 68k. */
4096 if (!flag_signed_overflow_ok
4097 && size == 2
4098 && add_number > 0x7fff)
4099 as_bad_where (fixP->fx_file, fixP->fx_line,
4100 "Signed .word overflow; switch may be too large; %ld at 0x%lx",
4101 (long) add_number,
4102 (unsigned long) (fragP->fr_address + where));
4103 #endif
4104 } /* not a bit fix */
4105 /* Once this fix has been applied, we don't have to output
4106 anything nothing more need be done. */
4107 #ifdef MD_APPLY_FIX3
4108 md_apply_fix3 (fixP, &add_number, this_segment_type);
4109 #else
4110 md_apply_fix (fixP, add_number);
4111 #endif
4112 } /* For each fixS in this segment. */
4113 } /* fixup_segment() */
4114
4115 #endif
4116
4117 /* The first entry in a .stab section is special. */
4118
4119 void
4120 obj_coff_init_stab_section (seg)
4121 segT seg;
4122 {
4123 char *file;
4124 char *p;
4125 char *stabstr_name;
4126 unsigned int stroff;
4127
4128 /* Make space for this first symbol. */
4129 p = frag_more (12);
4130 /* Zero it out. */
4131 memset (p, 0, 12);
4132 as_where (&file, (unsigned int *) NULL);
4133 stabstr_name = (char *) alloca (strlen (segment_info[seg].name) + 4);
4134 strcpy (stabstr_name, segment_info[seg].name);
4135 strcat (stabstr_name, "str");
4136 stroff = get_stab_string_offset (file, stabstr_name);
4137 know (stroff == 1);
4138 md_number_to_chars (p, stroff, 4);
4139 }
4140
4141 /* Fill in the counts in the first entry in a .stab section. */
4142
4143 static void
4144 adjust_stab_section(abfd, seg)
4145 bfd *abfd;
4146 segT seg;
4147 {
4148 segT stabstrseg = SEG_UNKNOWN;
4149 const char *secname, *name2;
4150 char *name;
4151 char *p = NULL;
4152 int i, strsz = 0, nsyms;
4153 fragS *frag = segment_info[seg].frchainP->frch_root;
4154
4155 /* Look for the associated string table section. */
4156
4157 secname = segment_info[seg].name;
4158 name = (char *) alloca (strlen (secname) + 4);
4159 strcpy (name, secname);
4160 strcat (name, "str");
4161
4162 for (i = SEG_E0; i < SEG_UNKNOWN; i++)
4163 {
4164 name2 = segment_info[i].name;
4165 if (name2 != NULL && strncmp(name2, name, 8) == 0)
4166 {
4167 stabstrseg = i;
4168 break;
4169 }
4170 }
4171
4172 /* If we found the section, get its size. */
4173 if (stabstrseg != SEG_UNKNOWN)
4174 strsz = size_section (abfd, stabstrseg);
4175
4176 nsyms = size_section (abfd, seg) / 12 - 1;
4177
4178 /* Look for the first frag of sufficient size for the initial stab
4179 symbol, and collect a pointer to it. */
4180 while (frag && frag->fr_fix < 12)
4181 frag = frag->fr_next;
4182 assert (frag != 0);
4183 p = frag->fr_literal;
4184 assert (p != 0);
4185
4186 /* Write in the number of stab symbols and the size of the string
4187 table. */
4188 bfd_h_put_16 (abfd, (bfd_vma) nsyms, (bfd_byte *) p + 6);
4189 bfd_h_put_32 (abfd, (bfd_vma) strsz, (bfd_byte *) p + 8);
4190 }
4191
4192 #endif /* not BFD_ASSEMBLER */
4193
4194 const pseudo_typeS obj_pseudo_table[] =
4195 {
4196 {"def", obj_coff_def, 0},
4197 {"dim", obj_coff_dim, 0},
4198 {"endef", obj_coff_endef, 0},
4199 {"line", obj_coff_line, 0},
4200 {"ln", obj_coff_ln, 0},
4201 {"appline", obj_coff_ln, 1},
4202 {"scl", obj_coff_scl, 0},
4203 {"size", obj_coff_size, 0},
4204 {"tag", obj_coff_tag, 0},
4205 {"type", obj_coff_type, 0},
4206 {"val", obj_coff_val, 0},
4207 {"section", obj_coff_section, 0},
4208 {"sect", obj_coff_section, 0},
4209 /* FIXME: We ignore the MRI short attribute. */
4210 {"section.s", obj_coff_section, 0},
4211 {"sect.s", obj_coff_section, 0},
4212 #ifndef BFD_ASSEMBLER
4213 {"use", obj_coff_section, 0},
4214 {"text", obj_coff_text, 0},
4215 {"data", obj_coff_data, 0},
4216 {"bss", obj_coff_bss, 0},
4217 {"lcomm", obj_coff_lcomm, 0},
4218 {"ident", obj_coff_ident, 0},
4219 #else
4220 {"optim", s_ignore, 0}, /* For sun386i cc (?) */
4221 {"ident", s_ignore, 0}, /* we don't yet handle this. */
4222 #endif
4223 {"ABORT", s_abort, 0},
4224 #ifdef TC_M88K
4225 /* The m88k uses sdef instead of def. */
4226 {"sdef", obj_coff_def, 0},
4227 #endif
4228 {NULL} /* end sentinel */
4229 }; /* obj_pseudo_table */
This page took 0.115989 seconds and 5 git commands to generate.