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 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
163 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
164 static void grow_bignum
PARAMS ((void));
165 static void pobegin
PARAMS ((void));
176 obj_read_begin_hook ();
178 /* Something close -- but not too close -- to a multiple of 1024.
179 The debugging malloc I'm using has 24 bytes of overhead. */
180 obstack_begin (¬es
, 5090);
181 obstack_begin (&cond_obstack
, 990);
183 #define BIGNUM_BEGIN_SIZE (16)
184 bignum_low
= xmalloc ((long) BIGNUM_BEGIN_SIZE
);
185 bignum_limit
= bignum_low
+ BIGNUM_BEGIN_SIZE
;
187 /* Use machine dependent syntax */
188 for (p
= line_separator_chars
; *p
; p
++)
189 is_end_of_line
[(unsigned char) *p
] = 1;
190 /* Use more. FIXME-SOMEDAY. */
193 /* set up pseudo-op tables */
195 struct hash_control
*po_hash
;
197 static const pseudo_typeS potable
[] =
199 {"abort", s_abort
, 0},
200 {"align", s_align_ptwo
, 0},
201 {"ascii", stringer
, 0},
202 {"asciz", stringer
, 1},
209 {"double", float_cons
, 'd'},
211 {"eject", listing_eject
, 0}, /* Formfeed listing */
214 {"endif", s_endif
, 0},
219 {"extern", s_ignore
, 0}, /* We treat all undef as ext */
220 {"appfile", s_app_file
, 1},
221 {"appline", s_app_line
, 0},
222 {"file", s_app_file
, 0},
224 {"float", float_cons
, 'f'},
225 {"global", s_globl
, 0},
226 {"globl", s_globl
, 0},
229 {"ifdef", s_ifdef
, 0},
230 {"ifeqs", s_ifeqs
, 0},
231 {"ifndef", s_ifdef
, 1},
232 {"ifnes", s_ifeqs
, 1},
233 {"ifnotdef", s_ifdef
, 1},
234 {"include", s_include
, 0},
236 {"lcomm", s_lcomm
, 0},
237 {"lflags", listing_flags
, 0}, /* Listing flags */
238 {"list", listing_list
, 1}, /* Turn listing on */
241 {"nolist", listing_list
, 0}, /* Turn listing off */
242 {"octa", big_cons
, 16},
244 {"psize", listing_psize
, 0}, /* set paper size */
246 {"quad", big_cons
, 8},
247 {"sbttl", listing_title
, 1}, /* Subtitle of listing */
252 {"single", float_cons
, 'f'},
254 {"space", s_space
, 0},
255 {"stabd", s_stab
, 'd'},
256 {"stabn", s_stab
, 'n'},
257 {"stabs", s_stab
, 's'},
258 {"string", stringer
, 1},
261 {"title", listing_title
, 0}, /* Listing title */
265 {"xstabs", s_xstab
, 's'},
267 {NULL
} /* end sentinel */
273 char *errtxt
; /* error text */
274 const pseudo_typeS
*pop
;
276 po_hash
= hash_new ();
278 /* Do the target-specific pseudo ops. */
279 for (pop
= md_pseudo_table
; pop
->poc_name
; pop
++)
281 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
282 if (errtxt
&& *errtxt
)
284 as_fatal ("error constructing md pseudo-op table");
288 /* Now object specific. Skip any that were in the target table. */
289 for (pop
= obj_pseudo_table
; pop
->poc_name
; pop
++)
291 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
292 if (errtxt
&& *errtxt
)
294 if (!strcmp (errtxt
, "exists"))
296 #ifdef DIE_ON_OVERRIDES
297 as_fatal ("pseudo op \".%s\" overridden.\n", pop
->poc_name
);
298 #endif /* DIE_ON_OVERRIDES */
299 continue; /* OK if target table overrides. */
303 as_fatal ("error constructing obj pseudo-op table");
304 } /* if overridden */
308 /* Now portable ones. Skip any that we've seen already. */
309 for (pop
= potable
; pop
->poc_name
; pop
++)
311 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
312 if (errtxt
&& *errtxt
)
314 if (!strcmp (errtxt
, "exists"))
316 #ifdef DIE_ON_OVERRIDES
317 as_fatal ("pseudo op \".%s\" overridden.\n", pop
->poc_name
);
318 #endif /* DIE_ON_OVERRIDES */
319 continue; /* OK if target table overrides. */
323 as_fatal ("error constructing obj pseudo-op table");
324 } /* if overridden */
331 #define HANDLE_CONDITIONAL_ASSEMBLY() \
332 if (ignore_input ()) \
334 while (! is_end_of_line[(unsigned char) *input_line_pointer++]) \
335 if (input_line_pointer == buffer_limit) \
341 /* read_a_source_file()
343 * We read the file, putting things into a web that
344 * represents what we have been reading.
347 read_a_source_file (name
)
351 register char *s
; /* string of symbol, '\0' appended */
355 buffer
= input_scrub_new_file (name
);
358 listing_newline ("");
360 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
361 { /* We have another line to parse. */
362 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
363 contin
: /* JF this goto is my fault I admit it.
364 Someone brave please re-write the whole
365 input section here? Pleeze??? */
366 while (input_line_pointer
< buffer_limit
)
368 /* We have more of this buffer to parse. */
371 * We now have input_line_pointer->1st char of next line.
372 * If input_line_pointer [-1] == '\n' then we just
373 * scanned another line: so bump line counters.
375 if (input_line_pointer
[-1] == '\n')
377 bump_line_counters ();
380 /* Text at the start of a line must be a label, we run down and stick a colon in */
381 if (is_name_beginner (*input_line_pointer
))
383 char *line_start
= input_line_pointer
;
384 char c
= get_symbol_end ();
386 *input_line_pointer
= c
;
388 input_line_pointer
++;
396 * We are at the begining of a line, or similar place.
397 * We expect a well-formed assembler statement.
398 * A "symbol-name:" is a statement.
400 * Depending on what compiler is used, the order of these tests
401 * may vary to catch most common case 1st.
402 * Each test is independent of all other tests at the (top) level.
403 * PLEASE make a compiler that doesn't use this assembler.
404 * It is crufty to waste a compiler's time encoding things for this
405 * assembler, which then wastes more time decoding it.
406 * (And communicating via (linear) files is silly!
407 * If you must pass stuff, please pass a tree!)
409 if ((c
= *input_line_pointer
++) == '\t'
414 c
= *input_line_pointer
++;
416 know (c
!= ' '); /* No further leading whitespace. */
419 * C is the 1st significant character.
420 * Input_line_pointer points after that character.
422 if (is_name_beginner (c
))
423 { /* want user-defined label or pseudo/opcode */
424 HANDLE_CONDITIONAL_ASSEMBLY ();
426 s
= --input_line_pointer
;
427 c
= get_symbol_end (); /* name's delimiter */
429 * C is character after symbol.
430 * That character's place in the input line is now '\0'.
431 * S points to the beginning of the symbol.
432 * [In case of pseudo-op, s->'.'.]
433 * Input_line_pointer->'\0' where c was.
435 if (TC_START_LABEL(c
, input_line_pointer
))
437 colon (s
); /* user-defined label */
438 *input_line_pointer
++ = ':'; /* Put ':' back for error messages' sake. */
439 /* Input_line_pointer->after ':'. */
445 || (input_line_pointer
[1] == '='
446 #ifdef TC_EQUAL_IN_INSN
447 && ! TC_EQUAL_IN_INSN (c
, input_line_pointer
)
452 demand_empty_rest_of_line ();
455 { /* expect pseudo-op or machine instruction */
457 if (!done_pseudo (s
))
464 /* The m88k uses pseudo-ops without a period. */
465 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
466 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
470 if (pop
!= NULL
|| *s
== '.')
475 * WARNING: c has next char, which may be end-of-line.
476 * We lookup the pseudo-op table with s+1 because we
477 * already know that the pseudo-op begins with a '.'.
481 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
483 /* Print the error msg now, while we still can */
486 as_bad ("Unknown pseudo-op: `%s'", s
);
487 *input_line_pointer
= c
;
492 /* Put it back for error messages etc. */
493 *input_line_pointer
= c
;
494 /* The following skip of whitespace is compulsory.
495 A well shaped space is sometimes all that separates
496 keyword from operands. */
497 if (c
== ' ' || c
== '\t')
499 input_line_pointer
++;
500 } /* Skip seperator after keyword. */
502 * Input_line is restored.
503 * Input_line_pointer->1st non-blank char
504 * after pseudo-operation.
508 ignore_rest_of_line ();
513 (*pop
->poc_handler
) (pop
->poc_val
);
514 } /* if we have one */
518 { /* machine instruction */
519 /* WARNING: c has char, which may be end-of-line. */
520 /* Also: input_line_pointer->`\0` where c was. */
521 *input_line_pointer
= c
;
522 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
523 #ifdef TC_EOL_IN_INSN
524 || TC_EOL_IN_INSN (input_line_pointer
)
528 input_line_pointer
++;
531 c
= *input_line_pointer
;
532 *input_line_pointer
= '\0';
534 md_assemble (s
); /* Assemble 1 instruction. */
536 *input_line_pointer
++ = c
;
538 /* We resume loop AFTER the end-of-line from this instruction */
543 } /* if (is_name_beginner(c) */
546 if (is_end_of_line
[(unsigned char) c
])
549 } /* empty statement */
552 #if defined(LOCAL_LABELS_DOLLAR) || defined(LOCAL_LABELS_FB)
554 { /* local label ("4:") */
555 char *backup
= input_line_pointer
;
557 HANDLE_CONDITIONAL_ASSEMBLY ();
561 while (isdigit (*input_line_pointer
))
563 temp
= (temp
* 10) + *input_line_pointer
- '0';
564 ++input_line_pointer
;
565 } /* read the whole number */
567 #ifdef LOCAL_LABELS_DOLLAR
568 if (*input_line_pointer
== '$'
569 && *(input_line_pointer
+ 1) == ':')
571 input_line_pointer
+= 2;
573 if (dollar_label_defined (temp
))
575 as_fatal ("label \"%d$\" redefined", temp
);
578 define_dollar_label (temp
);
579 colon (dollar_label_name (temp
, 0));
582 #endif /* LOCAL_LABELS_DOLLAR */
584 #ifdef LOCAL_LABELS_FB
585 if (*input_line_pointer
++ == ':')
587 fb_label_instance_inc (temp
);
588 colon (fb_label_name (temp
, 0));
591 #endif /* LOCAL_LABELS_FB */
593 input_line_pointer
= backup
;
594 } /* local label ("4:") */
595 #endif /* LOCAL_LABELS_DOLLAR or LOCAL_LABELS_FB */
597 if (c
&& strchr (line_comment_chars
, c
))
598 { /* Its a comment. Better say APP or NO_APP */
604 extern char *scrub_string
, *scrub_last_string
;
606 bump_line_counters ();
607 s
= input_line_pointer
;
608 if (strncmp (s
, "APP\n", 4))
609 continue; /* We ignore it */
612 ends
= strstr (s
, "#NO_APP\n");
619 /* The end of the #APP wasn't in this buffer. We
620 keep reading in buffers until we find the #NO_APP
621 that goes with this #APP There is one. The specs
623 tmp_len
= buffer_limit
- s
;
624 tmp_buf
= xmalloc (tmp_len
+ 1);
625 memcpy (tmp_buf
, s
, tmp_len
);
628 new_tmp
= input_scrub_next_buffer (&buffer
);
632 buffer_limit
= new_tmp
;
633 input_line_pointer
= buffer
;
634 ends
= strstr (buffer
, "#NO_APP\n");
638 num
= buffer_limit
- buffer
;
640 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
641 memcpy (tmp_buf
, buffer
+ tmp_len
, num
);
646 input_line_pointer
= ends
? ends
+ 8 : NULL
;
654 input_line_pointer
= ends
+ 8;
656 new_buf
= xmalloc (100);
661 scrub_last_string
= ends
;
666 ch
= do_scrub_next_char (scrub_from_string
, scrub_to_string
);
670 if (new_tmp
== new_buf
+ new_length
)
672 new_buf
= xrealloc (new_buf
, new_length
+ 100);
673 new_tmp
= new_buf
+ new_length
;
681 old_input
= input_line_pointer
;
682 old_limit
= buffer_limit
;
684 input_line_pointer
= new_buf
;
685 buffer_limit
= new_tmp
;
689 HANDLE_CONDITIONAL_ASSEMBLY ();
691 /* as_warn("Junk character %d.",c); Now done by ignore_rest */
692 input_line_pointer
--; /* Report unknown char as ignored. */
693 ignore_rest_of_line ();
694 } /* while (input_line_pointer<buffer_limit) */
697 bump_line_counters ();
701 input_line_pointer
= old_input
;
702 buffer_limit
= old_limit
;
707 } /* while (more buffers to scan) */
708 input_scrub_close (); /* Close the input file */
710 } /* read_a_source_file() */
715 as_fatal (".abort detected. Abandoning ship.");
718 /* For machines where ".align 4" means align to a 4 byte boundary. */
723 register unsigned int temp
;
724 register long temp_fill
;
726 unsigned long max_alignment
= 1 << 15;
728 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
729 temp
= arg
; /* Default value from pseudo-op table */
731 temp
= get_absolute_expression ();
733 if (temp
> max_alignment
)
735 as_bad ("Alignment too large: %d. assumed.", temp
= max_alignment
);
739 * For the sparc, `.align (1<<n)' actually means `.align n'
740 * so we have to convert it.
744 for (i
= 0; (temp
& 1) == 0; temp
>>= 1, ++i
)
748 as_bad ("Alignment not a power of 2");
751 if (*input_line_pointer
== ',')
753 input_line_pointer
++;
754 temp_fill
= get_absolute_expression ();
756 else if (now_seg
!= data_section
&& now_seg
!= bss_section
)
757 temp_fill
= NOP_OPCODE
;
760 /* Only make a frag if we HAVE to. . . */
761 if (temp
&& !need_pass_2
)
762 frag_align (temp
, (int) temp_fill
);
764 record_alignment (now_seg
, temp
);
766 demand_empty_rest_of_line ();
767 } /* s_align_bytes() */
769 /* For machines where ".align 4" means align to 2**4 boundary. */
774 register long temp_fill
;
775 long max_alignment
= 15;
777 temp
= get_absolute_expression ();
778 if (temp
> max_alignment
)
779 as_bad ("Alignment too large: %d. assumed.", temp
= max_alignment
);
782 as_bad ("Alignment negative. 0 assumed.");
785 if (*input_line_pointer
== ',')
787 input_line_pointer
++;
788 temp_fill
= get_absolute_expression ();
790 /* @@ Fix this right for BFD! */
791 else if (now_seg
!= data_section
&& now_seg
!= bss_section
)
792 temp_fill
= NOP_OPCODE
;
795 /* Only make a frag if we HAVE to. . . */
796 if (temp
&& !need_pass_2
)
797 frag_align (temp
, (int) temp_fill
);
799 record_alignment (now_seg
, temp
);
801 demand_empty_rest_of_line ();
802 } /* s_align_ptwo() */
811 register symbolS
*symbolP
;
813 name
= input_line_pointer
;
814 c
= get_symbol_end ();
815 /* just after name is now '\0' */
816 p
= input_line_pointer
;
819 if (*input_line_pointer
!= ',')
821 as_bad ("Expected comma after symbol-name: rest of line ignored.");
822 ignore_rest_of_line ();
825 input_line_pointer
++; /* skip ',' */
826 if ((temp
= get_absolute_expression ()) < 0)
828 as_warn (".COMMon length (%ld.) <0! Ignored.", (long) temp
);
829 ignore_rest_of_line ();
833 symbolP
= symbol_find_or_make (name
);
835 if (S_IS_DEFINED (symbolP
))
837 as_bad ("Ignoring attempt to re-define symbol");
838 ignore_rest_of_line ();
841 if (S_GET_VALUE (symbolP
))
843 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
844 as_bad ("Length of .comm \"%s\" is already %ld. Not changed to %ld.",
845 S_GET_NAME (symbolP
),
846 (long) S_GET_VALUE (symbolP
),
851 S_SET_VALUE (symbolP
, (valueT
) temp
);
852 S_SET_EXTERNAL (symbolP
);
855 if ( (!temp
) || !flagseen
['1'])
856 S_GET_OTHER(symbolP
) = const_flag
;
857 #endif /* not OBJ_VMS */
858 know (symbolP
->sy_frag
== &zero_address_frag
);
859 demand_empty_rest_of_line ();
868 temp
= get_absolute_expression ();
871 section
= text_section
;
875 section
= data_section
;
878 subseg_set (section
, (subsegT
) temp
);
880 subseg_new (section
, (subsegT
) temp
);
886 demand_empty_rest_of_line ();
889 /* Handle the .appfile pseudo-op. This is automatically generated by
890 do_scrub_next_char when a preprocessor # line comment is seen with
891 a file name. This default definition may be overridden by the
892 object or CPU specific pseudo-ops. This function is also the
893 default definition for .file; the APPFILE argument is 1 for
894 .appfile, 0 for .file. */
903 /* Some assemblers tolerate immediately following '"' */
904 if ((s
= demand_copy_string (&length
)) != 0)
906 /* If this is a fake .appfile, a fake newline was inserted into
907 the buffer. Passing -2 to new_logical_line tells it to
909 new_logical_line (s
, appfile
? -2 : -1);
910 demand_empty_rest_of_line ();
913 listing_source_file (s
);
917 c_dot_file_symbol (s
);
918 #endif /* OBJ_COFF */
924 /* Handle the .appline pseudo-op. This is automatically generated by
925 do_scrub_next_char when a preprocessor # line comment is seen.
926 This default definition may be overridden by the object or CPU
927 specific pseudo-ops. */
934 /* The given number is that of the next line. */
935 l
= get_absolute_expression () - 1;
936 new_logical_line ((char *) NULL
, l
);
939 listing_source_line (l
);
941 demand_empty_rest_of_line ();
947 long temp_repeat
= 0;
949 register long temp_fill
= 0;
953 temp_repeat
= get_absolute_expression ();
954 if (*input_line_pointer
== ',')
956 input_line_pointer
++;
957 temp_size
= get_absolute_expression ();
958 if (*input_line_pointer
== ',')
960 input_line_pointer
++;
961 temp_fill
= get_absolute_expression ();
964 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
965 #define BSD_FILL_SIZE_CROCK_8 (8)
966 if (temp_size
> BSD_FILL_SIZE_CROCK_8
)
968 as_warn (".fill size clamped to %d.", BSD_FILL_SIZE_CROCK_8
);
969 temp_size
= BSD_FILL_SIZE_CROCK_8
;
973 as_warn ("Size negative: .fill ignored.");
976 else if (temp_repeat
<= 0)
978 as_warn ("Repeat < 0, .fill ignored");
982 if (temp_size
&& !need_pass_2
)
984 p
= frag_var (rs_fill
, (int) temp_size
, (int) temp_size
, (relax_substateT
) 0, (symbolS
*) 0, temp_repeat
, (char *) 0);
985 memset (p
, 0, (int) temp_size
);
986 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
987 * flavoured AS. The following bizzare behaviour is to be
988 * compatible with above. I guess they tried to take up to 8
989 * bytes from a 4-byte expression and they forgot to sign
990 * extend. Un*x Sux. */
991 #define BSD_FILL_SIZE_CROCK_4 (4)
992 md_number_to_chars (p
, temp_fill
,
993 (temp_size
> BSD_FILL_SIZE_CROCK_4
994 ? BSD_FILL_SIZE_CROCK_4
996 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
997 * but emits no error message because it seems a legal thing to do.
998 * It is a degenerate case of .fill but could be emitted by a compiler.
1001 demand_empty_rest_of_line ();
1013 name
= input_line_pointer
;
1014 c
= get_symbol_end ();
1015 symbolP
= symbol_find_or_make (name
);
1016 *input_line_pointer
= c
;
1018 S_SET_EXTERNAL (symbolP
);
1021 input_line_pointer
++;
1023 if (*input_line_pointer
== '\n')
1028 demand_empty_rest_of_line ();
1032 s_lcomm (needs_align
)
1033 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1034 (alignment); 0 if it was an ".lcomm" (2 args only) */
1037 register char *name
;
1041 register symbolS
*symbolP
;
1042 segT current_seg
= now_seg
;
1043 subsegT current_subseg
= now_subseg
;
1044 const int max_alignment
= 15;
1046 segT bss_seg
= bss_section
;
1048 name
= input_line_pointer
;
1049 c
= get_symbol_end ();
1050 p
= input_line_pointer
;
1053 if (*input_line_pointer
!= ',')
1055 as_bad ("Expected comma after name");
1056 ignore_rest_of_line ();
1060 ++input_line_pointer
;
1062 if (*input_line_pointer
== '\n')
1064 as_bad ("Missing size expression");
1068 if ((temp
= get_absolute_expression ()) < 0)
1070 as_warn ("BSS length (%d.) <0! Ignored.", temp
);
1071 ignore_rest_of_line ();
1077 /* For MIPS ECOFF, small objects are put in .sbss. */
1078 if (temp
<= bfd_get_gp_size (stdoutput
))
1079 bss_seg
= subseg_new (".sbss", 1);
1087 if (*input_line_pointer
!= ',')
1089 as_bad ("Expected comma after size");
1090 ignore_rest_of_line ();
1093 input_line_pointer
++;
1095 if (*input_line_pointer
== '\n')
1097 as_bad ("Missing alignment");
1100 align
= get_absolute_expression ();
1101 if (align
> max_alignment
)
1103 align
= max_alignment
;
1104 as_warn ("Alignment too large: %d. assumed.", align
);
1109 as_warn ("Alignment negative. 0 assumed.");
1111 record_alignment (bss_seg
, align
);
1112 } /* if needs align */
1115 symbolP
= symbol_find_or_make (name
);
1119 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
1120 S_GET_OTHER (symbolP
) == 0 &&
1121 S_GET_DESC (symbolP
) == 0 &&
1122 #endif /* OBJ_AOUT or OBJ_BOUT */
1123 (S_GET_SEGMENT (symbolP
) == bss_seg
1124 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
1128 #ifdef BFD_ASSEMBLER
1129 subseg_set (bss_seg
, 1);
1131 subseg_new (bss_seg
, 1);
1135 frag_align (align
, 0);
1136 /* detach from old frag */
1137 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
1138 symbolP
->sy_frag
->fr_symbol
= NULL
;
1140 symbolP
->sy_frag
= frag_now
;
1141 p
= frag_var (rs_org
, 1, 1, (relax_substateT
)0, symbolP
,
1145 S_SET_SEGMENT (symbolP
, bss_seg
);
1148 /* The symbol may already have been created with a preceding
1149 ".globl" directive -- be careful not to step on storage class
1150 in that case. Otherwise, set it to static. */
1151 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
1153 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
1155 #endif /* OBJ_COFF */
1159 as_bad ("Ignoring attempt to re-define symbol %s.", name
);
1162 #ifdef BFD_ASSEMBLER
1163 subseg_set (current_seg
, current_subseg
);
1165 subseg_new (current_seg
, current_subseg
);
1168 demand_empty_rest_of_line ();
1186 register char *name
;
1190 register symbolS
*symbolP
;
1192 /* we permit ANY defined expression: BSD4.2 demands constants */
1193 name
= input_line_pointer
;
1194 c
= get_symbol_end ();
1195 p
= input_line_pointer
;
1198 if (*input_line_pointer
!= ',')
1201 as_bad ("Expected comma after name \"%s\"", name
);
1203 ignore_rest_of_line ();
1206 input_line_pointer
++;
1208 if (exp
.X_op
!= O_constant
1209 && exp
.X_op
!= O_register
)
1211 as_bad ("bad expression");
1212 ignore_rest_of_line ();
1216 symbolP
= symbol_find_or_make (name
);
1218 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
1219 symbolP->sy_desc == 0) out of this test because coff doesn't have
1220 those fields, and I can't see when they'd ever be tripped. I
1221 don't think I understand why they were here so I may have
1222 introduced a bug. As recently as 1.37 didn't have this test
1223 anyway. xoxorich. */
1225 if (S_GET_SEGMENT (symbolP
) == undefined_section
1226 && S_GET_VALUE (symbolP
) == 0)
1228 /* The name might be an undefined .global symbol; be sure to
1229 keep the "external" bit. */
1230 S_SET_SEGMENT (symbolP
,
1231 (exp
.X_op
== O_constant
1234 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
1238 as_bad ("Symbol %s already defined", name
);
1241 demand_empty_rest_of_line ();
1247 register segT segment
;
1249 register long temp_fill
;
1251 /* Don't believe the documentation of BSD 4.2 AS. There is no such
1252 thing as a sub-segment-relative origin. Any absolute origin is
1253 given a warning, then assumed to be segment-relative. Any
1254 segmented origin expression ("foo+42") had better be in the right
1255 segment or the .org is ignored.
1257 BSD 4.2 AS warns if you try to .org backwards. We cannot because
1258 we never know sub-segment sizes when we are reading code. BSD
1259 will crash trying to emit negative numbers of filler bytes in
1260 certain .orgs. We don't crash, but see as-write for that code.
1262 Don't make frag if need_pass_2==1. */
1263 segment
= get_known_segmented_expression (&exp
);
1264 if (*input_line_pointer
== ',')
1266 input_line_pointer
++;
1267 temp_fill
= get_absolute_expression ();
1273 if (segment
!= now_seg
&& segment
!= absolute_section
)
1274 as_bad ("Invalid segment \"%s\". Segment \"%s\" assumed.",
1275 segment_name (segment
), segment_name (now_seg
));
1276 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
.X_add_symbol
,
1277 exp
.X_add_number
, (char *) 0);
1279 } /* if (ok to make frag) */
1280 demand_empty_rest_of_line ();
1286 register char *name
;
1287 register char delim
;
1288 register char *end_name
;
1289 register symbolS
*symbolP
;
1292 * Especial apologies for the random logic:
1293 * this just grew, and could be parsed much more simply!
1296 name
= input_line_pointer
;
1297 delim
= get_symbol_end ();
1298 end_name
= input_line_pointer
;
1302 if (*input_line_pointer
!= ',')
1305 as_bad ("Expected comma after name \"%s\"", name
);
1307 ignore_rest_of_line ();
1311 input_line_pointer
++;
1314 if (name
[0] == '.' && name
[1] == '\0')
1316 /* Turn '. = mumble' into a .org mumble */
1317 register segT segment
;
1321 segment
= get_known_segmented_expression (&exp
);
1325 if (segment
!= now_seg
&& segment
!= absolute_section
)
1326 as_bad ("Invalid segment \"%s\". Segment \"%s\" assumed.",
1327 segment_name (segment
),
1328 segment_name (now_seg
));
1329 ptr
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
.X_add_symbol
,
1330 exp
.X_add_number
, (char *) 0);
1332 } /* if (ok to make frag) */
1338 if ((symbolP
= symbol_find (name
)) == NULL
1339 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
1341 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
1343 /* "set" symbols are local unless otherwise specified. */
1344 SF_SET_LOCAL (symbolP
);
1345 #endif /* OBJ_COFF */
1347 } /* make a new symbol */
1349 symbol_table_insert (symbolP
);
1352 pseudo_set (symbolP
);
1353 demand_empty_rest_of_line ();
1361 register long temp_fill
;
1364 /* Just like .fill, but temp_size = 1 */
1365 if (get_absolute_expression_and_terminator (&temp_repeat
) == ',')
1367 temp_fill
= get_absolute_expression ();
1371 input_line_pointer
--; /* Backup over what was not a ','. */
1376 temp_repeat
*= mult
;
1378 if (temp_repeat
<= 0)
1380 as_warn ("Repeat < 0, .space ignored");
1381 ignore_rest_of_line ();
1386 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
1387 temp_repeat
, (char *) 0);
1390 demand_empty_rest_of_line ();
1398 temp
= get_absolute_expression ();
1399 #ifdef BFD_ASSEMBLER
1400 subseg_set (text_section
, (subsegT
) temp
);
1402 subseg_new (text_section
, (subsegT
) temp
);
1404 demand_empty_rest_of_line ();
1409 demand_empty_rest_of_line ()
1412 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1414 input_line_pointer
++;
1418 ignore_rest_of_line ();
1420 /* Return having already swallowed end-of-line. */
1421 } /* Return pointing just after end-of-line. */
1424 ignore_rest_of_line () /* For suspect lines: gives warning. */
1426 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1428 if (isprint (*input_line_pointer
))
1429 as_bad ("Rest of line ignored. First ignored character is `%c'.",
1430 *input_line_pointer
);
1432 as_bad ("Rest of line ignored. First ignored character valued 0x%x.",
1433 *input_line_pointer
);
1434 while (input_line_pointer
< buffer_limit
1435 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
1437 input_line_pointer
++;
1440 input_line_pointer
++; /* Return pointing just after end-of-line. */
1441 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
1447 * In: Pointer to a symbol.
1448 * Input_line_pointer->expression.
1450 * Out: Input_line_pointer->just after any whitespace after expression.
1451 * Tried to set symbol to value of expression.
1452 * Will change symbols type, value, and frag;
1455 pseudo_set (symbolP
)
1459 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
1461 #endif /* OBJ_AOUT or OBJ_BOUT */
1463 know (symbolP
); /* NULL pointer is logic error. */
1464 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
1465 /* @@ Fix this right for BFD. */
1466 ext
= S_IS_EXTERNAL (symbolP
);
1467 #endif /* OBJ_AOUT or OBJ_BOUT */
1469 (void) expression (&exp
);
1471 if (exp
.X_op
== O_illegal
)
1472 as_bad ("illegal expression; zero assumed");
1473 else if (exp
.X_op
== O_absent
)
1474 as_bad ("missing expression; zero assumed");
1475 else if (exp
.X_op
== O_big
)
1476 as_bad ("%s number invalid; zero assumed",
1477 exp
.X_add_number
> 0 ? "bignum" : "floating point");
1478 else if (exp
.X_op
== O_subtract
1479 && (S_GET_SEGMENT (exp
.X_add_symbol
)
1480 == S_GET_SEGMENT (exp
.X_op_symbol
))
1481 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
1482 && exp
.X_add_symbol
->sy_frag
== exp
.X_op_symbol
->sy_frag
)
1484 exp
.X_op
= O_constant
;
1485 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
1486 - S_GET_VALUE (exp
.X_op_symbol
));
1494 exp
.X_add_number
= 0;
1497 S_SET_SEGMENT (symbolP
, absolute_section
);
1498 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
1499 /* @@ Fix this right for BFD. */
1501 S_SET_EXTERNAL (symbolP
);
1503 S_CLEAR_EXTERNAL (symbolP
);
1504 #endif /* OBJ_AOUT or OBJ_BOUT */
1505 S_SET_VALUE (symbolP
, exp
.X_add_number
);
1506 symbolP
->sy_frag
= &zero_address_frag
;
1510 S_SET_SEGMENT (symbolP
, reg_section
);
1511 S_SET_VALUE (symbolP
, exp
.X_add_number
);
1512 symbolP
->sy_frag
= &zero_address_frag
;
1516 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
)
1517 symbolP
->sy_value
= exp
;
1520 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (exp
.X_add_symbol
));
1521 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
1522 /* @@ Fix this right for BFD! */
1524 S_SET_EXTERNAL (symbolP
);
1526 S_CLEAR_EXTERNAL (symbolP
);
1527 #endif /* OBJ_AOUT or OBJ_BOUT */
1528 S_SET_VALUE (symbolP
,
1529 exp
.X_add_number
+ S_GET_VALUE (exp
.X_add_symbol
));
1530 symbolP
->sy_frag
= exp
.X_add_symbol
->sy_frag
;
1535 /* The value is some complex expression.
1536 FIXME: Should we set the segment to anything? */
1537 symbolP
->sy_value
= exp
;
1545 * CONStruct more frag of .bytes, or .words etc.
1546 * Should need_pass_2 be 1 then emit no frag(s).
1547 * This understands EXPRESSIONS, as opposed to big_cons().
1551 * This has a split personality. We use expression() to read the
1552 * value. We can detect if the value won't fit in a byte or word.
1553 * But we can't detect if expression() discarded significant digits
1554 * in the case of a long. Not worth the crocks required to fix it.
1557 /* Select a parser for cons expressions. */
1559 /* Some targets need to parse the expression in various fancy ways.
1560 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
1561 (for example, the HPPA does this). Otherwise, you can define
1562 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
1563 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
1564 are defined, which is the normal case, then only simple expressions
1567 #ifndef TC_PARSE_CONS_EXPRESSION
1568 #ifdef BITFIELD_CONS_EXPRESSIONS
1569 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
1571 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
1574 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_mri_cons (EXP)
1576 parse_mri_cons
PARAMS ((expressionS
*exp
));
1578 #ifdef REPEAT_CONS_EXPRESSIONS
1579 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
1581 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
1584 /* If we haven't gotten one yet, just call expression. */
1585 #ifndef TC_PARSE_CONS_EXPRESSION
1586 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
1590 /* worker to do .byte etc statements */
1591 /* clobbers input_line_pointer, checks */
1595 register unsigned int nbytes
; /* 1=.byte, 2=.word, 4=.long */
1599 if (is_it_end_of_statement ())
1601 demand_empty_rest_of_line ();
1607 TC_PARSE_CONS_EXPRESSION (&exp
, nbytes
);
1608 emit_expr (&exp
, nbytes
);
1610 while (*input_line_pointer
++ == ',');
1612 input_line_pointer
--; /* Put terminator back into stream. */
1613 demand_empty_rest_of_line ();
1616 /* Put the contents of expression EXP into the object file using
1617 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
1620 emit_expr (exp
, nbytes
)
1622 unsigned int nbytes
;
1627 /* Don't do anything if we are going to make another pass. */
1633 if (op
== O_absent
|| op
== O_illegal
)
1635 as_warn ("zero assumed for missing expression");
1636 exp
->X_add_number
= 0;
1639 else if (op
== O_big
)
1641 as_bad ("%s number invalid; zero assumed",
1642 exp
->X_add_number
> 0 ? "bignum" : "floating point");
1643 exp
->X_add_number
= 0;
1646 else if (op
== O_register
)
1648 as_warn ("register value used as expression");
1652 p
= frag_more (nbytes
);
1654 #ifndef WORKING_DOT_WORD
1655 /* If we have the difference of two symbols in a word, save it on
1656 the broken_words list. See the code in write.c. */
1657 if (op
== O_subtract
&& nbytes
== 2)
1659 struct broken_word
*x
;
1661 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
1662 x
->next_broken_word
= broken_words
;
1665 x
->word_goes_here
= p
;
1667 x
->add
= exp
->X_add_symbol
;
1668 x
->sub
= exp
->X_op_symbol
;
1669 x
->addnum
= exp
->X_add_number
;
1676 if (op
== O_constant
)
1681 register long unmask
;
1683 /* JF << of >= number of bits in the object is undefined. In
1684 particular SPARC (Sun 4) has problems */
1685 if (nbytes
>= sizeof (long))
1688 mask
= ~0 << (BITS_PER_CHAR
* nbytes
); /* Don't store these bits. */
1690 unmask
= ~mask
; /* Do store these bits. */
1693 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
1694 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
1697 get
= exp
->X_add_number
;
1699 if ((get
& mask
) != 0 && (get
& mask
) != mask
)
1700 { /* Leading bits contain both 0s & 1s. */
1701 as_warn ("Value 0x%lx truncated to 0x%lx.", get
, use
);
1703 md_number_to_chars (p
, use
, nbytes
); /* put bytes in right order. */
1707 md_number_to_chars (p
, (long) 0, nbytes
);
1709 /* Now we need to generate a fixS to record the symbol value.
1710 This is easy for BFD. For other targets it can be more
1711 complex. For very complex cases (currently, the HPPA and
1712 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
1713 want. For simpler cases, you can define TC_CONS_RELOC to be
1714 the name of the reloc code that should be stored in the fixS.
1715 If neither is defined, the code uses NO_RELOC if it is
1716 defined, and otherwise uses 0. */
1718 #ifdef BFD_ASSEMBLER
1719 #ifdef TC_CONS_FIX_NEW
1720 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
1722 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
, 0,
1723 /* @@ Should look at CPU word size. */
1724 nbytes
== 2 ? BFD_RELOC_16
1725 : nbytes
== 8 ? BFD_RELOC_64
1729 #ifdef TC_CONS_FIX_NEW
1730 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
1732 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
1733 it is defined, otherwise use NO_RELOC if it is defined,
1735 #ifndef TC_CONS_RELOC
1737 #define TC_CONS_RELOC NO_RELOC
1739 #define TC_CONS_RELOC 0
1742 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
, 0,
1744 #endif /* TC_CONS_FIX_NEW */
1745 #endif /* BFD_ASSEMBLER */
1749 #ifdef BITFIELD_CONS_EXPRESSIONS
1751 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
1752 w:x,y:z, where w and y are bitwidths and x and y are values. They
1753 then pack them all together. We do a little better in that we allow
1754 them in words, longs, etc. and we'll pack them in target byte order
1757 The rules are: pack least significat bit first, if a field doesn't
1758 entirely fit, put it in the next unit. Overflowing the bitfield is
1759 explicitly *not* even a warning. The bitwidth should be considered
1762 To use this function the tc-XXX.h file should define
1763 BITFIELD_CONS_EXPRESSIONS. */
1766 parse_bitfield_cons (exp
, nbytes
)
1768 unsigned int nbytes
;
1770 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
1771 char *hold
= input_line_pointer
;
1773 (void) expression (exp
);
1775 if (*input_line_pointer
== ':')
1781 unsigned long width
;
1783 if (*input_line_pointer
!= ':')
1785 input_line_pointer
= hold
;
1787 } /* next piece is not a bitfield */
1789 /* In the general case, we can't allow
1790 full expressions with symbol
1791 differences and such. The relocation
1792 entries for symbols not defined in this
1793 assembly would require arbitrary field
1794 widths, positions, and masks which most
1795 of our current object formats don't
1798 In the specific case where a symbol
1799 *is* defined in this assembly, we
1800 *could* build fixups and track it, but
1801 this could lead to confusion for the
1802 backends. I'm lazy. I'll take any
1803 SEG_ABSOLUTE. I think that means that
1804 you can use a previous .set or
1805 .equ type symbol. xoxorich. */
1807 if (exp
->X_op
== O_absent
)
1809 as_warn ("using a bit field width of zero");
1810 exp
->X_add_number
= 0;
1811 exp
->X_op
= O_constant
;
1812 } /* implied zero width bitfield */
1814 if (exp
->X_op
!= O_constant
)
1816 *input_line_pointer
= '\0';
1817 as_bad ("field width \"%s\" too complex for a bitfield", hold
);
1818 *input_line_pointer
= ':';
1819 demand_empty_rest_of_line ();
1823 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
1825 as_warn ("field width %d too big to fit in %d bytes: truncated to %d bits",
1826 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
1827 width
= BITS_PER_CHAR
* nbytes
;
1830 if (width
> bits_available
)
1832 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
1833 input_line_pointer
= hold
;
1834 exp
->X_add_number
= value
;
1838 hold
= ++input_line_pointer
; /* skip ':' */
1840 (void) expression (exp
);
1841 if (exp
->X_op
!= O_constant
)
1843 char cache
= *input_line_pointer
;
1845 *input_line_pointer
= '\0';
1846 as_bad ("field value \"%s\" too complex for a bitfield", hold
);
1847 *input_line_pointer
= cache
;
1848 demand_empty_rest_of_line ();
1852 value
|= ((~(-1 << width
) & exp
->X_add_number
)
1853 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
1855 if ((bits_available
-= width
) == 0
1856 || is_it_end_of_statement ()
1857 || *input_line_pointer
!= ',')
1860 } /* all the bitfields we're gonna get */
1862 hold
= ++input_line_pointer
;
1863 (void) expression (exp
);
1864 } /* forever loop */
1866 exp
->X_add_number
= value
;
1867 exp
->X_op
= O_constant
;
1868 } /* if looks like a bitfield */
1869 } /* parse_bitfield_cons() */
1871 #endif /* BITFIELD_CONS_EXPRESSIONS */
1876 parse_mri_cons (exp
, nbytes
)
1878 unsigned int nbytes
;
1880 if (*input_line_pointer
== '\'')
1882 /* An MRI style string, cut into as many bytes as will fit into
1883 a nbyte chunk, left justify if necessary, and separate with
1884 commas so we can try again later */
1886 unsigned int result
= 0;
1887 input_line_pointer
++;
1888 for (scan
= 0; scan
< nbytes
; scan
++)
1890 if (*input_line_pointer
== '\'')
1892 if (input_line_pointer
[1] == '\'')
1894 input_line_pointer
++;
1899 result
= (result
<< 8) | (*input_line_pointer
++);
1903 while (scan
< nbytes
)
1908 /* Create correct expression */
1909 exp
->X_op
= O_constant
;
1910 exp
->X_add_number
= result
;
1911 /* Fake it so that we can read the next char too */
1912 if (input_line_pointer
[0] != '\'' ||
1913 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
1915 input_line_pointer
-= 2;
1916 input_line_pointer
[0] = ',';
1917 input_line_pointer
[1] = '\'';
1920 input_line_pointer
++;
1928 #ifdef REPEAT_CONS_EXPRESSIONS
1930 /* Parse a repeat expression for cons. This is used by the MIPS
1931 assembler. The format is NUMBER:COUNT; NUMBER appears in the
1932 object file COUNT times.
1934 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
1937 parse_repeat_cons (exp
, nbytes
)
1939 unsigned int nbytes
;
1946 if (*input_line_pointer
!= ':')
1948 /* No repeat count. */
1952 ++input_line_pointer
;
1953 expression (&count
);
1954 if (count
.X_op
!= O_constant
1955 || count
.X_add_number
<= 0)
1957 as_warn ("Unresolvable or nonpositive repeat count; using 1");
1961 /* The cons function is going to output this expression once. So we
1962 output it count - 1 times. */
1963 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
1964 emit_expr (exp
, nbytes
);
1967 #endif /* REPEAT_CONS_EXPRESSIONS */
1972 * CONStruct more frag(s) of .quads, or .octa etc.
1973 * Makes 0 or more new frags.
1974 * If need_pass_2 == 1, generate no frag.
1975 * This understands only bignums, not expressions. Cons() understands
1978 * Constants recognised are '0...'(octal) '0x...'(hex) '...'(decimal).
1980 * This creates objects with struct obstack_control objs, destroying
1981 * any context objs held about a partially completed object. Beware!
1984 * I think it sucks to have 2 different types of integers, with 2
1985 * routines to read them, store them etc.
1986 * It would be nicer to permit bignums in expressions and only
1987 * complain if the result overflowed. However, due to "efficiency"...
1989 /* Worker to do .quad etc statements. Clobbers input_line_pointer, checks
1990 end-of-line. 8=.quad 16=.octa ... */
1994 register int nbytes
;
1996 register char c
; /* input_line_pointer->c. */
1998 register long length
; /* Number of chars in an object. */
1999 register int digit
; /* Value of 1 digit. */
2000 register int carry
; /* For multi-precision arithmetic. */
2001 register int work
; /* For multi-precision arithmetic. */
2002 register char *p
; /* For multi-precision arithmetic. */
2004 extern const char hex_value
[]; /* In hex_value.c. */
2007 * The following awkward logic is to parse ZERO or more strings,
2008 * comma seperated. Recall an expression includes its leading &
2009 * trailing blanks. We fake a leading ',' if there is (supposed to
2010 * be) a 1st expression, and keep demanding 1 expression for each ','.
2012 if (is_it_end_of_statement ())
2014 c
= 0; /* Skip loop. */
2018 c
= ','; /* Do loop. */
2019 --input_line_pointer
;
2023 ++input_line_pointer
;
2025 c
= *input_line_pointer
;
2026 /* C contains 1st non-blank character of what we hope is a number. */
2029 c
= *++input_line_pointer
;
2030 if (c
== 'x' || c
== 'X')
2032 c
= *++input_line_pointer
;
2045 * This feature (?) is here to stop people worrying about
2046 * mysterious zero constants: which is what they get when
2047 * they completely omit digits.
2049 if (hex_value
[(unsigned char) c
] >= radix
)
2051 as_bad ("Missing digits. 0 assumed.");
2053 bignum_high
= bignum_low
- 1; /* Start constant with 0 chars. */
2055 (digit
= hex_value
[(unsigned char) c
]) < radix
;
2056 c
= *++input_line_pointer
)
2058 /* Multiply existing number by radix, then add digit. */
2060 for (p
= bignum_low
; p
<= bignum_high
; p
++)
2062 work
= (*p
& MASK_CHAR
) * radix
+ carry
;
2063 *p
= work
& MASK_CHAR
;
2064 carry
= work
>> BITS_PER_CHAR
;
2069 *bignum_high
= carry
& MASK_CHAR
;
2070 know ((carry
& ~MASK_CHAR
) == 0);
2073 length
= bignum_high
- bignum_low
+ 1;
2074 if (length
> nbytes
)
2076 as_warn ("Most significant bits truncated in integer constant.");
2080 register long leading_zeroes
;
2082 for (leading_zeroes
= nbytes
- length
;
2092 char *src
= bignum_low
;
2093 p
= frag_more (nbytes
);
2094 if (target_big_endian
)
2097 for (i
= nbytes
- 1; i
>= 0; i
--)
2101 memcpy (p
, bignum_low
, (int) nbytes
);
2103 /* C contains character after number. */
2105 c
= *input_line_pointer
;
2106 /* C contains 1st non-blank character after number. */
2108 demand_empty_rest_of_line ();
2111 /* Extend bignum by 1 char. */
2115 register long length
;
2118 if (bignum_high
>= bignum_limit
)
2120 length
= bignum_limit
- bignum_low
;
2121 bignum_low
= xrealloc (bignum_low
, length
+ length
);
2122 bignum_high
= bignum_low
+ length
;
2123 bignum_limit
= bignum_low
+ length
+ length
;
2125 } /* grow_bignum(); */
2130 * CONStruct some more frag chars of .floats .ffloats etc.
2131 * Makes 0 or more new frags.
2132 * If need_pass_2 == 1, no frags are emitted.
2133 * This understands only floating literals, not expressions. Sorry.
2135 * A floating constant is defined by atof_generic(), except it is preceded
2136 * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
2137 * reading, I decided to be incompatible. This always tries to give you
2138 * rounded bits to the precision of the pseudo-op. Former AS did premature
2139 * truncatation, restored noisy bits instead of trailing 0s AND gave you
2140 * a choice of 2 flavours of noise according to which of 2 floating-point
2141 * scanners you directed AS to use.
2143 * In: input_line_pointer->whitespace before, or '0' of flonum.
2148 float_cons (float_type
)
2149 /* Clobbers input_line-pointer, checks end-of-line. */
2150 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
2153 int length
; /* Number of chars in an object. */
2154 register char *err
; /* Error from scanning floating literal. */
2155 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
2157 if (is_it_end_of_statement ())
2159 demand_empty_rest_of_line ();
2165 /* input_line_pointer->1st char of a flonum (we hope!). */
2168 /* Skip any 0{letter} that may be present. Don't even check if the
2169 * letter is legal. Someone may invent a "z" format and this routine
2170 * has no use for such information. Lusers beware: you get
2171 * diagnostics if your input is ill-conditioned.
2173 if (input_line_pointer
[0] == '0' && isalpha (input_line_pointer
[1]))
2174 input_line_pointer
+= 2;
2176 err
= md_atof (float_type
, temp
, &length
);
2177 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
2181 as_bad ("Bad floating literal: %s", err
);
2182 ignore_rest_of_line ();
2192 #ifdef REPEAT_CONS_EXPRESSIONS
2193 if (*input_line_pointer
== ':')
2195 expressionS count_exp
;
2197 ++input_line_pointer
;
2198 expression (&count_exp
);
2199 if (count_exp
.X_op
!= O_constant
2200 || count_exp
.X_add_number
<= 0)
2202 as_warn ("unresolvable or nonpositive repeat count; using 1");
2205 count
= count_exp
.X_add_number
;
2209 while (--count
>= 0)
2211 p
= frag_more (length
);
2212 memcpy (p
, temp
, length
);
2217 while (*input_line_pointer
++ == ',');
2219 --input_line_pointer
; /* Put terminator back into stream. */
2220 demand_empty_rest_of_line ();
2221 } /* float_cons() */
2226 * We read 0 or more ',' seperated, double-quoted strings.
2228 * Caller should have checked need_pass_2 is FALSE because we don't check it.
2233 stringer (append_zero
) /* Worker to do .ascii etc statements. */
2234 /* Checks end-of-line. */
2235 register int append_zero
; /* 0: don't append '\0', else 1 */
2237 register unsigned int c
;
2240 * The following awkward logic is to parse ZERO or more strings,
2241 * comma seperated. Recall a string expression includes spaces
2242 * before the opening '\"' and spaces after the closing '\"'.
2243 * We fake a leading ',' if there is (supposed to be)
2244 * a 1st, expression. We keep demanding expressions for each
2247 if (is_it_end_of_statement ())
2249 c
= 0; /* Skip loop. */
2250 ++input_line_pointer
; /* Compensate for end of loop. */
2254 c
= ','; /* Do loop. */
2256 while (c
== ',' || c
== '<' || c
== '"')
2259 switch (*input_line_pointer
)
2262 ++input_line_pointer
; /*->1st char of string. */
2263 while (is_a_char (c
= next_char_of_string ()))
2265 FRAG_APPEND_1_CHAR (c
);
2269 FRAG_APPEND_1_CHAR (0);
2271 know (input_line_pointer
[-1] == '\"');
2274 input_line_pointer
++;
2275 c
= get_single_number ();
2276 FRAG_APPEND_1_CHAR (c
);
2277 if (*input_line_pointer
!= '>')
2279 as_bad ("Expected <nn>");
2281 input_line_pointer
++;
2284 input_line_pointer
++;
2288 c
= *input_line_pointer
;
2291 demand_empty_rest_of_line ();
2294 /* FIXME-SOMEDAY: I had trouble here on characters with the
2295 high bits set. We'll probably also have trouble with
2296 multibyte chars, wide chars, etc. Also be careful about
2297 returning values bigger than 1 byte. xoxorich. */
2300 next_char_of_string ()
2302 register unsigned int c
;
2304 c
= *input_line_pointer
++ & CHAR_MASK
;
2312 switch (c
= *input_line_pointer
++)
2342 break; /* As itself. */
2357 for (number
= 0; isdigit (c
); c
= *input_line_pointer
++)
2359 number
= number
* 8 + c
- '0';
2363 --input_line_pointer
;
2367 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
2368 as_warn ("Unterminated string: Newline inserted.");
2374 #ifdef ONLY_STANDARD_ESCAPES
2375 as_bad ("Bad escaped character in string, '?' assumed");
2377 #endif /* ONLY_STANDARD_ESCAPES */
2380 } /* switch on escaped char */
2385 } /* switch on char */
2387 } /* next_char_of_string() */
2390 get_segmented_expression (expP
)
2391 register expressionS
*expP
;
2393 register segT retval
;
2395 retval
= expression (expP
);
2396 if (expP
->X_op
== O_illegal
2397 || expP
->X_op
== O_absent
2398 || expP
->X_op
== O_big
)
2400 as_bad ("expected address expression; zero assumed");
2401 expP
->X_op
= O_constant
;
2402 expP
->X_add_number
= 0;
2403 retval
= absolute_section
;
2409 get_known_segmented_expression (expP
)
2410 register expressionS
*expP
;
2412 register segT retval
;
2414 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
2416 /* There is no easy way to extract the undefined symbol from the
2418 if (expP
->X_add_symbol
!= NULL
2419 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
2420 as_warn ("symbol \"%s\" undefined; zero assumed",
2421 S_GET_NAME (expP
->X_add_symbol
));
2423 as_warn ("some symbol undefined; zero assumed");
2424 retval
= absolute_section
;
2425 expP
->X_op
= O_constant
;
2426 expP
->X_add_number
= 0;
2428 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
2430 } /* get_known_segmented_expression() */
2433 get_absolute_expression ()
2438 if (exp
.X_op
!= O_constant
)
2440 if (exp
.X_op
!= O_absent
)
2441 as_bad ("bad absolute expression; zero assumed");
2442 exp
.X_add_number
= 0;
2444 return exp
.X_add_number
;
2447 char /* return terminator */
2448 get_absolute_expression_and_terminator (val_pointer
)
2449 long *val_pointer
; /* return value of expression */
2451 /* FIXME: val_pointer should probably be offsetT *. */
2452 *val_pointer
= (long) get_absolute_expression ();
2453 return (*input_line_pointer
++);
2457 * demand_copy_C_string()
2459 * Like demand_copy_string, but return NULL if the string contains any '\0's.
2460 * Give a warning if that happens.
2463 demand_copy_C_string (len_pointer
)
2468 if ((s
= demand_copy_string (len_pointer
)) != 0)
2472 for (len
= *len_pointer
;
2481 as_bad ("This string may not contain \'\\0\'");
2489 * demand_copy_string()
2491 * Demand string, but return a safe (=private) copy of the string.
2492 * Return NULL if we can't read a string here.
2495 demand_copy_string (lenP
)
2498 register unsigned int c
;
2504 if (*input_line_pointer
== '\"')
2506 input_line_pointer
++; /* Skip opening quote. */
2508 while (is_a_char (c
= next_char_of_string ()))
2510 obstack_1grow (¬es
, c
);
2513 /* JF this next line is so demand_copy_C_string will return a null
2514 termanated string. */
2515 obstack_1grow (¬es
, '\0');
2516 retval
= obstack_finish (¬es
);
2520 as_warn ("Missing string");
2522 ignore_rest_of_line ();
2526 } /* demand_copy_string() */
2529 * is_it_end_of_statement()
2531 * In: Input_line_pointer->next character.
2533 * Do: Skip input_line_pointer over all whitespace.
2535 * Out: 1 if input_line_pointer->end-of-line.
2538 is_it_end_of_statement ()
2541 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
2542 } /* is_it_end_of_statement() */
2548 register symbolS
*symbolP
; /* symbol we are working with */
2550 input_line_pointer
++;
2551 if (*input_line_pointer
== '=')
2552 input_line_pointer
++;
2554 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
2555 input_line_pointer
++;
2557 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
2559 /* Turn '. = mumble' into a .org mumble */
2560 register segT segment
;
2564 segment
= get_known_segmented_expression (&exp
);
2567 if (segment
!= now_seg
&& segment
!= absolute_section
)
2568 as_warn ("Illegal segment \"%s\". Segment \"%s\" assumed.",
2569 segment_name (segment
),
2570 segment_name (now_seg
));
2571 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
.X_add_symbol
,
2572 exp
.X_add_number
, (char *) 0);
2574 } /* if (ok to make frag) */
2578 symbolP
= symbol_find_or_make (sym_name
);
2579 pseudo_set (symbolP
);
2583 /* .include -- include a file at this point. */
2596 filename
= demand_copy_string (&i
);
2597 demand_empty_rest_of_line ();
2598 path
= xmalloc (i
+ include_dir_maxlen
+ 5 /* slop */ );
2599 for (i
= 0; i
< include_dir_count
; i
++)
2601 strcpy (path
, include_dirs
[i
]);
2603 strcat (path
, filename
);
2604 if (0 != (try = fopen (path
, "r")))
2613 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
2614 newbuf
= input_scrub_include_file (path
, input_line_pointer
);
2615 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2619 add_include_dir (path
)
2624 if (include_dir_count
== 0)
2626 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
2627 include_dirs
[0] = "."; /* Current dir */
2628 include_dir_count
= 2;
2632 include_dir_count
++;
2633 include_dirs
= (char **) realloc (include_dirs
,
2634 include_dir_count
* sizeof (*include_dirs
));
2637 include_dirs
[include_dir_count
- 1] = path
; /* New one */
2640 if (i
> include_dir_maxlen
)
2641 include_dir_maxlen
= i
;
2642 } /* add_include_dir() */
2648 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2650 ++input_line_pointer
;
2652 ++input_line_pointer
;
2658 * Handle .stabX directives, which used to be open-coded.
2659 * So much creeping featurism overloaded the semantics that we decided
2660 * to put all .stabX thinking in one place. Here.
2662 * We try to make any .stabX directive legal. Other people's AS will often
2663 * do assembly-time consistency checks: eg assigning meaning to n_type bits
2664 * and "protecting" you from setting them to certain values. (They also zero
2665 * certain bits before emitting symbols. Tut tut.)
2667 * If an expression is not absolute we either gripe or use the relocation
2668 * information. Other people's assemblers silently forget information they
2669 * don't need and invent information they need that you didn't supply.
2673 change_to_section (name
, len
, exp
)
2678 #ifndef BFD_ASSEMBLER
2679 #ifdef MANY_SEGMENTS
2681 extern segment_info_type segment_info
[];
2683 /* Find out if we've already got a section of this name etc */
2684 for (i
= SEG_E0
; i
< SEG_E9
&& segment_info
[i
].scnhdr
.s_name
[0]; i
++)
2686 if (strncmp (segment_info
[i
].scnhdr
.s_name
, name
, len
) == 0)
2688 subseg_new (i
, exp
);
2692 /* No section, add one */
2693 strncpy (segment_info
[i
].scnhdr
.s_name
, name
, 8);
2694 segment_info
[i
].scnhdr
.s_flags
= 0 /* STYP_NOLOAD */;
2695 subseg_new (i
, exp
);
2701 * Build a string dictionary entry for a .stabX symbol.
2702 * The symbol is added to the .<secname>str section.
2705 #ifdef SEPARATE_STAB_SECTIONS
2708 get_stab_string_offset (string
, secname
)
2709 char *string
, *secname
;
2713 subsegT save_subseg
;
2714 unsigned int length
;
2715 unsigned int old_gdb_string_index
;
2719 /* @@FIXME -- there should be no static data here!
2720 This also has the effect of making all stab string tables large enough
2721 to contain all the contents written to any of them. This only matters
2722 with the Solaris native compiler for the moment, but it should be fixed
2724 static unsigned int gdb_string_index
= 0;
2726 old_gdb_string_index
= 0;
2727 length
= strlen (string
);
2728 clengthP
= (char *) &length
;
2730 { /* Ordinary case. */
2732 save_subseg
= now_subseg
;
2734 /* Create the stabstr sections, if they are not already created. */
2736 char *newsecname
= xmalloc (strlen (secname
) + 4);
2737 strcpy (newsecname
, secname
);
2738 strcat (newsecname
, "str");
2739 #ifdef BFD_ASSEMBLER
2740 seg
= bfd_get_section_by_name (stdoutput
, newsecname
);
2743 seg
= bfd_make_section_old_way (stdoutput
, newsecname
);
2744 bfd_set_section_flags (stdoutput
, seg
, SEC_READONLY
| SEC_ALLOC
);
2747 change_to_section(newsecname
, strlen(newsecname
), 0);
2749 /* free (newsecname);*/
2751 #ifdef BFD_ASSEMBLER
2752 subseg_set (seg
, save_subseg
);
2754 /* subseg_new (seg, save_subseg); */
2756 old_gdb_string_index
= gdb_string_index
;
2758 while ((c
= *string
++))
2762 FRAG_APPEND_1_CHAR (c
);
2765 FRAG_APPEND_1_CHAR ((char) 0);
2771 FRAG_APPEND_1_CHAR ((char) 0);
2775 #ifdef BFD_ASSEMBLER
2776 subseg_set (save_seg
, save_subseg
);
2778 /* subseg_new (save_seg, save_subseg); */
2781 return old_gdb_string_index
;
2784 #endif /* SEPARATE_STAB_SECTIONS */
2786 /* This can handle different kinds of stabs (s,n,d) and different
2787 kinds of stab sections. */
2790 s_stab_generic (what
, secname
)
2802 segT saved_seg
= now_seg
;
2804 subsegT saved_subseg
= now_subseg
;
2807 #ifdef SEPARATE_STAB_SECTIONS
2811 valu
= ((char *) obstack_next_free (&frags
)) - frag_now
->fr_literal
;
2813 #ifdef SEPARATE_STAB_SECTIONS
2814 #ifdef BFD_ASSEMBLER
2815 seg
= bfd_get_section_by_name (stdoutput
, secname
);
2818 seg
= subseg_new (secname
, 0);
2819 bfd_set_section_flags (stdoutput
, seg
,
2820 SEC_READONLY
| SEC_ALLOC
| SEC_RELOC
);
2821 subseg_set (saved_seg
, subseg
);
2825 change_to_section (secname
, strlen(secname
), 0);
2827 #endif /* SEPARATE_STAB_SECTIONS */
2830 * Enter with input_line_pointer pointing past .stabX and any following
2835 string
= demand_copy_C_string (&length
);
2837 if (*input_line_pointer
== ',')
2838 input_line_pointer
++;
2841 as_bad ("I need a comma after symbol's name");
2849 * Input_line_pointer->after ','. String->symbol name.
2853 #ifdef MAKE_STAB_SYMBOL
2854 MAKE_STAB_SYMBOL(symbol
, string
, secname
);
2856 symbol
= symbol_new (string
, undefined_section
, 0, (struct frag
*) 0);
2858 /* Make sure that the rest of this is going to work. */
2860 as_fatal ("no stab symbol created");
2865 S_SET_NAME (symbol
, NULL
); /* .stabd feature. */
2866 #ifdef STAB_SYMBOL_SET_VALUE
2867 STAB_SYMBOL_SET_VALUE (symbol
, valu
);
2869 S_SET_VALUE (symbol
, valu
);
2871 #if STAB_SYMBOL_SET_SEGMENT
2873 S_SET_SEGMENT (symbol
, now_seg
);
2875 symbol
->sy_frag
= frag_now
;
2879 symbol
->sy_frag
= &zero_address_frag
;
2883 symbol
->sy_frag
= &zero_address_frag
;
2891 if (get_absolute_expression_and_terminator (&longint
) == ',')
2893 saved_type
= longint
;
2894 S_SET_TYPE (symbol
, saved_type
);
2898 as_bad ("I want a comma after the n_type expression");
2900 input_line_pointer
--; /* Backup over a non-',' char. */
2906 if (get_absolute_expression_and_terminator (&longint
) == ',')
2907 S_SET_OTHER (symbol
, longint
);
2910 as_bad ("I want a comma after the n_other expression");
2912 input_line_pointer
--; /* Backup over a non-',' char. */
2918 S_SET_DESC (symbol
, get_absolute_expression ());
2919 if (what
== 's' || what
== 'n')
2921 if (*input_line_pointer
!= ',')
2923 as_bad ("I want a comma after the n_desc expression");
2928 input_line_pointer
++;
2933 /* Line is messed up - ignore it and get out of here. */
2936 ignore_rest_of_line ();
2937 #ifdef BFD_ASSEMBLER
2938 subseg_set (saved_seg
, saved_subseg
);
2940 subseg_new (saved_seg
, saved_subseg
);
2945 #ifdef BFD_ASSEMBLER
2946 subseg_set (seg
, subseg
);
2949 #if 0 /* needed for elf only? */
2951 /* allocate and discard -- filled in later */
2952 (void) frag_more (12);
2955 #ifdef SEPARATE_STAB_SECTIONS
2959 change_to_section(secname
, strlen(secname
), 0);
2960 toP
= frag_more (8);
2961 /* the string index portion of the stab */
2962 md_number_to_chars (toP
, (valueT
) S_GET_OFFSET_2(symbol
), 4);
2963 md_number_to_chars (toP
+ 4, (valueT
) S_GET_TYPE(symbol
), 1);
2964 md_number_to_chars (toP
+ 5, (valueT
) S_GET_OTHER(symbol
), 1);
2965 md_number_to_chars (toP
+ 6, (valueT
) S_GET_DESC(symbol
), 2);
2969 #ifdef SEPARATE_STAB_SECTIONS
2970 if (what
== 's' || what
== 'n')
2973 input_line_pointer
--;
2977 char *p
= frag_more (4);
2978 md_number_to_chars (p
, 0, 4);
2980 #ifdef BFD_ASSEMBLER
2981 subseg_set (saved_seg
, subseg
);
2983 /* subseg_new (saved_seg, subseg); */
2986 if (what
== 's' || what
== 'n')
2988 pseudo_set (symbol
);
2989 S_SET_TYPE (symbol
, saved_type
);
2993 #if 0 /* for elf only? */
2994 if (what
== 's' && S_GET_TYPE (symbol
) == N_SO
)
2996 fragS
*fragp
= seg_info (seg
)->frchainP
->frch_root
;
2998 && fragp
->fr_address
+ fragp
->fr_fix
< 12)
2999 fragp
= fragp
->fr_next
;
3000 assert (fragp
!= 0);
3001 assert (fragp
->fr_type
== rs_fill
);
3002 assert (fragp
->fr_address
== 0 && fragp
->fr_fix
>= 12);
3003 md_number_to_chars (fragp
->fr_literal
, (valueT
) symbol
->sy_name_offset
,
3010 switch (S_GET_TYPE (symbol
))
3013 listing_source_line (S_GET_DESC (symbol
));
3017 listing_source_file (string
);
3020 #endif /* !NO_LISTING */
3022 #ifdef SEPARATE_STAB_SECTIONS
3023 subseg_new (saved_seg
, saved_subseg
);
3026 demand_empty_rest_of_line ();
3029 /* Regular stab directive. */
3035 s_stab_generic (what
, ".stab");
3038 /* "Extended stabs", used in Solaris only now. */
3047 secname
= demand_copy_C_string (&length
);
3049 if (*input_line_pointer
== ',')
3050 input_line_pointer
++;
3053 as_bad ("comma missing in .xstabs");
3054 ignore_rest_of_line ();
3057 s_stab_generic (what
, secname
);
3060 /* Frob invented at RMS' request. Set the n_desc of a symbol. */
3071 name
= input_line_pointer
;
3072 c
= get_symbol_end ();
3073 p
= input_line_pointer
;
3076 if (*input_line_pointer
!= ',')
3079 as_bad ("Expected comma after name \"%s\"", name
);
3081 ignore_rest_of_line ();
3085 input_line_pointer
++;
3086 temp
= get_absolute_expression ();
3088 symbolP
= symbol_find_or_make (name
);
3090 S_SET_DESC (symbolP
, temp
);
3092 demand_empty_rest_of_line ();