1 /* read.c - read a source file -
2 Copyright (C) 1986, 1987, 1990, 1991, 1993 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
21 #define MASK_CHAR (0xFF) /* If your chars aren't 8 bits, you will
22 change this a bit. But then, GNU isn't
23 spozed to run on your machine anyway.
24 (RMS is so shortsighted sometimes.)
27 #define MASK_CHAR ((int)(unsigned char)-1)
31 /* This is the largest known floating point format (for now). It will
32 grow when we do 4361 style flonums. */
34 #define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
36 /* Routines that read assembler source text to build spagetti in memory.
37 Another group of these functions is in the expr.c module. */
48 /* We need this, despite the apparent object format dependency, since
49 it defines stab types, which all object formats can use now. */
51 #include "aout/stab_gnu.h"
53 #ifndef TC_START_LABEL
54 #define TC_START_LABEL(x,y) (x==':')
57 /* The NOP_OPCODE is for the alignment fill value.
58 * fill it a nop instruction so that the disassembler does not choke
62 #define NOP_OPCODE 0x00
65 char *input_line_pointer
; /*->next char of source file to parse. */
67 #if BITS_PER_CHAR != 8
68 /* The following table is indexed by[(char)] and will break if
69 a char does not have exactly 256 states (hopefully 0:255!)! */
74 /* The m88k unfortunately uses @ as a label beginner. */
78 /* used by is_... macros. our ctype[] */
79 const char lex_type
[256] =
81 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
82 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
83 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
84 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */
85 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
86 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 3, /* PQRSTUVWXYZ[\]^_ */
87 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
88 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, /* pqrstuvwxyz{|}~. */
89 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
90 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
91 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
92 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
93 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
94 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
95 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
101 * Out: 1 if this character ends a line.
104 char is_end_of_line
[256] =
107 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, 99, _
, _
, 99, _
, _
, /* @abcdefghijklmno */
109 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, 99, _
, _
, _
, _
, _
, /* @abcdefghijklmno */
111 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
113 _
,99, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* _!"#$%&'()*+,-./ */
114 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* 0123456789:;<=>? */
116 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
117 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, 99, _
, _
, _
, _
, /* 0123456789:;<=>? */
119 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
120 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
121 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
122 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
123 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
124 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
125 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
126 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
127 _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, _
, /* */
131 /* Functions private to this file. */
133 static char *buffer
; /* 1st char of each buffer of lines is here. */
134 static char *buffer_limit
; /*->1 + last char in buffer. */
136 static char *bignum_low
; /* Lowest char of bignum. */
137 static char *bignum_limit
; /* 1st illegal address of bignum. */
138 static char *bignum_high
; /* Highest char of bignum. */
139 /* May point to (bignum_start-1). */
140 /* Never >= bignum_limit. */
142 int target_big_endian
;
144 static char *old_buffer
; /* JF a hack */
145 static char *old_input
;
146 static char *old_limit
;
148 /* Variables for handling include file directory list. */
150 char **include_dirs
; /* List of pointers to directories to
151 search for .include's */
152 int include_dir_count
; /* How many are in the list */
153 int include_dir_maxlen
= 1;/* Length of longest in list */
155 #ifndef WORKING_DOT_WORD
156 struct broken_word
*broken_words
;
157 int new_broken_words
;
160 static char *demand_copy_string
PARAMS ((int *lenP
));
161 int is_it_end_of_statement
PARAMS ((void));
162 unsigned int next_char_of_string
PARAMS ((void));
163 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
164 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
165 static void grow_bignum
PARAMS ((void));
166 static void pobegin
PARAMS ((void));
177 obj_read_begin_hook ();
179 /* Something close -- but not too close -- to a multiple of 1024.
180 The debugging malloc I'm using has 24 bytes of overhead. */
181 obstack_begin (¬es
, 5090);
182 obstack_begin (&cond_obstack
, 990);
184 #define BIGNUM_BEGIN_SIZE (16)
185 bignum_low
= xmalloc ((long) BIGNUM_BEGIN_SIZE
);
186 bignum_limit
= bignum_low
+ BIGNUM_BEGIN_SIZE
;
188 /* Use machine dependent syntax */
189 for (p
= line_separator_chars
; *p
; p
++)
190 is_end_of_line
[*p
] = 1;
191 /* Use more. FIXME-SOMEDAY. */
194 /* set up pseudo-op tables */
196 struct hash_control
*po_hash
;
198 static const pseudo_typeS potable
[] =
200 {"abort", s_abort
, 0},
201 {"align", s_align_ptwo
, 0},
202 {"ascii", stringer
, 0},
203 {"asciz", stringer
, 1},
210 {"double", float_cons
, 'd'},
212 {"eject", listing_eject
, 0}, /* Formfeed listing */
215 {"endif", s_endif
, 0},
220 {"extern", s_ignore
, 0}, /* We treat all undef as ext */
221 {"appfile", s_app_file
, 1},
222 {"appline", s_app_line
, 0},
223 {"file", s_app_file
, 0},
225 {"float", float_cons
, 'f'},
226 {"global", s_globl
, 0},
227 {"globl", s_globl
, 0},
230 {"ifdef", s_ifdef
, 0},
231 {"ifeqs", s_ifeqs
, 0},
232 {"ifndef", s_ifdef
, 1},
233 {"ifnes", s_ifeqs
, 1},
234 {"ifnotdef", s_ifdef
, 1},
235 {"include", s_include
, 0},
237 {"lcomm", s_lcomm
, 0},
238 {"lflags", listing_flags
, 0}, /* Listing flags */
239 {"list", listing_list
, 1}, /* Turn listing on */
242 {"nolist", listing_list
, 0}, /* Turn listing off */
243 {"octa", big_cons
, 16},
245 {"psize", listing_psize
, 0}, /* set paper size */
247 {"quad", big_cons
, 8},
248 {"sbttl", listing_title
, 1}, /* Subtitle of listing */
253 {"single", float_cons
, 'f'},
255 {"space", s_space
, 0},
256 {"stabd", s_stab
, 'd'},
257 {"stabn", s_stab
, 'n'},
258 {"stabs", s_stab
, 's'},
259 {"string", stringer
, 1},
262 {"title", listing_title
, 0}, /* Listing title */
266 {"xstabs", s_xstab
, 's'},
268 {NULL
} /* end sentinel */
274 char *errtxt
; /* error text */
275 const pseudo_typeS
*pop
;
277 po_hash
= hash_new ();
279 /* Do the target-specific pseudo ops. */
280 for (pop
= md_pseudo_table
; pop
->poc_name
; pop
++)
282 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
283 if (errtxt
&& *errtxt
)
285 as_fatal ("error constructing md pseudo-op table");
289 /* Now object specific. Skip any that were in the target table. */
290 for (pop
= obj_pseudo_table
; pop
->poc_name
; pop
++)
292 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
293 if (errtxt
&& *errtxt
)
295 if (!strcmp (errtxt
, "exists"))
297 #ifdef DIE_ON_OVERRIDES
298 as_fatal ("pseudo op \".%s\" overridden.\n", pop
->poc_name
);
299 #endif /* DIE_ON_OVERRIDES */
300 continue; /* OK if target table overrides. */
304 as_fatal ("error constructing obj pseudo-op table");
305 } /* if overridden */
309 /* Now portable ones. Skip any that we've seen already. */
310 for (pop
= potable
; pop
->poc_name
; pop
++)
312 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
313 if (errtxt
&& *errtxt
)
315 if (!strcmp (errtxt
, "exists"))
317 #ifdef DIE_ON_OVERRIDES
318 as_fatal ("pseudo op \".%s\" overridden.\n", pop
->poc_name
);
319 #endif /* DIE_ON_OVERRIDES */
320 continue; /* OK if target table overrides. */
324 as_fatal ("error constructing obj pseudo-op table");
325 } /* if overridden */
332 #define HANDLE_CONDITIONAL_ASSEMBLY() \
333 if (ignore_input ()) \
335 while (! is_end_of_line[*input_line_pointer++]) \
336 if (input_line_pointer == buffer_limit) \
342 /* read_a_source_file()
344 * We read the file, putting things into a web that
345 * represents what we have been reading.
348 read_a_source_file (name
)
352 register char *s
; /* string of symbol, '\0' appended */
356 buffer
= input_scrub_new_file (name
);
359 listing_newline ("");
361 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
362 { /* We have another line to parse. */
363 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
364 contin
: /* JF this goto is my fault I admit it.
365 Someone brave please re-write the whole
366 input section here? Pleeze??? */
367 while (input_line_pointer
< buffer_limit
)
369 /* We have more of this buffer to parse. */
372 * We now have input_line_pointer->1st char of next line.
373 * If input_line_pointer [-1] == '\n' then we just
374 * scanned another line: so bump line counters.
376 if (input_line_pointer
[-1] == '\n')
378 bump_line_counters ();
381 /* Text at the start of a line must be a label, we run down and stick a colon in */
382 if (is_name_beginner (*input_line_pointer
))
384 char *line_start
= input_line_pointer
;
385 char c
= get_symbol_end ();
387 *input_line_pointer
= c
;
389 input_line_pointer
++;
397 * We are at the begining of a line, or similar place.
398 * We expect a well-formed assembler statement.
399 * A "symbol-name:" is a statement.
401 * Depending on what compiler is used, the order of these tests
402 * may vary to catch most common case 1st.
403 * Each test is independent of all other tests at the (top) level.
404 * PLEASE make a compiler that doesn't use this assembler.
405 * It is crufty to waste a compiler's time encoding things for this
406 * assembler, which then wastes more time decoding it.
407 * (And communicating via (linear) files is silly!
408 * If you must pass stuff, please pass a tree!)
410 if ((c
= *input_line_pointer
++) == '\t'
415 c
= *input_line_pointer
++;
417 know (c
!= ' '); /* No further leading whitespace. */
420 * C is the 1st significant character.
421 * Input_line_pointer points after that character.
423 if (is_name_beginner (c
))
424 { /* want user-defined label or pseudo/opcode */
425 HANDLE_CONDITIONAL_ASSEMBLY ();
427 s
= --input_line_pointer
;
428 c
= get_symbol_end (); /* name's delimiter */
430 * C is character after symbol.
431 * That character's place in the input line is now '\0'.
432 * S points to the beginning of the symbol.
433 * [In case of pseudo-op, s->'.'.]
434 * Input_line_pointer->'\0' where c was.
436 if (TC_START_LABEL(c
, input_line_pointer
))
438 colon (s
); /* user-defined label */
439 *input_line_pointer
++ = ':'; /* Put ':' back for error messages' sake. */
440 /* Input_line_pointer->after ':'. */
446 || (input_line_pointer
[1] == '='
447 #ifdef TC_EQUAL_IN_INSN
448 && ! TC_EQUAL_IN_INSN (c
, input_line_pointer
)
453 demand_empty_rest_of_line ();
456 { /* expect pseudo-op or machine instruction */
458 if (!done_pseudo (s
))
465 /* The m88k uses pseudo-ops without a period. */
466 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
467 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
471 if (pop
!= NULL
|| *s
== '.')
476 * WARNING: c has next char, which may be end-of-line.
477 * We lookup the pseudo-op table with s+1 because we
478 * already know that the pseudo-op begins with a '.'.
482 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
484 /* Print the error msg now, while we still can */
487 as_bad ("Unknown pseudo-op: `%s'", s
);
488 *input_line_pointer
= c
;
493 /* Put it back for error messages etc. */
494 *input_line_pointer
= c
;
495 /* The following skip of whitespace is compulsory.
496 A well shaped space is sometimes all that separates
497 keyword from operands. */
498 if (c
== ' ' || c
== '\t')
500 input_line_pointer
++;
501 } /* Skip seperator after keyword. */
503 * Input_line is restored.
504 * Input_line_pointer->1st non-blank char
505 * after pseudo-operation.
509 ignore_rest_of_line ();
514 (*pop
->poc_handler
) (pop
->poc_val
);
515 } /* if we have one */
519 { /* machine instruction */
520 /* WARNING: c has char, which may be end-of-line. */
521 /* Also: input_line_pointer->`\0` where c was. */
522 *input_line_pointer
= c
;
523 while (!is_end_of_line
[*input_line_pointer
]
524 #ifdef TC_EOL_IN_INSN
525 || TC_EOL_IN_INSN (input_line_pointer
)
529 input_line_pointer
++;
532 c
= *input_line_pointer
;
533 *input_line_pointer
= '\0';
535 md_assemble (s
); /* Assemble 1 instruction. */
537 *input_line_pointer
++ = c
;
539 /* We resume loop AFTER the end-of-line from this instruction */
544 } /* if (is_name_beginner(c) */
547 if (is_end_of_line
[c
])
550 } /* empty statement */
553 #if defined(LOCAL_LABELS_DOLLAR) || defined(LOCAL_LABELS_FB)
555 { /* local label ("4:") */
556 char *backup
= input_line_pointer
;
558 HANDLE_CONDITIONAL_ASSEMBLY ();
562 while (isdigit (*input_line_pointer
))
564 temp
= (temp
* 10) + *input_line_pointer
- '0';
565 ++input_line_pointer
;
566 } /* read the whole number */
568 #ifdef LOCAL_LABELS_DOLLAR
569 if (*input_line_pointer
== '$'
570 && *(input_line_pointer
+ 1) == ':')
572 input_line_pointer
+= 2;
574 if (dollar_label_defined (temp
))
576 as_fatal ("label \"%d$\" redefined", temp
);
579 define_dollar_label (temp
);
580 colon (dollar_label_name (temp
, 0));
583 #endif /* LOCAL_LABELS_DOLLAR */
585 #ifdef LOCAL_LABELS_FB
586 if (*input_line_pointer
++ == ':')
588 fb_label_instance_inc (temp
);
589 colon (fb_label_name (temp
, 0));
592 #endif /* LOCAL_LABELS_FB */
594 input_line_pointer
= backup
;
595 } /* local label ("4:") */
596 #endif /* LOCAL_LABELS_DOLLAR or LOCAL_LABELS_FB */
598 if (c
&& strchr (line_comment_chars
, c
))
599 { /* Its a comment. Better say APP or NO_APP */
605 extern char *scrub_string
, *scrub_last_string
;
607 bump_line_counters ();
608 s
= input_line_pointer
;
609 if (strncmp (s
, "APP\n", 4))
610 continue; /* We ignore it */
613 ends
= strstr (s
, "#NO_APP\n");
620 /* The end of the #APP wasn't in this buffer. We
621 keep reading in buffers until we find the #NO_APP
622 that goes with this #APP There is one. The specs
624 tmp_len
= buffer_limit
- s
;
625 tmp_buf
= xmalloc (tmp_len
+ 1);
626 memcpy (tmp_buf
, s
, tmp_len
);
629 new_tmp
= input_scrub_next_buffer (&buffer
);
633 buffer_limit
= new_tmp
;
634 input_line_pointer
= buffer
;
635 ends
= strstr (buffer
, "#NO_APP\n");
639 num
= buffer_limit
- buffer
;
641 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
642 memcpy (tmp_buf
, buffer
+ tmp_len
, num
);
647 input_line_pointer
= ends
? ends
+ 8 : NULL
;
655 input_line_pointer
= ends
+ 8;
657 new_buf
= xmalloc (100);
662 scrub_last_string
= ends
;
667 ch
= do_scrub_next_char (scrub_from_string
, scrub_to_string
);
671 if (new_tmp
== new_buf
+ new_length
)
673 new_buf
= xrealloc (new_buf
, new_length
+ 100);
674 new_tmp
= new_buf
+ new_length
;
682 old_input
= input_line_pointer
;
683 old_limit
= buffer_limit
;
685 input_line_pointer
= new_buf
;
686 buffer_limit
= new_tmp
;
690 HANDLE_CONDITIONAL_ASSEMBLY ();
692 /* as_warn("Junk character %d.",c); Now done by ignore_rest */
693 input_line_pointer
--; /* Report unknown char as ignored. */
694 ignore_rest_of_line ();
695 } /* while (input_line_pointer<buffer_limit) */
698 bump_line_counters ();
702 input_line_pointer
= old_input
;
703 buffer_limit
= old_limit
;
708 } /* while (more buffers to scan) */
709 input_scrub_close (); /* Close the input file */
711 } /* read_a_source_file() */
716 as_fatal (".abort detected. Abandoning ship.");
719 /* For machines where ".align 4" means align to a 4 byte boundary. */
724 register unsigned int temp
;
725 register long temp_fill
;
727 unsigned long max_alignment
= 1 << 15;
729 if (is_end_of_line
[*input_line_pointer
])
730 temp
= arg
; /* Default value from pseudo-op table */
732 temp
= get_absolute_expression ();
734 if (temp
> max_alignment
)
736 as_bad ("Alignment too large: %d. assumed.", temp
= max_alignment
);
740 * For the sparc, `.align (1<<n)' actually means `.align n'
741 * so we have to convert it.
745 for (i
= 0; (temp
& 1) == 0; temp
>>= 1, ++i
)
749 as_bad ("Alignment not a power of 2");
752 if (*input_line_pointer
== ',')
754 input_line_pointer
++;
755 temp_fill
= get_absolute_expression ();
757 else if (now_seg
!= data_section
&& now_seg
!= bss_section
)
758 temp_fill
= NOP_OPCODE
;
761 /* Only make a frag if we HAVE to. . . */
762 if (temp
&& !need_pass_2
)
763 frag_align (temp
, (int) temp_fill
);
765 record_alignment (now_seg
, temp
);
767 demand_empty_rest_of_line ();
768 } /* s_align_bytes() */
770 /* For machines where ".align 4" means align to 2**4 boundary. */
775 register long temp_fill
;
776 long max_alignment
= 15;
778 temp
= get_absolute_expression ();
779 if (temp
> max_alignment
)
780 as_bad ("Alignment too large: %d. assumed.", temp
= max_alignment
);
783 as_bad ("Alignment negative. 0 assumed.");
786 if (*input_line_pointer
== ',')
788 input_line_pointer
++;
789 temp_fill
= get_absolute_expression ();
791 /* @@ Fix this right for BFD! */
792 else if (now_seg
!= data_section
&& now_seg
!= bss_section
)
793 temp_fill
= NOP_OPCODE
;
796 /* Only make a frag if we HAVE to. . . */
797 if (temp
&& !need_pass_2
)
798 frag_align (temp
, (int) temp_fill
);
800 record_alignment (now_seg
, temp
);
802 demand_empty_rest_of_line ();
803 } /* s_align_ptwo() */
812 register symbolS
*symbolP
;
814 name
= input_line_pointer
;
815 c
= get_symbol_end ();
816 /* just after name is now '\0' */
817 p
= input_line_pointer
;
820 if (*input_line_pointer
!= ',')
822 as_bad ("Expected comma after symbol-name: rest of line ignored.");
823 ignore_rest_of_line ();
826 input_line_pointer
++; /* skip ',' */
827 if ((temp
= get_absolute_expression ()) < 0)
829 as_warn (".COMMon length (%d.) <0! Ignored.", temp
);
830 ignore_rest_of_line ();
834 symbolP
= symbol_find_or_make (name
);
836 if (S_IS_DEFINED (symbolP
))
838 as_bad ("Ignoring attempt to re-define symbol");
839 ignore_rest_of_line ();
842 if (S_GET_VALUE (symbolP
))
844 if (S_GET_VALUE (symbolP
) != temp
)
845 as_bad ("Length of .comm \"%s\" is already %d. Not changed to %d.",
846 S_GET_NAME (symbolP
),
847 S_GET_VALUE (symbolP
),
852 S_SET_VALUE (symbolP
, temp
);
853 S_SET_EXTERNAL (symbolP
);
856 if ( (!temp
) || !flagseen
['1'])
857 S_GET_OTHER(symbolP
) = const_flag
;
858 #endif /* not OBJ_VMS */
859 know (symbolP
->sy_frag
== &zero_address_frag
);
860 demand_empty_rest_of_line ();
869 temp
= get_absolute_expression ();
872 section
= text_section
;
876 section
= data_section
;
879 subseg_set (section
, (subsegT
) temp
);
881 subseg_new (section
, (subsegT
) temp
);
887 demand_empty_rest_of_line ();
890 /* Handle the .appfile pseudo-op. This is automatically generated by
891 do_scrub_next_char when a preprocessor # line comment is seen with
892 a file name. This default definition may be overridden by the
893 object or CPU specific pseudo-ops. This function is also the
894 default definition for .file; the APPFILE argument is 1 for
895 .appfile, 0 for .file. */
904 /* Some assemblers tolerate immediately following '"' */
905 if ((s
= demand_copy_string (&length
)) != 0)
907 /* If this is a fake .appfile, a fake newline was inserted into
908 the buffer. Passing -2 to new_logical_line tells it to
910 new_logical_line (s
, appfile
? -2 : -1);
911 demand_empty_rest_of_line ();
914 listing_source_file (s
);
918 c_dot_file_symbol (s
);
919 #endif /* OBJ_COFF */
925 /* Handle the .appline pseudo-op. This is automatically generated by
926 do_scrub_next_char when a preprocessor # line comment is seen.
927 This default definition may be overridden by the object or CPU
928 specific pseudo-ops. */
935 /* The given number is that of the next line. */
936 l
= get_absolute_expression () - 1;
937 new_logical_line ((char *) NULL
, l
);
940 listing_source_line (l
);
942 demand_empty_rest_of_line ();
948 long temp_repeat
= 0;
950 register long temp_fill
= 0;
954 temp_repeat
= get_absolute_expression ();
955 if (*input_line_pointer
== ',')
957 input_line_pointer
++;
958 temp_size
= get_absolute_expression ();
959 if (*input_line_pointer
== ',')
961 input_line_pointer
++;
962 temp_fill
= get_absolute_expression ();
965 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
966 #define BSD_FILL_SIZE_CROCK_8 (8)
967 if (temp_size
> BSD_FILL_SIZE_CROCK_8
)
969 as_warn (".fill size clamped to %d.", BSD_FILL_SIZE_CROCK_8
);
970 temp_size
= BSD_FILL_SIZE_CROCK_8
;
974 as_warn ("Size negative: .fill ignored.");
977 else if (temp_repeat
<= 0)
979 as_warn ("Repeat < 0, .fill ignored");
983 if (temp_size
&& !need_pass_2
)
985 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
, (relax_substateT
) 0, (symbolS
*) 0, temp_repeat
, (char *) 0);
986 memset (p
, 0, (int) temp_size
);
987 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
988 * flavoured AS. The following bizzare behaviour is to be
989 * compatible with above. I guess they tried to take up to 8
990 * bytes from a 4-byte expression and they forgot to sign
991 * extend. Un*x Sux. */
992 #define BSD_FILL_SIZE_CROCK_4 (4)
993 md_number_to_chars (p
, temp_fill
,
994 (temp_size
> BSD_FILL_SIZE_CROCK_4
995 ? BSD_FILL_SIZE_CROCK_4
997 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
998 * but emits no error message because it seems a legal thing to do.
999 * It is a degenerate case of .fill but could be emitted by a compiler.
1002 demand_empty_rest_of_line ();
1014 name
= input_line_pointer
;
1015 c
= get_symbol_end ();
1016 symbolP
= symbol_find_or_make (name
);
1017 *input_line_pointer
= c
;
1019 S_SET_EXTERNAL (symbolP
);
1022 input_line_pointer
++;
1024 if (*input_line_pointer
== '\n')
1029 demand_empty_rest_of_line ();
1033 s_lcomm (needs_align
)
1034 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1035 (alignment); 0 if it was an ".lcomm" (2 args only) */
1038 register char *name
;
1042 register symbolS
*symbolP
;
1043 segT current_seg
= now_seg
;
1044 subsegT current_subseg
= now_subseg
;
1045 const int max_alignment
= 15;
1047 segT bss_seg
= bss_section
;
1049 name
= input_line_pointer
;
1050 c
= get_symbol_end ();
1051 p
= input_line_pointer
;
1054 if (*input_line_pointer
!= ',')
1056 as_bad ("Expected comma after name");
1057 ignore_rest_of_line ();
1061 ++input_line_pointer
;
1063 if (*input_line_pointer
== '\n')
1065 as_bad ("Missing size expression");
1069 if ((temp
= get_absolute_expression ()) < 0)
1071 as_warn ("BSS length (%d.) <0! Ignored.", temp
);
1072 ignore_rest_of_line ();
1078 /* For MIPS ECOFF, small objects are put in .sbss. */
1079 if (temp
<= bfd_get_gp_size (stdoutput
))
1080 bss_seg
= subseg_new (".sbss", 1);
1088 if (*input_line_pointer
!= ',')
1090 as_bad ("Expected comma after size");
1091 ignore_rest_of_line ();
1094 input_line_pointer
++;
1096 if (*input_line_pointer
== '\n')
1098 as_bad ("Missing alignment");
1101 align
= get_absolute_expression ();
1102 if (align
> max_alignment
)
1104 align
= max_alignment
;
1105 as_warn ("Alignment too large: %d. assumed.", align
);
1110 as_warn ("Alignment negative. 0 assumed.");
1112 record_alignment (bss_seg
, align
);
1113 } /* if needs align */
1116 symbolP
= symbol_find_or_make (name
);
1120 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
1121 S_GET_OTHER (symbolP
) == 0 &&
1122 S_GET_DESC (symbolP
) == 0 &&
1123 #endif /* OBJ_AOUT or OBJ_BOUT */
1124 (S_GET_SEGMENT (symbolP
) == bss_seg
1125 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
1129 #ifdef BFD_ASSEMBLER
1130 subseg_set (bss_seg
, 1);
1132 subseg_new (bss_seg
, 1);
1136 frag_align (align
, 0);
1137 /* detach from old frag */
1138 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
1139 symbolP
->sy_frag
->fr_symbol
= NULL
;
1141 symbolP
->sy_frag
= frag_now
;
1142 p
= frag_var (rs_org
, 1, 1, (relax_substateT
)0, symbolP
,
1146 S_SET_SEGMENT (symbolP
, bss_seg
);
1149 /* The symbol may already have been created with a preceding
1150 ".globl" directive -- be careful not to step on storage class
1151 in that case. Otherwise, set it to static. */
1152 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
1154 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
1156 #endif /* OBJ_COFF */
1160 as_bad ("Ignoring attempt to re-define symbol %s.", name
);
1163 #ifdef BFD_ASSEMBLER
1164 subseg_set (current_seg
, current_subseg
);
1166 subseg_new (current_seg
, current_subseg
);
1169 demand_empty_rest_of_line ();
1187 register char *name
;
1191 register symbolS
*symbolP
;
1193 /* we permit ANY defined expression: BSD4.2 demands constants */
1194 name
= input_line_pointer
;
1195 c
= get_symbol_end ();
1196 p
= input_line_pointer
;
1199 if (*input_line_pointer
!= ',')
1202 as_bad ("Expected comma after name \"%s\"", name
);
1204 ignore_rest_of_line ();
1207 input_line_pointer
++;
1209 if (exp
.X_op
!= O_constant
1210 && exp
.X_op
!= O_register
)
1212 as_bad ("bad expression");
1213 ignore_rest_of_line ();
1217 symbolP
= symbol_find_or_make (name
);
1219 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
1220 symbolP->sy_desc == 0) out of this test because coff doesn't have
1221 those fields, and I can't see when they'd ever be tripped. I
1222 don't think I understand why they were here so I may have
1223 introduced a bug. As recently as 1.37 didn't have this test
1224 anyway. xoxorich. */
1226 if (S_GET_SEGMENT (symbolP
) == undefined_section
1227 && S_GET_VALUE (symbolP
) == 0)
1229 /* The name might be an undefined .global symbol; be sure to
1230 keep the "external" bit. */
1231 S_SET_SEGMENT (symbolP
,
1232 (exp
.X_op
== O_constant
1235 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
1239 as_bad ("Symbol %s already defined", name
);
1242 demand_empty_rest_of_line ();
1248 register segT segment
;
1250 register long temp_fill
;
1252 /* Don't believe the documentation of BSD 4.2 AS. There is no such
1253 thing as a sub-segment-relative origin. Any absolute origin is
1254 given a warning, then assumed to be segment-relative. Any
1255 segmented origin expression ("foo+42") had better be in the right
1256 segment or the .org is ignored.
1258 BSD 4.2 AS warns if you try to .org backwards. We cannot because
1259 we never know sub-segment sizes when we are reading code. BSD
1260 will crash trying to emit negative numbers of filler bytes in
1261 certain .orgs. We don't crash, but see as-write for that code.
1263 Don't make frag if need_pass_2==1. */
1264 segment
= get_known_segmented_expression (&exp
);
1265 if (*input_line_pointer
== ',')
1267 input_line_pointer
++;
1268 temp_fill
= get_absolute_expression ();
1274 if (segment
!= now_seg
&& segment
!= absolute_section
)
1275 as_bad ("Invalid segment \"%s\". Segment \"%s\" assumed.",
1276 segment_name (segment
), segment_name (now_seg
));
1277 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
.X_add_symbol
,
1278 exp
.X_add_number
, (char *) 0);
1280 } /* if (ok to make frag) */
1281 demand_empty_rest_of_line ();
1287 register char *name
;
1288 register char delim
;
1289 register char *end_name
;
1290 register symbolS
*symbolP
;
1293 * Especial apologies for the random logic:
1294 * this just grew, and could be parsed much more simply!
1297 name
= input_line_pointer
;
1298 delim
= get_symbol_end ();
1299 end_name
= input_line_pointer
;
1303 if (*input_line_pointer
!= ',')
1306 as_bad ("Expected comma after name \"%s\"", name
);
1308 ignore_rest_of_line ();
1312 input_line_pointer
++;
1315 if (name
[0] == '.' && name
[1] == '\0')
1317 /* Turn '. = mumble' into a .org mumble */
1318 register segT segment
;
1322 segment
= get_known_segmented_expression (&exp
);
1326 if (segment
!= now_seg
&& segment
!= absolute_section
)
1327 as_bad ("Invalid segment \"%s\". Segment \"%s\" assumed.",
1328 segment_name (segment
),
1329 segment_name (now_seg
));
1330 ptr
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
.X_add_symbol
,
1331 exp
.X_add_number
, (char *) 0);
1333 } /* if (ok to make frag) */
1339 if ((symbolP
= symbol_find (name
)) == NULL
1340 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
1342 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
1344 /* "set" symbols are local unless otherwise specified. */
1345 SF_SET_LOCAL (symbolP
);
1346 #endif /* OBJ_COFF */
1348 } /* make a new symbol */
1350 symbol_table_insert (symbolP
);
1353 pseudo_set (symbolP
);
1354 demand_empty_rest_of_line ();
1362 register long temp_fill
;
1365 /* Just like .fill, but temp_size = 1 */
1366 if (get_absolute_expression_and_terminator (&temp_repeat
) == ',')
1368 temp_fill
= get_absolute_expression ();
1372 input_line_pointer
--; /* Backup over what was not a ','. */
1377 temp_repeat
*= mult
;
1379 if (temp_repeat
<= 0)
1381 as_warn ("Repeat < 0, .space ignored");
1382 ignore_rest_of_line ();
1387 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
1388 temp_repeat
, (char *) 0);
1391 demand_empty_rest_of_line ();
1399 temp
= get_absolute_expression ();
1400 #ifdef BFD_ASSEMBLER
1401 subseg_set (text_section
, (subsegT
) temp
);
1403 subseg_new (text_section
, (subsegT
) temp
);
1405 demand_empty_rest_of_line ();
1410 demand_empty_rest_of_line ()
1413 if (is_end_of_line
[*input_line_pointer
])
1415 input_line_pointer
++;
1419 ignore_rest_of_line ();
1421 /* Return having already swallowed end-of-line. */
1422 } /* Return pointing just after end-of-line. */
1425 ignore_rest_of_line () /* For suspect lines: gives warning. */
1427 if (!is_end_of_line
[*input_line_pointer
])
1429 if (isprint (*input_line_pointer
))
1430 as_bad ("Rest of line ignored. First ignored character is `%c'.",
1431 *input_line_pointer
);
1433 as_bad ("Rest of line ignored. First ignored character valued 0x%x.",
1434 *input_line_pointer
);
1435 while (input_line_pointer
< buffer_limit
1436 && !is_end_of_line
[*input_line_pointer
])
1438 input_line_pointer
++;
1441 input_line_pointer
++; /* Return pointing just after end-of-line. */
1442 know (is_end_of_line
[input_line_pointer
[-1]]);
1448 * In: Pointer to a symbol.
1449 * Input_line_pointer->expression.
1451 * Out: Input_line_pointer->just after any whitespace after expression.
1452 * Tried to set symbol to value of expression.
1453 * Will change symbols type, value, and frag;
1456 pseudo_set (symbolP
)
1460 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
1462 #endif /* OBJ_AOUT or OBJ_BOUT */
1464 know (symbolP
); /* NULL pointer is logic error. */
1465 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
1466 /* @@ Fix this right for BFD. */
1467 ext
= S_IS_EXTERNAL (symbolP
);
1468 #endif /* OBJ_AOUT or OBJ_BOUT */
1470 (void) expression (&exp
);
1472 if (exp
.X_op
== O_illegal
)
1473 as_bad ("illegal expression; zero assumed");
1474 else if (exp
.X_op
== O_absent
)
1475 as_bad ("missing expression; zero assumed");
1476 else if (exp
.X_op
== O_big
)
1477 as_bad ("%s number invalid; zero assumed",
1478 exp
.X_add_number
> 0 ? "bignum" : "floating point");
1479 else if (exp
.X_op
== O_subtract
1480 && (S_GET_SEGMENT (exp
.X_add_symbol
)
1481 == S_GET_SEGMENT (exp
.X_op_symbol
))
1482 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
1483 && exp
.X_add_symbol
->sy_frag
== exp
.X_op_symbol
->sy_frag
)
1485 exp
.X_op
= O_constant
;
1486 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
1487 - S_GET_VALUE (exp
.X_op_symbol
));
1495 exp
.X_add_number
= 0;
1498 S_SET_SEGMENT (symbolP
, absolute_section
);
1499 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
1500 /* @@ Fix this right for BFD. */
1502 S_SET_EXTERNAL (symbolP
);
1504 S_CLEAR_EXTERNAL (symbolP
);
1505 #endif /* OBJ_AOUT or OBJ_BOUT */
1506 S_SET_VALUE (symbolP
, exp
.X_add_number
);
1507 symbolP
->sy_frag
= &zero_address_frag
;
1511 S_SET_SEGMENT (symbolP
, reg_section
);
1512 S_SET_VALUE (symbolP
, exp
.X_add_number
);
1513 symbolP
->sy_frag
= &zero_address_frag
;
1517 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
)
1518 symbolP
->sy_value
= exp
;
1521 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (exp
.X_add_symbol
));
1522 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
1523 /* @@ Fix this right for BFD! */
1525 S_SET_EXTERNAL (symbolP
);
1527 S_CLEAR_EXTERNAL (symbolP
);
1528 #endif /* OBJ_AOUT or OBJ_BOUT */
1529 S_SET_VALUE (symbolP
,
1530 exp
.X_add_number
+ S_GET_VALUE (exp
.X_add_symbol
));
1531 symbolP
->sy_frag
= exp
.X_add_symbol
->sy_frag
;
1536 /* The value is some complex expression.
1537 FIXME: Should we set the segment to anything? */
1538 symbolP
->sy_value
= exp
;
1546 * CONStruct more frag of .bytes, or .words etc.
1547 * Should need_pass_2 be 1 then emit no frag(s).
1548 * This understands EXPRESSIONS, as opposed to big_cons().
1552 * This has a split personality. We use expression() to read the
1553 * value. We can detect if the value won't fit in a byte or word.
1554 * But we can't detect if expression() discarded significant digits
1555 * in the case of a long. Not worth the crocks required to fix it.
1558 /* Select a parser for cons expressions. */
1560 /* Some targets need to parse the expression in various fancy ways.
1561 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
1562 (for example, the HPPA does this). Otherwise, you can define
1563 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
1564 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
1565 are defined, which is the normal case, then only simple expressions
1568 #ifndef TC_PARSE_CONS_EXPRESSION
1569 #ifdef BITFIELD_CONS_EXPRESSIONS
1570 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
1572 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
1575 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_mri_cons (EXP)
1577 parse_mri_cons
PARAMS ((expressionS
*exp
));
1579 #ifdef REPEAT_CONS_EXPRESSIONS
1580 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
1582 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
1585 /* If we haven't gotten one yet, just call expression. */
1586 #ifndef TC_PARSE_CONS_EXPRESSION
1587 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
1591 /* worker to do .byte etc statements */
1592 /* clobbers input_line_pointer, checks */
1596 register unsigned int nbytes
; /* 1=.byte, 2=.word, 4=.long */
1600 if (is_it_end_of_statement ())
1602 demand_empty_rest_of_line ();
1608 TC_PARSE_CONS_EXPRESSION (&exp
, nbytes
);
1609 emit_expr (&exp
, nbytes
);
1611 while (*input_line_pointer
++ == ',');
1613 input_line_pointer
--; /* Put terminator back into stream. */
1614 demand_empty_rest_of_line ();
1617 /* Put the contents of expression EXP into the object file using
1618 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
1621 emit_expr (exp
, nbytes
)
1623 unsigned int nbytes
;
1628 /* Don't do anything if we are going to make another pass. */
1634 if (op
== O_absent
|| op
== O_illegal
)
1636 as_warn ("zero assumed for missing expression");
1637 exp
->X_add_number
= 0;
1640 else if (op
== O_big
)
1642 as_bad ("%s number invalid; zero assumed",
1643 exp
->X_add_number
> 0 ? "bignum" : "floating point");
1644 exp
->X_add_number
= 0;
1647 else if (op
== O_register
)
1649 as_warn ("register value used as expression");
1653 p
= frag_more (nbytes
);
1655 #ifndef WORKING_DOT_WORD
1656 /* If we have the difference of two symbols in a word, save it on
1657 the broken_words list. See the code in write.c. */
1658 if (op
== O_subtract
&& nbytes
== 2)
1660 struct broken_word
*x
;
1662 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
1663 x
->next_broken_word
= broken_words
;
1666 x
->word_goes_here
= p
;
1668 x
->add
= exp
->X_add_symbol
;
1669 x
->sub
= exp
->X_op_symbol
;
1670 x
->addnum
= exp
->X_add_number
;
1677 if (op
== O_constant
)
1682 register long unmask
;
1684 /* JF << of >= number of bits in the object is undefined. In
1685 particular SPARC (Sun 4) has problems */
1686 if (nbytes
>= sizeof (long))
1689 mask
= ~0 << (BITS_PER_CHAR
* nbytes
); /* Don't store these bits. */
1691 unmask
= ~mask
; /* Do store these bits. */
1694 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
1695 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
1698 get
= exp
->X_add_number
;
1700 if ((get
& mask
) != 0 && (get
& mask
) != mask
)
1701 { /* Leading bits contain both 0s & 1s. */
1702 as_warn ("Value 0x%x truncated to 0x%x.", get
, use
);
1704 md_number_to_chars (p
, use
, nbytes
); /* put bytes in right order. */
1708 md_number_to_chars (p
, (long) 0, nbytes
);
1710 /* Now we need to generate a fixS to record the symbol value.
1711 This is easy for BFD. For other targets it can be more
1712 complex. For very complex cases (currently, the HPPA and
1713 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
1714 want. For simpler cases, you can define TC_CONS_RELOC to be
1715 the name of the reloc code that should be stored in the fixS.
1716 If neither is defined, the code uses NO_RELOC if it is
1717 defined, and otherwise uses 0. */
1719 #ifdef BFD_ASSEMBLER
1720 #ifdef TC_CONS_FIX_NEW
1721 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
1723 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
, 0,
1724 /* @@ Should look at CPU word size. */
1725 nbytes
== 2 ? BFD_RELOC_16
1726 : nbytes
== 8 ? BFD_RELOC_64
1730 #ifdef TC_CONS_FIX_NEW
1731 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
1733 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
1734 it is defined, otherwise use NO_RELOC if it is defined,
1736 #ifndef TC_CONS_RELOC
1738 #define TC_CONS_RELOC NO_RELOC
1740 #define TC_CONS_RELOC 0
1743 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
, 0,
1745 #endif /* TC_CONS_FIX_NEW */
1746 #endif /* BFD_ASSEMBLER */
1750 #ifdef BITFIELD_CONS_EXPRESSIONS
1752 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
1753 w:x,y:z, where w and y are bitwidths and x and y are values. They
1754 then pack them all together. We do a little better in that we allow
1755 them in words, longs, etc. and we'll pack them in target byte order
1758 The rules are: pack least significat bit first, if a field doesn't
1759 entirely fit, put it in the next unit. Overflowing the bitfield is
1760 explicitly *not* even a warning. The bitwidth should be considered
1763 To use this function the tc-XXX.h file should define
1764 BITFIELD_CONS_EXPRESSIONS. */
1767 parse_bitfield_cons (exp
, nbytes
)
1769 unsigned int nbytes
;
1771 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
1772 char *hold
= input_line_pointer
;
1774 (void) expression (exp
);
1776 if (*input_line_pointer
== ':')
1782 unsigned long width
;
1784 if (*input_line_pointer
!= ':')
1786 input_line_pointer
= hold
;
1788 } /* next piece is not a bitfield */
1790 /* In the general case, we can't allow
1791 full expressions with symbol
1792 differences and such. The relocation
1793 entries for symbols not defined in this
1794 assembly would require arbitrary field
1795 widths, positions, and masks which most
1796 of our current object formats don't
1799 In the specific case where a symbol
1800 *is* defined in this assembly, we
1801 *could* build fixups and track it, but
1802 this could lead to confusion for the
1803 backends. I'm lazy. I'll take any
1804 SEG_ABSOLUTE. I think that means that
1805 you can use a previous .set or
1806 .equ type symbol. xoxorich. */
1808 if (exp
->X_op
== O_absent
)
1810 as_warn ("using a bit field width of zero");
1811 exp
->X_add_number
= 0;
1812 exp
->X_op
= O_constant
;
1813 } /* implied zero width bitfield */
1815 if (exp
->X_op
!= O_constant
)
1817 *input_line_pointer
= '\0';
1818 as_bad ("field width \"%s\" too complex for a bitfield", hold
);
1819 *input_line_pointer
= ':';
1820 demand_empty_rest_of_line ();
1824 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
1826 as_warn ("field width %d too big to fit in %d bytes: truncated to %d bits",
1827 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
1828 width
= BITS_PER_CHAR
* nbytes
;
1831 if (width
> bits_available
)
1833 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
1834 input_line_pointer
= hold
;
1835 exp
->X_add_number
= value
;
1839 hold
= ++input_line_pointer
; /* skip ':' */
1841 (void) expression (exp
);
1842 if (exp
->X_op
!= O_constant
)
1844 char cache
= *input_line_pointer
;
1846 *input_line_pointer
= '\0';
1847 as_bad ("field value \"%s\" too complex for a bitfield", hold
);
1848 *input_line_pointer
= cache
;
1849 demand_empty_rest_of_line ();
1853 value
|= ((~(-1 << width
) & exp
->X_add_number
)
1854 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
1856 if ((bits_available
-= width
) == 0
1857 || is_it_end_of_statement ()
1858 || *input_line_pointer
!= ',')
1861 } /* all the bitfields we're gonna get */
1863 hold
= ++input_line_pointer
;
1864 (void) expression (exp
);
1865 } /* forever loop */
1867 exp
->X_add_number
= value
;
1868 exp
->X_op
= O_constant
;
1869 } /* if looks like a bitfield */
1870 } /* parse_bitfield_cons() */
1872 #endif /* BITFIELD_CONS_EXPRESSIONS */
1877 parse_mri_cons (exp
, nbytes
)
1879 unsigned int nbytes
;
1881 if (*input_line_pointer
== '\'')
1883 /* An MRI style string, cut into as many bytes as will fit into
1884 a nbyte chunk, left justify if necessary, and separate with
1885 commas so we can try again later */
1887 unsigned int result
= 0;
1888 input_line_pointer
++;
1889 for (scan
= 0; scan
< nbytes
; scan
++)
1891 if (*input_line_pointer
== '\'')
1893 if (input_line_pointer
[1] == '\'')
1895 input_line_pointer
++;
1900 result
= (result
<< 8) | (*input_line_pointer
++);
1904 while (scan
< nbytes
)
1909 /* Create correct expression */
1910 exp
->X_op
= O_constant
;
1911 exp
->X_add_number
= result
;
1912 /* Fake it so that we can read the next char too */
1913 if (input_line_pointer
[0] != '\'' ||
1914 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
1916 input_line_pointer
-= 2;
1917 input_line_pointer
[0] = ',';
1918 input_line_pointer
[1] = '\'';
1921 input_line_pointer
++;
1929 #ifdef REPEAT_CONS_EXPRESSIONS
1931 /* Parse a repeat expression for cons. This is used by the MIPS
1932 assembler. The format is NUMBER:COUNT; NUMBER appears in the
1933 object file COUNT times.
1935 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
1938 parse_repeat_cons (exp
, nbytes
)
1940 unsigned int nbytes
;
1947 if (*input_line_pointer
!= ':')
1949 /* No repeat count. */
1953 ++input_line_pointer
;
1954 expression (&count
);
1955 if (count
.X_op
!= O_constant
1956 || count
.X_add_number
<= 0)
1958 as_warn ("Unresolvable or nonpositive repeat count; using 1");
1962 /* The cons function is going to output this expression once. So we
1963 output it count - 1 times. */
1964 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
1965 emit_expr (exp
, nbytes
);
1968 #endif /* REPEAT_CONS_EXPRESSIONS */
1973 * CONStruct more frag(s) of .quads, or .octa etc.
1974 * Makes 0 or more new frags.
1975 * If need_pass_2 == 1, generate no frag.
1976 * This understands only bignums, not expressions. Cons() understands
1979 * Constants recognised are '0...'(octal) '0x...'(hex) '...'(decimal).
1981 * This creates objects with struct obstack_control objs, destroying
1982 * any context objs held about a partially completed object. Beware!
1985 * I think it sucks to have 2 different types of integers, with 2
1986 * routines to read them, store them etc.
1987 * It would be nicer to permit bignums in expressions and only
1988 * complain if the result overflowed. However, due to "efficiency"...
1990 /* Worker to do .quad etc statements. Clobbers input_line_pointer, checks
1991 end-of-line. 8=.quad 16=.octa ... */
1995 register int nbytes
;
1997 register char c
; /* input_line_pointer->c. */
1999 register long length
; /* Number of chars in an object. */
2000 register int digit
; /* Value of 1 digit. */
2001 register int carry
; /* For multi-precision arithmetic. */
2002 register int work
; /* For multi-precision arithmetic. */
2003 register char *p
; /* For multi-precision arithmetic. */
2005 extern const char hex_value
[]; /* In hex_value.c. */
2008 * The following awkward logic is to parse ZERO or more strings,
2009 * comma seperated. Recall an expression includes its leading &
2010 * trailing blanks. We fake a leading ',' if there is (supposed to
2011 * be) a 1st expression, and keep demanding 1 expression for each ','.
2013 if (is_it_end_of_statement ())
2015 c
= 0; /* Skip loop. */
2019 c
= ','; /* Do loop. */
2020 --input_line_pointer
;
2024 ++input_line_pointer
;
2026 c
= *input_line_pointer
;
2027 /* C contains 1st non-blank character of what we hope is a number. */
2030 c
= *++input_line_pointer
;
2031 if (c
== 'x' || c
== 'X')
2033 c
= *++input_line_pointer
;
2046 * This feature (?) is here to stop people worrying about
2047 * mysterious zero constants: which is what they get when
2048 * they completely omit digits.
2050 if (hex_value
[c
] >= radix
)
2052 as_bad ("Missing digits. 0 assumed.");
2054 bignum_high
= bignum_low
- 1; /* Start constant with 0 chars. */
2055 for (; (digit
= hex_value
[c
]) < radix
; c
= *++input_line_pointer
)
2057 /* Multiply existing number by radix, then add digit. */
2059 for (p
= bignum_low
; p
<= bignum_high
; p
++)
2061 work
= (*p
& MASK_CHAR
) * radix
+ carry
;
2062 *p
= work
& MASK_CHAR
;
2063 carry
= work
>> BITS_PER_CHAR
;
2068 *bignum_high
= carry
& MASK_CHAR
;
2069 know ((carry
& ~MASK_CHAR
) == 0);
2072 length
= bignum_high
- bignum_low
+ 1;
2073 if (length
> nbytes
)
2075 as_warn ("Most significant bits truncated in integer constant.");
2079 register long leading_zeroes
;
2081 for (leading_zeroes
= nbytes
- length
;
2091 char *src
= bignum_low
;
2092 p
= frag_more (nbytes
);
2093 if (target_big_endian
)
2096 for (i
= nbytes
- 1; i
>= 0; i
--)
2100 memcpy (p
, bignum_low
, (int) nbytes
);
2102 /* C contains character after number. */
2104 c
= *input_line_pointer
;
2105 /* C contains 1st non-blank character after number. */
2107 demand_empty_rest_of_line ();
2110 /* Extend bignum by 1 char. */
2114 register long length
;
2117 if (bignum_high
>= bignum_limit
)
2119 length
= bignum_limit
- bignum_low
;
2120 bignum_low
= xrealloc (bignum_low
, length
+ length
);
2121 bignum_high
= bignum_low
+ length
;
2122 bignum_limit
= bignum_low
+ length
+ length
;
2124 } /* grow_bignum(); */
2129 * CONStruct some more frag chars of .floats .ffloats etc.
2130 * Makes 0 or more new frags.
2131 * If need_pass_2 == 1, no frags are emitted.
2132 * This understands only floating literals, not expressions. Sorry.
2134 * A floating constant is defined by atof_generic(), except it is preceded
2135 * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
2136 * reading, I decided to be incompatible. This always tries to give you
2137 * rounded bits to the precision of the pseudo-op. Former AS did premature
2138 * truncatation, restored noisy bits instead of trailing 0s AND gave you
2139 * a choice of 2 flavours of noise according to which of 2 floating-point
2140 * scanners you directed AS to use.
2142 * In: input_line_pointer->whitespace before, or '0' of flonum.
2147 float_cons (float_type
)
2148 /* Clobbers input_line-pointer, checks end-of-line. */
2149 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
2152 int length
; /* Number of chars in an object. */
2153 register char *err
; /* Error from scanning floating literal. */
2154 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
2156 if (is_it_end_of_statement ())
2158 demand_empty_rest_of_line ();
2164 /* input_line_pointer->1st char of a flonum (we hope!). */
2167 /* Skip any 0{letter} that may be present. Don't even check if the
2168 * letter is legal. Someone may invent a "z" format and this routine
2169 * has no use for such information. Lusers beware: you get
2170 * diagnostics if your input is ill-conditioned.
2172 if (input_line_pointer
[0] == '0' && isalpha (input_line_pointer
[1]))
2173 input_line_pointer
+= 2;
2175 err
= md_atof (float_type
, temp
, &length
);
2176 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
2180 as_bad ("Bad floating literal: %s", err
);
2181 ignore_rest_of_line ();
2191 #ifdef REPEAT_CONS_EXPRESSIONS
2192 if (*input_line_pointer
== ':')
2194 expressionS count_exp
;
2196 ++input_line_pointer
;
2197 expression (&count_exp
);
2198 if (count_exp
.X_op
!= O_constant
2199 || count_exp
.X_add_number
<= 0)
2201 as_warn ("unresolvable or nonpositive repeat count; using 1");
2204 count
= count_exp
.X_add_number
;
2208 while (--count
>= 0)
2210 p
= frag_more (length
);
2211 memcpy (p
, temp
, length
);
2216 while (*input_line_pointer
++ == ',');
2218 --input_line_pointer
; /* Put terminator back into stream. */
2219 demand_empty_rest_of_line ();
2220 } /* float_cons() */
2225 * We read 0 or more ',' seperated, double-quoted strings.
2227 * Caller should have checked need_pass_2 is FALSE because we don't check it.
2232 stringer (append_zero
) /* Worker to do .ascii etc statements. */
2233 /* Checks end-of-line. */
2234 register int append_zero
; /* 0: don't append '\0', else 1 */
2236 register unsigned int c
;
2239 * The following awkward logic is to parse ZERO or more strings,
2240 * comma seperated. Recall a string expression includes spaces
2241 * before the opening '\"' and spaces after the closing '\"'.
2242 * We fake a leading ',' if there is (supposed to be)
2243 * a 1st, expression. We keep demanding expressions for each
2246 if (is_it_end_of_statement ())
2248 c
= 0; /* Skip loop. */
2249 ++input_line_pointer
; /* Compensate for end of loop. */
2253 c
= ','; /* Do loop. */
2255 while (c
== ',' || c
== '<' || c
== '"')
2258 switch (*input_line_pointer
)
2261 ++input_line_pointer
; /*->1st char of string. */
2262 while (is_a_char (c
= next_char_of_string ()))
2264 FRAG_APPEND_1_CHAR (c
);
2268 FRAG_APPEND_1_CHAR (0);
2270 know (input_line_pointer
[-1] == '\"');
2273 input_line_pointer
++;
2274 c
= get_single_number ();
2275 FRAG_APPEND_1_CHAR (c
);
2276 if (*input_line_pointer
!= '>')
2278 as_bad ("Expected <nn>");
2280 input_line_pointer
++;
2283 input_line_pointer
++;
2287 c
= *input_line_pointer
;
2290 demand_empty_rest_of_line ();
2293 /* FIXME-SOMEDAY: I had trouble here on characters with the
2294 high bits set. We'll probably also have trouble with
2295 multibyte chars, wide chars, etc. Also be careful about
2296 returning values bigger than 1 byte. xoxorich. */
2299 next_char_of_string ()
2301 register unsigned int c
;
2303 c
= *input_line_pointer
++ & CHAR_MASK
;
2311 switch (c
= *input_line_pointer
++)
2341 break; /* As itself. */
2356 for (number
= 0; isdigit (c
); c
= *input_line_pointer
++)
2358 number
= number
* 8 + c
- '0';
2362 --input_line_pointer
;
2366 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
2367 as_warn ("Unterminated string: Newline inserted.");
2373 #ifdef ONLY_STANDARD_ESCAPES
2374 as_bad ("Bad escaped character in string, '?' assumed");
2376 #endif /* ONLY_STANDARD_ESCAPES */
2379 } /* switch on escaped char */
2384 } /* switch on char */
2386 } /* next_char_of_string() */
2389 get_segmented_expression (expP
)
2390 register expressionS
*expP
;
2392 register segT retval
;
2394 retval
= expression (expP
);
2395 if (expP
->X_op
== O_illegal
2396 || expP
->X_op
== O_absent
2397 || expP
->X_op
== O_big
)
2399 as_bad ("expected address expression; zero assumed");
2400 expP
->X_op
= O_constant
;
2401 expP
->X_add_number
= 0;
2402 retval
= absolute_section
;
2408 get_known_segmented_expression (expP
)
2409 register expressionS
*expP
;
2411 register segT retval
;
2413 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
2415 /* There is no easy way to extract the undefined symbol from the
2417 if (expP
->X_add_symbol
!= NULL
2418 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
2419 as_warn ("symbol \"%s\" undefined; zero assumed",
2420 S_GET_NAME (expP
->X_add_symbol
));
2422 as_warn ("some symbol undefined; zero assumed");
2423 retval
= absolute_section
;
2424 expP
->X_op
= O_constant
;
2425 expP
->X_add_number
= 0;
2427 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
2429 } /* get_known_segmented_expression() */
2431 /* static */ long /* JF was static, but can't be if the MD pseudos are to use it */
2432 get_absolute_expression ()
2437 if (exp
.X_op
!= O_constant
)
2439 if (exp
.X_op
!= O_absent
)
2440 as_bad ("bad absolute expression; zero assumed");
2441 exp
.X_add_number
= 0;
2443 return exp
.X_add_number
;
2446 char /* return terminator */
2447 get_absolute_expression_and_terminator (val_pointer
)
2448 long *val_pointer
; /* return value of expression */
2450 *val_pointer
= get_absolute_expression ();
2451 return (*input_line_pointer
++);
2455 * demand_copy_C_string()
2457 * Like demand_copy_string, but return NULL if the string contains any '\0's.
2458 * Give a warning if that happens.
2461 demand_copy_C_string (len_pointer
)
2466 if ((s
= demand_copy_string (len_pointer
)) != 0)
2470 for (len
= *len_pointer
;
2479 as_bad ("This string may not contain \'\\0\'");
2487 * demand_copy_string()
2489 * Demand string, but return a safe (=private) copy of the string.
2490 * Return NULL if we can't read a string here.
2493 demand_copy_string (lenP
)
2496 register unsigned int c
;
2502 if (*input_line_pointer
== '\"')
2504 input_line_pointer
++; /* Skip opening quote. */
2506 while (is_a_char (c
= next_char_of_string ()))
2508 obstack_1grow (¬es
, c
);
2511 /* JF this next line is so demand_copy_C_string will return a null
2512 termanated string. */
2513 obstack_1grow (¬es
, '\0');
2514 retval
= obstack_finish (¬es
);
2518 as_warn ("Missing string");
2520 ignore_rest_of_line ();
2524 } /* demand_copy_string() */
2527 * is_it_end_of_statement()
2529 * In: Input_line_pointer->next character.
2531 * Do: Skip input_line_pointer over all whitespace.
2533 * Out: 1 if input_line_pointer->end-of-line.
2536 is_it_end_of_statement ()
2539 return (is_end_of_line
[*input_line_pointer
]);
2540 } /* is_it_end_of_statement() */
2546 register symbolS
*symbolP
; /* symbol we are working with */
2548 input_line_pointer
++;
2549 if (*input_line_pointer
== '=')
2550 input_line_pointer
++;
2552 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
2553 input_line_pointer
++;
2555 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
2557 /* Turn '. = mumble' into a .org mumble */
2558 register segT segment
;
2562 segment
= get_known_segmented_expression (&exp
);
2565 if (segment
!= now_seg
&& segment
!= absolute_section
)
2566 as_warn ("Illegal segment \"%s\". Segment \"%s\" assumed.",
2567 segment_name (segment
),
2568 segment_name (now_seg
));
2569 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
.X_add_symbol
,
2570 exp
.X_add_number
, (char *) 0);
2572 } /* if (ok to make frag) */
2576 symbolP
= symbol_find_or_make (sym_name
);
2577 pseudo_set (symbolP
);
2581 /* .include -- include a file at this point. */
2594 filename
= demand_copy_string (&i
);
2595 demand_empty_rest_of_line ();
2596 path
= xmalloc (i
+ include_dir_maxlen
+ 5 /* slop */ );
2597 for (i
= 0; i
< include_dir_count
; i
++)
2599 strcpy (path
, include_dirs
[i
]);
2601 strcat (path
, filename
);
2602 if (0 != (try = fopen (path
, "r")))
2611 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
2612 newbuf
= input_scrub_include_file (path
, input_line_pointer
);
2613 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2617 add_include_dir (path
)
2622 if (include_dir_count
== 0)
2624 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
2625 include_dirs
[0] = "."; /* Current dir */
2626 include_dir_count
= 2;
2630 include_dir_count
++;
2631 include_dirs
= (char **) realloc (include_dirs
,
2632 include_dir_count
* sizeof (*include_dirs
));
2635 include_dirs
[include_dir_count
- 1] = path
; /* New one */
2638 if (i
> include_dir_maxlen
)
2639 include_dir_maxlen
= i
;
2640 } /* add_include_dir() */
2646 while (!is_end_of_line
[*input_line_pointer
])
2648 ++input_line_pointer
;
2650 ++input_line_pointer
;
2656 * Handle .stabX directives, which used to be open-coded.
2657 * So much creeping featurism overloaded the semantics that we decided
2658 * to put all .stabX thinking in one place. Here.
2660 * We try to make any .stabX directive legal. Other people's AS will often
2661 * do assembly-time consistency checks: eg assigning meaning to n_type bits
2662 * and "protecting" you from setting them to certain values. (They also zero
2663 * certain bits before emitting symbols. Tut tut.)
2665 * If an expression is not absolute we either gripe or use the relocation
2666 * information. Other people's assemblers silently forget information they
2667 * don't need and invent information they need that you didn't supply.
2671 change_to_section (name
, len
, exp
)
2676 #ifndef BFD_ASSEMBLER
2677 #ifdef MANY_SEGMENTS
2679 extern segment_info_type segment_info
[];
2681 /* Find out if we've already got a section of this name etc */
2682 for (i
= SEG_E0
; i
< SEG_E9
&& segment_info
[i
].scnhdr
.s_name
[0]; i
++)
2684 if (strncmp (segment_info
[i
].scnhdr
.s_name
, name
, len
) == 0)
2686 subseg_new (i
, exp
);
2690 /* No section, add one */
2691 strncpy (segment_info
[i
].scnhdr
.s_name
, name
, 8);
2692 segment_info
[i
].scnhdr
.s_flags
= 0 /* STYP_NOLOAD */;
2693 subseg_new (i
, exp
);
2699 * Build a string dictionary entry for a .stabX symbol.
2700 * The symbol is added to the .<secname>str section.
2704 get_stab_string_offset (string
, secname
)
2705 char *string
, *secname
;
2709 subsegT save_subseg
;
2710 unsigned int length
;
2711 unsigned int old_gdb_string_index
;
2715 /* @@FIXME -- there should be no static data here!
2716 This also has the effect of making all stab string tables large enough
2717 to contain all the contents written to any of them. This only matters
2718 with the Solaris native compiler for the moment, but it should be fixed
2720 static unsigned int gdb_string_index
= 0;
2722 old_gdb_string_index
= 0;
2723 length
= strlen (string
);
2724 clengthP
= (char *) &length
;
2726 { /* Ordinary case. */
2728 save_subseg
= now_subseg
;
2730 /* Create the stabstr sections, if they are not already created. */
2732 char *newsecname
= xmalloc (strlen (secname
) + 4);
2733 strcpy (newsecname
, secname
);
2734 strcat (newsecname
, "str");
2735 #ifdef BFD_ASSEMBLER
2736 seg
= bfd_get_section_by_name (stdoutput
, newsecname
);
2739 seg
= bfd_make_section_old_way (stdoutput
, newsecname
);
2740 bfd_set_section_flags (stdoutput
, seg
, SEC_READONLY
| SEC_ALLOC
);
2743 change_to_section(newsecname
, strlen(newsecname
), 0);
2745 /* free (newsecname);*/
2747 #ifdef BFD_ASSEMBLER
2748 subseg_set (seg
, save_subseg
);
2750 /* subseg_new (seg, save_subseg); */
2752 old_gdb_string_index
= gdb_string_index
;
2754 while ((c
= *string
++))
2758 FRAG_APPEND_1_CHAR (c
);
2761 FRAG_APPEND_1_CHAR ((char) 0);
2767 FRAG_APPEND_1_CHAR ((char) 0);
2771 #ifdef BFD_ASSEMBLER
2772 subseg_set (save_seg
, save_subseg
);
2774 /* subseg_new (save_seg, save_subseg); */
2777 return old_gdb_string_index
;
2780 /* This can handle different kinds of stabs (s,n,d) and different
2781 kinds of stab sections. */
2784 s_stab_generic (what
, secname
)
2797 segT saved_seg
= now_seg
;
2799 subsegT saved_subseg
= now_subseg
;
2805 valu
= ((char *) obstack_next_free (&frags
)) - frag_now
->fr_literal
;
2807 #ifdef SEPARATE_STAB_SECTIONS
2808 #ifdef BFD_ASSEMBLER
2809 seg
= bfd_get_section_by_name (stdoutput
, secname
);
2812 seg
= subseg_new (secname
, 0);
2813 bfd_set_section_flags (stdoutput
, seg
,
2814 SEC_READONLY
| SEC_ALLOC
| SEC_RELOC
);
2815 subseg_set (saved_seg
, subseg
);
2819 change_to_section (secname
, strlen(secname
), 0);
2821 #endif /* SEPARATE_STAB_SECTIONS */
2824 * Enter with input_line_pointer pointing past .stabX and any following
2829 string
= demand_copy_C_string (&length
);
2831 if (*input_line_pointer
== ',')
2832 input_line_pointer
++;
2835 as_bad ("I need a comma after symbol's name");
2843 * Input_line_pointer->after ','. String->symbol name.
2847 #ifdef MAKE_STAB_SYMBOL
2848 MAKE_STAB_SYMBOL(symbol
, string
, secname
);
2850 symbol
= symbol_new (string
, undefined_section
, 0, (struct frag
*) 0);
2852 /* Make sure that the rest of this is going to work. */
2854 as_fatal ("no stab symbol created");
2859 S_SET_NAME (symbol
, NULL
); /* .stabd feature. */
2860 #ifdef STAB_SYMBOL_SET_VALUE
2861 STAB_SYMBOL_SET_VALUE (symbol
, valu
);
2863 S_SET_VALUE (symbol
, valu
);
2865 #if STAB_SYMBOL_SET_SEGMENT
2867 S_SET_SEGMENT (symbol
, now_seg
);
2869 symbol
->sy_frag
= frag_now
;
2873 symbol
->sy_frag
= &zero_address_frag
;
2877 symbol
->sy_frag
= &zero_address_frag
;
2885 if (get_absolute_expression_and_terminator (&longint
) == ',')
2887 saved_type
= longint
;
2888 S_SET_TYPE (symbol
, saved_type
);
2892 as_bad ("I want a comma after the n_type expression");
2894 input_line_pointer
--; /* Backup over a non-',' char. */
2900 if (get_absolute_expression_and_terminator (&longint
) == ',')
2901 S_SET_OTHER (symbol
, longint
);
2904 as_bad ("I want a comma after the n_other expression");
2906 input_line_pointer
--; /* Backup over a non-',' char. */
2912 S_SET_DESC (symbol
, get_absolute_expression ());
2913 if (what
== 's' || what
== 'n')
2915 if (*input_line_pointer
!= ',')
2917 as_bad ("I want a comma after the n_desc expression");
2922 input_line_pointer
++;
2927 /* Line is messed up - ignore it and get out of here. */
2930 ignore_rest_of_line ();
2931 #ifdef BFD_ASSEMBLER
2932 subseg_set (saved_seg
, saved_subseg
);
2934 subseg_new (saved_seg
, saved_subseg
);
2939 #ifdef BFD_ASSEMBLER
2940 subseg_set (seg
, subseg
);
2943 #if 0 /* needed for elf only? */
2945 /* allocate and discard -- filled in later */
2946 (void) frag_more (12);
2949 #ifdef SEPARATE_STAB_SECTIONS
2950 change_to_section(secname
, strlen(secname
), 0);
2951 toP
= frag_more (8);
2952 /* the string index portion of the stab */
2953 md_number_to_chars (toP
, (valueT
) S_GET_OFFSET_2(symbol
), 4);
2954 md_number_to_chars (toP
+ 4, (valueT
) S_GET_TYPE(symbol
), 1);
2955 md_number_to_chars (toP
+ 5, (valueT
) S_GET_OTHER(symbol
), 1);
2956 md_number_to_chars (toP
+ 6, (valueT
) S_GET_DESC(symbol
), 2);
2959 #ifdef SEPARATE_STAB_SECTIONS
2960 if (what
== 's' || what
== 'n')
2963 input_line_pointer
--;
2967 char *p
= frag_more (4);
2968 md_number_to_chars (p
, 0, 4);
2970 #ifdef BFD_ASSEMBLER
2971 subseg_set (saved_seg
, subseg
);
2973 /* subseg_new (saved_seg, subseg); */
2976 if (what
== 's' || what
== 'n')
2978 pseudo_set (symbol
);
2979 S_SET_TYPE (symbol
, saved_type
);
2983 #if 0 /* for elf only? */
2984 if (what
== 's' && S_GET_TYPE (symbol
) == N_SO
)
2986 fragS
*fragp
= seg_info (seg
)->frchainP
->frch_root
;
2988 && fragp
->fr_address
+ fragp
->fr_fix
< 12)
2989 fragp
= fragp
->fr_next
;
2990 assert (fragp
!= 0);
2991 assert (fragp
->fr_type
== rs_fill
);
2992 assert (fragp
->fr_address
== 0 && fragp
->fr_fix
>= 12);
2993 md_number_to_chars (fragp
->fr_literal
, (valueT
) symbol
->sy_name_offset
,
3000 switch (S_GET_TYPE (symbol
))
3003 listing_source_line (S_GET_DESC (symbol
));
3007 listing_source_file (string
);
3010 #endif /* !NO_LISTING */
3012 #ifdef SEPARATE_STAB_SECTIONS
3013 subseg_new (saved_seg
, saved_subseg
);
3016 demand_empty_rest_of_line ();
3019 /* Regular stab directive. */
3025 s_stab_generic (what
, ".stab");
3028 /* "Extended stabs", used in Solaris only now. */
3037 secname
= demand_copy_C_string (&length
);
3039 if (*input_line_pointer
== ',')
3040 input_line_pointer
++;
3043 as_bad ("comma missing in .xstabs");
3044 ignore_rest_of_line ();
3047 s_stab_generic (what
, secname
);
3050 /* Frob invented at RMS' request. Set the n_desc of a symbol. */
3061 name
= input_line_pointer
;
3062 c
= get_symbol_end ();
3063 p
= input_line_pointer
;
3066 if (*input_line_pointer
!= ',')
3069 as_bad ("Expected comma after name \"%s\"", name
);
3071 ignore_rest_of_line ();
3075 input_line_pointer
++;
3076 temp
= get_absolute_expression ();
3078 symbolP
= symbol_find_or_make (name
);
3080 S_SET_DESC (symbolP
, temp
);
3082 demand_empty_rest_of_line ();