1 /* read.c - read a source file -
2 Copyright (C) 1986, 87, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
3 2000 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #define MASK_CHAR (0xFF) /* If your chars aren't 8 bits, you will
24 change this a bit. But then, GNU isn't
25 spozed to run on your machine anyway.
26 (RMS is so shortsighted sometimes.)
29 #define MASK_CHAR ((int)(unsigned char)-1)
33 /* This is the largest known floating point format (for now). It will
34 grow when we do 4361 style flonums. */
36 #define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
38 /* Routines that read assembler source text to build spagetti in memory.
39 Another group of these functions is in the expr.c module. */
52 #ifndef TC_START_LABEL
53 #define TC_START_LABEL(x,y) (x==':')
56 /* Set by the object-format or the target. */
57 #ifndef TC_IMPLICIT_LCOMM_ALIGNMENT
58 #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) \
62 else if ((SIZE) >= 4) \
64 else if ((SIZE) >= 2) \
71 /* The NOP_OPCODE is for the alignment fill value.
72 * fill it a nop instruction so that the disassembler does not choke
76 #define NOP_OPCODE 0x00
79 char *input_line_pointer; /*->next char of source file to parse. */
81 #if BITS_PER_CHAR != 8
82 /* The following table is indexed by[(char)] and will break if
83 a char does not have exactly 256 states (hopefully 0:255!)! */
88 /* The m88k unfortunately uses @ as a label beginner. */
93 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
98 /* The Delta 68k assembler permits % inside label names. */
103 /* The PowerPC Windows NT assemblers permits ? inside label names. */
108 /* The IA-64 assembler uses # as a suffix designating a symbol. We include
109 it in the symbol and strip it out in tc_canonicalize_symbol_name. */
114 /* The a29k assembler does not permits labels to start with $. */
119 /* The Delta 68k assembler permits ~ at start of label names. */
123 /* used by is_... macros. our ctype[] */
126 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
127 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
128 0, 0, 0, LEX_HASH, LEX_DOLLAR, LEX_PCT, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
129 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM, /* 0123456789:;<=>? */
130 LEX_AT, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
131 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR, 0, LEX_BR, 0, 3, /* PQRSTUVWXYZ[\]^_ */
132 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
133 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR, 0, LEX_BR, LEX_TILDE, 0, /* pqrstuvwxyz{|}~. */
134 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
135 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
136 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
137 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
138 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
139 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
140 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
141 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
147 * Out: 1 if this character ends a line.
149 char is_end_of_line[256] =
152 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, /* @abcdefghijklmno */
154 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* @abcdefghijklmno */
156 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
157 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* _!"#$%&'()*+,-./ */
158 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, /* 0123456789:;<=>? */
159 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
160 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
161 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
162 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
163 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
164 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
165 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
166 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
167 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
170 /* Functions private to this file. */
172 static char *buffer; /* 1st char of each buffer of lines is here. */
173 static char *buffer_limit; /*->1 + last char in buffer. */
175 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1 in the
176 tc-<CPU>.h file. See the "Porting GAS" section of the internals manual. */
177 int target_big_endian = TARGET_BYTES_BIG_ENDIAN;
179 static char *old_buffer; /* JF a hack */
180 static char *old_input;
181 static char *old_limit;
183 /* Variables for handling include file directory table. */
185 char **include_dirs; /* Table of pointers to directories to
186 search for .include's */
187 int include_dir_count; /* How many are in the table */
188 int include_dir_maxlen = 1;/* Length of longest in table */
190 #ifndef WORKING_DOT_WORD
191 struct broken_word *broken_words;
192 int new_broken_words;
195 /* The current offset into the absolute section. We don't try to
196 build frags in the absolute section, since no data can be stored
197 there. We just keep track of the current offset. */
198 addressT abs_section_offset;
200 /* If this line had an MRI style label, it is stored in this variable.
201 This is used by some of the MRI pseudo-ops. */
204 /* This global variable is used to support MRI common sections. We
205 translate such sections into a common symbol. This variable is
206 non-NULL when we are in an MRI common section. */
207 symbolS *mri_common_symbol;
209 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
210 need to align to an even byte boundary unless the next pseudo-op is
211 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
213 static int mri_pending_align;
217 /* This variable is set to be non-zero if the next string we see might
218 be the name of the source file in DWARF debugging information. See
219 the comment in emit_expr for the format we look for. */
220 static int dwarf_file_string;
224 static void cons_worker PARAMS ((int, int));
225 static int scrub_from_string PARAMS ((char *, int));
226 static void do_align PARAMS ((int, char *, int, int));
227 static void s_align PARAMS ((int, int));
228 static void s_lcomm_internal PARAMS ((int, int));
229 static int hex_float PARAMS ((int, char *));
230 static inline int sizeof_sleb128 PARAMS ((offsetT));
231 static inline int sizeof_uleb128 PARAMS ((valueT));
232 static inline int output_sleb128 PARAMS ((char *, offsetT));
233 static inline int output_uleb128 PARAMS ((char *, valueT));
234 static inline int output_big_sleb128 PARAMS ((char *, LITTLENUM_TYPE *, int));
235 static inline int output_big_uleb128 PARAMS ((char *, LITTLENUM_TYPE *, int));
236 static int output_big_leb128 PARAMS ((char *, LITTLENUM_TYPE *, int, int));
237 static void do_org PARAMS ((segT, expressionS *, int));
238 char *demand_copy_string PARAMS ((int *lenP));
239 static segT get_segmented_expression PARAMS ((expressionS *expP));
240 static segT get_known_segmented_expression PARAMS ((expressionS * expP));
241 static void pobegin PARAMS ((void));
242 static int get_line_sb PARAMS ((sb *));
243 static void generate_file_debug PARAMS ((void));
252 obj_read_begin_hook ();
254 /* Something close -- but not too close -- to a multiple of 1024.
255 The debugging malloc I'm using has 24 bytes of overhead. */
256 obstack_begin (¬es, chunksize);
257 obstack_begin (&cond_obstack, chunksize);
259 /* Use machine dependent syntax */
260 for (p = line_separator_chars; *p; p++)
261 is_end_of_line[(unsigned char) *p] = 1;
262 /* Use more. FIXME-SOMEDAY. */
268 /* set up pseudo-op tables */
270 static struct hash_control *po_hash;
272 static const pseudo_typeS potable[] =
274 {"abort", s_abort, 0},
275 {"align", s_align_ptwo, 0},
276 {"ascii", stringer, 0},
277 {"asciz", stringer, 1},
278 {"balign", s_align_bytes, 0},
279 {"balignw", s_align_bytes, -2},
280 {"balignl", s_align_bytes, -4},
284 {"common", s_mri_common, 0},
285 {"common.s", s_mri_common, 1},
289 {"dc.d", float_cons, 'd'},
291 {"dc.s", float_cons, 'f'},
293 {"dc.x", float_cons, 'x'},
295 {"dcb.b", s_space, 1},
296 {"dcb.d", s_float_space, 'd'},
297 {"dcb.l", s_space, 4},
298 {"dcb.s", s_float_space, 'f'},
299 {"dcb.w", s_space, 2},
300 {"dcb.x", s_float_space, 'x'},
302 {"ds.b", s_space, 1},
303 {"ds.d", s_space, 8},
304 {"ds.l", s_space, 4},
305 {"ds.p", s_space, 12},
306 {"ds.s", s_space, 4},
307 {"ds.w", s_space, 2},
308 {"ds.x", s_space, 12},
309 {"debug", s_ignore, 0},
314 {"double", float_cons, 'd'},
316 {"eject", listing_eject, 0}, /* Formfeed listing */
318 {"elsec", s_else, 0},
319 {"elseif", s_elseif, (int) O_ne},
321 {"endc", s_endif, 0},
322 {"endfunc", s_func, 1},
323 {"endif", s_endif, 0},
328 {"exitm", s_mexit, 0},
330 {"extern", s_ignore, 0}, /* We treat all undef as ext */
331 {"appfile", s_app_file, 1},
332 {"appline", s_app_line, 0},
334 {"file", s_app_file, 0},
336 {"float", float_cons, 'f'},
337 {"format", s_ignore, 0},
339 {"global", s_globl, 0},
340 {"globl", s_globl, 0},
342 {"if", s_if, (int) O_ne},
344 {"ifdef", s_ifdef, 0},
345 {"ifeq", s_if, (int) O_eq},
346 {"ifeqs", s_ifeqs, 0},
347 {"ifge", s_if, (int) O_ge},
348 {"ifgt", s_if, (int) O_gt},
349 {"ifle", s_if, (int) O_le},
350 {"iflt", s_if, (int) O_lt},
352 {"ifndef", s_ifdef, 1},
353 {"ifne", s_if, (int) O_ne},
354 {"ifnes", s_ifeqs, 1},
355 {"ifnotdef", s_ifdef, 1},
356 {"include", s_include, 0},
362 {"lcomm", s_lcomm, 0},
363 {"lflags", listing_flags, 0}, /* Listing flags */
364 {"linkonce", s_linkonce, 0},
365 {"list", listing_list, 1}, /* Turn listing on */
366 {"llen", listing_psize, 1},
369 {"macro", s_macro, 0},
370 {"mexit", s_mexit, 0},
372 {".mri", s_mri, 0}, /* Special case so .mri works in MRI mode. */
373 {"name", s_ignore, 0},
374 {"noformat", s_ignore, 0},
375 {"nolist", listing_list, 0}, /* Turn listing off */
376 {"nopage", listing_nopage, 0},
378 {"offset", s_struct, 0},
380 {"p2align", s_align_ptwo, 0},
381 {"p2alignw", s_align_ptwo, -2},
382 {"p2alignl", s_align_ptwo, -4},
383 {"page", listing_eject, 0},
384 {"plen", listing_psize, 0},
385 {"print", s_print, 0},
386 {"psize", listing_psize, 0}, /* set paper size */
387 {"purgem", s_purgem, 0},
392 {"sbttl", listing_title, 1}, /* Subtitle of listing */
397 {"single", float_cons, 'f'},
399 {"space", s_space, 0},
400 {"skip", s_space, 0},
401 {"sleb128", s_leb128, 1},
402 {"spc", s_ignore, 0},
403 {"stabd", s_stab, 'd'},
404 {"stabn", s_stab, 'n'},
405 {"stabs", s_stab, 's'},
406 {"string", stringer, 1},
407 {"struct", s_struct, 0},
411 /* This is for gcc to use. It's only just been added (2/94), so gcc
412 won't be able to use it for a while -- probably a year or more.
413 But once this has been released, check with gcc maintainers
414 before deleting it or even changing the spelling. */
415 {"this_GCC_requires_the_GNU_assembler", s_ignore, 0},
416 /* If we're folding case -- done for some targets, not necessarily
417 all -- the above string in an input file will be converted to
418 this one. Match it either way... */
419 {"this_gcc_requires_the_gnu_assembler", s_ignore, 0},
421 {"title", listing_title, 0}, /* Listing title */
422 {"ttl", listing_title, 0},
424 {"uleb128", s_leb128, 0},
428 {"xdef", s_globl, 0},
429 {"xref", s_ignore, 0},
430 {"xstabs", s_xstab, 's'},
432 {"zero", s_space, 0},
433 {NULL, NULL, 0} /* end sentinel */
436 static int pop_override_ok = 0;
437 static const char *pop_table_name;
441 const pseudo_typeS *table;
444 const pseudo_typeS *pop;
445 for (pop = table; pop->poc_name; pop++)
447 errtxt = hash_insert (po_hash, pop->poc_name, (char *) pop);
448 if (errtxt && (!pop_override_ok || strcmp (errtxt, "exists")))
449 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name,
454 #ifndef md_pop_insert
455 #define md_pop_insert() pop_insert(md_pseudo_table)
458 #ifndef obj_pop_insert
459 #define obj_pop_insert() pop_insert(obj_pseudo_table)
465 po_hash = hash_new ();
467 /* Do the target-specific pseudo ops. */
468 pop_table_name = "md";
471 /* Now object specific. Skip any that were in the target table. */
472 pop_table_name = "obj";
476 /* Now portable ones. Skip any that we've seen already. */
477 pop_table_name = "standard";
478 pop_insert (potable);
481 #define HANDLE_CONDITIONAL_ASSEMBLY() \
482 if (ignore_input ()) \
484 while (! is_end_of_line[(unsigned char) *input_line_pointer++]) \
485 if (input_line_pointer == buffer_limit) \
491 /* This function is used when scrubbing the characters between #APP
494 static char *scrub_string;
495 static char *scrub_string_end;
498 scrub_from_string (buf, buflen)
504 copy = scrub_string_end - scrub_string;
507 memcpy (buf, scrub_string, copy);
508 scrub_string += copy;
512 /* read_a_source_file()
514 * We read the file, putting things into a web that
515 * represents what we have been reading.
518 read_a_source_file (name)
522 register char *s; /* string of symbol, '\0' appended */
526 buffer = input_scrub_new_file (name);
529 listing_newline (NULL);
530 register_dependency (name);
532 /* Generate debugging information before we've read anything in to denote
533 this file as the "main" source file and not a subordinate one
534 (e.g. N_SO vs N_SOL in stabs). */
535 generate_file_debug ();
537 while ((buffer_limit = input_scrub_next_buffer (&input_line_pointer)) != 0)
538 { /* We have another line to parse. */
539 know (buffer_limit[-1] == '\n'); /* Must have a sentinel. */
540 contin: /* JF this goto is my fault I admit it.
541 Someone brave please re-write the whole
542 input section here? Pleeze??? */
543 while (input_line_pointer < buffer_limit)
545 /* We have more of this buffer to parse. */
548 * We now have input_line_pointer->1st char of next line.
549 * If input_line_pointer [-1] == '\n' then we just
550 * scanned another line: so bump line counters.
552 if (is_end_of_line[(unsigned char) input_line_pointer[-1]])
554 #ifdef md_start_line_hook
555 md_start_line_hook ();
558 if (input_line_pointer[-1] == '\n')
559 bump_line_counters ();
563 if (LABELS_WITHOUT_COLONS || flag_m68k_mri)
565 /* Text at the start of a line must be a label, we
566 run down and stick a colon in. */
567 if (is_name_beginner (*input_line_pointer))
569 char *line_start = input_line_pointer;
574 HANDLE_CONDITIONAL_ASSEMBLY ();
576 c = get_symbol_end ();
578 /* In MRI mode, the EQU and MACRO pseudoops must
579 be handled specially. */
583 char *rest = input_line_pointer + 1;
587 if (*rest == ' ' || *rest == '\t')
589 if ((strncasecmp (rest, "EQU", 3) == 0
590 || strncasecmp (rest, "SET", 3) == 0)
591 && (rest[3] == ' ' || rest[3] == '\t'))
593 input_line_pointer = rest + 3;
595 strncasecmp (rest, "SET", 3) == 0);
598 if (strncasecmp (rest, "MACRO", 5) == 0
601 || is_end_of_line[(unsigned char) rest[5]]))
605 /* In MRI mode, we need to handle the MACRO
606 pseudo-op specially: we don't want to put the
607 symbol in the symbol table. */
609 #ifdef TC_START_LABEL_WITHOUT_COLON
610 && TC_START_LABEL_WITHOUT_COLON(c,
614 line_label = colon (line_start);
616 line_label = symbol_create (line_start,
621 *input_line_pointer = c;
623 input_line_pointer++;
629 * We are at the begining of a line, or similar place.
630 * We expect a well-formed assembler statement.
631 * A "symbol-name:" is a statement.
633 * Depending on what compiler is used, the order of these tests
634 * may vary to catch most common case 1st.
635 * Each test is independent of all other tests at the (top) level.
636 * PLEASE make a compiler that doesn't use this assembler.
637 * It is crufty to waste a compiler's time encoding things for this
638 * assembler, which then wastes more time decoding it.
639 * (And communicating via (linear) files is silly!
640 * If you must pass stuff, please pass a tree!)
642 if ((c = *input_line_pointer++) == '\t'
647 c = *input_line_pointer++;
649 know (c != ' '); /* No further leading whitespace. */
652 /* If listing is on, and we are expanding a macro, then give
653 the listing code the contents of the expanded line. */
656 if ((listing & LISTING_MACEXP) && macro_nest > 0)
661 /* Find the end of the current expanded macro line. */
662 for (s = input_line_pointer-1; *s ; ++s)
663 if (is_end_of_line[(unsigned char) *s])
666 /* Copy it for safe keeping. Also give an indication of
667 how much macro nesting is involved at this point. */
668 len = s - (input_line_pointer-1);
669 copy = (char *) xmalloc (len + macro_nest + 2);
670 memset (copy, '>', macro_nest);
671 copy[macro_nest] = ' ';
672 memcpy (copy + macro_nest + 1, input_line_pointer-1, len);
673 copy[macro_nest+1+len] = '\0';
675 /* Install the line with the listing facility. */
676 listing_newline (copy);
679 listing_newline (NULL);
684 * C is the 1st significant character.
685 * Input_line_pointer points after that character.
687 if (is_name_beginner (c))
689 /* want user-defined label or pseudo/opcode */
690 HANDLE_CONDITIONAL_ASSEMBLY ();
692 s = --input_line_pointer;
693 c = get_symbol_end (); /* name's delimiter */
695 * C is character after symbol.
696 * That character's place in the input line is now '\0'.
697 * S points to the beginning of the symbol.
698 * [In case of pseudo-op, s->'.'.]
699 * Input_line_pointer->'\0' where c was.
701 if (TC_START_LABEL(c, input_line_pointer))
705 char *rest = input_line_pointer + 1;
707 /* In MRI mode, \tsym: set 0 is permitted. */
711 if (*rest == ' ' || *rest == '\t')
713 if ((strncasecmp (rest, "EQU", 3) == 0
714 || strncasecmp (rest, "SET", 3) == 0)
715 && (rest[3] == ' ' || rest[3] == '\t'))
717 input_line_pointer = rest + 3;
723 line_label = colon (s); /* user-defined label */
724 *input_line_pointer++ = ':'; /* Put ':' back for error messages' sake. */
725 /* Input_line_pointer->after ':'. */
731 || ((c == ' ' || c == '\t')
732 && input_line_pointer[1] == '='
733 #ifdef TC_EQUAL_IN_INSN
734 && ! TC_EQUAL_IN_INSN (c, input_line_pointer)
739 demand_empty_rest_of_line ();
742 { /* expect pseudo-op or machine instruction */
745 #define IGNORE_OPCODE_CASE
746 #ifdef IGNORE_OPCODE_CASE
751 if (isupper ((unsigned char) *s2))
758 if (NO_PSEUDO_DOT || flag_m68k_mri)
760 /* The MRI assembler and the m88k use pseudo-ops
762 pop = (pseudo_typeS *) hash_find (po_hash, s);
763 if (pop != NULL && pop->poc_handler == NULL)
768 || (! flag_m68k_mri && *s == '.'))
773 * WARNING: c has next char, which may be end-of-line.
774 * We lookup the pseudo-op table with s+1 because we
775 * already know that the pseudo-op begins with a '.'.
779 pop = (pseudo_typeS *) hash_find (po_hash, s + 1);
781 /* In MRI mode, we may need to insert an
782 automatic alignment directive. What a hack
784 if (mri_pending_align
786 || ! ((pop->poc_handler == cons
787 && pop->poc_val == 1)
788 || (pop->poc_handler == s_space
789 && pop->poc_val == 1)
790 #ifdef tc_conditional_pseudoop
791 || tc_conditional_pseudoop (pop)
793 || pop->poc_handler == s_if
794 || pop->poc_handler == s_ifdef
795 || pop->poc_handler == s_ifc
796 || pop->poc_handler == s_ifeqs
797 || pop->poc_handler == s_else
798 || pop->poc_handler == s_endif
799 || pop->poc_handler == s_globl
800 || pop->poc_handler == s_ignore)))
802 do_align (1, (char *) NULL, 0, 0);
803 mri_pending_align = 0;
804 if (line_label != NULL)
806 symbol_set_frag (line_label, frag_now);
807 S_SET_VALUE (line_label, frag_now_fix ());
811 /* Print the error msg now, while we still can */
814 as_bad (_("Unknown pseudo-op: `%s'"), s);
815 *input_line_pointer = c;
820 /* Put it back for error messages etc. */
821 *input_line_pointer = c;
822 /* The following skip of whitespace is compulsory.
823 A well shaped space is sometimes all that separates
824 keyword from operands. */
825 if (c == ' ' || c == '\t')
826 input_line_pointer++;
828 * Input_line is restored.
829 * Input_line_pointer->1st non-blank char
830 * after pseudo-operation.
832 (*pop->poc_handler) (pop->poc_val);
834 /* If that was .end, just get out now. */
835 if (pop->poc_handler == s_end)
841 #ifdef QUOTES_IN_INSN
845 /* WARNING: c has char, which may be end-of-line. */
846 /* Also: input_line_pointer->`\0` where c was. */
847 *input_line_pointer = c;
848 while (!is_end_of_line[(unsigned char) *input_line_pointer]
850 #ifdef TC_EOL_IN_INSN
851 || TC_EOL_IN_INSN (input_line_pointer)
855 if (flag_m68k_mri && *input_line_pointer == '\'')
857 #ifdef QUOTES_IN_INSN
860 else if (*input_line_pointer == '"')
862 else if (*input_line_pointer == '\\')
865 input_line_pointer++;
868 c = *input_line_pointer;
869 *input_line_pointer = '\0';
871 generate_lineno_debug ();
879 if (check_macro (s, &out, '\0', &err, ¯o))
883 *input_line_pointer++ = c;
884 input_scrub_include_sb (&out,
885 input_line_pointer, 1);
888 input_scrub_next_buffer (&input_line_pointer);
890 md_macro_info (macro);
896 if (mri_pending_align)
898 do_align (1, (char *) NULL, 0, 0);
899 mri_pending_align = 0;
900 if (line_label != NULL)
902 symbol_set_frag (line_label, frag_now);
903 S_SET_VALUE (line_label, frag_now_fix ());
907 md_assemble (s); /* Assemble 1 instruction. */
909 *input_line_pointer++ = c;
911 /* We resume loop AFTER the end-of-line from
916 } /* if (is_name_beginner(c) */
919 /* Empty statement? */
920 if (is_end_of_line[(unsigned char) c])
923 if ((LOCAL_LABELS_DOLLAR || LOCAL_LABELS_FB)
924 && isdigit ((unsigned char) c))
926 /* local label ("4:") */
927 char *backup = input_line_pointer;
929 HANDLE_CONDITIONAL_ASSEMBLY ();
933 while (isdigit ((unsigned char) *input_line_pointer))
935 temp = (temp * 10) + *input_line_pointer - '0';
936 ++input_line_pointer;
937 } /* read the whole number */
939 if (LOCAL_LABELS_DOLLAR
940 && *input_line_pointer == '$'
941 && *(input_line_pointer + 1) == ':')
943 input_line_pointer += 2;
945 if (dollar_label_defined (temp))
947 as_fatal (_("label \"%d$\" redefined"), temp);
950 define_dollar_label (temp);
951 colon (dollar_label_name (temp, 0));
956 && *input_line_pointer++ == ':')
958 fb_label_instance_inc (temp);
959 colon (fb_label_name (temp, 0));
963 input_line_pointer = backup;
964 } /* local label ("4:") */
966 if (c && strchr (line_comment_chars, c))
967 { /* Its a comment. Better say APP or NO_APP */
971 unsigned int new_length;
974 bump_line_counters ();
975 s = input_line_pointer;
976 if (strncmp (s, "APP\n", 4))
977 continue; /* We ignore it */
980 ends = strstr (s, "#NO_APP\n");
984 unsigned int tmp_len;
987 /* The end of the #APP wasn't in this buffer. We
988 keep reading in buffers until we find the #NO_APP
989 that goes with this #APP There is one. The specs
991 tmp_len = buffer_limit - s;
992 tmp_buf = xmalloc (tmp_len + 1);
993 memcpy (tmp_buf, s, tmp_len);
996 new_tmp = input_scrub_next_buffer (&buffer);
1000 buffer_limit = new_tmp;
1001 input_line_pointer = buffer;
1002 ends = strstr (buffer, "#NO_APP\n");
1004 num = ends - buffer;
1006 num = buffer_limit - buffer;
1008 tmp_buf = xrealloc (tmp_buf, tmp_len + num);
1009 memcpy (tmp_buf + tmp_len, buffer, num);
1014 input_line_pointer = ends ? ends + 8 : NULL;
1022 input_line_pointer = ends + 8;
1026 scrub_string_end = ends;
1028 new_length = ends - s;
1029 new_buf = (char *) xmalloc (new_length);
1036 space = (new_buf + new_length) - new_tmp;
1037 size = do_scrub_chars (scrub_from_string, new_tmp, space);
1045 new_buf = xrealloc (new_buf, new_length + 100);
1046 new_tmp = new_buf + new_length;
1052 old_buffer = buffer;
1053 old_input = input_line_pointer;
1054 old_limit = buffer_limit;
1056 input_line_pointer = new_buf;
1057 buffer_limit = new_tmp;
1061 HANDLE_CONDITIONAL_ASSEMBLY ();
1063 #ifdef tc_unrecognized_line
1064 if (tc_unrecognized_line (c))
1068 /* as_warn("Junk character %d.",c); Now done by ignore_rest */
1069 input_line_pointer--; /* Report unknown char as ignored. */
1070 ignore_rest_of_line ();
1071 } /* while (input_line_pointer<buffer_limit) */
1073 #ifdef md_after_pass_hook
1074 md_after_pass_hook ();
1080 bump_line_counters ();
1083 buffer = old_buffer;
1084 input_line_pointer = old_input;
1085 buffer_limit = old_limit;
1090 } /* while (more buffers to scan) */
1097 input_scrub_close (); /* Close the input file */
1100 /* For most MRI pseudo-ops, the line actually ends at the first
1101 nonquoted space. This function looks for that point, stuffs a null
1102 in, and sets *STOPCP to the character that used to be there, and
1103 returns the location.
1105 Until I hear otherwise, I am going to assume that this is only true
1106 for the m68k MRI assembler. */
1109 mri_comment_field (stopcp)
1117 know (flag_m68k_mri);
1119 for (s = input_line_pointer;
1120 ((! is_end_of_line[(unsigned char) *s] && *s != ' ' && *s != '\t')
1125 inquote = ! inquote;
1135 for (s = input_line_pointer; ! is_end_of_line[(unsigned char) *s]; s++)
1145 /* Skip to the end of an MRI comment field. */
1148 mri_comment_end (stop, stopc)
1154 input_line_pointer = stop;
1156 while (! is_end_of_line[(unsigned char) *input_line_pointer])
1157 ++input_line_pointer;
1162 int ignore ATTRIBUTE_UNUSED;
1164 as_fatal (_(".abort detected. Abandoning ship."));
1167 /* Guts of .align directive. N is the power of two to which to align.
1168 FILL may be NULL, or it may point to the bytes of the fill pattern.
1169 LEN is the length of whatever FILL points to, if anything. MAX is
1170 the maximum number of characters to skip when doing the alignment,
1171 or 0 if there is no maximum. */
1174 do_align (n, fill, len, max)
1183 md_do_align (n, fill, len, max, just_record_alignment);
1188 if (subseg_text_p (now_seg))
1189 default_fill = NOP_OPCODE;
1192 fill = &default_fill;
1196 /* Only make a frag if we HAVE to. . . */
1197 if (n != 0 && !need_pass_2)
1200 frag_align (n, *fill, max);
1202 frag_align_pattern (n, fill, len, max);
1206 just_record_alignment:
1209 record_alignment (now_seg, n - OCTETS_PER_BYTE_POWER);
1212 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1213 (in bytes). A negative ARG is the negative of the length of the
1214 fill pattern. BYTES_P is non-zero if the alignment value should be
1215 interpreted as the byte boundary, rather than the power of 2. */
1218 s_align (arg, bytes_p)
1222 register unsigned int align;
1230 stop = mri_comment_field (&stopc);
1232 if (is_end_of_line[(unsigned char) *input_line_pointer])
1237 align = arg; /* Default value from pseudo-op table */
1241 align = get_absolute_expression ();
1247 /* Convert to a power of 2. */
1252 for (i = 0; (align & 1) == 0; align >>= 1, ++i)
1255 as_bad (_("Alignment not a power of 2"));
1263 as_bad (_("Alignment too large: %u assumed"), align);
1266 if (*input_line_pointer != ',')
1273 ++input_line_pointer;
1274 if (*input_line_pointer == ',')
1278 fill = get_absolute_expression ();
1283 if (*input_line_pointer != ',')
1287 ++input_line_pointer;
1288 max = get_absolute_expression ();
1295 as_warn (_("expected fill pattern missing"));
1296 do_align (align, (char *) NULL, 0, max);
1311 do_align (align, &fill_char, fill_len, max);
1317 if ((size_t) fill_len > sizeof ab)
1319 md_number_to_chars (ab, fill, fill_len);
1320 do_align (align, ab, fill_len, max);
1324 demand_empty_rest_of_line ();
1327 mri_comment_end (stop, stopc);
1330 /* Handle the .align pseudo-op on machines where ".align 4" means
1331 align to a 4 byte boundary. */
1340 /* Handle the .align pseudo-op on machines where ".align 4" means align
1341 to a 2**4 boundary. */
1352 int ignore ATTRIBUTE_UNUSED;
1354 register char *name;
1358 register symbolS *symbolP;
1363 stop = mri_comment_field (&stopc);
1365 name = input_line_pointer;
1366 c = get_symbol_end ();
1367 /* just after name is now '\0' */
1368 p = input_line_pointer;
1371 if (*input_line_pointer != ',')
1373 as_bad (_("Expected comma after symbol-name: rest of line ignored."));
1374 ignore_rest_of_line ();
1376 mri_comment_end (stop, stopc);
1379 input_line_pointer++; /* skip ',' */
1380 if ((temp = get_absolute_expression ()) < 0)
1382 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp);
1383 ignore_rest_of_line ();
1385 mri_comment_end (stop, stopc);
1389 symbolP = symbol_find_or_make (name);
1391 if (S_IS_DEFINED (symbolP) && ! S_IS_COMMON (symbolP))
1393 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
1394 S_GET_NAME (symbolP));
1395 ignore_rest_of_line ();
1397 mri_comment_end (stop, stopc);
1400 if (S_GET_VALUE (symbolP))
1402 if (S_GET_VALUE (symbolP) != (valueT) temp)
1403 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
1404 S_GET_NAME (symbolP),
1405 (long) S_GET_VALUE (symbolP),
1410 S_SET_VALUE (symbolP, (valueT) temp);
1411 S_SET_EXTERNAL (symbolP);
1415 extern int flag_one;
1416 if ( (!temp) || !flag_one)
1417 S_GET_OTHER(symbolP) = const_flag;
1419 #endif /* not OBJ_VMS */
1420 know (symbolP->sy_frag == &zero_address_frag);
1422 demand_empty_rest_of_line ();
1425 mri_comment_end (stop, stopc);
1428 /* The MRI COMMON pseudo-op. We handle this by creating a common
1429 symbol with the appropriate name. We make s_space do the right
1430 thing by increasing the size. */
1433 s_mri_common (small)
1434 int small ATTRIBUTE_UNUSED;
1450 stop = mri_comment_field (&stopc);
1454 name = input_line_pointer;
1455 if (! isdigit ((unsigned char) *name))
1456 c = get_symbol_end ();
1461 ++input_line_pointer;
1463 while (isdigit ((unsigned char) *input_line_pointer));
1464 c = *input_line_pointer;
1465 *input_line_pointer = '\0';
1467 if (line_label != NULL)
1469 alc = (char *) xmalloc (strlen (S_GET_NAME (line_label))
1470 + (input_line_pointer - name)
1472 sprintf (alc, "%s%s", name, S_GET_NAME (line_label));
1477 sym = symbol_find_or_make (name);
1478 *input_line_pointer = c;
1482 if (*input_line_pointer != ',')
1486 ++input_line_pointer;
1487 align = get_absolute_expression ();
1490 if (S_IS_DEFINED (sym) && ! S_IS_COMMON (sym))
1492 as_bad (_("attempt to re-define symbol `%s'"), S_GET_NAME (sym));
1493 ignore_rest_of_line ();
1494 mri_comment_end (stop, stopc);
1498 S_SET_EXTERNAL (sym);
1499 mri_common_symbol = sym;
1503 S_SET_ALIGN (sym, align);
1506 if (line_label != NULL)
1509 exp.X_op = O_symbol;
1510 exp.X_add_symbol = sym;
1511 exp.X_add_number = 0;
1512 symbol_set_value_expression (line_label, &exp);
1513 symbol_set_frag (line_label, &zero_address_frag);
1514 S_SET_SEGMENT (line_label, expr_section);
1517 /* FIXME: We just ignore the small argument, which distinguishes
1518 COMMON and COMMON.S. I don't know what we can do about it. */
1520 /* Ignore the type and hptype. */
1521 if (*input_line_pointer == ',')
1522 input_line_pointer += 2;
1523 if (*input_line_pointer == ',')
1524 input_line_pointer += 2;
1526 demand_empty_rest_of_line ();
1528 mri_comment_end (stop, stopc);
1533 int ignore ATTRIBUTE_UNUSED;
1538 temp = get_absolute_expression ();
1539 if (flag_readonly_data_in_text)
1541 section = text_section;
1545 section = data_section;
1547 subseg_set (section, (subsegT) temp);
1552 demand_empty_rest_of_line ();
1555 /* Handle the .appfile pseudo-op. This is automatically generated by
1556 do_scrub_chars when a preprocessor # line comment is seen with a
1557 file name. This default definition may be overridden by the object
1558 or CPU specific pseudo-ops. This function is also the default
1559 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1563 s_app_file (appfile)
1569 /* Some assemblers tolerate immediately following '"' */
1570 if ((s = demand_copy_string (&length)) != 0)
1572 /* If this is a fake .appfile, a fake newline was inserted into
1573 the buffer. Passing -2 to new_logical_line tells it to
1576 = (! new_logical_line (s, appfile ? -2 : -1) && appfile);
1578 /* In MRI mode, the preprocessor may have inserted an extraneous
1581 && *input_line_pointer == '\''
1582 && is_end_of_line[(unsigned char) input_line_pointer[1]])
1583 ++input_line_pointer;
1585 demand_empty_rest_of_line ();
1590 listing_source_file (s);
1592 register_dependency (s);
1600 /* Handle the .appline pseudo-op. This is automatically generated by
1601 do_scrub_chars when a preprocessor # line comment is seen. This
1602 default definition may be overridden by the object or CPU specific
1607 int ignore ATTRIBUTE_UNUSED;
1611 /* The given number is that of the next line. */
1612 l = get_absolute_expression () - 1;
1614 /* Some of the back ends can't deal with non-positive line numbers.
1615 Besides, it's silly. */
1616 as_warn (_("Line numbers must be positive; line number %d rejected."), l+1);
1619 new_logical_line ((char *) NULL, l);
1622 listing_source_line (l);
1625 demand_empty_rest_of_line ();
1628 /* Handle the .end pseudo-op. Actually, the real work is done in
1629 read_a_source_file. */
1633 int ignore ATTRIBUTE_UNUSED;
1637 /* The MRI assembler permits the start symbol to follow .end,
1638 but we don't support that. */
1640 if (! is_end_of_line[(unsigned char) *input_line_pointer]
1641 && *input_line_pointer != '*'
1642 && *input_line_pointer != '!')
1643 as_warn (_("start address not supported"));
1647 /* Handle the .err pseudo-op. */
1651 int ignore ATTRIBUTE_UNUSED;
1653 as_bad (_(".err encountered"));
1654 demand_empty_rest_of_line ();
1657 /* Handle the MRI fail pseudo-op. */
1661 int ignore ATTRIBUTE_UNUSED;
1668 stop = mri_comment_field (&stopc);
1670 temp = get_absolute_expression ();
1672 as_warn (_(".fail %ld encountered"), (long) temp);
1674 as_bad (_(".fail %ld encountered"), (long) temp);
1676 demand_empty_rest_of_line ();
1679 mri_comment_end (stop, stopc);
1684 int ignore ATTRIBUTE_UNUSED;
1686 expressionS rep_exp;
1688 register long fill = 0;
1691 #ifdef md_flush_pending_output
1692 md_flush_pending_output ();
1695 get_known_segmented_expression (&rep_exp);
1696 if (*input_line_pointer == ',')
1698 input_line_pointer++;
1699 size = get_absolute_expression ();
1700 if (*input_line_pointer == ',')
1702 input_line_pointer++;
1703 fill = get_absolute_expression ();
1707 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1708 #define BSD_FILL_SIZE_CROCK_8 (8)
1709 if (size > BSD_FILL_SIZE_CROCK_8)
1711 as_warn (_(".fill size clamped to %d."), BSD_FILL_SIZE_CROCK_8);
1712 size = BSD_FILL_SIZE_CROCK_8;
1716 as_warn (_("Size negative: .fill ignored."));
1719 else if (rep_exp.X_op == O_constant && rep_exp.X_add_number <= 0)
1721 if (rep_exp.X_add_number < 0)
1722 as_warn (_("Repeat < 0, .fill ignored"));
1726 if (size && !need_pass_2)
1728 if (rep_exp.X_op == O_constant)
1730 p = frag_var (rs_fill, (int) size, (int) size,
1731 (relax_substateT) 0, (symbolS *) 0,
1732 (offsetT) rep_exp.X_add_number,
1737 /* We don't have a constant repeat count, so we can't use
1738 rs_fill. We can get the same results out of rs_space,
1739 but its argument is in bytes, so we must multiply the
1740 repeat count by size. */
1743 rep_sym = make_expr_symbol (&rep_exp);
1746 expressionS size_exp;
1747 size_exp.X_op = O_constant;
1748 size_exp.X_add_number = size;
1750 rep_exp.X_op = O_multiply;
1751 rep_exp.X_add_symbol = rep_sym;
1752 rep_exp.X_op_symbol = make_expr_symbol (&size_exp);
1753 rep_exp.X_add_number = 0;
1754 rep_sym = make_expr_symbol (&rep_exp);
1757 p = frag_var (rs_space, (int) size, (int) size,
1758 (relax_substateT) 0, rep_sym, (offsetT) 0, (char *) 0);
1760 memset (p, 0, (unsigned int) size);
1761 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1762 * flavoured AS. The following bizzare behaviour is to be
1763 * compatible with above. I guess they tried to take up to 8
1764 * bytes from a 4-byte expression and they forgot to sign
1765 * extend. Un*x Sux. */
1766 #define BSD_FILL_SIZE_CROCK_4 (4)
1767 md_number_to_chars (p, (valueT) fill,
1768 (size > BSD_FILL_SIZE_CROCK_4
1769 ? BSD_FILL_SIZE_CROCK_4
1771 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1772 * but emits no error message because it seems a legal thing to do.
1773 * It is a degenerate case of .fill but could be emitted by a compiler.
1776 demand_empty_rest_of_line ();
1781 int ignore ATTRIBUTE_UNUSED;
1790 stop = mri_comment_field (&stopc);
1794 name = input_line_pointer;
1795 c = get_symbol_end ();
1796 symbolP = symbol_find_or_make (name);
1797 S_SET_EXTERNAL (symbolP);
1799 *input_line_pointer = c;
1801 c = *input_line_pointer;
1804 input_line_pointer++;
1806 if (*input_line_pointer == '\n')
1812 demand_empty_rest_of_line ();
1815 mri_comment_end (stop, stopc);
1818 /* Handle the MRI IRP and IRPC pseudo-ops. */
1830 as_where (&file, &line);
1833 while (! is_end_of_line[(unsigned char) *input_line_pointer])
1834 sb_add_char (&s, *input_line_pointer++);
1838 err = expand_irp (irpc, 0, &s, &out, get_line_sb, '\0');
1840 as_bad_where (file, line, "%s", err);
1844 input_scrub_include_sb (&out, input_line_pointer, 1);
1846 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
1849 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1850 the section to only be linked once. However, this is not supported
1851 by most object file formats. This takes an optional argument,
1852 which is what to do about duplicates. */
1856 int ignore ATTRIBUTE_UNUSED;
1858 enum linkonce_type type;
1862 type = LINKONCE_DISCARD;
1864 if (! is_end_of_line[(unsigned char) *input_line_pointer])
1869 s = input_line_pointer;
1870 c = get_symbol_end ();
1871 if (strcasecmp (s, "discard") == 0)
1872 type = LINKONCE_DISCARD;
1873 else if (strcasecmp (s, "one_only") == 0)
1874 type = LINKONCE_ONE_ONLY;
1875 else if (strcasecmp (s, "same_size") == 0)
1876 type = LINKONCE_SAME_SIZE;
1877 else if (strcasecmp (s, "same_contents") == 0)
1878 type = LINKONCE_SAME_CONTENTS;
1880 as_warn (_("unrecognized .linkonce type `%s'"), s);
1882 *input_line_pointer = c;
1885 #ifdef obj_handle_link_once
1886 obj_handle_link_once (type);
1887 #else /* ! defined (obj_handle_link_once) */
1888 #ifdef BFD_ASSEMBLER
1892 if ((bfd_applicable_section_flags (stdoutput) & SEC_LINK_ONCE) == 0)
1893 as_warn (_(".linkonce is not supported for this object file format"));
1895 flags = bfd_get_section_flags (stdoutput, now_seg);
1896 flags |= SEC_LINK_ONCE;
1901 case LINKONCE_DISCARD:
1902 flags |= SEC_LINK_DUPLICATES_DISCARD;
1904 case LINKONCE_ONE_ONLY:
1905 flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
1907 case LINKONCE_SAME_SIZE:
1908 flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
1910 case LINKONCE_SAME_CONTENTS:
1911 flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
1914 if (! bfd_set_section_flags (stdoutput, now_seg, flags))
1915 as_bad (_("bfd_set_section_flags: %s"),
1916 bfd_errmsg (bfd_get_error ()));
1918 #else /* ! defined (BFD_ASSEMBLER) */
1919 as_warn (_(".linkonce is not supported for this object file format"));
1920 #endif /* ! defined (BFD_ASSEMBLER) */
1921 #endif /* ! defined (obj_handle_link_once) */
1923 demand_empty_rest_of_line ();
1927 s_lcomm_internal (needs_align, bytes_p)
1928 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1929 (alignment); 0 if it was an ".lcomm" (2 args only) */
1931 /* 1 if the alignment value should be interpreted as the byte boundary,
1932 rather than the power of 2. */
1935 register char *name;
1939 register symbolS *symbolP;
1940 segT current_seg = now_seg;
1941 subsegT current_subseg = now_subseg;
1942 const int max_alignment = 15;
1944 segT bss_seg = bss_section;
1946 name = input_line_pointer;
1947 c = get_symbol_end ();
1948 p = input_line_pointer;
1952 /* Accept an optional comma after the name. The comma used to be
1953 required, but Irix 5 cc does not generate it. */
1954 if (*input_line_pointer == ',')
1956 ++input_line_pointer;
1960 if (*input_line_pointer == '\n')
1962 as_bad (_("Missing size expression"));
1966 if ((temp = get_absolute_expression ()) < 0)
1968 as_warn (_("BSS length (%d.) <0! Ignored."), temp);
1969 ignore_rest_of_line ();
1973 #if defined (TC_MIPS) || defined (TC_ALPHA)
1974 if (OUTPUT_FLAVOR == bfd_target_ecoff_flavour
1975 || OUTPUT_FLAVOR == bfd_target_elf_flavour)
1977 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1978 if (temp <= bfd_get_gp_size (stdoutput))
1980 bss_seg = subseg_new (".sbss", 1);
1981 seg_info (bss_seg)->bss = 1;
1982 #ifdef BFD_ASSEMBLER
1983 if (! bfd_set_section_flags (stdoutput, bss_seg, SEC_ALLOC))
1984 as_warn (_("error setting flags for \".sbss\": %s"),
1985 bfd_errmsg (bfd_get_error ()));
1993 TC_IMPLICIT_LCOMM_ALIGNMENT (temp, align);
1995 /* Still zero unless TC_IMPLICIT_LCOMM_ALIGNMENT set it. */
1997 record_alignment(bss_seg, align);
2004 if (*input_line_pointer != ',')
2006 as_bad (_("Expected comma after size"));
2007 ignore_rest_of_line ();
2010 input_line_pointer++;
2012 if (*input_line_pointer == '\n')
2014 as_bad (_("Missing alignment"));
2017 align = get_absolute_expression ();
2020 /* Convert to a power of 2. */
2025 for (i = 0; (align & 1) == 0; align >>= 1, ++i)
2028 as_bad (_("Alignment not a power of 2"));
2032 if (align > max_alignment)
2034 align = max_alignment;
2035 as_warn (_("Alignment too large: %d. assumed."), align);
2040 as_warn (_("Alignment negative. 0 assumed."));
2042 record_alignment (bss_seg, align);
2043 } /* if needs align */
2046 /* Assume some objects may require alignment on some systems. */
2047 #if defined (TC_ALPHA) && ! defined (VMS)
2050 align = ffs (temp) - 1;
2051 if (temp % (1 << align))
2058 symbolP = symbol_find_or_make (name);
2062 #if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT) \
2063 || defined (OBJ_BOUT) || defined (OBJ_MAYBE_BOUT))
2064 #ifdef BFD_ASSEMBLER
2065 (OUTPUT_FLAVOR != bfd_target_aout_flavour
2066 || (S_GET_OTHER (symbolP) == 0 && S_GET_DESC (symbolP) == 0)) &&
2068 (S_GET_OTHER (symbolP) == 0 && S_GET_DESC (symbolP) == 0) &&
2071 (S_GET_SEGMENT (symbolP) == bss_seg
2072 || (!S_IS_DEFINED (symbolP) && S_GET_VALUE (symbolP) == 0)))
2076 subseg_set (bss_seg, 1);
2079 frag_align (align, 0, 0);
2080 /* detach from old frag */
2081 if (S_GET_SEGMENT (symbolP) == bss_seg)
2082 symbol_get_frag (symbolP)->fr_symbol = NULL;
2084 symbol_set_frag (symbolP, frag_now);
2085 pfrag = frag_var (rs_org, 1, 1, (relax_substateT)0, symbolP,
2086 (offsetT) temp, (char *) 0);
2089 S_SET_SEGMENT (symbolP, bss_seg);
2092 /* The symbol may already have been created with a preceding
2093 ".globl" directive -- be careful not to step on storage class
2094 in that case. Otherwise, set it to static. */
2095 if (S_GET_STORAGE_CLASS (symbolP) != C_EXT)
2097 S_SET_STORAGE_CLASS (symbolP, C_STAT);
2099 #endif /* OBJ_COFF */
2102 S_SET_SIZE (symbolP, temp);
2106 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
2107 S_GET_NAME (symbolP));
2109 subseg_set (current_seg, current_subseg);
2111 demand_empty_rest_of_line ();
2112 } /* s_lcomm_internal() */
2115 s_lcomm (needs_align)
2118 s_lcomm_internal (needs_align, 0);
2121 void s_lcomm_bytes (needs_align)
2124 s_lcomm_internal (needs_align, 1);
2129 int ignore ATTRIBUTE_UNUSED;
2131 register char *name;
2135 register symbolS *symbolP;
2137 /* we permit ANY defined expression: BSD4.2 demands constants */
2138 name = input_line_pointer;
2139 c = get_symbol_end ();
2140 p = input_line_pointer;
2143 if (*input_line_pointer != ',')
2146 as_bad (_("Expected comma after name \"%s\""), name);
2148 ignore_rest_of_line ();
2151 input_line_pointer++;
2153 if (exp.X_op != O_constant
2154 && exp.X_op != O_register)
2156 as_bad (_("bad expression"));
2157 ignore_rest_of_line ();
2161 symbolP = symbol_find_or_make (name);
2163 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2164 symbolP->sy_desc == 0) out of this test because coff doesn't have
2165 those fields, and I can't see when they'd ever be tripped. I
2166 don't think I understand why they were here so I may have
2167 introduced a bug. As recently as 1.37 didn't have this test
2168 anyway. xoxorich. */
2170 if (S_GET_SEGMENT (symbolP) == undefined_section
2171 && S_GET_VALUE (symbolP) == 0)
2173 /* The name might be an undefined .global symbol; be sure to
2174 keep the "external" bit. */
2175 S_SET_SEGMENT (symbolP,
2176 (exp.X_op == O_constant
2179 S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
2183 as_bad (_("Symbol %s already defined"), name);
2186 demand_empty_rest_of_line ();
2189 /* Read a line into an sb. */
2195 char quote1, quote2, inquote;
2197 if (input_line_pointer[-1] == '\n')
2198 bump_line_counters ();
2200 if (input_line_pointer >= buffer_limit)
2202 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
2203 if (buffer_limit == 0)
2207 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2208 code needs to be changed. */
2209 if (! flag_m68k_mri)
2217 #ifdef LEX_IS_STRINGQUOTE
2222 while (! is_end_of_line[(unsigned char) *input_line_pointer]
2223 || (inquote != '\0' && *input_line_pointer != '\n'))
2225 if (inquote == *input_line_pointer)
2227 else if (inquote == '\0')
2229 if (*input_line_pointer == quote1)
2231 else if (*input_line_pointer == quote2)
2234 sb_add_char (line, *input_line_pointer++);
2236 while (input_line_pointer < buffer_limit
2237 && is_end_of_line[(unsigned char) *input_line_pointer])
2239 if (input_line_pointer[-1] == '\n')
2240 bump_line_counters ();
2241 ++input_line_pointer;
2246 /* Define a macro. This is an interface to macro.c, which is shared
2247 between gas and gasp. */
2251 int ignore ATTRIBUTE_UNUSED;
2260 as_where (&file, &line);
2263 while (! is_end_of_line[(unsigned char) *input_line_pointer])
2264 sb_add_char (&s, *input_line_pointer++);
2267 if (line_label != NULL)
2268 sb_add_string (&label, S_GET_NAME (line_label));
2270 err = define_macro (0, &s, &label, get_line_sb, &name);
2272 as_bad_where (file, line, "%s", err);
2275 if (line_label != NULL)
2277 S_SET_SEGMENT (line_label, undefined_section);
2278 S_SET_VALUE (line_label, 0);
2279 symbol_set_frag (line_label, &zero_address_frag);
2282 if (((NO_PSEUDO_DOT || flag_m68k_mri)
2283 && hash_find (po_hash, name) != NULL)
2286 && hash_find (po_hash, name + 1) != NULL))
2287 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2294 /* Handle the .mexit pseudo-op, which immediately exits a macro
2299 int ignore ATTRIBUTE_UNUSED;
2301 cond_exit_macro (macro_nest);
2302 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
2305 /* Switch in and out of MRI mode. */
2309 int ignore ATTRIBUTE_UNUSED;
2313 on = get_absolute_expression ();
2314 old_flag = flag_mri;
2332 /* Operator precedence changes in m68k MRI mode, so we need to
2333 update the operator rankings. */
2334 expr_set_precedence ();
2336 #ifdef MRI_MODE_CHANGE
2338 MRI_MODE_CHANGE (on);
2341 demand_empty_rest_of_line ();
2344 /* Handle changing the location counter. */
2347 do_org (segment, exp, fill)
2352 if (segment != now_seg && segment != absolute_section)
2353 as_bad (_("invalid segment \"%s\"; segment \"%s\" assumed"),
2354 segment_name (segment), segment_name (now_seg));
2356 if (now_seg == absolute_section)
2359 as_warn (_("ignoring fill value in absolute section"));
2360 if (exp->X_op != O_constant)
2362 as_bad (_("only constant offsets supported in absolute section"));
2363 exp->X_add_number = 0;
2365 abs_section_offset = exp->X_add_number;
2371 p = frag_var (rs_org, 1, 1, (relax_substateT) 0, exp->X_add_symbol,
2372 exp->X_add_number * OCTETS_PER_BYTE, (char *) NULL);
2379 int ignore ATTRIBUTE_UNUSED;
2381 register segT segment;
2383 register long temp_fill;
2385 #ifdef md_flush_pending_output
2386 md_flush_pending_output ();
2389 /* The m68k MRI assembler has a different meaning for .org. It
2390 means to create an absolute section at a given address. We can't
2391 support that--use a linker script instead. */
2394 as_bad (_("MRI style ORG pseudo-op not supported"));
2395 ignore_rest_of_line ();
2399 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2400 thing as a sub-segment-relative origin. Any absolute origin is
2401 given a warning, then assumed to be segment-relative. Any
2402 segmented origin expression ("foo+42") had better be in the right
2403 segment or the .org is ignored.
2405 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2406 we never know sub-segment sizes when we are reading code. BSD
2407 will crash trying to emit negative numbers of filler bytes in
2408 certain .orgs. We don't crash, but see as-write for that code.
2410 Don't make frag if need_pass_2==1. */
2411 segment = get_known_segmented_expression (&exp);
2412 if (*input_line_pointer == ',')
2414 input_line_pointer++;
2415 temp_fill = get_absolute_expression ();
2421 do_org (segment, &exp, temp_fill);
2423 demand_empty_rest_of_line ();
2426 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2427 called by the obj-format routine which handles section changing
2428 when in MRI mode. It will create a new section, and return it. It
2429 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2430 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2431 flags will be set in the section. */
2435 char *type ATTRIBUTE_UNUSED;
2445 name = input_line_pointer;
2446 if (! isdigit ((unsigned char) *name))
2447 c = get_symbol_end ();
2452 ++input_line_pointer;
2454 while (isdigit ((unsigned char) *input_line_pointer));
2455 c = *input_line_pointer;
2456 *input_line_pointer = '\0';
2459 name = xstrdup (name);
2461 *input_line_pointer = c;
2463 seg = subseg_new (name, 0);
2465 if (*input_line_pointer == ',')
2469 ++input_line_pointer;
2470 align = get_absolute_expression ();
2471 record_alignment (seg, align);
2475 if (*input_line_pointer == ',')
2477 c = *++input_line_pointer;
2478 c = toupper ((unsigned char) c);
2479 if (c == 'C' || c == 'D' || c == 'M' || c == 'R')
2482 as_bad (_("unrecognized section type"));
2483 ++input_line_pointer;
2485 #ifdef BFD_ASSEMBLER
2489 flags = SEC_NO_FLAGS;
2491 flags = SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE;
2492 else if (*type == 'D' || *type == 'M')
2493 flags = SEC_ALLOC | SEC_LOAD | SEC_DATA;
2494 else if (*type == 'R')
2495 flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_READONLY | SEC_ROM;
2496 if (flags != SEC_NO_FLAGS)
2498 if (! bfd_set_section_flags (stdoutput, seg, flags))
2499 as_warn (_("error setting flags for \"%s\": %s"),
2500 bfd_section_name (stdoutput, seg),
2501 bfd_errmsg (bfd_get_error ()));
2507 /* Ignore the HP type. */
2508 if (*input_line_pointer == ',')
2509 input_line_pointer += 2;
2511 demand_empty_rest_of_line ();
2513 #else /* ! TC_M68K */
2522 name = input_line_pointer;
2523 c = get_symbol_end ();
2525 name = xstrdup (name);
2527 *input_line_pointer = c;
2529 seg = subseg_new (name, 0);
2531 if (*input_line_pointer != ',')
2537 ++input_line_pointer;
2539 sectype = input_line_pointer;
2540 c = get_symbol_end ();
2541 if (*sectype == '\0')
2543 else if (strcasecmp (sectype, "text") == 0)
2545 else if (strcasecmp (sectype, "data") == 0)
2547 else if (strcasecmp (sectype, "romdata") == 0)
2550 as_warn (_("unrecognized section type `%s'"), sectype);
2551 *input_line_pointer = c;
2554 if (*input_line_pointer == ',')
2558 ++input_line_pointer;
2560 seccmd = input_line_pointer;
2561 c = get_symbol_end ();
2562 if (strcasecmp (seccmd, "absolute") == 0)
2564 as_bad (_("absolute sections are not supported"));
2565 *input_line_pointer = c;
2566 ignore_rest_of_line ();
2569 else if (strcasecmp (seccmd, "align") == 0)
2573 *input_line_pointer = c;
2574 align = get_absolute_expression ();
2575 record_alignment (seg, align);
2579 as_warn (_("unrecognized section command `%s'"), seccmd);
2580 *input_line_pointer = c;
2584 demand_empty_rest_of_line ();
2586 #else /* ! TC_I960 */
2587 /* The MRI assembler seems to use different forms of .sect for
2588 different targets. */
2589 as_bad ("MRI mode not supported for this target");
2590 ignore_rest_of_line ();
2591 #endif /* ! TC_I960 */
2592 #endif /* ! TC_M68K */
2595 /* Handle the .print pseudo-op. */
2599 int ignore ATTRIBUTE_UNUSED;
2604 s = demand_copy_C_string (&len);
2606 demand_empty_rest_of_line ();
2609 /* Handle the .purgem pseudo-op. */
2613 int ignore ATTRIBUTE_UNUSED;
2615 if (is_it_end_of_statement ())
2617 demand_empty_rest_of_line ();
2627 name = input_line_pointer;
2628 c = get_symbol_end ();
2629 delete_macro (name);
2630 *input_line_pointer = c;
2633 while (*input_line_pointer++ == ',');
2635 --input_line_pointer;
2636 demand_empty_rest_of_line ();
2639 /* Handle the .rept pseudo-op. */
2643 int ignore ATTRIBUTE_UNUSED;
2647 count = get_absolute_expression ();
2649 do_repeat(count, "REPT", "ENDR");
2652 /* This function provides a generic repeat block implementation. It allows
2653 different directives to be used as the start/end keys. */
2656 do_repeat (count, start, end)
2665 if (! buffer_and_nest (start, end, &one, get_line_sb))
2667 as_bad (_("%s without %s"), start, end);
2673 sb_add_sb (&many, &one);
2677 input_scrub_include_sb (&many, input_line_pointer, 1);
2679 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
2682 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2683 input buffers to skip. Assumes that conditionals preceding the loop end
2684 are properly nested.
2686 This function makes it easier to implement a premature "break" out of the
2687 loop. The EXTRA arg accounts for other buffers we might have inserted,
2688 such as line substitutions. */
2694 cond_exit_macro (macro_nest);
2695 while (extra-- >= 0)
2696 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
2699 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2700 this is .equiv, and it is an error if the symbol is already
2707 register char *name;
2708 register char delim;
2709 register char *end_name;
2710 register symbolS *symbolP;
2713 * Especial apologies for the random logic:
2714 * this just grew, and could be parsed much more simply!
2717 name = input_line_pointer;
2718 delim = get_symbol_end ();
2719 end_name = input_line_pointer;
2723 if (*input_line_pointer != ',')
2726 as_bad (_("Expected comma after name \"%s\""), name);
2728 ignore_rest_of_line ();
2732 input_line_pointer++;
2735 if (name[0] == '.' && name[1] == '\0')
2737 /* Turn '. = mumble' into a .org mumble */
2738 register segT segment;
2741 segment = get_known_segmented_expression (&exp);
2744 do_org (segment, &exp, 0);
2750 if ((symbolP = symbol_find (name)) == NULL
2751 && (symbolP = md_undefined_symbol (name)) == NULL)
2754 /* When doing symbol listings, play games with dummy fragments living
2755 outside the normal fragment chain to record the file and line info
2757 if (listing & LISTING_SYMBOLS)
2759 extern struct list_info_struct *listing_tail;
2760 fragS *dummy_frag = (fragS *) xmalloc (sizeof(fragS));
2761 memset (dummy_frag, 0, sizeof(fragS));
2762 dummy_frag->fr_type = rs_fill;
2763 dummy_frag->line = listing_tail;
2764 symbolP = symbol_new (name, undefined_section, 0, dummy_frag);
2765 dummy_frag->fr_symbol = symbolP;
2769 symbolP = symbol_new (name, undefined_section, 0, &zero_address_frag);
2772 /* "set" symbols are local unless otherwise specified. */
2773 SF_SET_LOCAL (symbolP);
2774 #endif /* OBJ_COFF */
2776 } /* make a new symbol */
2778 symbol_table_insert (symbolP);
2783 && S_IS_DEFINED (symbolP)
2784 && S_GET_SEGMENT (symbolP) != reg_section)
2785 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP));
2787 pseudo_set (symbolP);
2788 demand_empty_rest_of_line ();
2802 #ifdef md_flush_pending_output
2803 md_flush_pending_output ();
2807 stop = mri_comment_field (&stopc);
2809 /* In m68k MRI mode, we need to align to a word boundary, unless
2811 if (flag_m68k_mri && mult > 1)
2813 if (now_seg == absolute_section)
2815 abs_section_offset += abs_section_offset & 1;
2816 if (line_label != NULL)
2817 S_SET_VALUE (line_label, abs_section_offset);
2819 else if (mri_common_symbol != NULL)
2823 val = S_GET_VALUE (mri_common_symbol);
2826 S_SET_VALUE (mri_common_symbol, val + 1);
2827 if (line_label != NULL)
2829 expressionS *symexp;
2831 symexp = symbol_get_value_expression (line_label);
2832 know (symexp->X_op == O_symbol);
2833 know (symexp->X_add_symbol == mri_common_symbol);
2834 symexp->X_add_number += 1;
2840 do_align (1, (char *) NULL, 0, 0);
2841 if (line_label != NULL)
2843 symbol_set_frag (line_label, frag_now);
2844 S_SET_VALUE (line_label, frag_now_fix ());
2854 if (*input_line_pointer == ',')
2856 ++input_line_pointer;
2861 val.X_op = O_constant;
2862 val.X_add_number = 0;
2865 if (val.X_op != O_constant
2866 || val.X_add_number < - 0x80
2867 || val.X_add_number > 0xff
2868 || (mult != 0 && mult != 1 && val.X_add_number != 0))
2870 if (exp.X_op != O_constant)
2871 as_bad (_("Unsupported variable size or fill value"));
2878 bytes = mult * exp.X_add_number;
2879 for (i = 0; i < exp.X_add_number; i++)
2880 emit_expr (&val, mult);
2885 if (exp.X_op == O_constant)
2889 repeat = exp.X_add_number;
2896 as_warn (_(".space repeat count is zero, ignored"));
2897 else if (repeat < 0)
2898 as_warn (_(".space repeat count is negative, ignored"));
2902 /* If we are in the absolute section, just bump the offset. */
2903 if (now_seg == absolute_section)
2905 abs_section_offset += repeat;
2909 /* If we are secretly in an MRI common section, then
2910 creating space just increases the size of the common
2912 if (mri_common_symbol != NULL)
2914 S_SET_VALUE (mri_common_symbol,
2915 S_GET_VALUE (mri_common_symbol) + repeat);
2920 p = frag_var (rs_fill, 1, 1, (relax_substateT) 0, (symbolS *) 0,
2921 (offsetT) repeat, (char *) 0);
2925 if (now_seg == absolute_section)
2927 as_bad (_("space allocation too complex in absolute section"));
2928 subseg_set (text_section, 0);
2930 if (mri_common_symbol != NULL)
2932 as_bad (_("space allocation too complex in common section"));
2933 mri_common_symbol = NULL;
2936 p = frag_var (rs_space, 1, 1, (relax_substateT) 0,
2937 make_expr_symbol (&exp), (offsetT) 0, (char *) 0);
2941 *p = val.X_add_number;
2946 /* In MRI mode, after an odd number of bytes, we must align to an
2947 even word boundary, unless the next instruction is a dc.b, ds.b
2949 if (flag_mri && (bytes & 1) != 0)
2950 mri_pending_align = 1;
2952 demand_empty_rest_of_line ();
2955 mri_comment_end (stop, stopc);
2958 /* This is like s_space, but the value is a floating point number with
2959 the given precision. This is for the MRI dcb.s pseudo-op and
2963 s_float_space (float_type)
2968 char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT];
2973 stop = mri_comment_field (&stopc);
2975 count = get_absolute_expression ();
2978 if (*input_line_pointer != ',')
2980 as_bad (_("missing value"));
2981 ignore_rest_of_line ();
2983 mri_comment_end (stop, stopc);
2987 ++input_line_pointer;
2991 /* Skip any 0{letter} that may be present. Don't even check if the
2992 * letter is legal. */
2993 if (input_line_pointer[0] == '0'
2994 && isalpha ((unsigned char) input_line_pointer[1]))
2995 input_line_pointer += 2;
2997 /* Accept :xxxx, where the x's are hex digits, for a floating point
2998 with the exact digits specified. */
2999 if (input_line_pointer[0] == ':')
3001 flen = hex_float (float_type, temp);
3004 ignore_rest_of_line ();
3006 mri_comment_end (stop, stopc);
3014 err = md_atof (float_type, temp, &flen);
3015 know (flen <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
3019 as_bad (_("Bad floating literal: %s"), err);
3020 ignore_rest_of_line ();
3022 mri_comment_end (stop, stopc);
3027 while (--count >= 0)
3031 p = frag_more (flen);
3032 memcpy (p, temp, (unsigned int) flen);
3035 demand_empty_rest_of_line ();
3038 mri_comment_end (stop, stopc);
3041 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3045 int ignore ATTRIBUTE_UNUSED;
3051 stop = mri_comment_field (&stopc);
3052 abs_section_offset = get_absolute_expression ();
3053 subseg_set (absolute_section, 0);
3054 demand_empty_rest_of_line ();
3056 mri_comment_end (stop, stopc);
3061 int ignore ATTRIBUTE_UNUSED;
3065 temp = get_absolute_expression ();
3066 subseg_set (text_section, (subsegT) temp);
3067 demand_empty_rest_of_line ();
3069 const_flag &= ~IN_DEFAULT_SECTION;
3075 demand_empty_rest_of_line ()
3078 if (is_end_of_line[(unsigned char) *input_line_pointer])
3080 input_line_pointer++;
3084 ignore_rest_of_line ();
3086 /* Return having already swallowed end-of-line. */
3087 } /* Return pointing just after end-of-line. */
3090 ignore_rest_of_line () /* For suspect lines: gives warning. */
3092 if (!is_end_of_line[(unsigned char) *input_line_pointer])
3094 if (isprint ((unsigned char) *input_line_pointer))
3095 as_bad (_("Rest of line ignored. First ignored character is `%c'."),
3096 *input_line_pointer);
3098 as_bad (_("Rest of line ignored. First ignored character valued 0x%x."),
3099 *input_line_pointer);
3100 while (input_line_pointer < buffer_limit
3101 && !is_end_of_line[(unsigned char) *input_line_pointer])
3103 input_line_pointer++;
3106 input_line_pointer++; /* Return pointing just after end-of-line. */
3107 know (is_end_of_line[(unsigned char) input_line_pointer[-1]]);
3111 discard_rest_of_line ()
3113 while (input_line_pointer < buffer_limit
3114 && !is_end_of_line[(unsigned char) *input_line_pointer])
3116 input_line_pointer++;
3118 input_line_pointer++; /* Return pointing just after end-of-line. */
3119 know (is_end_of_line[(unsigned char) input_line_pointer[-1]]);
3125 * In: Pointer to a symbol.
3126 * Input_line_pointer->expression.
3128 * Out: Input_line_pointer->just after any whitespace after expression.
3129 * Tried to set symbol to value of expression.
3130 * Will change symbols type, value, and frag;
3133 pseudo_set (symbolP)
3137 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3139 #endif /* OBJ_AOUT or OBJ_BOUT */
3141 know (symbolP); /* NULL pointer is logic error. */
3142 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3143 ext = S_IS_EXTERNAL (symbolP);
3144 #endif /* OBJ_AOUT or OBJ_BOUT */
3146 (void) expression (&exp);
3148 if (exp.X_op == O_illegal)
3149 as_bad (_("illegal expression; zero assumed"));
3150 else if (exp.X_op == O_absent)
3151 as_bad (_("missing expression; zero assumed"));
3152 else if (exp.X_op == O_big)
3154 if (exp.X_add_number > 0)
3155 as_bad (_("bignum invalid; zero assumed"));
3157 as_bad (_("floating point number invalid; zero assumed"));
3159 else if (exp.X_op == O_subtract
3160 && (S_GET_SEGMENT (exp.X_add_symbol)
3161 == S_GET_SEGMENT (exp.X_op_symbol))
3162 && SEG_NORMAL (S_GET_SEGMENT (exp.X_add_symbol))
3163 && (symbol_get_frag (exp.X_add_symbol)
3164 == symbol_get_frag (exp.X_op_symbol)))
3166 exp.X_op = O_constant;
3167 exp.X_add_number = (S_GET_VALUE (exp.X_add_symbol)
3168 - S_GET_VALUE (exp.X_op_symbol));
3176 exp.X_add_number = 0;
3179 S_SET_SEGMENT (symbolP, absolute_section);
3180 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3182 S_SET_EXTERNAL (symbolP);
3184 S_CLEAR_EXTERNAL (symbolP);
3185 #endif /* OBJ_AOUT or OBJ_BOUT */
3186 S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
3187 if (exp.X_op != O_constant)
3188 symbol_set_frag (symbolP, &zero_address_frag);
3192 S_SET_SEGMENT (symbolP, reg_section);
3193 S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
3194 symbol_set_frag (symbolP, &zero_address_frag);
3198 if (S_GET_SEGMENT (exp.X_add_symbol) == undefined_section
3199 || exp.X_add_number != 0)
3200 symbol_set_value_expression (symbolP, &exp);
3201 else if (symbol_section_p (symbolP))
3202 as_bad ("invalid attempt to set value of section symbol");
3205 symbolS *s = exp.X_add_symbol;
3207 S_SET_SEGMENT (symbolP, S_GET_SEGMENT (s));
3208 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3210 S_SET_EXTERNAL (symbolP);
3212 S_CLEAR_EXTERNAL (symbolP);
3213 #endif /* OBJ_AOUT or OBJ_BOUT */
3214 S_SET_VALUE (symbolP,
3215 exp.X_add_number + S_GET_VALUE (s));
3216 symbol_set_frag (symbolP, symbol_get_frag (s));
3217 copy_symbol_attributes (symbolP, s);
3222 /* The value is some complex expression.
3223 FIXME: Should we set the segment to anything? */
3224 symbol_set_value_expression (symbolP, &exp);
3232 * CONStruct more frag of .bytes, or .words etc.
3233 * Should need_pass_2 be 1 then emit no frag(s).
3234 * This understands EXPRESSIONS.
3238 * This has a split personality. We use expression() to read the
3239 * value. We can detect if the value won't fit in a byte or word.
3240 * But we can't detect if expression() discarded significant digits
3241 * in the case of a long. Not worth the crocks required to fix it.
3244 /* Select a parser for cons expressions. */
3246 /* Some targets need to parse the expression in various fancy ways.
3247 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3248 (for example, the HPPA does this). Otherwise, you can define
3249 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3250 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3251 are defined, which is the normal case, then only simple expressions
3256 parse_mri_cons PARAMS ((expressionS *exp, unsigned int nbytes));
3259 #ifndef TC_PARSE_CONS_EXPRESSION
3260 #ifdef BITFIELD_CONS_EXPRESSIONS
3261 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3263 parse_bitfield_cons PARAMS ((expressionS *exp, unsigned int nbytes));
3265 #ifdef REPEAT_CONS_EXPRESSIONS
3266 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3268 parse_repeat_cons PARAMS ((expressionS *exp, unsigned int nbytes));
3271 /* If we haven't gotten one yet, just call expression. */
3272 #ifndef TC_PARSE_CONS_EXPRESSION
3273 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3277 /* worker to do .byte etc statements */
3278 /* clobbers input_line_pointer, checks */
3281 cons_worker (nbytes, rva)
3282 register int nbytes; /* 1=.byte, 2=.word, 4=.long */
3290 #ifdef md_flush_pending_output
3291 md_flush_pending_output ();
3295 stop = mri_comment_field (&stopc);
3297 if (is_it_end_of_statement ())
3299 demand_empty_rest_of_line ();
3301 mri_comment_end (stop, stopc);
3305 #ifdef md_cons_align
3306 md_cons_align (nbytes);
3314 parse_mri_cons (&exp, (unsigned int) nbytes);
3317 TC_PARSE_CONS_EXPRESSION (&exp, (unsigned int) nbytes);
3321 if (exp.X_op == O_symbol)
3322 exp.X_op = O_symbol_rva;
3324 as_fatal (_("rva without symbol"));
3326 emit_expr (&exp, (unsigned int) nbytes);
3329 while (*input_line_pointer++ == ',');
3331 /* In MRI mode, after an odd number of bytes, we must align to an
3332 even word boundary, unless the next instruction is a dc.b, ds.b
3334 if (flag_mri && nbytes == 1 && (c & 1) != 0)
3335 mri_pending_align = 1;
3337 input_line_pointer--; /* Put terminator back into stream. */
3339 demand_empty_rest_of_line ();
3342 mri_comment_end (stop, stopc);
3350 cons_worker (size, 0);
3357 cons_worker (size, 1);
3360 /* Put the contents of expression EXP into the object file using
3361 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3364 emit_expr (exp, nbytes)
3366 unsigned int nbytes;
3370 valueT extra_digit = 0;
3372 /* Don't do anything if we are going to make another pass. */
3378 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3379 appear as a four byte positive constant in the .line section,
3380 followed by a 2 byte 0xffff. Look for that case here. */
3382 static int dwarf_line = -1;
3384 if (strcmp (segment_name (now_seg), ".line") != 0)
3386 else if (dwarf_line >= 0
3388 && exp->X_op == O_constant
3389 && (exp->X_add_number == -1 || exp->X_add_number == 0xffff))
3390 listing_source_line ((unsigned int) dwarf_line);
3391 else if (nbytes == 4
3392 && exp->X_op == O_constant
3393 && exp->X_add_number >= 0)
3394 dwarf_line = exp->X_add_number;
3399 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3400 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3401 AT_sibling (0x12) followed by a four byte address of the sibling
3402 followed by a 2 byte AT_name (0x38) followed by the name of the
3403 file. We look for that case here. */
3405 static int dwarf_file = 0;
3407 if (strcmp (segment_name (now_seg), ".debug") != 0)
3409 else if (dwarf_file == 0
3411 && exp->X_op == O_constant
3412 && exp->X_add_number == 0x11)
3414 else if (dwarf_file == 1
3416 && exp->X_op == O_constant
3417 && exp->X_add_number == 0x12)
3419 else if (dwarf_file == 2
3422 else if (dwarf_file == 3
3424 && exp->X_op == O_constant
3425 && exp->X_add_number == 0x38)
3430 /* The variable dwarf_file_string tells stringer that the string
3431 may be the name of the source file. */
3432 if (dwarf_file == 4)
3433 dwarf_file_string = 1;
3435 dwarf_file_string = 0;
3440 if (check_eh_frame (exp, &nbytes))
3445 /* Allow `.word 0' in the absolute section. */
3446 if (now_seg == absolute_section)
3448 if (op != O_constant || exp->X_add_number != 0)
3449 as_bad (_("attempt to store value in absolute section"));
3450 abs_section_offset += nbytes;
3454 /* Handle a negative bignum. */
3456 && exp->X_add_number == 0
3457 && symbol_get_value_expression (exp->X_add_symbol)->X_op == O_big
3458 && symbol_get_value_expression (exp->X_add_symbol)->X_add_number > 0)
3461 unsigned long carry;
3463 exp = symbol_get_value_expression (exp->X_add_symbol);
3465 /* Negate the bignum: one's complement each digit and add 1. */
3467 for (i = 0; i < exp->X_add_number; i++)
3471 next = (((~ (generic_bignum[i] & LITTLENUM_MASK))
3474 generic_bignum[i] = next & LITTLENUM_MASK;
3475 carry = next >> LITTLENUM_NUMBER_OF_BITS;
3478 /* We can ignore any carry out, because it will be handled by
3479 extra_digit if it is needed. */
3481 extra_digit = (valueT) -1;
3485 if (op == O_absent || op == O_illegal)
3487 as_warn (_("zero assumed for missing expression"));
3488 exp->X_add_number = 0;
3491 else if (op == O_big && exp->X_add_number <= 0)
3493 as_bad (_("floating point number invalid; zero assumed"));
3494 exp->X_add_number = 0;
3497 else if (op == O_register)
3499 as_warn (_("register value used as expression"));
3503 p = frag_more ((int) nbytes);
3505 #ifndef WORKING_DOT_WORD
3506 /* If we have the difference of two symbols in a word, save it on
3507 the broken_words list. See the code in write.c. */
3508 if (op == O_subtract && nbytes == 2)
3510 struct broken_word *x;
3512 x = (struct broken_word *) xmalloc (sizeof (struct broken_word));
3513 x->next_broken_word = broken_words;
3516 x->subseg = now_subseg;
3518 x->word_goes_here = p;
3520 x->add = exp->X_add_symbol;
3521 x->sub = exp->X_op_symbol;
3522 x->addnum = exp->X_add_number;
3529 /* If we have an integer, but the number of bytes is too large to
3530 pass to md_number_to_chars, handle it as a bignum. */
3531 if (op == O_constant && nbytes > sizeof (valueT))
3536 if (! exp->X_unsigned && exp->X_add_number < 0)
3537 extra_digit = (valueT) -1;
3538 val = (valueT) exp->X_add_number;
3542 generic_bignum[gencnt] = val & LITTLENUM_MASK;
3543 val >>= LITTLENUM_NUMBER_OF_BITS;
3547 op = exp->X_op = O_big;
3548 exp->X_add_number = gencnt;
3551 if (op == O_constant)
3553 register valueT get;
3554 register valueT use;
3555 register valueT mask;
3557 register valueT unmask;
3559 /* JF << of >= number of bits in the object is undefined. In
3560 particular SPARC (Sun 4) has problems */
3561 if (nbytes >= sizeof (valueT))
3564 if (nbytes > sizeof (valueT))
3567 hibit = (valueT) 1 << (nbytes * BITS_PER_CHAR - 1);
3571 /* Don't store these bits. */
3572 mask = ~(valueT) 0 << (BITS_PER_CHAR * nbytes);
3573 hibit = (valueT) 1 << (nbytes * BITS_PER_CHAR - 1);
3576 unmask = ~mask; /* Do store these bits. */
3579 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3580 mask = ~(unmask >> 1); /* Includes sign bit now. */
3583 get = exp->X_add_number;
3585 if ((get & mask) != 0
3586 && ((get & mask) != mask
3587 || (get & hibit) == 0))
3588 { /* Leading bits contain both 0s & 1s. */
3589 as_warn (_("Value 0x%lx truncated to 0x%lx."),
3590 (unsigned long) get, (unsigned long) use);
3592 /* put bytes in right order. */
3593 md_number_to_chars (p, use, (int) nbytes);
3595 else if (op == O_big)
3598 LITTLENUM_TYPE *nums;
3600 know (nbytes % CHARS_PER_LITTLENUM == 0);
3602 size = exp->X_add_number * CHARS_PER_LITTLENUM;
3605 as_warn (_("Bignum truncated to %d bytes"), nbytes);
3609 if (target_big_endian)
3611 while (nbytes > size)
3613 md_number_to_chars (p, extra_digit, CHARS_PER_LITTLENUM);
3614 nbytes -= CHARS_PER_LITTLENUM;
3615 p += CHARS_PER_LITTLENUM;
3618 nums = generic_bignum + size / CHARS_PER_LITTLENUM;
3622 md_number_to_chars (p, (valueT) *nums, CHARS_PER_LITTLENUM);
3623 size -= CHARS_PER_LITTLENUM;
3624 p += CHARS_PER_LITTLENUM;
3629 nums = generic_bignum;
3632 md_number_to_chars (p, (valueT) *nums, CHARS_PER_LITTLENUM);
3634 size -= CHARS_PER_LITTLENUM;
3635 p += CHARS_PER_LITTLENUM;
3636 nbytes -= CHARS_PER_LITTLENUM;
3641 md_number_to_chars (p, extra_digit, CHARS_PER_LITTLENUM);
3642 nbytes -= CHARS_PER_LITTLENUM;
3643 p += CHARS_PER_LITTLENUM;
3649 memset (p, 0, nbytes);
3651 /* Now we need to generate a fixS to record the symbol value.
3652 This is easy for BFD. For other targets it can be more
3653 complex. For very complex cases (currently, the HPPA and
3654 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3655 want. For simpler cases, you can define TC_CONS_RELOC to be
3656 the name of the reloc code that should be stored in the fixS.
3657 If neither is defined, the code uses NO_RELOC if it is
3658 defined, and otherwise uses 0. */
3660 #ifdef BFD_ASSEMBLER
3661 #ifdef TC_CONS_FIX_NEW
3662 TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp);
3665 bfd_reloc_code_real_type r;
3682 as_bad (_("unsupported BFD relocation size %u"), nbytes);
3686 fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp,
3691 #ifdef TC_CONS_FIX_NEW
3692 TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp);
3694 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3695 it is defined, otherwise use NO_RELOC if it is defined,
3697 #ifndef TC_CONS_RELOC
3699 #define TC_CONS_RELOC NO_RELOC
3701 #define TC_CONS_RELOC 0
3704 fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp, 0,
3706 #endif /* TC_CONS_FIX_NEW */
3707 #endif /* BFD_ASSEMBLER */
3711 #ifdef BITFIELD_CONS_EXPRESSIONS
3713 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3714 w:x,y:z, where w and y are bitwidths and x and y are values. They
3715 then pack them all together. We do a little better in that we allow
3716 them in words, longs, etc. and we'll pack them in target byte order
3719 The rules are: pack least significat bit first, if a field doesn't
3720 entirely fit, put it in the next unit. Overflowing the bitfield is
3721 explicitly *not* even a warning. The bitwidth should be considered
3724 To use this function the tc-XXX.h file should define
3725 BITFIELD_CONS_EXPRESSIONS. */
3728 parse_bitfield_cons (exp, nbytes)
3730 unsigned int nbytes;
3732 unsigned int bits_available = BITS_PER_CHAR * nbytes;
3733 char *hold = input_line_pointer;
3735 (void) expression (exp);
3737 if (*input_line_pointer == ':')
3743 unsigned long width;
3745 if (*input_line_pointer != ':')
3747 input_line_pointer = hold;
3749 } /* next piece is not a bitfield */
3751 /* In the general case, we can't allow
3752 full expressions with symbol
3753 differences and such. The relocation
3754 entries for symbols not defined in this
3755 assembly would require arbitrary field
3756 widths, positions, and masks which most
3757 of our current object formats don't
3760 In the specific case where a symbol
3761 *is* defined in this assembly, we
3762 *could* build fixups and track it, but
3763 this could lead to confusion for the
3764 backends. I'm lazy. I'll take any
3765 SEG_ABSOLUTE. I think that means that
3766 you can use a previous .set or
3767 .equ type symbol. xoxorich. */
3769 if (exp->X_op == O_absent)
3771 as_warn (_("using a bit field width of zero"));
3772 exp->X_add_number = 0;
3773 exp->X_op = O_constant;
3774 } /* implied zero width bitfield */
3776 if (exp->X_op != O_constant)
3778 *input_line_pointer = '\0';
3779 as_bad (_("field width \"%s\" too complex for a bitfield"), hold);
3780 *input_line_pointer = ':';
3781 demand_empty_rest_of_line ();
3785 if ((width = exp->X_add_number) > (BITS_PER_CHAR * nbytes))
3787 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3788 width, nbytes, (BITS_PER_CHAR * nbytes));
3789 width = BITS_PER_CHAR * nbytes;
3792 if (width > bits_available)
3794 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3795 input_line_pointer = hold;
3796 exp->X_add_number = value;
3800 hold = ++input_line_pointer; /* skip ':' */
3802 (void) expression (exp);
3803 if (exp->X_op != O_constant)
3805 char cache = *input_line_pointer;
3807 *input_line_pointer = '\0';
3808 as_bad (_("field value \"%s\" too complex for a bitfield"), hold);
3809 *input_line_pointer = cache;
3810 demand_empty_rest_of_line ();
3814 value |= ((~(-1 << width) & exp->X_add_number)
3815 << ((BITS_PER_CHAR * nbytes) - bits_available));
3817 if ((bits_available -= width) == 0
3818 || is_it_end_of_statement ()
3819 || *input_line_pointer != ',')
3822 } /* all the bitfields we're gonna get */
3824 hold = ++input_line_pointer;
3825 (void) expression (exp);
3826 } /* forever loop */
3828 exp->X_add_number = value;
3829 exp->X_op = O_constant;
3830 exp->X_unsigned = 1;
3831 } /* if looks like a bitfield */
3832 } /* parse_bitfield_cons() */
3834 #endif /* BITFIELD_CONS_EXPRESSIONS */
3836 /* Handle an MRI style string expression. */
3840 parse_mri_cons (exp, nbytes)
3842 unsigned int nbytes;
3844 if (*input_line_pointer != '\''
3845 && (input_line_pointer[1] != '\''
3846 || (*input_line_pointer != 'A'
3847 && *input_line_pointer != 'E')))
3848 TC_PARSE_CONS_EXPRESSION (exp, nbytes);
3852 unsigned int result = 0;
3854 /* An MRI style string. Cut into as many bytes as will fit into
3855 a nbyte chunk, left justify if necessary, and separate with
3856 commas so we can try again later. */
3857 if (*input_line_pointer == 'A')
3858 ++input_line_pointer;
3859 else if (*input_line_pointer == 'E')
3861 as_bad (_("EBCDIC constants are not supported"));
3862 ++input_line_pointer;
3865 input_line_pointer++;
3866 for (scan = 0; scan < nbytes; scan++)
3868 if (*input_line_pointer == '\'')
3870 if (input_line_pointer[1] == '\'')
3872 input_line_pointer++;
3877 result = (result << 8) | (*input_line_pointer++);
3881 while (scan < nbytes)
3886 /* Create correct expression */
3887 exp->X_op = O_constant;
3888 exp->X_add_number = result;
3889 /* Fake it so that we can read the next char too */
3890 if (input_line_pointer[0] != '\'' ||
3891 (input_line_pointer[0] == '\'' && input_line_pointer[1] == '\''))
3893 input_line_pointer -= 2;
3894 input_line_pointer[0] = ',';
3895 input_line_pointer[1] = '\'';
3898 input_line_pointer++;
3901 #endif /* TC_M68K */
3903 #ifdef REPEAT_CONS_EXPRESSIONS
3905 /* Parse a repeat expression for cons. This is used by the MIPS
3906 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3907 object file COUNT times.
3909 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3912 parse_repeat_cons (exp, nbytes)
3914 unsigned int nbytes;
3921 if (*input_line_pointer != ':')
3923 /* No repeat count. */
3927 ++input_line_pointer;
3928 expression (&count);
3929 if (count.X_op != O_constant
3930 || count.X_add_number <= 0)
3932 as_warn (_("Unresolvable or nonpositive repeat count; using 1"));
3936 /* The cons function is going to output this expression once. So we
3937 output it count - 1 times. */
3938 for (i = count.X_add_number - 1; i > 0; i--)
3939 emit_expr (exp, nbytes);
3942 #endif /* REPEAT_CONS_EXPRESSIONS */
3944 /* Parse a floating point number represented as a hex constant. This
3945 permits users to specify the exact bits they want in the floating
3949 hex_float (float_type, bytes)
3983 as_bad (_("Unknown floating type type '%c'"), float_type);
3987 /* It would be nice if we could go through expression to parse the
3988 hex constant, but if we get a bignum it's a pain to sort it into
3989 the buffer correctly. */
3991 while (hex_p (*input_line_pointer) || *input_line_pointer == '_')
3995 /* The MRI assembler accepts arbitrary underscores strewn about
3996 through the hex constant, so we ignore them as well. */
3997 if (*input_line_pointer == '_')
3999 ++input_line_pointer;
4005 as_warn (_("Floating point constant too large"));
4008 d = hex_value (*input_line_pointer) << 4;
4009 ++input_line_pointer;
4010 while (*input_line_pointer == '_')
4011 ++input_line_pointer;
4012 if (hex_p (*input_line_pointer))
4014 d += hex_value (*input_line_pointer);
4015 ++input_line_pointer;
4017 if (target_big_endian)
4020 bytes[length - i - 1] = d;
4026 if (target_big_endian)
4027 memset (bytes + i, 0, length - i);
4029 memset (bytes, 0, length - i);
4038 * CONStruct some more frag chars of .floats .ffloats etc.
4039 * Makes 0 or more new frags.
4040 * If need_pass_2 == 1, no frags are emitted.
4041 * This understands only floating literals, not expressions. Sorry.
4043 * A floating constant is defined by atof_generic(), except it is preceded
4044 * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4045 * reading, I decided to be incompatible. This always tries to give you
4046 * rounded bits to the precision of the pseudo-op. Former AS did premature
4047 * truncatation, restored noisy bits instead of trailing 0s AND gave you
4048 * a choice of 2 flavours of noise according to which of 2 floating-point
4049 * scanners you directed AS to use.
4051 * In: input_line_pointer->whitespace before, or '0' of flonum.
4056 float_cons (float_type)
4057 /* Clobbers input_line-pointer, checks end-of-line. */
4058 register int float_type; /* 'f':.ffloat ... 'F':.float ... */
4061 int length; /* Number of chars in an object. */
4062 register char *err; /* Error from scanning floating literal. */
4063 char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT];
4065 if (is_it_end_of_statement ())
4067 demand_empty_rest_of_line ();
4071 #ifdef md_flush_pending_output
4072 md_flush_pending_output ();
4077 /* input_line_pointer->1st char of a flonum (we hope!). */
4080 /* Skip any 0{letter} that may be present. Don't even check if the
4081 * letter is legal. Someone may invent a "z" format and this routine
4082 * has no use for such information. Lusers beware: you get
4083 * diagnostics if your input is ill-conditioned.
4085 if (input_line_pointer[0] == '0'
4086 && isalpha ((unsigned char) input_line_pointer[1]))
4087 input_line_pointer += 2;
4089 /* Accept :xxxx, where the x's are hex digits, for a floating
4090 point with the exact digits specified. */
4091 if (input_line_pointer[0] == ':')
4093 ++input_line_pointer;
4094 length = hex_float (float_type, temp);
4097 ignore_rest_of_line ();
4103 err = md_atof (float_type, temp, &length);
4104 know (length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
4108 as_bad (_("Bad floating literal: %s"), err);
4109 ignore_rest_of_line ();
4120 #ifdef REPEAT_CONS_EXPRESSIONS
4121 if (*input_line_pointer == ':')
4123 expressionS count_exp;
4125 ++input_line_pointer;
4126 expression (&count_exp);
4127 if (count_exp.X_op != O_constant
4128 || count_exp.X_add_number <= 0)
4130 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4133 count = count_exp.X_add_number;
4137 while (--count >= 0)
4139 p = frag_more (length);
4140 memcpy (p, temp, (unsigned int) length);
4145 while (*input_line_pointer++ == ',');
4147 --input_line_pointer; /* Put terminator back into stream. */
4148 demand_empty_rest_of_line ();
4149 } /* float_cons() */
4151 /* Return the size of a LEB128 value */
4154 sizeof_sleb128 (value)
4157 register int size = 0;
4158 register unsigned byte;
4162 byte = (value & 0x7f);
4163 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4164 Fortunately, we can structure things so that the extra work reduces
4165 to a noop on systems that do things "properly". */
4166 value = (value >> 7) | ~(-(offsetT)1 >> 7);
4169 while (!(((value == 0) && ((byte & 0x40) == 0))
4170 || ((value == -1) && ((byte & 0x40) != 0))));
4176 sizeof_uleb128 (value)
4179 register int size = 0;
4180 register unsigned byte;
4184 byte = (value & 0x7f);
4194 sizeof_leb128 (value, sign)
4199 return sizeof_sleb128 ((offsetT) value);
4201 return sizeof_uleb128 (value);
4204 /* Output a LEB128 value. */
4207 output_sleb128 (p, value)
4211 register char *orig = p;
4216 unsigned byte = (value & 0x7f);
4218 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4219 Fortunately, we can structure things so that the extra work reduces
4220 to a noop on systems that do things "properly". */
4221 value = (value >> 7) | ~(-(offsetT)1 >> 7);
4223 more = !((((value == 0) && ((byte & 0x40) == 0))
4224 || ((value == -1) && ((byte & 0x40) != 0))));
4236 output_uleb128 (p, value)
4244 unsigned byte = (value & 0x7f);
4247 /* More bytes to follow. */
4258 output_leb128 (p, value, sign)
4264 return output_sleb128 (p, (offsetT) value);
4266 return output_uleb128 (p, value);
4269 /* Do the same for bignums. We combine sizeof with output here in that
4270 we don't output for NULL values of P. It isn't really as critical as
4271 for "normal" values that this be streamlined. */
4274 output_big_sleb128 (p, bignum, size)
4276 LITTLENUM_TYPE *bignum;
4284 /* Strip leading sign extensions off the bignum. */
4285 while (size > 0 && bignum[size-1] == (LITTLENUM_TYPE)-1)
4290 if (loaded < 7 && size > 0)
4292 val |= (*bignum << loaded);
4293 loaded += 8 * CHARS_PER_LITTLENUM;
4304 if ((val == 0 && (byte & 0x40) == 0)
4305 || (~(val | ~(((valueT)1 << loaded) - 1)) == 0
4306 && (byte & 0x40) != 0))
4314 while (byte & 0x80);
4320 output_big_uleb128 (p, bignum, size)
4322 LITTLENUM_TYPE *bignum;
4330 /* Strip leading zeros off the bignum. */
4331 /* XXX: Is this needed? */
4332 while (size > 0 && bignum[size-1] == 0)
4337 if (loaded < 7 && size > 0)
4339 val |= (*bignum << loaded);
4340 loaded += 8 * CHARS_PER_LITTLENUM;
4349 if (size > 0 || val)
4356 while (byte & 0x80);
4362 output_big_leb128 (p, bignum, size, sign)
4364 LITTLENUM_TYPE *bignum;
4368 return output_big_sleb128 (p, bignum, size);
4370 return output_big_uleb128 (p, bignum, size);
4373 /* Generate the appropriate fragments for a given expression to emit a
4377 emit_leb128_expr(exp, sign)
4381 operatorT op = exp->X_op;
4383 if (op == O_absent || op == O_illegal)
4385 as_warn (_("zero assumed for missing expression"));
4386 exp->X_add_number = 0;
4389 else if (op == O_big && exp->X_add_number <= 0)
4391 as_bad (_("floating point number invalid; zero assumed"));
4392 exp->X_add_number = 0;
4395 else if (op == O_register)
4397 as_warn (_("register value used as expression"));
4401 if (op == O_constant)
4403 /* If we've got a constant, emit the thing directly right now. */
4405 valueT value = exp->X_add_number;
4409 size = sizeof_leb128 (value, sign);
4410 p = frag_more (size);
4411 output_leb128 (p, value, sign);
4413 else if (op == O_big)
4415 /* O_big is a different sort of constant. */
4420 size = output_big_leb128 (NULL, generic_bignum, exp->X_add_number, sign);
4421 p = frag_more (size);
4422 output_big_leb128 (p, generic_bignum, exp->X_add_number, sign);
4426 /* Otherwise, we have to create a variable sized fragment and
4427 resolve things later. */
4429 frag_var (rs_leb128, sizeof_uleb128 (~(valueT)0), 0, sign,
4430 make_expr_symbol (exp), 0, (char *) NULL);
4434 /* Parse the .sleb128 and .uleb128 pseudos. */
4444 emit_leb128_expr (&exp, sign);
4445 } while (*input_line_pointer++ == ',');
4447 input_line_pointer--;
4448 demand_empty_rest_of_line ();
4454 * We read 0 or more ',' separated, double-quoted strings.
4456 * Caller should have checked need_pass_2 is FALSE because we don't check it.
4461 stringer (append_zero) /* Worker to do .ascii etc statements. */
4462 /* Checks end-of-line. */
4463 register int append_zero; /* 0: don't append '\0', else 1 */
4465 register unsigned int c;
4468 #ifdef md_flush_pending_output
4469 md_flush_pending_output ();
4473 * The following awkward logic is to parse ZERO or more strings,
4474 * comma separated. Recall a string expression includes spaces
4475 * before the opening '\"' and spaces after the closing '\"'.
4476 * We fake a leading ',' if there is (supposed to be)
4477 * a 1st, expression. We keep demanding expressions for each
4480 if (is_it_end_of_statement ())
4482 c = 0; /* Skip loop. */
4483 ++input_line_pointer; /* Compensate for end of loop. */
4487 c = ','; /* Do loop. */
4489 while (c == ',' || c == '<' || c == '"')
4492 switch (*input_line_pointer)
4495 ++input_line_pointer; /*->1st char of string. */
4496 start = input_line_pointer;
4497 while (is_a_char (c = next_char_of_string ()))
4499 FRAG_APPEND_1_CHAR (c);
4503 FRAG_APPEND_1_CHAR (0);
4505 know (input_line_pointer[-1] == '\"');
4509 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4510 will emit .string with a filename in the .debug section
4511 after a sequence of constants. See the comment in
4512 emit_expr for the sequence. emit_expr will set
4513 dwarf_file_string to non-zero if this string might be a
4514 source file name. */
4515 if (strcmp (segment_name (now_seg), ".debug") != 0)
4516 dwarf_file_string = 0;
4517 else if (dwarf_file_string)
4519 c = input_line_pointer[-1];
4520 input_line_pointer[-1] = '\0';
4521 listing_source_file (start);
4522 input_line_pointer[-1] = c;
4529 input_line_pointer++;
4530 c = get_single_number ();
4531 FRAG_APPEND_1_CHAR (c);
4532 if (*input_line_pointer != '>')
4534 as_bad (_("Expected <nn>"));
4536 input_line_pointer++;
4539 input_line_pointer++;
4543 c = *input_line_pointer;
4546 demand_empty_rest_of_line ();
4549 /* FIXME-SOMEDAY: I had trouble here on characters with the
4550 high bits set. We'll probably also have trouble with
4551 multibyte chars, wide chars, etc. Also be careful about
4552 returning values bigger than 1 byte. xoxorich. */
4555 next_char_of_string ()
4557 register unsigned int c;
4559 c = *input_line_pointer++ & CHAR_MASK;
4567 as_warn (_("Unterminated string: Newline inserted."));
4568 bump_line_counters ();
4571 #ifndef NO_STRING_ESCAPES
4573 switch (c = *input_line_pointer++)
4601 break; /* As itself. */
4617 for (i = 0, number = 0; isdigit (c) && i < 3; c = *input_line_pointer++, i++)
4619 number = number * 8 + c - '0';
4623 --input_line_pointer;
4632 c = *input_line_pointer++;
4633 while (isxdigit (c))
4636 number = number * 16 + c - '0';
4637 else if (isupper (c))
4638 number = number * 16 + c - 'A' + 10;
4640 number = number * 16 + c - 'a' + 10;
4641 c = *input_line_pointer++;
4644 --input_line_pointer;
4649 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4650 as_warn (_("Unterminated string: Newline inserted."));
4652 bump_line_counters ();
4657 #ifdef ONLY_STANDARD_ESCAPES
4658 as_bad (_("Bad escaped character in string, '?' assumed"));
4660 #endif /* ONLY_STANDARD_ESCAPES */
4663 } /* switch on escaped char */
4665 #endif /* ! defined (NO_STRING_ESCAPES) */
4669 } /* switch on char */
4671 } /* next_char_of_string() */
4674 get_segmented_expression (expP)
4675 register expressionS *expP;
4677 register segT retval;
4679 retval = expression (expP);
4680 if (expP->X_op == O_illegal
4681 || expP->X_op == O_absent
4682 || expP->X_op == O_big)
4684 as_bad (_("expected address expression; zero assumed"));
4685 expP->X_op = O_constant;
4686 expP->X_add_number = 0;
4687 retval = absolute_section;
4693 get_known_segmented_expression (expP)
4694 register expressionS *expP;
4696 register segT retval;
4698 if ((retval = get_segmented_expression (expP)) == undefined_section)
4700 /* There is no easy way to extract the undefined symbol from the
4702 if (expP->X_add_symbol != NULL
4703 && S_GET_SEGMENT (expP->X_add_symbol) != expr_section)
4704 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4705 S_GET_NAME (expP->X_add_symbol));
4707 as_warn (_("some symbol undefined; zero assumed"));
4708 retval = absolute_section;
4709 expP->X_op = O_constant;
4710 expP->X_add_number = 0;
4712 know (retval == absolute_section || SEG_NORMAL (retval));
4714 } /* get_known_segmented_expression() */
4717 get_absolute_expression ()
4722 if (exp.X_op != O_constant)
4724 if (exp.X_op != O_absent)
4725 as_bad (_("bad or irreducible absolute expression; zero assumed"));
4726 exp.X_add_number = 0;
4728 return exp.X_add_number;
4731 char /* return terminator */
4732 get_absolute_expression_and_terminator (val_pointer)
4733 long *val_pointer; /* return value of expression */
4735 /* FIXME: val_pointer should probably be offsetT *. */
4736 *val_pointer = (long) get_absolute_expression ();
4737 return (*input_line_pointer++);
4741 * demand_copy_C_string()
4743 * Like demand_copy_string, but return NULL if the string contains any '\0's.
4744 * Give a warning if that happens.
4747 demand_copy_C_string (len_pointer)
4752 if ((s = demand_copy_string (len_pointer)) != 0)
4756 for (len = *len_pointer; len > 0; len--)
4763 as_bad (_("This string may not contain \'\\0\'"));
4771 * demand_copy_string()
4773 * Demand string, but return a safe (=private) copy of the string.
4774 * Return NULL if we can't read a string here.
4777 demand_copy_string (lenP)
4780 register unsigned int c;
4786 if (*input_line_pointer == '\"')
4788 input_line_pointer++; /* Skip opening quote. */
4790 while (is_a_char (c = next_char_of_string ()))
4792 obstack_1grow (¬es, c);
4795 /* JF this next line is so demand_copy_C_string will return a
4796 null terminated string. */
4797 obstack_1grow (¬es, '\0');
4798 retval = obstack_finish (¬es);
4802 as_warn (_("Missing string"));
4804 ignore_rest_of_line ();
4808 } /* demand_copy_string() */
4811 * is_it_end_of_statement()
4813 * In: Input_line_pointer->next character.
4815 * Do: Skip input_line_pointer over all whitespace.
4817 * Out: 1 if input_line_pointer->end-of-line.
4820 is_it_end_of_statement ()
4823 return (is_end_of_line[(unsigned char) *input_line_pointer]);
4824 } /* is_it_end_of_statement() */
4827 equals (sym_name, reassign)
4831 register symbolS *symbolP; /* symbol we are working with */
4835 input_line_pointer++;
4836 if (*input_line_pointer == '=')
4837 input_line_pointer++;
4839 while (*input_line_pointer == ' ' || *input_line_pointer == '\t')
4840 input_line_pointer++;
4843 stop = mri_comment_field (&stopc);
4845 if (sym_name[0] == '.' && sym_name[1] == '\0')
4847 /* Turn '. = mumble' into a .org mumble */
4848 register segT segment;
4851 segment = get_known_segmented_expression (&exp);
4853 do_org (segment, &exp, 0);
4857 symbolP = symbol_find_or_make (sym_name);
4858 /* Permit register names to be redefined. */
4860 && S_IS_DEFINED (symbolP)
4861 && S_GET_SEGMENT (symbolP) != reg_section)
4862 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP));
4863 pseudo_set (symbolP);
4868 ignore_rest_of_line (); /* check garbage after the expression */
4869 mri_comment_end (stop, stopc);
4873 /* .include -- include a file at this point. */
4878 int arg ATTRIBUTE_UNUSED;
4885 if (! flag_m68k_mri)
4887 filename = demand_copy_string (&i);
4888 if (filename == NULL)
4890 /* demand_copy_string has already printed an error and
4891 called ignore_rest_of_line. */
4899 while (! is_end_of_line[(unsigned char) *input_line_pointer]
4900 && *input_line_pointer != ' '
4901 && *input_line_pointer != '\t')
4903 obstack_1grow (¬es, *input_line_pointer);
4904 ++input_line_pointer;
4907 obstack_1grow (¬es, '\0');
4908 filename = obstack_finish (¬es);
4909 while (! is_end_of_line[(unsigned char) *input_line_pointer])
4910 ++input_line_pointer;
4912 demand_empty_rest_of_line ();
4913 path = xmalloc ((unsigned long) i + include_dir_maxlen + 5 /* slop */ );
4914 for (i = 0; i < include_dir_count; i++)
4916 strcpy (path, include_dirs[i]);
4918 strcat (path, filename);
4919 if (0 != (try = fopen (path, "r")))
4928 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
4929 register_dependency (path);
4930 input_scrub_insert_file (path);
4934 add_include_dir (path)
4939 if (include_dir_count == 0)
4941 include_dirs = (char **) xmalloc (2 * sizeof (*include_dirs));
4942 include_dirs[0] = "."; /* Current dir */
4943 include_dir_count = 2;
4947 include_dir_count++;
4948 include_dirs = (char **) realloc (include_dirs,
4949 include_dir_count * sizeof (*include_dirs));
4952 include_dirs[include_dir_count - 1] = path; /* New one */
4955 if (i > include_dir_maxlen)
4956 include_dir_maxlen = i;
4957 } /* add_include_dir() */
4959 /* Output debugging information to denote the source file. */
4962 generate_file_debug ()
4964 if (debug_type == DEBUG_STABS)
4965 stabs_generate_asm_file ();
4968 /* Output line number debugging information for the current source line. */
4971 generate_lineno_debug ()
4973 #ifdef ECOFF_DEBUGGING
4974 /* ECOFF assemblers automatically generate debugging information.
4975 FIXME: This should probably be handled elsewhere. */
4976 if (debug_type == DEBUG_UNSPECIFIED)
4978 if (ECOFF_DEBUGGING && ecoff_no_current_file ())
4979 debug_type = DEBUG_ECOFF;
4981 debug_type = DEBUG_NONE;
4987 case DEBUG_UNSPECIFIED:
4991 stabs_generate_asm_lineno ();
4994 ecoff_generate_asm_lineno ();
5003 /* Output debugging information to mark a function entry point or end point.
5004 END_P is zero for .func, and non-zero for .endfunc. */
5010 do_s_func (end_p, NULL);
5013 /* Subroutine of s_func so targets can choose a different default prefix.
5014 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5017 do_s_func (end_p, default_prefix)
5019 const char *default_prefix;
5021 /* Record the current function so that we can issue an error message for
5022 misplaced .func,.endfunc, and also so that .endfunc needs no
5024 static char *current_name;
5025 static char *current_label;
5029 if (current_name == NULL)
5031 as_bad (_("missing .func"));
5032 ignore_rest_of_line ();
5036 if (debug_type == DEBUG_STABS)
5037 stabs_generate_asm_endfunc (current_name, current_label);
5039 current_name = current_label = NULL;
5046 if (current_name != NULL)
5048 as_bad (_(".endfunc missing for previous .func"));
5049 ignore_rest_of_line ();
5053 name = input_line_pointer;
5054 delim1 = get_symbol_end ();
5055 name = xstrdup (name);
5056 *input_line_pointer = delim1;
5058 if (*input_line_pointer != ',')
5061 asprintf (&label, "%s%s", default_prefix, name);
5064 char leading_char = 0;
5065 #ifdef BFD_ASSEMBLER
5066 leading_char = bfd_get_symbol_leading_char (stdoutput);
5068 /* Missing entry point, use function's name with the leading
5071 asprintf (&label, "%c%s", leading_char, name);
5078 ++input_line_pointer;
5080 label = input_line_pointer;
5081 delim2 = get_symbol_end ();
5082 label = xstrdup (label);
5083 *input_line_pointer = delim2;
5086 if (debug_type == DEBUG_STABS)
5087 stabs_generate_asm_func (name, label);
5089 current_name = name;
5090 current_label = label;
5093 demand_empty_rest_of_line ();
5098 int arg ATTRIBUTE_UNUSED;
5100 while (!is_end_of_line[(unsigned char) *input_line_pointer])
5102 ++input_line_pointer;
5104 ++input_line_pointer;
5109 read_print_statistics (file)
5112 hash_print_statistics (file, "pseudo-op table", po_hash);
5115 /* Inserts the given line into the input stream.
5117 This call avoids macro/conditionals nesting checking, since the contents of
5118 the line are assumed to replace the contents of a line already scanned.
5120 An appropriate use of this function would be substition of input lines when
5121 called by md_start_line_hook(). The given line is assumed to already be
5122 properly scrubbed. */
5125 input_scrub_insert_line (line)
5130 sb_add_string (&newline, line);
5131 input_scrub_include_sb (&newline, input_line_pointer, 0);
5133 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
5136 /* Insert a file into the input stream; the path must resolve to an actual
5137 file; no include path searching or dependency registering is performed. */
5140 input_scrub_insert_file (path)
5143 input_scrub_include_file (path, input_line_pointer);
5144 buffer_limit = input_scrub_next_buffer (&input_line_pointer);