1 /* read.c - read a source file -
2 Copyright (C) 1986-2015 Free Software Foundation, Inc.
4 This file is part of GAS, the GNU Assembler.
6 GAS is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
11 GAS is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GAS; see the file COPYING. If not, write to the Free
18 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
21 /* If your chars aren't 8 bits, you will change this a bit (eg. to 0xFF).
22 But then, GNU isn't spozed to run on your machine anyway.
23 (RMS is so shortsighted sometimes.) */
24 #define MASK_CHAR ((int)(unsigned char) -1)
26 /* This is the largest known floating point format (for now). It will
27 grow when we do 4361 style flonums. */
28 #define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
30 /* Routines that read assembler source text to build spaghetti in memory.
31 Another group of these functions is in the expr.c module. */
34 #include "safe-ctype.h"
40 #include "dw2gencfi.h"
43 #ifndef TC_START_LABEL
44 #define TC_START_LABEL(STR, NUL_CHAR, NEXT_CHAR) (NEXT_CHAR == ':')
47 /* Set by the object-format or the target. */
48 #ifndef TC_IMPLICIT_LCOMM_ALIGNMENT
49 #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) \
54 else if ((SIZE) >= 4) \
56 else if ((SIZE) >= 2) \
64 char *input_line_pointer; /*->next char of source file to parse. */
66 #if BITS_PER_CHAR != 8
67 /* The following table is indexed by[(char)] and will break if
68 a char does not have exactly 256 states (hopefully 0:255!)! */
77 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
82 /* The Delta 68k assembler permits % inside label names. */
87 /* The PowerPC Windows NT assemblers permits ? inside label names. */
92 /* The IA-64 assembler uses # as a suffix designating a symbol. We include
93 it in the symbol and strip it out in tc_canonicalize_symbol_name. */
102 /* The Delta 68k assembler permits ~ at start of label names. */
106 /* Used by is_... macros. our ctype[]. */
107 char lex_type[256] = {
108 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
109 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
110 0, 0, 0, LEX_HASH, LEX_DOLLAR, LEX_PCT, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
111 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM, /* 0123456789:;<=>? */
112 LEX_AT, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
113 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR, 0, LEX_BR, 0, 3, /* PQRSTUVWXYZ[\]^_ */
114 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
115 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR, 0, LEX_BR, LEX_TILDE, 0, /* pqrstuvwxyz{|}~. */
116 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
117 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
118 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
119 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
120 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
121 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
122 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
123 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
127 Out: 1 if this character ends a line.
128 2 if this character is a line separator. */
129 char is_end_of_line[256] = {
131 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, /* @abcdefghijklmno */
133 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* @abcdefghijklmno */
135 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
136 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* _!"#$%&'()*+,-./ */
137 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */
138 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
139 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
140 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
141 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
142 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
143 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
144 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
145 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
146 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
147 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
148 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
149 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* */
152 #ifndef TC_CASE_SENSITIVE
153 char original_case_string[128];
156 /* Functions private to this file. */
158 static char *buffer; /* 1st char of each buffer of lines is here. */
159 static char *buffer_limit; /*->1 + last char in buffer. */
161 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1
162 in the tc-<CPU>.h file. See the "Porting GAS" section of the
164 int target_big_endian = TARGET_BYTES_BIG_ENDIAN;
166 /* Variables for handling include file directory table. */
168 /* Table of pointers to directories to search for .include's. */
171 /* How many are in the table. */
172 int include_dir_count;
174 /* Length of longest in table. */
175 int include_dir_maxlen = 1;
177 #ifndef WORKING_DOT_WORD
178 struct broken_word *broken_words;
179 int new_broken_words;
182 /* The current offset into the absolute section. We don't try to
183 build frags in the absolute section, since no data can be stored
184 there. We just keep track of the current offset. */
185 addressT abs_section_offset;
187 /* If this line had an MRI style label, it is stored in this variable.
188 This is used by some of the MRI pseudo-ops. */
191 /* This global variable is used to support MRI common sections. We
192 translate such sections into a common symbol. This variable is
193 non-NULL when we are in an MRI common section. */
194 symbolS *mri_common_symbol;
196 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
197 need to align to an even byte boundary unless the next pseudo-op is
198 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
200 static int mri_pending_align;
204 /* This variable is set to be non-zero if the next string we see might
205 be the name of the source file in DWARF debugging information. See
206 the comment in emit_expr for the format we look for. */
207 static int dwarf_file_string;
211 /* If the target defines the md_frag_max_var hook then we know
212 enough to implement the .bundle_align_mode features. */
213 #ifdef md_frag_max_var
214 # define HANDLE_BUNDLE
218 /* .bundle_align_mode sets this. Normally it's zero. When nonzero,
219 it's the exponent of the bundle size, and aligned instruction bundle
220 mode is in effect. */
221 static unsigned int bundle_align_p2;
223 /* These are set by .bundle_lock and .bundle_unlock. .bundle_lock sets
224 bundle_lock_frag to frag_now and then starts a new frag with
225 frag_align_code. At the same time, bundle_lock_frain gets frchain_now,
226 so that .bundle_unlock can verify that we didn't change segments.
227 .bundle_unlock resets both to NULL. If we detect a bundling violation,
228 then we reset bundle_lock_frchain to NULL as an indicator that we've
229 already diagnosed the error with as_bad and don't need a cascade of
230 redundant errors, but bundle_lock_frag remains set to indicate that
231 we are expecting to see .bundle_unlock. */
232 static fragS *bundle_lock_frag;
233 static frchainS *bundle_lock_frchain;
235 /* This is incremented by .bundle_lock and decremented by .bundle_unlock,
237 static unsigned int bundle_lock_depth;
240 static void do_s_func (int end_p, const char *default_prefix);
241 static void do_align (int, char *, int, int);
242 static void s_align (int, int);
243 static void s_altmacro (int);
244 static void s_bad_end (int);
245 static void s_reloc (int);
246 static int hex_float (int, char *);
247 static segT get_known_segmented_expression (expressionS * expP);
248 static void pobegin (void);
249 static size_t get_non_macro_line_sb (sb *);
250 static void generate_file_debug (void);
251 static char *_find_end_of_line (char *, int, int, int);
259 obj_read_begin_hook ();
261 /* Something close -- but not too close -- to a multiple of 1024.
262 The debugging malloc I'm using has 24 bytes of overhead. */
263 obstack_begin (¬es, chunksize);
264 obstack_begin (&cond_obstack, chunksize);
266 #ifndef tc_line_separator_chars
267 #define tc_line_separator_chars line_separator_chars
269 /* Use machine dependent syntax. */
270 for (p = tc_line_separator_chars; *p; p++)
271 is_end_of_line[(unsigned char) *p] = 2;
272 /* Use more. FIXME-SOMEDAY. */
278 #ifndef TC_ADDRESS_BYTES
279 #define TC_ADDRESS_BYTES address_bytes
284 /* Choose smallest of 1, 2, 4, 8 bytes that is large enough to
285 contain an address. */
286 int n = (stdoutput->arch_info->bits_per_address - 1) / 8;
294 /* Set up pseudo-op tables. */
296 static struct hash_control *po_hash;
298 static const pseudo_typeS potable[] = {
299 {"abort", s_abort, 0},
300 {"align", s_align_ptwo, 0},
301 {"altmacro", s_altmacro, 1},
302 {"ascii", stringer, 8+0},
303 {"asciz", stringer, 8+1},
304 {"balign", s_align_bytes, 0},
305 {"balignw", s_align_bytes, -2},
306 {"balignl", s_align_bytes, -4},
309 {"bundle_align_mode", s_bundle_align_mode, 0},
310 {"bundle_lock", s_bundle_lock, 0},
311 {"bundle_unlock", s_bundle_unlock, 0},
315 {"common", s_mri_common, 0},
316 {"common.s", s_mri_common, 1},
319 #ifdef TC_ADDRESS_BYTES
323 {"dc.d", float_cons, 'd'},
325 {"dc.s", float_cons, 'f'},
327 {"dc.x", float_cons, 'x'},
329 {"dcb.b", s_space, 1},
330 {"dcb.d", s_float_space, 'd'},
331 {"dcb.l", s_space, 4},
332 {"dcb.s", s_float_space, 'f'},
333 {"dcb.w", s_space, 2},
334 {"dcb.x", s_float_space, 'x'},
336 {"ds.b", s_space, 1},
337 {"ds.d", s_space, 8},
338 {"ds.l", s_space, 4},
339 {"ds.p", s_space, 12},
340 {"ds.s", s_space, 4},
341 {"ds.w", s_space, 2},
342 {"ds.x", s_space, 12},
343 {"debug", s_ignore, 0},
348 {"double", float_cons, 'd'},
350 {"eject", listing_eject, 0}, /* Formfeed listing. */
352 {"elsec", s_else, 0},
353 {"elseif", s_elseif, (int) O_ne},
355 {"endc", s_endif, 0},
356 {"endfunc", s_func, 1},
357 {"endif", s_endif, 0},
358 {"endm", s_bad_end, 0},
359 {"endr", s_bad_end, 1},
365 {"error", s_errwarn, 1},
366 {"exitm", s_mexit, 0},
368 {"extern", s_ignore, 0}, /* We treat all undef as ext. */
369 {"appfile", s_app_file, 1},
370 {"appline", s_app_line, 1},
372 {"file", s_app_file, 0},
374 {"float", float_cons, 'f'},
375 {"format", s_ignore, 0},
377 {"global", s_globl, 0},
378 {"globl", s_globl, 0},
380 {"if", s_if, (int) O_ne},
383 {"ifdef", s_ifdef, 0},
384 {"ifeq", s_if, (int) O_eq},
385 {"ifeqs", s_ifeqs, 0},
386 {"ifge", s_if, (int) O_ge},
387 {"ifgt", s_if, (int) O_gt},
388 {"ifle", s_if, (int) O_le},
389 {"iflt", s_if, (int) O_lt},
392 {"ifndef", s_ifdef, 1},
393 {"ifne", s_if, (int) O_ne},
394 {"ifnes", s_ifeqs, 1},
395 {"ifnotdef", s_ifdef, 1},
396 {"incbin", s_incbin, 0},
397 {"include", s_include, 0},
403 {"lcomm", s_lcomm, 0},
404 {"lflags", s_ignore, 0}, /* Listing flags. */
405 {"linefile", s_app_line, 0},
406 {"linkonce", s_linkonce, 0},
407 {"list", listing_list, 1}, /* Turn listing on. */
408 {"llen", listing_psize, 1},
411 {"macro", s_macro, 0},
412 {"mexit", s_mexit, 0},
414 {".mri", s_mri, 0}, /* Special case so .mri works in MRI mode. */
415 {"name", s_ignore, 0},
416 {"noaltmacro", s_altmacro, 0},
417 {"noformat", s_ignore, 0},
418 {"nolist", listing_list, 0}, /* Turn listing off. */
419 {"nopage", listing_nopage, 0},
421 {"offset", s_struct, 0},
423 {"p2align", s_align_ptwo, 0},
424 {"p2alignw", s_align_ptwo, -2},
425 {"p2alignl", s_align_ptwo, -4},
426 {"page", listing_eject, 0},
427 {"plen", listing_psize, 0},
428 {"print", s_print, 0},
429 {"psize", listing_psize, 0}, /* Set paper size. */
430 {"purgem", s_purgem, 0},
432 {"reloc", s_reloc, 0},
436 {"sbttl", listing_title, 1}, /* Subtitle of listing. */
441 {"single", float_cons, 'f'},
443 {"space", s_space, 0},
444 {"skip", s_space, 0},
445 {"sleb128", s_leb128, 1},
446 {"spc", s_ignore, 0},
447 {"stabd", s_stab, 'd'},
448 {"stabn", s_stab, 'n'},
449 {"stabs", s_stab, 's'},
450 {"string", stringer, 8+1},
451 {"string8", stringer, 8+1},
452 {"string16", stringer, 16+1},
453 {"string32", stringer, 32+1},
454 {"string64", stringer, 64+1},
455 {"struct", s_struct, 0},
459 /* This is for gcc to use. It's only just been added (2/94), so gcc
460 won't be able to use it for a while -- probably a year or more.
461 But once this has been released, check with gcc maintainers
462 before deleting it or even changing the spelling. */
463 {"this_GCC_requires_the_GNU_assembler", s_ignore, 0},
464 /* If we're folding case -- done for some targets, not necessarily
465 all -- the above string in an input file will be converted to
466 this one. Match it either way... */
467 {"this_gcc_requires_the_gnu_assembler", s_ignore, 0},
469 {"title", listing_title, 0}, /* Listing title. */
470 {"ttl", listing_title, 0},
472 {"uleb128", s_leb128, 0},
476 {"xdef", s_globl, 0},
477 {"xref", s_ignore, 0},
478 {"xstabs", s_xstab, 's'},
479 {"warning", s_errwarn, 0},
480 {"weakref", s_weakref, 0},
482 {"zero", s_space, 0},
483 {NULL, NULL, 0} /* End sentinel. */
487 get_absolute_expr (expressionS *exp)
489 expression_and_evaluate (exp);
490 if (exp->X_op != O_constant)
492 if (exp->X_op != O_absent)
493 as_bad (_("bad or irreducible absolute expression"));
494 exp->X_add_number = 0;
496 return exp->X_add_number;
500 get_absolute_expression (void)
504 return get_absolute_expr (&exp);
507 static int pop_override_ok = 0;
508 static const char *pop_table_name;
511 pop_insert (const pseudo_typeS *table)
514 const pseudo_typeS *pop;
515 for (pop = table; pop->poc_name; pop++)
517 errtxt = hash_insert (po_hash, pop->poc_name, (char *) pop);
518 if (errtxt && (!pop_override_ok || strcmp (errtxt, "exists")))
519 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name,
524 #ifndef md_pop_insert
525 #define md_pop_insert() pop_insert(md_pseudo_table)
528 #ifndef obj_pop_insert
529 #define obj_pop_insert() pop_insert(obj_pseudo_table)
532 #ifndef cfi_pop_insert
533 #define cfi_pop_insert() pop_insert(cfi_pseudo_table)
539 po_hash = hash_new ();
541 /* Do the target-specific pseudo ops. */
542 pop_table_name = "md";
545 /* Now object specific. Skip any that were in the target table. */
546 pop_table_name = "obj";
550 /* Now portable ones. Skip any that we've seen already. */
551 pop_table_name = "standard";
552 pop_insert (potable);
555 pop_table_name = "cfi";
560 #define HANDLE_CONDITIONAL_ASSEMBLY(num_read) \
561 if (ignore_input ()) \
563 char *eol = find_end_of_line (input_line_pointer - (num_read), \
565 input_line_pointer = (input_line_pointer <= buffer_limit \
566 && eol >= buffer_limit) \
572 /* This function is used when scrubbing the characters between #APP
575 static char *scrub_string;
576 static char *scrub_string_end;
579 scrub_from_string (char *buf, size_t buflen)
583 copy = scrub_string_end - scrub_string;
586 memcpy (buf, scrub_string, copy);
587 scrub_string += copy;
591 /* Helper function of read_a_source_file, which tries to expand a macro. */
593 try_macro (char term, const char *line)
599 if (check_macro (line, &out, &err, ¯o))
603 *input_line_pointer++ = term;
604 input_scrub_include_sb (&out,
605 input_line_pointer, 1);
608 input_scrub_next_buffer (&input_line_pointer);
610 md_macro_info (macro);
618 /* Start a new instruction bundle. Returns the rs_align_code frag that
619 will be used to align the new bundle. */
623 fragS *frag = frag_now;
625 frag_align_code (0, 0);
627 while (frag->fr_type != rs_align_code)
628 frag = frag->fr_next;
630 gas_assert (frag != frag_now);
635 /* Calculate the maximum size after relaxation of the region starting
636 at the given frag and extending through frag_now (which is unfinished). */
638 pending_bundle_size (fragS *frag)
640 unsigned int offset = frag->fr_fix;
641 unsigned int size = 0;
643 gas_assert (frag != frag_now);
644 gas_assert (frag->fr_type == rs_align_code);
646 while (frag != frag_now)
648 /* This should only happen in what will later become an error case. */
652 size += frag->fr_fix;
653 if (frag->fr_type == rs_machine_dependent)
654 size += md_frag_max_var (frag);
656 frag = frag->fr_next;
659 gas_assert (frag == frag_now);
660 size += frag_now_fix ();
661 if (frag->fr_type == rs_machine_dependent)
662 size += md_frag_max_var (frag);
664 gas_assert (size >= offset);
666 return size - offset;
669 /* Finish off the frag created to ensure bundle alignment. */
671 finish_bundle (fragS *frag, unsigned int size)
673 gas_assert (bundle_align_p2 > 0);
674 gas_assert (frag->fr_type == rs_align_code);
678 /* If there is more than a single byte, then we need to set up the
679 alignment frag. Otherwise we leave it at its initial state from
680 calling frag_align_code (0, 0), so that it does nothing. */
681 frag->fr_offset = bundle_align_p2;
682 frag->fr_subtype = size - 1;
685 /* We do this every time rather than just in s_bundle_align_mode
686 so that we catch any affected section without needing hooks all
687 over for all paths that do section changes. It's cheap enough. */
688 record_alignment (now_seg, bundle_align_p2 - OCTETS_PER_BYTE_POWER);
691 /* Assemble one instruction. This takes care of the bundle features
692 around calling md_assemble. */
694 assemble_one (char *line)
696 fragS *insn_start_frag = NULL;
698 if (bundle_lock_frchain != NULL && bundle_lock_frchain != frchain_now)
700 as_bad (_("cannot change section or subsection inside .bundle_lock"));
701 /* Clearing this serves as a marker that we have already complained. */
702 bundle_lock_frchain = NULL;
705 if (bundle_lock_frchain == NULL && bundle_align_p2 > 0)
706 insn_start_frag = start_bundle ();
710 if (bundle_lock_frchain != NULL)
712 /* Make sure this hasn't pushed the locked sequence
713 past the bundle size. */
714 unsigned int bundle_size = pending_bundle_size (bundle_lock_frag);
715 if (bundle_size > (1U << bundle_align_p2))
717 .bundle_lock sequence at %u bytes but .bundle_align_mode limit is %u bytes"),
718 bundle_size, 1U << bundle_align_p2);
720 else if (bundle_align_p2 > 0)
722 unsigned int insn_size = pending_bundle_size (insn_start_frag);
724 if (insn_size > (1U << bundle_align_p2))
726 single instruction is %u bytes long but .bundle_align_mode limit is %u"),
727 (unsigned int) insn_size, 1U << bundle_align_p2);
729 finish_bundle (insn_start_frag, insn_size);
733 #else /* !HANDLE_BUNDLE */
735 # define assemble_one(line) md_assemble(line)
737 #endif /* HANDLE_BUNDLE */
739 /* We read the file, putting things into a web that represents what we
740 have been reading. */
742 read_a_source_file (char *name)
746 char *s; /* String of symbol, '\0' appended. */
754 buffer = input_scrub_new_file (name);
757 listing_newline (NULL);
758 register_dependency (name);
760 /* Generate debugging information before we've read anything in to denote
761 this file as the "main" source file and not a subordinate one
762 (e.g. N_SO vs N_SOL in stabs). */
763 generate_file_debug ();
765 while ((buffer_limit = input_scrub_next_buffer (&input_line_pointer)) != 0)
766 { /* We have another line to parse. */
768 /* In order to avoid listing macro expansion lines with labels
769 multiple times, keep track of which line was last issued. */
770 static char *last_eol;
774 while (input_line_pointer < buffer_limit)
776 bfd_boolean was_new_line;
777 /* We have more of this buffer to parse. */
779 /* We now have input_line_pointer->1st char of next line.
780 If input_line_pointer [-1] == '\n' then we just
781 scanned another line: so bump line counters. */
782 was_new_line = is_end_of_line[(unsigned char) input_line_pointer[-1]];
785 symbol_set_value_now (&dot_symbol);
786 #ifdef md_start_line_hook
787 md_start_line_hook ();
789 if (input_line_pointer[-1] == '\n')
790 bump_line_counters ();
794 /* If listing is on, and we are expanding a macro, then give
795 the listing code the contents of the expanded line. */
798 if ((listing & LISTING_MACEXP) && macro_nest > 0)
800 /* Find the end of the current expanded macro line. */
801 s = find_end_of_line (input_line_pointer, flag_m68k_mri);
809 /* Copy it for safe keeping. Also give an indication of
810 how much macro nesting is involved at this point. */
811 len = s - input_line_pointer;
812 copy = (char *) xmalloc (len + macro_nest + 2);
813 memset (copy, '>', macro_nest);
814 copy[macro_nest] = ' ';
815 memcpy (copy + macro_nest + 1, input_line_pointer, len);
816 copy[macro_nest + 1 + len] = '\0';
818 /* Install the line with the listing facility. */
819 listing_newline (copy);
823 listing_newline (NULL);
830 if (LABELS_WITHOUT_COLONS || flag_m68k_mri)
832 next_char = * input_line_pointer;
833 /* Text at the start of a line must be a label, we
834 run down and stick a colon in. */
835 if (is_name_beginner (next_char) || next_char == '"')
840 HANDLE_CONDITIONAL_ASSEMBLY (0);
842 nul_char = get_symbol_name (& line_start);
843 next_char = (nul_char == '"' ? input_line_pointer[1] : nul_char);
845 /* In MRI mode, the EQU and MACRO pseudoops must
846 be handled specially. */
850 char *rest = input_line_pointer + 1;
854 if (*rest == ' ' || *rest == '\t')
856 if ((strncasecmp (rest, "EQU", 3) == 0
857 || strncasecmp (rest, "SET", 3) == 0)
858 && (rest[3] == ' ' || rest[3] == '\t'))
860 input_line_pointer = rest + 3;
862 strncasecmp (rest, "SET", 3) == 0);
865 if (strncasecmp (rest, "MACRO", 5) == 0
868 || is_end_of_line[(unsigned char) rest[5]]))
872 /* In MRI mode, we need to handle the MACRO
873 pseudo-op specially: we don't want to put the
874 symbol in the symbol table. */
876 #ifdef TC_START_LABEL_WITHOUT_COLON
877 && TC_START_LABEL_WITHOUT_COLON (nul_char, next_char)
880 line_label = colon (line_start);
882 line_label = symbol_create (line_start,
887 next_char = restore_line_pointer (nul_char);
888 if (next_char == ':')
889 input_line_pointer++;
894 /* We are at the beginning of a line, or similar place.
895 We expect a well-formed assembler statement.
896 A "symbol-name:" is a statement.
898 Depending on what compiler is used, the order of these tests
899 may vary to catch most common case 1st.
900 Each test is independent of all other tests at the (top)
903 nul_char = next_char = *input_line_pointer++;
904 while (next_char == '\t' || next_char == ' ' || next_char == '\f');
906 /* C is the 1st significant character.
907 Input_line_pointer points after that character. */
908 if (is_name_beginner (next_char) || next_char == '"')
912 /* Want user-defined label or pseudo/opcode. */
913 HANDLE_CONDITIONAL_ASSEMBLY (1);
915 --input_line_pointer;
916 nul_char = get_symbol_name (& s); /* name's delimiter. */
917 next_char = (nul_char == '"' ? input_line_pointer[1] : nul_char);
918 rest = input_line_pointer + (nul_char == '"' ? 2 : 1);
920 /* NEXT_CHAR is character after symbol.
921 The end of symbol in the input line is now '\0'.
922 S points to the beginning of the symbol.
923 [In case of pseudo-op, s->'.'.]
924 Input_line_pointer->'\0' where NUL_CHAR was. */
925 if (TC_START_LABEL (s, nul_char, next_char))
929 /* In MRI mode, \tsym: set 0 is permitted. */
933 if (*rest == ' ' || *rest == '\t')
936 if ((strncasecmp (rest, "EQU", 3) == 0
937 || strncasecmp (rest, "SET", 3) == 0)
938 && (rest[3] == ' ' || rest[3] == '\t'))
940 input_line_pointer = rest + 3;
946 line_label = colon (s); /* User-defined label. */
947 restore_line_pointer (nul_char);
948 ++ input_line_pointer;
949 #ifdef tc_check_label
950 tc_check_label (line_label);
952 /* Input_line_pointer->after ':'. */
955 else if ((next_char == '=' && *rest == '=')
956 || ((next_char == ' ' || next_char == '\t')
961 demand_empty_rest_of_line ();
963 else if ((next_char == '='
964 || ((next_char == ' ' || next_char == '\t')
966 #ifdef TC_EQUAL_IN_INSN
967 && !TC_EQUAL_IN_INSN (next_char, s)
972 demand_empty_rest_of_line ();
976 /* Expect pseudo-op or machine instruction. */
979 #ifndef TC_CASE_SENSITIVE
983 strncpy (original_case_string, s2, sizeof (original_case_string));
984 original_case_string[sizeof (original_case_string) - 1] = 0;
993 if (NO_PSEUDO_DOT || flag_m68k_mri)
995 /* The MRI assembler uses pseudo-ops without
997 pop = (pseudo_typeS *) hash_find (po_hash, s);
998 if (pop != NULL && pop->poc_handler == NULL)
1003 || (!flag_m68k_mri && *s == '.'))
1007 WARNING: next_char may be end-of-line.
1008 We lookup the pseudo-op table with s+1 because we
1009 already know that the pseudo-op begins with a '.'. */
1012 pop = (pseudo_typeS *) hash_find (po_hash, s + 1);
1013 if (pop && !pop->poc_handler)
1016 /* In MRI mode, we may need to insert an
1017 automatic alignment directive. What a hack
1019 if (mri_pending_align
1021 || !((pop->poc_handler == cons
1022 && pop->poc_val == 1)
1023 || (pop->poc_handler == s_space
1024 && pop->poc_val == 1)
1025 #ifdef tc_conditional_pseudoop
1026 || tc_conditional_pseudoop (pop)
1028 || pop->poc_handler == s_if
1029 || pop->poc_handler == s_ifdef
1030 || pop->poc_handler == s_ifc
1031 || pop->poc_handler == s_ifeqs
1032 || pop->poc_handler == s_else
1033 || pop->poc_handler == s_endif
1034 || pop->poc_handler == s_globl
1035 || pop->poc_handler == s_ignore)))
1037 do_align (1, (char *) NULL, 0, 0);
1038 mri_pending_align = 0;
1040 if (line_label != NULL)
1042 symbol_set_frag (line_label, frag_now);
1043 S_SET_VALUE (line_label, frag_now_fix ());
1047 /* Print the error msg now, while we still can. */
1050 char *end = input_line_pointer;
1052 (void) restore_line_pointer (nul_char);
1054 nul_char = next_char = *--input_line_pointer;
1055 *input_line_pointer = '\0';
1056 if (! macro_defined || ! try_macro (next_char, s))
1059 as_bad (_("unknown pseudo-op: `%s'"), s);
1060 *input_line_pointer++ = nul_char;
1065 /* Put it back for error messages etc. */
1066 next_char = restore_line_pointer (nul_char);
1067 /* The following skip of whitespace is compulsory.
1068 A well shaped space is sometimes all that separates
1069 keyword from operands. */
1070 if (next_char == ' ' || next_char == '\t')
1071 input_line_pointer++;
1073 /* Input_line is restored.
1074 Input_line_pointer->1st non-blank char
1075 after pseudo-operation. */
1076 (*pop->poc_handler) (pop->poc_val);
1078 /* If that was .end, just get out now. */
1079 if (pop->poc_handler == s_end)
1084 /* WARNING: next_char may be end-of-line. */
1085 /* Also: input_line_pointer->`\0` where nul_char was. */
1086 (void) restore_line_pointer (nul_char);
1087 input_line_pointer = _find_end_of_line (input_line_pointer, flag_m68k_mri, 1, 0);
1088 next_char = nul_char = *input_line_pointer;
1089 *input_line_pointer = '\0';
1091 generate_lineno_debug ();
1093 if (macro_defined && try_macro (next_char, s))
1096 if (mri_pending_align)
1098 do_align (1, (char *) NULL, 0, 0);
1099 mri_pending_align = 0;
1100 if (line_label != NULL)
1102 symbol_set_frag (line_label, frag_now);
1103 S_SET_VALUE (line_label, frag_now_fix ());
1107 assemble_one (s); /* Assemble 1 instruction. */
1109 *input_line_pointer++ = nul_char;
1111 /* We resume loop AFTER the end-of-line from
1112 this instruction. */
1118 /* Empty statement? */
1119 if (is_end_of_line[(unsigned char) next_char])
1122 if ((LOCAL_LABELS_DOLLAR || LOCAL_LABELS_FB) && ISDIGIT (next_char))
1124 /* local label ("4:") */
1125 char *backup = input_line_pointer;
1127 HANDLE_CONDITIONAL_ASSEMBLY (1);
1129 temp = next_char - '0';
1131 if (nul_char == '"')
1132 ++ input_line_pointer;
1134 /* Read the whole number. */
1135 while (ISDIGIT (*input_line_pointer))
1137 temp = (temp * 10) + *input_line_pointer - '0';
1138 ++input_line_pointer;
1141 if (LOCAL_LABELS_DOLLAR
1142 && *input_line_pointer == '$'
1143 && *(input_line_pointer + 1) == ':')
1145 input_line_pointer += 2;
1147 if (dollar_label_defined (temp))
1149 as_fatal (_("label \"%d$\" redefined"), temp);
1152 define_dollar_label (temp);
1153 colon (dollar_label_name (temp, 0));
1158 && *input_line_pointer++ == ':')
1160 fb_label_instance_inc (temp);
1161 colon (fb_label_name (temp, 0));
1165 input_line_pointer = backup;
1168 if (next_char && strchr (line_comment_chars, next_char))
1169 { /* Its a comment. Better say APP or NO_APP. */
1174 unsigned int new_length;
1177 s = input_line_pointer;
1178 if (strncmp (s, "APP\n", 4))
1181 ignore_rest_of_line ();
1184 bump_line_counters ();
1187 ends = strstr (s, "#NO_APP\n");
1191 unsigned int tmp_len;
1194 /* The end of the #APP wasn't in this buffer. We
1195 keep reading in buffers until we find the #NO_APP
1196 that goes with this #APP There is one. The specs
1198 tmp_len = buffer_limit - s;
1199 tmp_buf = (char *) xmalloc (tmp_len + 1);
1200 memcpy (tmp_buf, s, tmp_len);
1203 new_tmp = input_scrub_next_buffer (&buffer);
1207 buffer_limit = new_tmp;
1208 input_line_pointer = buffer;
1209 ends = strstr (buffer, "#NO_APP\n");
1211 num = ends - buffer;
1213 num = buffer_limit - buffer;
1215 tmp_buf = (char *) xrealloc (tmp_buf, tmp_len + num);
1216 memcpy (tmp_buf + tmp_len, buffer, num);
1221 input_line_pointer = ends ? ends + 8 : NULL;
1229 input_line_pointer = ends + 8;
1233 scrub_string_end = ends;
1235 new_length = ends - s;
1236 new_buf = (char *) xmalloc (new_length);
1243 space = (new_buf + new_length) - new_tmp;
1244 size = do_scrub_chars (scrub_from_string, new_tmp, space);
1252 new_buf = (char *) xrealloc (new_buf, new_length + 100);
1253 new_tmp = new_buf + new_length;
1260 /* We've "scrubbed" input to the preferred format. In the
1261 process we may have consumed the whole of the remaining
1262 file (and included files). We handle this formatted
1263 input similar to that of macro expansion, letting
1264 actual macro expansion (possibly nested) and other
1265 input expansion work. Beware that in messages, line
1266 numbers and possibly file names will be incorrect. */
1267 new_length = strlen (new_buf);
1268 sb_build (&sbuf, new_length);
1269 sb_add_buffer (&sbuf, new_buf, new_length);
1270 input_scrub_include_sb (&sbuf, input_line_pointer, 0);
1272 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
1277 HANDLE_CONDITIONAL_ASSEMBLY (1);
1279 #ifdef tc_unrecognized_line
1280 if (tc_unrecognized_line (next_char))
1283 input_line_pointer--;
1284 /* Report unknown char as error. */
1285 demand_empty_rest_of_line ();
1290 symbol_set_value_now (&dot_symbol);
1292 #ifdef HANDLE_BUNDLE
1293 if (bundle_lock_frag != NULL)
1295 as_bad_where (bundle_lock_frag->fr_file, bundle_lock_frag->fr_line,
1296 _(".bundle_lock with no matching .bundle_unlock"));
1297 bundle_lock_frag = NULL;
1298 bundle_lock_frchain = NULL;
1299 bundle_lock_depth = 0;
1306 /* Close the input file. */
1307 input_scrub_close ();
1308 #ifdef WARN_COMMENTS
1310 if (warn_comment && found_comment)
1311 as_warn_where (found_comment_file, found_comment,
1312 "first comment found here");
1317 /* Convert O_constant expression EXP into the equivalent O_big representation.
1318 Take the sign of the number from SIGN rather than X_add_number. */
1321 convert_to_bignum (expressionS *exp, int sign)
1326 value = exp->X_add_number;
1327 for (i = 0; i < sizeof (exp->X_add_number) / CHARS_PER_LITTLENUM; i++)
1329 generic_bignum[i] = value & LITTLENUM_MASK;
1330 value >>= LITTLENUM_NUMBER_OF_BITS;
1332 /* Add a sequence of sign bits if the top bit of X_add_number is not
1333 the sign of the original value. */
1334 if ((exp->X_add_number < 0) == !sign)
1335 generic_bignum[i++] = sign ? LITTLENUM_MASK : 0;
1337 exp->X_add_number = i;
1343 flagword flags = bfd_get_section_flags (stdoutput, now_seg);
1345 return (flags & SEC_ALLOC) && !(flags & (SEC_LOAD | SEC_HAS_CONTENTS));
1348 /* For most MRI pseudo-ops, the line actually ends at the first
1349 nonquoted space. This function looks for that point, stuffs a null
1350 in, and sets *STOPCP to the character that used to be there, and
1351 returns the location.
1353 Until I hear otherwise, I am going to assume that this is only true
1354 for the m68k MRI assembler. */
1357 mri_comment_field (char *stopcp)
1363 know (flag_m68k_mri);
1365 for (s = input_line_pointer;
1366 ((!is_end_of_line[(unsigned char) *s] && *s != ' ' && *s != '\t')
1374 for (s = input_line_pointer;
1375 !is_end_of_line[(unsigned char) *s];
1385 /* Skip to the end of an MRI comment field. */
1388 mri_comment_end (char *stop, int stopc)
1392 input_line_pointer = stop;
1394 while (!is_end_of_line[(unsigned char) *input_line_pointer])
1395 ++input_line_pointer;
1399 s_abort (int ignore ATTRIBUTE_UNUSED)
1401 as_fatal (_(".abort detected. Abandoning ship."));
1404 /* Guts of .align directive. N is the power of two to which to align.
1405 FILL may be NULL, or it may point to the bytes of the fill pattern.
1406 LEN is the length of whatever FILL points to, if anything. MAX is
1407 the maximum number of characters to skip when doing the alignment,
1408 or 0 if there is no maximum. */
1411 do_align (int n, char *fill, int len, int max)
1413 if (now_seg == absolute_section || in_bss ())
1417 if (*fill++ != '\0')
1419 if (now_seg == absolute_section)
1420 as_warn (_("ignoring fill value in absolute section"));
1422 as_warn (_("ignoring fill value in section `%s'"),
1423 segment_name (now_seg));
1430 #ifdef md_flush_pending_output
1431 md_flush_pending_output ();
1434 md_do_align (n, fill, len, max, just_record_alignment);
1437 /* Only make a frag if we HAVE to... */
1438 if (n != 0 && !need_pass_2)
1442 if (subseg_text_p (now_seg))
1443 frag_align_code (n, max);
1445 frag_align (n, 0, max);
1448 frag_align (n, *fill, max);
1450 frag_align_pattern (n, fill, len, max);
1454 just_record_alignment: ATTRIBUTE_UNUSED_LABEL
1457 record_alignment (now_seg, n - OCTETS_PER_BYTE_POWER);
1460 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1461 (in bytes). A negative ARG is the negative of the length of the
1462 fill pattern. BYTES_P is non-zero if the alignment value should be
1463 interpreted as the byte boundary, rather than the power of 2. */
1464 #ifndef TC_ALIGN_LIMIT
1465 #define TC_ALIGN_LIMIT (stdoutput->arch_info->bits_per_address - 1)
1469 s_align (int arg, int bytes_p)
1471 unsigned int align_limit = TC_ALIGN_LIMIT;
1480 stop = mri_comment_field (&stopc);
1482 if (is_end_of_line[(unsigned char) *input_line_pointer])
1487 align = arg; /* Default value from pseudo-op table. */
1491 align = get_absolute_expression ();
1494 #ifdef TC_ALIGN_ZERO_IS_DEFAULT
1495 if (arg > 0 && align == 0)
1502 /* Convert to a power of 2. */
1507 for (i = 0; (align & 1) == 0; align >>= 1, ++i)
1510 as_bad (_("alignment not a power of 2"));
1516 if (align > align_limit)
1518 align = align_limit;
1519 as_warn (_("alignment too large: %u assumed"), align);
1522 if (*input_line_pointer != ',')
1529 ++input_line_pointer;
1530 if (*input_line_pointer == ',')
1534 fill = get_absolute_expression ();
1539 if (*input_line_pointer != ',')
1543 ++input_line_pointer;
1544 max = get_absolute_expression ();
1551 as_warn (_("expected fill pattern missing"));
1552 do_align (align, (char *) NULL, 0, max);
1567 do_align (align, &fill_char, fill_len, max);
1573 if ((size_t) fill_len > sizeof ab)
1575 md_number_to_chars (ab, fill, fill_len);
1576 do_align (align, ab, fill_len, max);
1580 demand_empty_rest_of_line ();
1583 mri_comment_end (stop, stopc);
1586 /* Handle the .align pseudo-op on machines where ".align 4" means
1587 align to a 4 byte boundary. */
1590 s_align_bytes (int arg)
1595 /* Handle the .align pseudo-op on machines where ".align 4" means align
1596 to a 2**4 boundary. */
1599 s_align_ptwo (int arg)
1604 /* Switch in and out of alternate macro mode. */
1609 demand_empty_rest_of_line ();
1610 macro_set_alternate (on);
1613 /* Read a symbol name from input_line_pointer.
1615 Stores the symbol name in a buffer and returns a pointer to this buffer.
1616 The buffer is xalloc'ed. It is the caller's responsibility to free
1619 The name is not left in the i_l_p buffer as it may need processing
1620 to handle escape characters.
1622 Advances i_l_p to the next non-whitespace character.
1624 If a symbol name could not be read, the routine issues an error
1625 messages, skips to the end of the line and returns NULL. */
1628 read_symbol_name (void)
1634 c = *input_line_pointer++;
1638 #define SYM_NAME_CHUNK_LEN 128
1639 ptrdiff_t len = SYM_NAME_CHUNK_LEN;
1643 start = name = xmalloc (len + 1);
1645 name_end = name + SYM_NAME_CHUNK_LEN;
1647 while (is_a_char (C = next_char_of_string ()))
1649 if (name >= name_end)
1653 sofar = name - start;
1654 len += SYM_NAME_CHUNK_LEN;
1655 start = xrealloc (start, len + 1);
1656 name_end = start + len;
1657 name = start + sofar;
1664 /* Since quoted symbol names can contain non-ASCII characters,
1665 check the string and warn if it cannot be recognised by the
1666 current character set. */
1667 if (mbstowcs (NULL, name, len) == (size_t) -1)
1668 as_warn (_("symbol name not recognised in the current locale"));
1670 else if (is_name_beginner (c) || c == '\001')
1674 name = input_line_pointer - 1;
1676 /* We accept \001 in a name in case this is
1677 being called with a constructed string. */
1678 while (is_part_of_name (c = *input_line_pointer++)
1682 len = (input_line_pointer - name) - 1;
1683 start = xmalloc (len + 1);
1685 memcpy (start, name, len);
1688 /* Skip a name ender char if one is present. */
1689 if (! is_name_ender (c))
1690 --input_line_pointer;
1693 name = start = NULL;
1697 as_bad (_("expected symbol name"));
1698 ignore_rest_of_line ();
1709 s_comm_internal (int param,
1710 symbolS *(*comm_parse_extra) (int, symbolS *, addressT))
1714 symbolS *symbolP = NULL;
1720 stop = mri_comment_field (&stopc);
1722 if ((name = read_symbol_name ()) == NULL)
1725 /* Accept an optional comma after the name. The comma used to be
1726 required, but Irix 5 cc does not generate it for .lcomm. */
1727 if (*input_line_pointer == ',')
1728 input_line_pointer++;
1730 temp = get_absolute_expr (&exp);
1732 size &= ((addressT) 2 << (stdoutput->arch_info->bits_per_address - 1)) - 1;
1733 if (exp.X_op == O_absent)
1735 as_bad (_("missing size expression"));
1736 ignore_rest_of_line ();
1739 else if (temp != size || !exp.X_unsigned)
1741 as_warn (_("size (%ld) out of range, ignored"), (long) temp);
1742 ignore_rest_of_line ();
1746 symbolP = symbol_find_or_make (name);
1747 if ((S_IS_DEFINED (symbolP) || symbol_equated_p (symbolP))
1748 && !S_IS_COMMON (symbolP))
1750 if (!S_IS_VOLATILE (symbolP))
1753 as_bad (_("symbol `%s' is already defined"), name);
1754 ignore_rest_of_line ();
1757 symbolP = symbol_clone (symbolP, 1);
1758 S_SET_SEGMENT (symbolP, undefined_section);
1759 S_SET_VALUE (symbolP, 0);
1760 symbol_set_frag (symbolP, &zero_address_frag);
1761 S_CLEAR_VOLATILE (symbolP);
1764 size = S_GET_VALUE (symbolP);
1767 else if (size != temp)
1768 as_warn (_("size of \"%s\" is already %ld; not changing to %ld"),
1769 name, (long) size, (long) temp);
1771 if (comm_parse_extra != NULL)
1772 symbolP = (*comm_parse_extra) (param, symbolP, size);
1775 S_SET_VALUE (symbolP, (valueT) size);
1776 S_SET_EXTERNAL (symbolP);
1777 S_SET_SEGMENT (symbolP, bfd_com_section_ptr);
1780 demand_empty_rest_of_line ();
1783 mri_comment_end (stop, stopc);
1792 s_comm_internal (ignore, NULL);
1795 /* The MRI COMMON pseudo-op. We handle this by creating a common
1796 symbol with the appropriate name. We make s_space do the right
1797 thing by increasing the size. */
1800 s_mri_common (int small ATTRIBUTE_UNUSED)
1816 stop = mri_comment_field (&stopc);
1820 name = input_line_pointer;
1821 if (!ISDIGIT (*name))
1822 c = get_symbol_name (& name);
1827 ++input_line_pointer;
1829 while (ISDIGIT (*input_line_pointer));
1831 c = *input_line_pointer;
1832 *input_line_pointer = '\0';
1834 if (line_label != NULL)
1836 alc = (char *) xmalloc (strlen (S_GET_NAME (line_label))
1837 + (input_line_pointer - name)
1839 sprintf (alc, "%s%s", name, S_GET_NAME (line_label));
1844 sym = symbol_find_or_make (name);
1845 c = restore_line_pointer (c);
1849 if (*input_line_pointer != ',')
1853 ++input_line_pointer;
1854 align = get_absolute_expression ();
1857 if (S_IS_DEFINED (sym) && !S_IS_COMMON (sym))
1859 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (sym));
1860 ignore_rest_of_line ();
1861 mri_comment_end (stop, stopc);
1865 S_SET_EXTERNAL (sym);
1866 S_SET_SEGMENT (sym, bfd_com_section_ptr);
1867 mri_common_symbol = sym;
1871 S_SET_ALIGN (sym, align);
1876 if (line_label != NULL)
1879 exp.X_op = O_symbol;
1880 exp.X_add_symbol = sym;
1881 exp.X_add_number = 0;
1882 symbol_set_value_expression (line_label, &exp);
1883 symbol_set_frag (line_label, &zero_address_frag);
1884 S_SET_SEGMENT (line_label, expr_section);
1887 /* FIXME: We just ignore the small argument, which distinguishes
1888 COMMON and COMMON.S. I don't know what we can do about it. */
1890 /* Ignore the type and hptype. */
1891 if (*input_line_pointer == ',')
1892 input_line_pointer += 2;
1893 if (*input_line_pointer == ',')
1894 input_line_pointer += 2;
1896 demand_empty_rest_of_line ();
1898 mri_comment_end (stop, stopc);
1902 s_data (int ignore ATTRIBUTE_UNUSED)
1907 temp = get_absolute_expression ();
1908 if (flag_readonly_data_in_text)
1910 section = text_section;
1914 section = data_section;
1916 subseg_set (section, (subsegT) temp);
1918 demand_empty_rest_of_line ();
1921 /* Handle the .appfile pseudo-op. This is automatically generated by
1922 do_scrub_chars when a preprocessor # line comment is seen with a
1923 file name. This default definition may be overridden by the object
1924 or CPU specific pseudo-ops. This function is also the default
1925 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1929 s_app_file_string (char *file, int appfile ATTRIBUTE_UNUSED)
1933 listing_source_file (file);
1935 register_dependency (file);
1937 obj_app_file (file, appfile);
1942 s_app_file (int appfile)
1947 /* Some assemblers tolerate immediately following '"'. */
1948 if ((s = demand_copy_string (&length)) != 0)
1951 = (!new_logical_line_flags (s, -1, 1) && appfile);
1953 /* In MRI mode, the preprocessor may have inserted an extraneous
1956 && *input_line_pointer == '\''
1957 && is_end_of_line[(unsigned char) input_line_pointer[1]])
1958 ++input_line_pointer;
1960 demand_empty_rest_of_line ();
1962 s_app_file_string (s, appfile);
1967 get_linefile_number (int *flag)
1971 if (*input_line_pointer < '0' || *input_line_pointer > '9')
1974 *flag = get_absolute_expression ();
1979 /* Handle the .appline pseudo-op. This is automatically generated by
1980 do_scrub_chars when a preprocessor # line comment is seen. This
1981 default definition may be overridden by the object or CPU specific
1985 s_app_line (int appline)
1990 /* The given number is that of the next line. */
1992 l = get_absolute_expression ();
1993 else if (!get_linefile_number (&l))
1995 ignore_rest_of_line ();
2002 /* Some of the back ends can't deal with non-positive line numbers.
2003 Besides, it's silly. GCC however will generate a line number of
2004 zero when it is pre-processing builtins for assembler-with-cpp files:
2008 We do not want to barf on this, especially since such files are used
2009 in the GCC and GDB testsuites. So we check for negative line numbers
2010 rather than non-positive line numbers. */
2011 as_warn (_("line numbers must be positive; line number %d rejected"),
2022 if (*input_line_pointer == '"')
2023 file = demand_copy_string (&length);
2029 while (get_linefile_number (&this_flag))
2032 /* From GCC's cpp documentation:
2033 1: start of a new file.
2034 2: returning to a file after having included
2036 3: following text comes from a system header file.
2037 4: following text should be treated as extern "C".
2039 4 is nonsensical for the assembler; 3, we don't
2040 care about, so we ignore it just in case a
2041 system header file is included while
2042 preprocessing assembly. So 1 and 2 are all we
2043 care about, and they are mutually incompatible.
2044 new_logical_line_flags() demands this. */
2047 if (flags && flags != (1 << this_flag))
2048 as_warn (_("incompatible flag %i in line directive"),
2051 flags |= 1 << this_flag;
2056 /* We ignore these. */
2060 as_warn (_("unsupported flag %i in line directive"),
2065 if (!is_end_of_line[(unsigned char)*input_line_pointer])
2070 if (appline || file)
2072 new_logical_line_flags (file, l, flags);
2075 listing_source_line (l);
2079 if (appline || file)
2080 demand_empty_rest_of_line ();
2082 ignore_rest_of_line ();
2085 /* Handle the .end pseudo-op. Actually, the real work is done in
2086 read_a_source_file. */
2089 s_end (int ignore ATTRIBUTE_UNUSED)
2093 /* The MRI assembler permits the start symbol to follow .end,
2094 but we don't support that. */
2096 if (!is_end_of_line[(unsigned char) *input_line_pointer]
2097 && *input_line_pointer != '*'
2098 && *input_line_pointer != '!')
2099 as_warn (_("start address not supported"));
2103 /* Handle the .err pseudo-op. */
2106 s_err (int ignore ATTRIBUTE_UNUSED)
2108 as_bad (_(".err encountered"));
2109 demand_empty_rest_of_line ();
2112 /* Handle the .error and .warning pseudo-ops. */
2118 /* The purpose for the conditional assignment is not to
2119 internationalize the directive itself, but that we need a
2120 self-contained message, one that can be passed like the
2121 demand_copy_C_string return value, and with no assumption on the
2122 location of the name of the directive within the message. */
2124 = (err ? _(".error directive invoked in source file")
2125 : _(".warning directive invoked in source file"));
2127 if (!is_it_end_of_statement ())
2129 if (*input_line_pointer != '\"')
2131 as_bad (_("%s argument must be a string"),
2132 err ? ".error" : ".warning");
2133 ignore_rest_of_line ();
2137 msg = demand_copy_C_string (&len);
2145 as_warn ("%s", msg);
2146 demand_empty_rest_of_line ();
2149 /* Handle the MRI fail pseudo-op. */
2152 s_fail (int ignore ATTRIBUTE_UNUSED)
2159 stop = mri_comment_field (&stopc);
2161 temp = get_absolute_expression ();
2163 as_warn (_(".fail %ld encountered"), (long) temp);
2165 as_bad (_(".fail %ld encountered"), (long) temp);
2167 demand_empty_rest_of_line ();
2170 mri_comment_end (stop, stopc);
2174 s_fill (int ignore ATTRIBUTE_UNUSED)
2176 expressionS rep_exp;
2181 #ifdef md_flush_pending_output
2182 md_flush_pending_output ();
2185 #ifdef md_cons_align
2189 get_known_segmented_expression (&rep_exp);
2190 if (*input_line_pointer == ',')
2192 input_line_pointer++;
2193 size = get_absolute_expression ();
2194 if (*input_line_pointer == ',')
2196 input_line_pointer++;
2197 fill = get_absolute_expression ();
2201 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
2202 #define BSD_FILL_SIZE_CROCK_8 (8)
2203 if (size > BSD_FILL_SIZE_CROCK_8)
2205 as_warn (_(".fill size clamped to %d"), BSD_FILL_SIZE_CROCK_8);
2206 size = BSD_FILL_SIZE_CROCK_8;
2210 as_warn (_("size negative; .fill ignored"));
2213 else if (rep_exp.X_op == O_constant && rep_exp.X_add_number <= 0)
2215 if (rep_exp.X_add_number < 0)
2216 as_warn (_("repeat < 0; .fill ignored"));
2220 if (size && !need_pass_2)
2222 if (now_seg == absolute_section)
2224 if (rep_exp.X_op != O_constant)
2225 as_bad (_("non-constant fill count for absolute section"));
2226 else if (fill && rep_exp.X_add_number != 0)
2227 as_bad (_("attempt to fill absolute section with non-zero value"));
2228 abs_section_offset += rep_exp.X_add_number * size;
2231 && (rep_exp.X_op != O_constant || rep_exp.X_add_number != 0)
2233 as_bad (_("attempt to fill section `%s' with non-zero value"),
2234 segment_name (now_seg));
2236 if (rep_exp.X_op == O_constant)
2238 p = frag_var (rs_fill, (int) size, (int) size,
2239 (relax_substateT) 0, (symbolS *) 0,
2240 (offsetT) rep_exp.X_add_number,
2245 /* We don't have a constant repeat count, so we can't use
2246 rs_fill. We can get the same results out of rs_space,
2247 but its argument is in bytes, so we must multiply the
2248 repeat count by size. */
2251 rep_sym = make_expr_symbol (&rep_exp);
2254 expressionS size_exp;
2255 size_exp.X_op = O_constant;
2256 size_exp.X_add_number = size;
2258 rep_exp.X_op = O_multiply;
2259 rep_exp.X_add_symbol = rep_sym;
2260 rep_exp.X_op_symbol = make_expr_symbol (&size_exp);
2261 rep_exp.X_add_number = 0;
2262 rep_sym = make_expr_symbol (&rep_exp);
2265 p = frag_var (rs_space, (int) size, (int) size,
2266 (relax_substateT) 0, rep_sym, (offsetT) 0, (char *) 0);
2269 memset (p, 0, (unsigned int) size);
2271 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
2272 flavoured AS. The following bizarre behaviour is to be
2273 compatible with above. I guess they tried to take up to 8
2274 bytes from a 4-byte expression and they forgot to sign
2276 #define BSD_FILL_SIZE_CROCK_4 (4)
2277 md_number_to_chars (p, (valueT) fill,
2278 (size > BSD_FILL_SIZE_CROCK_4
2279 ? BSD_FILL_SIZE_CROCK_4
2281 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
2282 but emits no error message because it seems a legal thing to do.
2283 It is a degenerate case of .fill but could be emitted by a
2286 demand_empty_rest_of_line ();
2290 s_globl (int ignore ATTRIBUTE_UNUSED)
2299 stop = mri_comment_field (&stopc);
2303 if ((name = read_symbol_name ()) == NULL)
2306 symbolP = symbol_find_or_make (name);
2307 S_SET_EXTERNAL (symbolP);
2310 c = *input_line_pointer;
2313 input_line_pointer++;
2315 if (is_end_of_line[(unsigned char) *input_line_pointer])
2323 demand_empty_rest_of_line ();
2326 mri_comment_end (stop, stopc);
2329 /* Handle the MRI IRP and IRPC pseudo-ops. */
2340 as_where (&file, &line);
2342 eol = find_end_of_line (input_line_pointer, 0);
2343 sb_build (&s, eol - input_line_pointer);
2344 sb_add_buffer (&s, input_line_pointer, eol - input_line_pointer);
2345 input_line_pointer = eol;
2349 err = expand_irp (irpc, 0, &s, &out, get_non_macro_line_sb);
2351 as_bad_where (file, line, "%s", err);
2355 input_scrub_include_sb (&out, input_line_pointer, 1);
2357 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
2360 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
2361 the section to only be linked once. However, this is not supported
2362 by most object file formats. This takes an optional argument,
2363 which is what to do about duplicates. */
2366 s_linkonce (int ignore ATTRIBUTE_UNUSED)
2368 enum linkonce_type type;
2372 type = LINKONCE_DISCARD;
2374 if (!is_end_of_line[(unsigned char) *input_line_pointer])
2379 c = get_symbol_name (& s);
2380 if (strcasecmp (s, "discard") == 0)
2381 type = LINKONCE_DISCARD;
2382 else if (strcasecmp (s, "one_only") == 0)
2383 type = LINKONCE_ONE_ONLY;
2384 else if (strcasecmp (s, "same_size") == 0)
2385 type = LINKONCE_SAME_SIZE;
2386 else if (strcasecmp (s, "same_contents") == 0)
2387 type = LINKONCE_SAME_CONTENTS;
2389 as_warn (_("unrecognized .linkonce type `%s'"), s);
2391 (void) restore_line_pointer (c);
2394 #ifdef obj_handle_link_once
2395 obj_handle_link_once (type);
2396 #else /* ! defined (obj_handle_link_once) */
2400 if ((bfd_applicable_section_flags (stdoutput) & SEC_LINK_ONCE) == 0)
2401 as_warn (_(".linkonce is not supported for this object file format"));
2403 flags = bfd_get_section_flags (stdoutput, now_seg);
2404 flags |= SEC_LINK_ONCE;
2409 case LINKONCE_DISCARD:
2410 flags |= SEC_LINK_DUPLICATES_DISCARD;
2412 case LINKONCE_ONE_ONLY:
2413 flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
2415 case LINKONCE_SAME_SIZE:
2416 flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
2418 case LINKONCE_SAME_CONTENTS:
2419 flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
2422 if (!bfd_set_section_flags (stdoutput, now_seg, flags))
2423 as_bad (_("bfd_set_section_flags: %s"),
2424 bfd_errmsg (bfd_get_error ()));
2426 #endif /* ! defined (obj_handle_link_once) */
2428 demand_empty_rest_of_line ();
2432 bss_alloc (symbolS *symbolP, addressT size, int align)
2435 segT current_seg = now_seg;
2436 subsegT current_subseg = now_subseg;
2437 segT bss_seg = bss_section;
2439 #if defined (TC_MIPS) || defined (TC_ALPHA)
2440 if (OUTPUT_FLAVOR == bfd_target_ecoff_flavour
2441 || OUTPUT_FLAVOR == bfd_target_elf_flavour)
2443 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
2444 if (size <= bfd_get_gp_size (stdoutput))
2446 bss_seg = subseg_new (".sbss", 1);
2447 seg_info (bss_seg)->bss = 1;
2448 if (!bfd_set_section_flags (stdoutput, bss_seg, SEC_ALLOC))
2449 as_warn (_("error setting flags for \".sbss\": %s"),
2450 bfd_errmsg (bfd_get_error ()));
2454 subseg_set (bss_seg, 1);
2458 record_alignment (bss_seg, align);
2459 frag_align (align, 0, 0);
2462 /* Detach from old frag. */
2463 if (S_GET_SEGMENT (symbolP) == bss_seg)
2464 symbol_get_frag (symbolP)->fr_symbol = NULL;
2466 symbol_set_frag (symbolP, frag_now);
2467 pfrag = frag_var (rs_org, 1, 1, 0, symbolP, size, NULL);
2471 S_SET_SIZE (symbolP, size);
2473 S_SET_SEGMENT (symbolP, bss_seg);
2476 /* The symbol may already have been created with a preceding
2477 ".globl" directive -- be careful not to step on storage class
2478 in that case. Otherwise, set it to static. */
2479 if (S_GET_STORAGE_CLASS (symbolP) != C_EXT)
2480 S_SET_STORAGE_CLASS (symbolP, C_STAT);
2481 #endif /* OBJ_COFF */
2483 subseg_set (current_seg, current_subseg);
2487 parse_align (int align_bytes)
2493 if (*input_line_pointer != ',')
2496 as_bad (_("expected alignment after size"));
2497 ignore_rest_of_line ();
2501 input_line_pointer++;
2504 align = get_absolute_expr (&exp);
2505 if (exp.X_op == O_absent)
2508 if (!exp.X_unsigned)
2510 as_warn (_("alignment negative; 0 assumed"));
2514 if (align_bytes && align != 0)
2516 /* convert to a power of 2 alignment */
2517 unsigned int alignp2 = 0;
2518 while ((align & 1) == 0)
2519 align >>= 1, ++alignp2;
2522 as_bad (_("alignment not a power of 2"));
2523 ignore_rest_of_line ();
2531 /* Called from s_comm_internal after symbol name and size have been
2532 parsed. NEEDS_ALIGN is 0 if it was an ".lcomm" (2 args only),
2533 1 if this was a ".bss" directive which has a 3rd argument
2534 (alignment as a power of 2), or 2 if this was a ".bss" directive
2535 with alignment in bytes. */
2538 s_lcomm_internal (int needs_align, symbolS *symbolP, addressT size)
2544 align = parse_align (needs_align - 1);
2545 if (align == (addressT) -1)
2549 /* Assume some objects may require alignment on some systems. */
2550 TC_IMPLICIT_LCOMM_ALIGNMENT (size, align);
2552 bss_alloc (symbolP, size, align);
2557 s_lcomm (int needs_align)
2559 s_comm_internal (needs_align, s_lcomm_internal);
2563 s_lcomm_bytes (int needs_align)
2565 s_comm_internal (needs_align * 2, s_lcomm_internal);
2569 s_lsym (int ignore ATTRIBUTE_UNUSED)
2575 /* We permit ANY defined expression: BSD4.2 demands constants. */
2576 if ((name = read_symbol_name ()) == NULL)
2579 if (*input_line_pointer != ',')
2581 as_bad (_("expected comma after \"%s\""), name);
2585 input_line_pointer++;
2586 expression_and_evaluate (&exp);
2588 if (exp.X_op != O_constant
2589 && exp.X_op != O_register)
2591 as_bad (_("bad expression"));
2595 symbolP = symbol_find_or_make (name);
2597 if (S_GET_SEGMENT (symbolP) == undefined_section)
2599 /* The name might be an undefined .global symbol; be sure to
2600 keep the "external" bit. */
2601 S_SET_SEGMENT (symbolP,
2602 (exp.X_op == O_constant
2605 S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
2609 as_bad (_("symbol `%s' is already defined"), name);
2612 demand_empty_rest_of_line ();
2617 ignore_rest_of_line ();
2622 /* Read a line into an sb. Returns the character that ended the line
2623 or zero if there are no more lines. */
2626 get_line_sb (sb *line, int in_macro)
2630 if (input_line_pointer[-1] == '\n')
2631 bump_line_counters ();
2633 if (input_line_pointer >= buffer_limit)
2635 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
2636 if (buffer_limit == 0)
2640 eol = _find_end_of_line (input_line_pointer, flag_m68k_mri, 0, in_macro);
2641 sb_add_buffer (line, input_line_pointer, eol - input_line_pointer);
2642 input_line_pointer = eol;
2644 /* Don't skip multiple end-of-line characters, because that breaks support
2645 for the IA-64 stop bit (;;) which looks like two consecutive end-of-line
2646 characters but isn't. Instead just skip one end of line character and
2647 return the character skipped so that the caller can re-insert it if
2649 return *input_line_pointer++;
2653 get_non_macro_line_sb (sb *line)
2655 return get_line_sb (line, 0);
2659 get_macro_line_sb (sb *line)
2661 return get_line_sb (line, 1);
2664 /* Define a macro. This is an interface to macro.c. */
2667 s_macro (int ignore ATTRIBUTE_UNUSED)
2675 as_where (&file, &line);
2677 eol = find_end_of_line (input_line_pointer, 0);
2678 sb_build (&s, eol - input_line_pointer);
2679 sb_add_buffer (&s, input_line_pointer, eol - input_line_pointer);
2680 input_line_pointer = eol;
2682 if (line_label != NULL)
2687 name = S_GET_NAME (line_label);
2688 len = strlen (name);
2689 sb_build (&label, len);
2690 sb_add_buffer (&label, name, len);
2691 err = define_macro (0, &s, &label, get_macro_line_sb, file, line, &name);
2695 err = define_macro (0, &s, NULL, get_macro_line_sb, file, line, &name);
2697 as_bad_where (file, line, err, name);
2700 if (line_label != NULL)
2702 S_SET_SEGMENT (line_label, absolute_section);
2703 S_SET_VALUE (line_label, 0);
2704 symbol_set_frag (line_label, &zero_address_frag);
2707 if (((NO_PSEUDO_DOT || flag_m68k_mri)
2708 && hash_find (po_hash, name) != NULL)
2711 && hash_find (po_hash, name + 1) != NULL))
2712 as_warn_where (file,
2714 _("attempt to redefine pseudo-op `%s' ignored"),
2721 /* Handle the .mexit pseudo-op, which immediately exits a macro
2725 s_mexit (int ignore ATTRIBUTE_UNUSED)
2729 cond_exit_macro (macro_nest);
2730 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
2733 as_warn (_("ignoring macro exit outside a macro definition."));
2736 /* Switch in and out of MRI mode. */
2739 s_mri (int ignore ATTRIBUTE_UNUSED)
2742 #ifdef MRI_MODE_CHANGE
2746 on = get_absolute_expression ();
2747 #ifdef MRI_MODE_CHANGE
2748 old_flag = flag_mri;
2767 /* Operator precedence changes in m68k MRI mode, so we need to
2768 update the operator rankings. */
2769 expr_set_precedence ();
2771 #ifdef MRI_MODE_CHANGE
2773 MRI_MODE_CHANGE (on);
2776 demand_empty_rest_of_line ();
2779 /* Handle changing the location counter. */
2782 do_org (segT segment, expressionS *exp, int fill)
2784 if (segment != now_seg
2785 && segment != absolute_section
2786 && segment != expr_section)
2787 as_bad (_("invalid segment \"%s\""), segment_name (segment));
2789 if (now_seg == absolute_section)
2792 as_warn (_("ignoring fill value in absolute section"));
2793 if (exp->X_op != O_constant)
2795 as_bad (_("only constant offsets supported in absolute section"));
2796 exp->X_add_number = 0;
2798 abs_section_offset = exp->X_add_number;
2803 symbolS *sym = exp->X_add_symbol;
2804 offsetT off = exp->X_add_number * OCTETS_PER_BYTE;
2806 if (fill && in_bss ())
2807 as_warn (_("ignoring fill value in section `%s'"),
2808 segment_name (now_seg));
2810 if (exp->X_op != O_constant && exp->X_op != O_symbol)
2812 /* Handle complex expressions. */
2813 sym = make_expr_symbol (exp);
2817 p = frag_var (rs_org, 1, 1, (relax_substateT) 0, sym, off, (char *) 0);
2823 s_org (int ignore ATTRIBUTE_UNUSED)
2829 #ifdef md_flush_pending_output
2830 md_flush_pending_output ();
2833 /* The m68k MRI assembler has a different meaning for .org. It
2834 means to create an absolute section at a given address. We can't
2835 support that--use a linker script instead. */
2838 as_bad (_("MRI style ORG pseudo-op not supported"));
2839 ignore_rest_of_line ();
2843 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2844 thing as a sub-segment-relative origin. Any absolute origin is
2845 given a warning, then assumed to be segment-relative. Any
2846 segmented origin expression ("foo+42") had better be in the right
2847 segment or the .org is ignored.
2849 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2850 we never know sub-segment sizes when we are reading code. BSD
2851 will crash trying to emit negative numbers of filler bytes in
2852 certain .orgs. We don't crash, but see as-write for that code.
2854 Don't make frag if need_pass_2==1. */
2855 segment = get_known_segmented_expression (&exp);
2856 if (*input_line_pointer == ',')
2858 input_line_pointer++;
2859 temp_fill = get_absolute_expression ();
2865 do_org (segment, &exp, temp_fill);
2867 demand_empty_rest_of_line ();
2870 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2871 called by the obj-format routine which handles section changing
2872 when in MRI mode. It will create a new section, and return it. It
2873 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2874 'M' (mixed), or 'R' (romable). The flags will be set in the section. */
2877 s_mri_sect (char *type ATTRIBUTE_UNUSED)
2887 name = input_line_pointer;
2888 if (!ISDIGIT (*name))
2889 c = get_symbol_name (& name);
2894 ++input_line_pointer;
2896 while (ISDIGIT (*input_line_pointer));
2898 c = *input_line_pointer;
2899 *input_line_pointer = '\0';
2902 name = xstrdup (name);
2904 c = restore_line_pointer (c);
2906 seg = subseg_new (name, 0);
2912 ++input_line_pointer;
2913 align = get_absolute_expression ();
2914 record_alignment (seg, align);
2918 if (*input_line_pointer == ',')
2920 c = *++input_line_pointer;
2922 if (c == 'C' || c == 'D' || c == 'M' || c == 'R')
2925 as_bad (_("unrecognized section type"));
2926 ++input_line_pointer;
2931 flags = SEC_NO_FLAGS;
2933 flags = SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE;
2934 else if (*type == 'D' || *type == 'M')
2935 flags = SEC_ALLOC | SEC_LOAD | SEC_DATA;
2936 else if (*type == 'R')
2937 flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_READONLY | SEC_ROM;
2938 if (flags != SEC_NO_FLAGS)
2940 if (!bfd_set_section_flags (stdoutput, seg, flags))
2941 as_warn (_("error setting flags for \"%s\": %s"),
2942 bfd_section_name (stdoutput, seg),
2943 bfd_errmsg (bfd_get_error ()));
2948 /* Ignore the HP type. */
2949 if (*input_line_pointer == ',')
2950 input_line_pointer += 2;
2952 demand_empty_rest_of_line ();
2954 #else /* ! TC_M68K */
2963 c = get_symbol_name (& name);
2965 name = xstrdup (name);
2967 c = restore_line_pointer (c);
2969 seg = subseg_new (name, 0);
2977 ++input_line_pointer;
2979 c = get_symbol_name (& sectype);
2980 if (*sectype == '\0')
2982 else if (strcasecmp (sectype, "text") == 0)
2984 else if (strcasecmp (sectype, "data") == 0)
2986 else if (strcasecmp (sectype, "romdata") == 0)
2989 as_warn (_("unrecognized section type `%s'"), sectype);
2990 (void) restore_line_pointer (c);
2993 if (*input_line_pointer == ',')
2997 ++input_line_pointer;
2999 c = get_symbol_name (& seccmd);
3000 if (strcasecmp (seccmd, "absolute") == 0)
3002 as_bad (_("absolute sections are not supported"));
3003 *input_line_pointer = c;
3004 ignore_rest_of_line ();
3007 else if (strcasecmp (seccmd, "align") == 0)
3011 (void) restore_line_pointer (c);
3012 align = get_absolute_expression ();
3013 record_alignment (seg, align);
3017 as_warn (_("unrecognized section command `%s'"), seccmd);
3018 (void) restore_line_pointer (c);
3022 demand_empty_rest_of_line ();
3024 #else /* ! TC_I960 */
3025 /* The MRI assembler seems to use different forms of .sect for
3026 different targets. */
3027 as_bad ("MRI mode not supported for this target");
3028 ignore_rest_of_line ();
3029 #endif /* ! TC_I960 */
3030 #endif /* ! TC_M68K */
3033 /* Handle the .print pseudo-op. */
3036 s_print (int ignore ATTRIBUTE_UNUSED)
3041 s = demand_copy_C_string (&len);
3044 demand_empty_rest_of_line ();
3047 /* Handle the .purgem pseudo-op. */
3050 s_purgem (int ignore ATTRIBUTE_UNUSED)
3052 if (is_it_end_of_statement ())
3054 demand_empty_rest_of_line ();
3064 c = get_symbol_name (& name);
3065 delete_macro (name);
3066 *input_line_pointer = c;
3067 SKIP_WHITESPACE_AFTER_NAME ();
3069 while (*input_line_pointer++ == ',');
3071 --input_line_pointer;
3072 demand_empty_rest_of_line ();
3075 /* Handle the .endm/.endr pseudo-ops. */
3078 s_bad_end (int endr)
3080 as_warn (_(".end%c encountered without preceding %s"),
3082 endr ? ".rept, .irp, or .irpc" : ".macro");
3083 demand_empty_rest_of_line ();
3086 /* Handle the .rept pseudo-op. */
3089 s_rept (int ignore ATTRIBUTE_UNUSED)
3093 count = get_absolute_expression ();
3095 do_repeat (count, "REPT", "ENDR");
3098 /* This function provides a generic repeat block implementation. It allows
3099 different directives to be used as the start/end keys. */
3102 do_repeat (int count, const char *start, const char *end)
3108 if (!buffer_and_nest (start, end, &one, get_non_macro_line_sb))
3110 as_bad (_("%s without %s"), start, end);
3114 sb_build (&many, count * one.len);
3116 sb_add_sb (&many, &one);
3120 input_scrub_include_sb (&many, input_line_pointer, 1);
3122 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
3125 /* Like do_repeat except that any text matching EXPANDER in the
3126 block is replaced by the itteration count. */
3129 do_repeat_with_expander (int count,
3132 const char * expander)
3138 if (!buffer_and_nest (start, end, &one, get_non_macro_line_sb))
3140 as_bad (_("%s without %s"), start, end);
3146 if (expander != NULL && strstr (one.ptr, expander) != NULL)
3148 while (count -- > 0)
3154 sb_build (& processed, one.len);
3155 sb_add_sb (& processed, & one);
3156 sub = strstr (processed.ptr, expander);
3157 len = sprintf (sub, "%d", count);
3158 gas_assert (len < 8);
3159 strcpy (sub + len, sub + 8);
3160 processed.len -= (8 - len);
3161 sb_add_sb (& many, & processed);
3162 sb_kill (& processed);
3167 sb_add_sb (&many, &one);
3171 input_scrub_include_sb (&many, input_line_pointer, 1);
3173 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
3176 /* Skip to end of current repeat loop; EXTRA indicates how many additional
3177 input buffers to skip. Assumes that conditionals preceding the loop end
3178 are properly nested.
3180 This function makes it easier to implement a premature "break" out of the
3181 loop. The EXTRA arg accounts for other buffers we might have inserted,
3182 such as line substitutions. */
3185 end_repeat (int extra)
3187 cond_exit_macro (macro_nest);
3188 while (extra-- >= 0)
3189 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
3193 assign_symbol (char *name, int mode)
3197 if (name[0] == '.' && name[1] == '\0')
3199 /* Turn '. = mumble' into a .org mumble. */
3203 segment = get_known_segmented_expression (&exp);
3206 do_org (segment, &exp, 0);
3211 if ((symbolP = symbol_find (name)) == NULL
3212 && (symbolP = md_undefined_symbol (name)) == NULL)
3214 symbolP = symbol_find_or_make (name);
3216 /* When doing symbol listings, play games with dummy fragments living
3217 outside the normal fragment chain to record the file and line info
3219 if (listing & LISTING_SYMBOLS)
3221 extern struct list_info_struct *listing_tail;
3222 fragS *dummy_frag = (fragS *) xcalloc (1, sizeof (fragS));
3223 dummy_frag->line = listing_tail;
3224 dummy_frag->fr_symbol = symbolP;
3225 symbol_set_frag (symbolP, dummy_frag);
3228 #if defined (OBJ_COFF) && !defined (TE_PE)
3229 /* "set" symbols are local unless otherwise specified. */
3230 SF_SET_LOCAL (symbolP);
3234 if (S_IS_DEFINED (symbolP) || symbol_equated_p (symbolP))
3236 if ((mode != 0 || !S_IS_VOLATILE (symbolP))
3237 && !S_CAN_BE_REDEFINED (symbolP))
3239 as_bad (_("symbol `%s' is already defined"), name);
3240 symbolP = symbol_clone (symbolP, 0);
3242 /* If the symbol is volatile, copy the symbol and replace the
3243 original with the copy, so that previous uses of the symbol will
3244 retain the value of the symbol at the point of use. */
3245 else if (S_IS_VOLATILE (symbolP))
3246 symbolP = symbol_clone (symbolP, 1);
3250 S_SET_VOLATILE (symbolP);
3252 S_SET_FORWARD_REF (symbolP);
3254 pseudo_set (symbolP);
3257 /* Handle the .equ, .equiv, .eqv, and .set directives. If EQUIV is 1,
3258 then this is .equiv, and it is an error if the symbol is already
3259 defined. If EQUIV is -1, the symbol additionally is a forward
3267 /* Especial apologies for the random logic:
3268 this just grew, and could be parsed much more simply!
3270 if ((name = read_symbol_name ()) == NULL)
3273 if (*input_line_pointer != ',')
3275 as_bad (_("expected comma after \"%s\""), name);
3276 ignore_rest_of_line ();
3281 input_line_pointer++;
3282 assign_symbol (name, equiv);
3283 demand_empty_rest_of_line ();
3297 #ifdef md_flush_pending_output
3298 md_flush_pending_output ();
3301 #ifdef md_cons_align
3306 stop = mri_comment_field (&stopc);
3308 /* In m68k MRI mode, we need to align to a word boundary, unless
3310 if (flag_m68k_mri && mult > 1)
3312 if (now_seg == absolute_section)
3314 abs_section_offset += abs_section_offset & 1;
3315 if (line_label != NULL)
3316 S_SET_VALUE (line_label, abs_section_offset);
3318 else if (mri_common_symbol != NULL)
3322 mri_val = S_GET_VALUE (mri_common_symbol);
3323 if ((mri_val & 1) != 0)
3325 S_SET_VALUE (mri_common_symbol, mri_val + 1);
3326 if (line_label != NULL)
3328 expressionS *symexp;
3330 symexp = symbol_get_value_expression (line_label);
3331 know (symexp->X_op == O_symbol);
3332 know (symexp->X_add_symbol == mri_common_symbol);
3333 symexp->X_add_number += 1;
3339 do_align (1, (char *) NULL, 0, 0);
3340 if (line_label != NULL)
3342 symbol_set_frag (line_label, frag_now);
3343 S_SET_VALUE (line_label, frag_now_fix ());
3353 if (*input_line_pointer == ',')
3355 ++input_line_pointer;
3360 val.X_op = O_constant;
3361 val.X_add_number = 0;
3364 if ((val.X_op != O_constant
3365 || val.X_add_number < - 0x80
3366 || val.X_add_number > 0xff
3367 || (mult != 0 && mult != 1 && val.X_add_number != 0))
3368 && (now_seg != absolute_section && !in_bss ()))
3370 resolve_expression (&exp);
3371 if (exp.X_op != O_constant)
3372 as_bad (_("unsupported variable size or fill value"));
3379 bytes = mult * exp.X_add_number;
3380 for (i = 0; i < exp.X_add_number; i++)
3381 emit_expr (&val, mult);
3386 if (now_seg == absolute_section || mri_common_symbol != NULL)
3387 resolve_expression (&exp);
3389 if (exp.X_op == O_constant)
3393 repeat = exp.X_add_number;
3400 as_warn (_(".space repeat count is zero, ignored"));
3401 else if (repeat < 0)
3402 as_warn (_(".space repeat count is negative, ignored"));
3406 /* If we are in the absolute section, just bump the offset. */
3407 if (now_seg == absolute_section)
3409 if (val.X_op != O_constant || val.X_add_number != 0)
3410 as_warn (_("ignoring fill value in absolute section"));
3411 abs_section_offset += repeat;
3415 /* If we are secretly in an MRI common section, then
3416 creating space just increases the size of the common
3418 if (mri_common_symbol != NULL)
3420 S_SET_VALUE (mri_common_symbol,
3421 S_GET_VALUE (mri_common_symbol) + repeat);
3426 p = frag_var (rs_fill, 1, 1, (relax_substateT) 0, (symbolS *) 0,
3427 (offsetT) repeat, (char *) 0);
3431 if (now_seg == absolute_section)
3433 as_bad (_("space allocation too complex in absolute section"));
3434 subseg_set (text_section, 0);
3437 if (mri_common_symbol != NULL)
3439 as_bad (_("space allocation too complex in common section"));
3440 mri_common_symbol = NULL;
3444 p = frag_var (rs_space, 1, 1, (relax_substateT) 0,
3445 make_expr_symbol (&exp), (offsetT) 0, (char *) 0);
3448 if ((val.X_op != O_constant || val.X_add_number != 0) && in_bss ())
3449 as_warn (_("ignoring fill value in section `%s'"),
3450 segment_name (now_seg));
3452 *p = val.X_add_number;
3457 /* In MRI mode, after an odd number of bytes, we must align to an
3458 even word boundary, unless the next instruction is a dc.b, ds.b
3460 if (flag_mri && (bytes & 1) != 0)
3461 mri_pending_align = 1;
3463 demand_empty_rest_of_line ();
3466 mri_comment_end (stop, stopc);
3469 /* This is like s_space, but the value is a floating point number with
3470 the given precision. This is for the MRI dcb.s pseudo-op and
3474 s_float_space (int float_type)
3478 char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT];
3482 #ifdef md_cons_align
3487 stop = mri_comment_field (&stopc);
3489 count = get_absolute_expression ();
3492 if (*input_line_pointer != ',')
3494 as_bad (_("missing value"));
3495 ignore_rest_of_line ();
3497 mri_comment_end (stop, stopc);
3501 ++input_line_pointer;
3505 /* Skip any 0{letter} that may be present. Don't even check if the
3506 * letter is legal. */
3507 if (input_line_pointer[0] == '0'
3508 && ISALPHA (input_line_pointer[1]))
3509 input_line_pointer += 2;
3511 /* Accept :xxxx, where the x's are hex digits, for a floating point
3512 with the exact digits specified. */
3513 if (input_line_pointer[0] == ':')
3515 flen = hex_float (float_type, temp);
3518 ignore_rest_of_line ();
3520 mri_comment_end (stop, stopc);
3528 err = md_atof (float_type, temp, &flen);
3529 know (flen <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
3530 know (err != NULL || flen > 0);
3533 as_bad (_("bad floating literal: %s"), err);
3534 ignore_rest_of_line ();
3536 mri_comment_end (stop, stopc);
3541 while (--count >= 0)
3545 p = frag_more (flen);
3546 memcpy (p, temp, (unsigned int) flen);
3549 demand_empty_rest_of_line ();
3552 mri_comment_end (stop, stopc);
3555 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3558 s_struct (int ignore ATTRIBUTE_UNUSED)
3564 stop = mri_comment_field (&stopc);
3565 abs_section_offset = get_absolute_expression ();
3566 #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
3567 /* The ELF backend needs to know that we are changing sections, so
3568 that .previous works correctly. */
3570 obj_elf_section_change_hook ();
3572 subseg_set (absolute_section, 0);
3573 demand_empty_rest_of_line ();
3575 mri_comment_end (stop, stopc);
3579 s_text (int ignore ATTRIBUTE_UNUSED)
3583 temp = get_absolute_expression ();
3584 subseg_set (text_section, (subsegT) temp);
3585 demand_empty_rest_of_line ();
3588 /* .weakref x, y sets x as an alias to y that, as long as y is not
3589 referenced directly, will cause y to become a weak symbol. */
3591 s_weakref (int ignore ATTRIBUTE_UNUSED)
3598 if ((name = read_symbol_name ()) == NULL)
3601 symbolP = symbol_find_or_make (name);
3603 if (S_IS_DEFINED (symbolP) || symbol_equated_p (symbolP))
3605 if (!S_IS_VOLATILE (symbolP))
3607 as_bad (_("symbol `%s' is already defined"), name);
3610 symbolP = symbol_clone (symbolP, 1);
3611 S_CLEAR_VOLATILE (symbolP);
3616 if (*input_line_pointer != ',')
3618 as_bad (_("expected comma after \"%s\""), name);
3622 input_line_pointer++;
3627 if ((name = read_symbol_name ()) == NULL)
3630 if ((symbolP2 = symbol_find_noref (name, 1)) == NULL
3631 && (symbolP2 = md_undefined_symbol (name)) == NULL)
3633 symbolP2 = symbol_find_or_make (name);
3634 S_SET_WEAKREFD (symbolP2);
3638 symbolS *symp = symbolP2;
3640 while (S_IS_WEAKREFR (symp) && symp != symbolP)
3642 expressionS *expP = symbol_get_value_expression (symp);
3644 gas_assert (expP->X_op == O_symbol
3645 && expP->X_add_number == 0);
3646 symp = expP->X_add_symbol;
3648 if (symp == symbolP)
3652 loop = concat (S_GET_NAME (symbolP),
3653 " => ", S_GET_NAME (symbolP2), (const char *) NULL);
3656 while (symp != symbolP)
3658 char *old_loop = loop;
3660 symp = symbol_get_value_expression (symp)->X_add_symbol;
3661 loop = concat (loop, " => ", S_GET_NAME (symp),
3662 (const char *) NULL);
3666 as_bad (_("%s: would close weakref loop: %s"),
3667 S_GET_NAME (symbolP), loop);
3671 ignore_rest_of_line ();
3675 /* Short-circuiting instead of just checking here might speed
3676 things up a tiny little bit, but loop error messages would
3677 miss intermediate links. */
3678 /* symbolP2 = symp; */
3681 memset (&exp, 0, sizeof (exp));
3682 exp.X_op = O_symbol;
3683 exp.X_add_symbol = symbolP2;
3685 S_SET_SEGMENT (symbolP, undefined_section);
3686 symbol_set_value_expression (symbolP, &exp);
3687 symbol_set_frag (symbolP, &zero_address_frag);
3688 S_SET_WEAKREFR (symbolP);
3690 demand_empty_rest_of_line ();
3695 ignore_rest_of_line ();
3701 /* Verify that we are at the end of a line. If not, issue an error and
3705 demand_empty_rest_of_line (void)
3708 if (is_end_of_line[(unsigned char) *input_line_pointer])
3709 input_line_pointer++;
3712 if (ISPRINT (*input_line_pointer))
3713 as_bad (_("junk at end of line, first unrecognized character is `%c'"),
3714 *input_line_pointer);
3716 as_bad (_("junk at end of line, first unrecognized character valued 0x%x"),
3717 *input_line_pointer);
3718 ignore_rest_of_line ();
3721 /* Return pointing just after end-of-line. */
3722 know (is_end_of_line[(unsigned char) input_line_pointer[-1]]);
3725 /* Silently advance to the end of line. Use this after already having
3726 issued an error about something bad. */
3729 ignore_rest_of_line (void)
3731 while (input_line_pointer < buffer_limit
3732 && !is_end_of_line[(unsigned char) *input_line_pointer])
3733 input_line_pointer++;
3735 input_line_pointer++;
3737 /* Return pointing just after end-of-line. */
3738 know (is_end_of_line[(unsigned char) input_line_pointer[-1]]);
3741 /* Sets frag for given symbol to zero_address_frag, except when the
3742 symbol frag is already set to a dummy listing frag. */
3745 set_zero_frag (symbolS *symbolP)
3747 if (symbol_get_frag (symbolP)->fr_type != rs_dummy)
3748 symbol_set_frag (symbolP, &zero_address_frag);
3751 /* In: Pointer to a symbol.
3752 Input_line_pointer->expression.
3754 Out: Input_line_pointer->just after any whitespace after expression.
3755 Tried to set symbol to value of expression.
3756 Will change symbols type, value, and frag; */
3759 pseudo_set (symbolS *symbolP)
3764 know (symbolP); /* NULL pointer is logic error. */
3766 if (!S_IS_FORWARD_REF (symbolP))
3767 (void) expression (&exp);
3769 (void) deferred_expression (&exp);
3771 if (exp.X_op == O_illegal)
3772 as_bad (_("illegal expression"));
3773 else if (exp.X_op == O_absent)
3774 as_bad (_("missing expression"));
3775 else if (exp.X_op == O_big)
3777 if (exp.X_add_number > 0)
3778 as_bad (_("bignum invalid"));
3780 as_bad (_("floating point number invalid"));
3782 else if (exp.X_op == O_subtract
3783 && !S_IS_FORWARD_REF (symbolP)
3784 && SEG_NORMAL (S_GET_SEGMENT (exp.X_add_symbol))
3785 && (symbol_get_frag (exp.X_add_symbol)
3786 == symbol_get_frag (exp.X_op_symbol)))
3788 exp.X_op = O_constant;
3789 exp.X_add_number = (S_GET_VALUE (exp.X_add_symbol)
3790 - S_GET_VALUE (exp.X_op_symbol));
3793 if (symbol_section_p (symbolP))
3795 as_bad ("attempt to set value of section symbol");
3804 exp.X_add_number = 0;
3807 S_SET_SEGMENT (symbolP, absolute_section);
3808 S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
3809 set_zero_frag (symbolP);
3813 #ifndef TC_GLOBAL_REGISTER_SYMBOL_OK
3814 if (S_IS_EXTERNAL (symbolP))
3816 as_bad ("can't equate global symbol `%s' with register name",
3817 S_GET_NAME (symbolP));
3821 S_SET_SEGMENT (symbolP, reg_section);
3822 S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
3823 set_zero_frag (symbolP);
3824 symbol_get_value_expression (symbolP)->X_op = O_register;
3828 seg = S_GET_SEGMENT (exp.X_add_symbol);
3829 /* For x=undef+const, create an expression symbol.
3830 For x=x+const, just update x except when x is an undefined symbol
3831 For x=defined+const, evaluate x. */
3832 if (symbolP == exp.X_add_symbol
3833 && (seg != undefined_section
3834 || !symbol_constant_p (symbolP)))
3836 *symbol_X_add_number (symbolP) += exp.X_add_number;
3839 else if (!S_IS_FORWARD_REF (symbolP) && seg != undefined_section)
3841 symbolS *s = exp.X_add_symbol;
3843 if (S_IS_COMMON (s))
3844 as_bad (_("`%s' can't be equated to common symbol '%s'"),
3845 S_GET_NAME (symbolP), S_GET_NAME (s));
3847 S_SET_SEGMENT (symbolP, seg);
3848 S_SET_VALUE (symbolP, exp.X_add_number + S_GET_VALUE (s));
3849 symbol_set_frag (symbolP, symbol_get_frag (s));
3850 copy_symbol_attributes (symbolP, s);
3853 S_SET_SEGMENT (symbolP, undefined_section);
3854 symbol_set_value_expression (symbolP, &exp);
3855 copy_symbol_attributes (symbolP, exp.X_add_symbol);
3856 set_zero_frag (symbolP);
3860 /* The value is some complex expression. */
3861 S_SET_SEGMENT (symbolP, expr_section);
3862 symbol_set_value_expression (symbolP, &exp);
3863 set_zero_frag (symbolP);
3870 CONStruct more frag of .bytes, or .words etc.
3871 Should need_pass_2 be 1 then emit no frag(s).
3872 This understands EXPRESSIONS.
3876 This has a split personality. We use expression() to read the
3877 value. We can detect if the value won't fit in a byte or word.
3878 But we can't detect if expression() discarded significant digits
3879 in the case of a long. Not worth the crocks required to fix it. */
3881 /* Select a parser for cons expressions. */
3883 /* Some targets need to parse the expression in various fancy ways.
3884 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3885 (for example, the HPPA does this). Otherwise, you can define
3886 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3887 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3888 are defined, which is the normal case, then only simple expressions
3893 parse_mri_cons (expressionS *exp, unsigned int nbytes);
3896 #ifndef TC_PARSE_CONS_EXPRESSION
3897 #ifdef BITFIELD_CONS_EXPRESSIONS
3898 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) \
3899 (parse_bitfield_cons (EXP, NBYTES), TC_PARSE_CONS_RETURN_NONE)
3901 parse_bitfield_cons (expressionS *exp, unsigned int nbytes);
3903 #ifdef REPEAT_CONS_EXPRESSIONS
3904 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) \
3905 (parse_repeat_cons (EXP, NBYTES), TC_PARSE_CONS_RETURN_NONE)
3907 parse_repeat_cons (expressionS *exp, unsigned int nbytes);
3910 /* If we haven't gotten one yet, just call expression. */
3911 #ifndef TC_PARSE_CONS_EXPRESSION
3912 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) \
3913 (expression (EXP), TC_PARSE_CONS_RETURN_NONE)
3918 do_parse_cons_expression (expressionS *exp,
3919 int nbytes ATTRIBUTE_UNUSED)
3921 (void) TC_PARSE_CONS_EXPRESSION (exp, nbytes);
3925 /* Worker to do .byte etc statements.
3926 Clobbers input_line_pointer and checks end-of-line. */
3929 cons_worker (int nbytes, /* 1=.byte, 2=.word, 4=.long. */
3937 #ifdef md_flush_pending_output
3938 md_flush_pending_output ();
3942 stop = mri_comment_field (&stopc);
3944 if (is_it_end_of_statement ())
3946 demand_empty_rest_of_line ();
3948 mri_comment_end (stop, stopc);
3952 #ifdef TC_ADDRESS_BYTES
3954 nbytes = TC_ADDRESS_BYTES ();
3957 #ifdef md_cons_align
3958 md_cons_align (nbytes);
3964 TC_PARSE_CONS_RETURN_TYPE ret = TC_PARSE_CONS_RETURN_NONE;
3965 #ifdef TC_CONS_FIX_CHECK
3966 fixS **cur_fix = &frchain_now->fix_tail;
3968 if (*cur_fix != NULL)
3969 cur_fix = &(*cur_fix)->fx_next;
3974 parse_mri_cons (&exp, (unsigned int) nbytes);
3979 if (*input_line_pointer == '"')
3981 as_bad (_("unexpected `\"' in expression"));
3982 ignore_rest_of_line ();
3986 ret = TC_PARSE_CONS_EXPRESSION (&exp, (unsigned int) nbytes);
3991 if (exp.X_op == O_symbol)
3992 exp.X_op = O_symbol_rva;
3994 as_fatal (_("rva without symbol"));
3996 emit_expr_with_reloc (&exp, (unsigned int) nbytes, ret);
3997 #ifdef TC_CONS_FIX_CHECK
3998 TC_CONS_FIX_CHECK (&exp, nbytes, *cur_fix);
4002 while (*input_line_pointer++ == ',');
4004 /* In MRI mode, after an odd number of bytes, we must align to an
4005 even word boundary, unless the next instruction is a dc.b, ds.b
4007 if (flag_mri && nbytes == 1 && (c & 1) != 0)
4008 mri_pending_align = 1;
4010 input_line_pointer--; /* Put terminator back into stream. */
4012 demand_empty_rest_of_line ();
4015 mri_comment_end (stop, stopc);
4021 cons_worker (size, 0);
4027 cons_worker (size, 1);
4030 /* .reloc offset, reloc_name, symbol+addend. */
4033 s_reloc (int ignore ATTRIBUTE_UNUSED)
4040 struct reloc_list *reloc;
4041 struct _bfd_rel { char *name; bfd_reloc_code_real_type code; };
4042 static struct _bfd_rel bfd_relocs[] = {
4043 { "NONE", BFD_RELOC_NONE },
4044 { "8", BFD_RELOC_8 },
4045 { "16", BFD_RELOC_16 },
4046 { "32", BFD_RELOC_32 },
4047 { "64", BFD_RELOC_64 }
4050 reloc = (struct reloc_list *) xmalloc (sizeof (*reloc));
4053 stop = mri_comment_field (&stopc);
4062 as_bad (_("missing or bad offset expression"));
4065 exp.X_add_symbol = section_symbol (now_seg);
4066 exp.X_op = O_symbol;
4069 if (exp.X_add_number == 0)
4071 reloc->u.a.offset_sym = exp.X_add_symbol;
4076 reloc->u.a.offset_sym = make_expr_symbol (&exp);
4081 if (*input_line_pointer != ',')
4083 as_bad (_("missing reloc type"));
4087 ++input_line_pointer;
4089 c = get_symbol_name (& r_name);
4090 if (strncasecmp (r_name, "BFD_RELOC_", 10) == 0)
4094 for (reloc->u.a.howto = NULL, i = 0; i < ARRAY_SIZE (bfd_relocs); i++)
4095 if (strcasecmp (r_name + 10, bfd_relocs[i].name) == 0)
4097 reloc->u.a.howto = bfd_reloc_type_lookup (stdoutput,
4098 bfd_relocs[i].code);
4103 reloc->u.a.howto = bfd_reloc_name_lookup (stdoutput, r_name);
4104 *input_line_pointer = c;
4105 if (reloc->u.a.howto == NULL)
4107 as_bad (_("unrecognized reloc type"));
4111 exp.X_op = O_absent;
4112 SKIP_WHITESPACE_AFTER_NAME ();
4113 if (*input_line_pointer == ',')
4115 ++input_line_pointer;
4123 as_bad (_("bad reloc expression"));
4125 ignore_rest_of_line ();
4128 mri_comment_end (stop, stopc);
4131 reloc->u.a.sym = NULL;
4132 reloc->u.a.addend = 0;
4135 reloc->u.a.sym = NULL;
4136 reloc->u.a.addend = exp.X_add_number;
4139 reloc->u.a.sym = exp.X_add_symbol;
4140 reloc->u.a.addend = exp.X_add_number;
4143 reloc->u.a.sym = make_expr_symbol (&exp);
4144 reloc->u.a.addend = 0;
4148 as_where (&reloc->file, &reloc->line);
4149 reloc->next = reloc_list;
4152 demand_empty_rest_of_line ();
4154 mri_comment_end (stop, stopc);
4157 /* Put the contents of expression EXP into the object file using
4158 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
4161 emit_expr (expressionS *exp, unsigned int nbytes)
4163 emit_expr_with_reloc (exp, nbytes, TC_PARSE_CONS_RETURN_NONE);
4167 emit_expr_with_reloc (expressionS *exp,
4168 unsigned int nbytes,
4169 TC_PARSE_CONS_RETURN_TYPE reloc)
4173 valueT extra_digit = 0;
4175 /* Don't do anything if we are going to make another pass. */
4180 dot_value = frag_now_fix ();
4181 dot_frag = frag_now;
4185 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
4186 appear as a four byte positive constant in the .line section,
4187 followed by a 2 byte 0xffff. Look for that case here. */
4189 static int dwarf_line = -1;
4191 if (strcmp (segment_name (now_seg), ".line") != 0)
4193 else if (dwarf_line >= 0
4195 && exp->X_op == O_constant
4196 && (exp->X_add_number == -1 || exp->X_add_number == 0xffff))
4197 listing_source_line ((unsigned int) dwarf_line);
4198 else if (nbytes == 4
4199 && exp->X_op == O_constant
4200 && exp->X_add_number >= 0)
4201 dwarf_line = exp->X_add_number;
4206 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
4207 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
4208 AT_sibling (0x12) followed by a four byte address of the sibling
4209 followed by a 2 byte AT_name (0x38) followed by the name of the
4210 file. We look for that case here. */
4212 static int dwarf_file = 0;
4214 if (strcmp (segment_name (now_seg), ".debug") != 0)
4216 else if (dwarf_file == 0
4218 && exp->X_op == O_constant
4219 && exp->X_add_number == 0x11)
4221 else if (dwarf_file == 1
4223 && exp->X_op == O_constant
4224 && exp->X_add_number == 0x12)
4226 else if (dwarf_file == 2
4229 else if (dwarf_file == 3
4231 && exp->X_op == O_constant
4232 && exp->X_add_number == 0x38)
4237 /* The variable dwarf_file_string tells stringer that the string
4238 may be the name of the source file. */
4239 if (dwarf_file == 4)
4240 dwarf_file_string = 1;
4242 dwarf_file_string = 0;
4247 if (check_eh_frame (exp, &nbytes))
4252 /* Handle a negative bignum. */
4254 && exp->X_add_number == 0
4255 && symbol_get_value_expression (exp->X_add_symbol)->X_op == O_big
4256 && symbol_get_value_expression (exp->X_add_symbol)->X_add_number > 0)
4259 unsigned long carry;
4261 exp = symbol_get_value_expression (exp->X_add_symbol);
4263 /* Negate the bignum: one's complement each digit and add 1. */
4265 for (i = 0; i < exp->X_add_number; i++)
4269 next = (((~(generic_bignum[i] & LITTLENUM_MASK))
4272 generic_bignum[i] = next & LITTLENUM_MASK;
4273 carry = next >> LITTLENUM_NUMBER_OF_BITS;
4276 /* We can ignore any carry out, because it will be handled by
4277 extra_digit if it is needed. */
4279 extra_digit = (valueT) -1;
4283 if (op == O_absent || op == O_illegal)
4285 as_warn (_("zero assumed for missing expression"));
4286 exp->X_add_number = 0;
4289 else if (op == O_big && exp->X_add_number <= 0)
4291 as_bad (_("floating point number invalid"));
4292 exp->X_add_number = 0;
4295 else if (op == O_register)
4297 as_warn (_("register value used as expression"));
4301 /* Allow `.word 0' in the absolute section. */
4302 if (now_seg == absolute_section)
4304 if (op != O_constant || exp->X_add_number != 0)
4305 as_bad (_("attempt to store value in absolute section"));
4306 abs_section_offset += nbytes;
4310 /* Allow `.word 0' in BSS style sections. */
4311 if ((op != O_constant || exp->X_add_number != 0) && in_bss ())
4312 as_bad (_("attempt to store non-zero value in section `%s'"),
4313 segment_name (now_seg));
4315 p = frag_more ((int) nbytes);
4317 if (reloc != TC_PARSE_CONS_RETURN_NONE)
4319 emit_expr_fix (exp, nbytes, frag_now, p, reloc);
4323 #ifndef WORKING_DOT_WORD
4324 /* If we have the difference of two symbols in a word, save it on
4325 the broken_words list. See the code in write.c. */
4326 if (op == O_subtract && nbytes == 2)
4328 struct broken_word *x;
4330 x = (struct broken_word *) xmalloc (sizeof (struct broken_word));
4331 x->next_broken_word = broken_words;
4334 x->subseg = now_subseg;
4336 x->word_goes_here = p;
4338 x->add = exp->X_add_symbol;
4339 x->sub = exp->X_op_symbol;
4340 x->addnum = exp->X_add_number;
4348 /* If we have an integer, but the number of bytes is too large to
4349 pass to md_number_to_chars, handle it as a bignum. */
4350 if (op == O_constant && nbytes > sizeof (valueT))
4352 extra_digit = exp->X_unsigned ? 0 : -1;
4353 convert_to_bignum (exp, !exp->X_unsigned);
4357 if (op == O_constant)
4365 /* JF << of >= number of bits in the object is undefined. In
4366 particular SPARC (Sun 4) has problems. */
4367 if (nbytes >= sizeof (valueT))
4370 if (nbytes > sizeof (valueT))
4373 hibit = (valueT) 1 << (nbytes * BITS_PER_CHAR - 1);
4377 /* Don't store these bits. */
4378 mask = ~(valueT) 0 << (BITS_PER_CHAR * nbytes);
4379 hibit = (valueT) 1 << (nbytes * BITS_PER_CHAR - 1);
4382 unmask = ~mask; /* Do store these bits. */
4385 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
4386 mask = ~(unmask >> 1); /* Includes sign bit now. */
4389 get = exp->X_add_number;
4391 if ((get & mask) != 0
4392 && ((get & mask) != mask
4393 || (get & hibit) == 0))
4394 { /* Leading bits contain both 0s & 1s. */
4395 #if defined (BFD64) && BFD_HOST_64BIT_LONG_LONG
4397 as_warn (_("value 0x%llx truncated to 0x%llx"),
4398 (unsigned long long) get, (unsigned long long) use);
4400 as_warn (_("value 0x%I64x truncated to 0x%I64x"),
4401 (unsigned long long) get, (unsigned long long) use);
4404 as_warn (_("value 0x%lx truncated to 0x%lx"),
4405 (unsigned long) get, (unsigned long) use);
4408 /* Put bytes in right order. */
4409 md_number_to_chars (p, use, (int) nbytes);
4411 else if (op == O_big)
4414 LITTLENUM_TYPE *nums;
4416 size = exp->X_add_number * CHARS_PER_LITTLENUM;
4419 int i = nbytes / CHARS_PER_LITTLENUM;
4422 LITTLENUM_TYPE sign = 0;
4423 if ((generic_bignum[--i]
4424 & (1 << (LITTLENUM_NUMBER_OF_BITS - 1))) != 0)
4425 sign = ~(LITTLENUM_TYPE) 0;
4426 while (++i < exp->X_add_number)
4427 if (generic_bignum[i] != sign)
4430 if (i < exp->X_add_number)
4431 as_warn (_("bignum truncated to %d bytes"), nbytes);
4437 md_number_to_chars (p, (valueT) generic_bignum[0], 1);
4440 know (nbytes % CHARS_PER_LITTLENUM == 0);
4442 if (target_big_endian)
4444 while (nbytes > size)
4446 md_number_to_chars (p, extra_digit, CHARS_PER_LITTLENUM);
4447 nbytes -= CHARS_PER_LITTLENUM;
4448 p += CHARS_PER_LITTLENUM;
4451 nums = generic_bignum + size / CHARS_PER_LITTLENUM;
4452 while (size >= CHARS_PER_LITTLENUM)
4455 md_number_to_chars (p, (valueT) *nums, CHARS_PER_LITTLENUM);
4456 size -= CHARS_PER_LITTLENUM;
4457 p += CHARS_PER_LITTLENUM;
4462 nums = generic_bignum;
4463 while (size >= CHARS_PER_LITTLENUM)
4465 md_number_to_chars (p, (valueT) *nums, CHARS_PER_LITTLENUM);
4467 size -= CHARS_PER_LITTLENUM;
4468 p += CHARS_PER_LITTLENUM;
4469 nbytes -= CHARS_PER_LITTLENUM;
4472 while (nbytes >= CHARS_PER_LITTLENUM)
4474 md_number_to_chars (p, extra_digit, CHARS_PER_LITTLENUM);
4475 nbytes -= CHARS_PER_LITTLENUM;
4476 p += CHARS_PER_LITTLENUM;
4481 emit_expr_fix (exp, nbytes, frag_now, p, TC_PARSE_CONS_RETURN_NONE);
4485 emit_expr_fix (expressionS *exp, unsigned int nbytes, fragS *frag, char *p,
4486 TC_PARSE_CONS_RETURN_TYPE r ATTRIBUTE_UNUSED)
4489 unsigned int size = nbytes;
4491 memset (p, 0, size);
4493 /* Generate a fixS to record the symbol value. */
4495 #ifdef TC_CONS_FIX_NEW
4496 TC_CONS_FIX_NEW (frag, p - frag->fr_literal + offset, size, exp, r);
4498 if (r != TC_PARSE_CONS_RETURN_NONE)
4500 reloc_howto_type *reloc_howto;
4502 reloc_howto = bfd_reloc_type_lookup (stdoutput, r);
4503 size = bfd_get_reloc_size (reloc_howto);
4507 as_bad (_("%s relocations do not fit in %u bytes\n"),
4508 reloc_howto->name, nbytes);
4511 else if (target_big_endian)
4512 offset = nbytes - size;
4533 as_bad (_("unsupported BFD relocation size %u"), size);
4536 fix_new_exp (frag, p - frag->fr_literal + offset, size,
4541 #ifdef BITFIELD_CONS_EXPRESSIONS
4543 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
4544 w:x,y:z, where w and y are bitwidths and x and y are values. They
4545 then pack them all together. We do a little better in that we allow
4546 them in words, longs, etc. and we'll pack them in target byte order
4549 The rules are: pack least significant bit first, if a field doesn't
4550 entirely fit, put it in the next unit. Overflowing the bitfield is
4551 explicitly *not* even a warning. The bitwidth should be considered
4554 To use this function the tc-XXX.h file should define
4555 BITFIELD_CONS_EXPRESSIONS. */
4558 parse_bitfield_cons (exp, nbytes)
4560 unsigned int nbytes;
4562 unsigned int bits_available = BITS_PER_CHAR * nbytes;
4563 char *hold = input_line_pointer;
4565 (void) expression (exp);
4567 if (*input_line_pointer == ':')
4574 unsigned long width;
4576 if (*input_line_pointer != ':')
4578 input_line_pointer = hold;
4580 } /* Next piece is not a bitfield. */
4582 /* In the general case, we can't allow
4583 full expressions with symbol
4584 differences and such. The relocation
4585 entries for symbols not defined in this
4586 assembly would require arbitrary field
4587 widths, positions, and masks which most
4588 of our current object formats don't
4591 In the specific case where a symbol
4592 *is* defined in this assembly, we
4593 *could* build fixups and track it, but
4594 this could lead to confusion for the
4595 backends. I'm lazy. I'll take any
4596 SEG_ABSOLUTE. I think that means that
4597 you can use a previous .set or
4598 .equ type symbol. xoxorich. */
4600 if (exp->X_op == O_absent)
4602 as_warn (_("using a bit field width of zero"));
4603 exp->X_add_number = 0;
4604 exp->X_op = O_constant;
4605 } /* Implied zero width bitfield. */
4607 if (exp->X_op != O_constant)
4609 *input_line_pointer = '\0';
4610 as_bad (_("field width \"%s\" too complex for a bitfield"), hold);
4611 *input_line_pointer = ':';
4612 demand_empty_rest_of_line ();
4614 } /* Too complex. */
4616 if ((width = exp->X_add_number) > (BITS_PER_CHAR * nbytes))
4618 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
4619 width, nbytes, (BITS_PER_CHAR * nbytes));
4620 width = BITS_PER_CHAR * nbytes;
4623 if (width > bits_available)
4625 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
4626 input_line_pointer = hold;
4627 exp->X_add_number = value;
4632 hold = ++input_line_pointer;
4634 (void) expression (exp);
4635 if (exp->X_op != O_constant)
4637 char cache = *input_line_pointer;
4639 *input_line_pointer = '\0';
4640 as_bad (_("field value \"%s\" too complex for a bitfield"), hold);
4641 *input_line_pointer = cache;
4642 demand_empty_rest_of_line ();
4644 } /* Too complex. */
4646 value |= ((~(-(1 << width)) & exp->X_add_number)
4647 << ((BITS_PER_CHAR * nbytes) - bits_available));
4649 if ((bits_available -= width) == 0
4650 || is_it_end_of_statement ()
4651 || *input_line_pointer != ',')
4654 } /* All the bitfields we're gonna get. */
4656 hold = ++input_line_pointer;
4657 (void) expression (exp);
4660 exp->X_add_number = value;
4661 exp->X_op = O_constant;
4662 exp->X_unsigned = 1;
4663 exp->X_extrabit = 0;
4667 #endif /* BITFIELD_CONS_EXPRESSIONS */
4669 /* Handle an MRI style string expression. */
4673 parse_mri_cons (expressionS *exp, unsigned int nbytes)
4675 if (*input_line_pointer != '\''
4676 && (input_line_pointer[1] != '\''
4677 || (*input_line_pointer != 'A'
4678 && *input_line_pointer != 'E')))
4679 (void) TC_PARSE_CONS_EXPRESSION (exp, nbytes);
4683 unsigned int result = 0;
4685 /* An MRI style string. Cut into as many bytes as will fit into
4686 a nbyte chunk, left justify if necessary, and separate with
4687 commas so we can try again later. */
4688 if (*input_line_pointer == 'A')
4689 ++input_line_pointer;
4690 else if (*input_line_pointer == 'E')
4692 as_bad (_("EBCDIC constants are not supported"));
4693 ++input_line_pointer;
4696 input_line_pointer++;
4697 for (scan = 0; scan < nbytes; scan++)
4699 if (*input_line_pointer == '\'')
4701 if (input_line_pointer[1] == '\'')
4703 input_line_pointer++;
4708 result = (result << 8) | (*input_line_pointer++);
4712 while (scan < nbytes)
4718 /* Create correct expression. */
4719 exp->X_op = O_constant;
4720 exp->X_add_number = result;
4722 /* Fake it so that we can read the next char too. */
4723 if (input_line_pointer[0] != '\'' ||
4724 (input_line_pointer[0] == '\'' && input_line_pointer[1] == '\''))
4726 input_line_pointer -= 2;
4727 input_line_pointer[0] = ',';
4728 input_line_pointer[1] = '\'';
4731 input_line_pointer++;
4734 #endif /* TC_M68K */
4736 #ifdef REPEAT_CONS_EXPRESSIONS
4738 /* Parse a repeat expression for cons. This is used by the MIPS
4739 assembler. The format is NUMBER:COUNT; NUMBER appears in the
4740 object file COUNT times.
4742 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
4745 parse_repeat_cons (exp, nbytes)
4747 unsigned int nbytes;
4754 if (*input_line_pointer != ':')
4756 /* No repeat count. */
4760 ++input_line_pointer;
4761 expression (&count);
4762 if (count.X_op != O_constant
4763 || count.X_add_number <= 0)
4765 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4769 /* The cons function is going to output this expression once. So we
4770 output it count - 1 times. */
4771 for (i = count.X_add_number - 1; i > 0; i--)
4772 emit_expr (exp, nbytes);
4775 #endif /* REPEAT_CONS_EXPRESSIONS */
4777 /* Parse a floating point number represented as a hex constant. This
4778 permits users to specify the exact bits they want in the floating
4782 hex_float (int float_type, char *bytes)
4814 as_bad (_("unknown floating type type '%c'"), float_type);
4818 /* It would be nice if we could go through expression to parse the
4819 hex constant, but if we get a bignum it's a pain to sort it into
4820 the buffer correctly. */
4822 while (hex_p (*input_line_pointer) || *input_line_pointer == '_')
4826 /* The MRI assembler accepts arbitrary underscores strewn about
4827 through the hex constant, so we ignore them as well. */
4828 if (*input_line_pointer == '_')
4830 ++input_line_pointer;
4836 as_warn (_("floating point constant too large"));
4839 d = hex_value (*input_line_pointer) << 4;
4840 ++input_line_pointer;
4841 while (*input_line_pointer == '_')
4842 ++input_line_pointer;
4843 if (hex_p (*input_line_pointer))
4845 d += hex_value (*input_line_pointer);
4846 ++input_line_pointer;
4848 if (target_big_endian)
4851 bytes[length - i - 1] = d;
4857 if (target_big_endian)
4858 memset (bytes + i, 0, length - i);
4860 memset (bytes, 0, length - i);
4868 CONStruct some more frag chars of .floats .ffloats etc.
4869 Makes 0 or more new frags.
4870 If need_pass_2 == 1, no frags are emitted.
4871 This understands only floating literals, not expressions. Sorry.
4873 A floating constant is defined by atof_generic(), except it is preceded
4874 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4875 reading, I decided to be incompatible. This always tries to give you
4876 rounded bits to the precision of the pseudo-op. Former AS did premature
4877 truncation, restored noisy bits instead of trailing 0s AND gave you
4878 a choice of 2 flavours of noise according to which of 2 floating-point
4879 scanners you directed AS to use.
4881 In: input_line_pointer->whitespace before, or '0' of flonum. */
4884 float_cons (/* Clobbers input_line-pointer, checks end-of-line. */
4885 int float_type /* 'f':.ffloat ... 'F':.float ... */)
4888 int length; /* Number of chars in an object. */
4889 char *err; /* Error from scanning floating literal. */
4890 char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT];
4892 if (is_it_end_of_statement ())
4894 demand_empty_rest_of_line ();
4898 if (now_seg == absolute_section)
4900 as_bad (_("attempt to store float in absolute section"));
4901 ignore_rest_of_line ();
4907 as_bad (_("attempt to store float in section `%s'"),
4908 segment_name (now_seg));
4909 ignore_rest_of_line ();
4913 #ifdef md_flush_pending_output
4914 md_flush_pending_output ();
4917 #ifdef md_cons_align
4923 /* input_line_pointer->1st char of a flonum (we hope!). */
4926 /* Skip any 0{letter} that may be present. Don't even check if the
4927 letter is legal. Someone may invent a "z" format and this routine
4928 has no use for such information. Lusers beware: you get
4929 diagnostics if your input is ill-conditioned. */
4930 if (input_line_pointer[0] == '0'
4931 && ISALPHA (input_line_pointer[1]))
4932 input_line_pointer += 2;
4934 /* Accept :xxxx, where the x's are hex digits, for a floating
4935 point with the exact digits specified. */
4936 if (input_line_pointer[0] == ':')
4938 ++input_line_pointer;
4939 length = hex_float (float_type, temp);
4942 ignore_rest_of_line ();
4948 err = md_atof (float_type, temp, &length);
4949 know (length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
4950 know (err != NULL || length > 0);
4953 as_bad (_("bad floating literal: %s"), err);
4954 ignore_rest_of_line ();
4965 #ifdef REPEAT_CONS_EXPRESSIONS
4966 if (*input_line_pointer == ':')
4968 expressionS count_exp;
4970 ++input_line_pointer;
4971 expression (&count_exp);
4973 if (count_exp.X_op != O_constant
4974 || count_exp.X_add_number <= 0)
4975 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4977 count = count_exp.X_add_number;
4981 while (--count >= 0)
4983 p = frag_more (length);
4984 memcpy (p, temp, (unsigned int) length);
4989 while (*input_line_pointer++ == ',');
4991 /* Put terminator back into stream. */
4992 --input_line_pointer;
4993 demand_empty_rest_of_line ();
4996 /* Return the size of a LEB128 value. */
4999 sizeof_sleb128 (offsetT value)
5006 byte = (value & 0x7f);
5007 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
5008 Fortunately, we can structure things so that the extra work reduces
5009 to a noop on systems that do things "properly". */
5010 value = (value >> 7) | ~(-(offsetT)1 >> 7);
5013 while (!(((value == 0) && ((byte & 0x40) == 0))
5014 || ((value == -1) && ((byte & 0x40) != 0))));
5020 sizeof_uleb128 (valueT value)
5035 sizeof_leb128 (valueT value, int sign)
5038 return sizeof_sleb128 ((offsetT) value);
5040 return sizeof_uleb128 (value);
5043 /* Output a LEB128 value. */
5046 output_sleb128 (char *p, offsetT value)
5053 unsigned byte = (value & 0x7f);
5055 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
5056 Fortunately, we can structure things so that the extra work reduces
5057 to a noop on systems that do things "properly". */
5058 value = (value >> 7) | ~(-(offsetT)1 >> 7);
5060 more = !((((value == 0) && ((byte & 0x40) == 0))
5061 || ((value == -1) && ((byte & 0x40) != 0))));
5073 output_uleb128 (char *p, valueT value)
5079 unsigned byte = (value & 0x7f);
5082 /* More bytes to follow. */
5093 output_leb128 (char *p, valueT value, int sign)
5096 return output_sleb128 (p, (offsetT) value);
5098 return output_uleb128 (p, value);
5101 /* Do the same for bignums. We combine sizeof with output here in that
5102 we don't output for NULL values of P. It isn't really as critical as
5103 for "normal" values that this be streamlined. */
5106 output_big_sleb128 (char *p, LITTLENUM_TYPE *bignum, int size)
5113 /* Strip leading sign extensions off the bignum. */
5115 && bignum[size - 1] == LITTLENUM_MASK
5116 && bignum[size - 2] > LITTLENUM_MASK / 2)
5121 /* OR in the next part of the littlenum. */
5122 val |= (*bignum << loaded);
5123 loaded += LITTLENUM_NUMBER_OF_BITS;
5127 /* Add bytes until there are less than 7 bits left in VAL
5128 or until every non-sign bit has been written. */
5135 || val != ((byte & 0x40) == 0 ? 0 : ((valueT) 1 << loaded) - 1))
5142 while ((byte & 0x80) != 0 && loaded >= 7);
5146 /* Mop up any left-over bits (of which there will be less than 7). */
5147 if ((byte & 0x80) != 0)
5149 /* Sign-extend VAL. */
5150 if (val & (1 << (loaded - 1)))
5151 val |= ~0U << loaded;
5161 output_big_uleb128 (char *p, LITTLENUM_TYPE *bignum, int size)
5168 /* Strip leading zeros off the bignum. */
5169 /* XXX: Is this needed? */
5170 while (size > 0 && bignum[size - 1] == 0)
5175 if (loaded < 7 && size > 0)
5177 val |= (*bignum << loaded);
5178 loaded += 8 * CHARS_PER_LITTLENUM;
5187 if (size > 0 || val)
5194 while (byte & 0x80);
5200 output_big_leb128 (char *p, LITTLENUM_TYPE *bignum, int size, int sign)
5203 return output_big_sleb128 (p, bignum, size);
5205 return output_big_uleb128 (p, bignum, size);
5208 /* Generate the appropriate fragments for a given expression to emit a
5209 leb128 value. SIGN is 1 for sleb, 0 for uleb. */
5212 emit_leb128_expr (expressionS *exp, int sign)
5214 operatorT op = exp->X_op;
5215 unsigned int nbytes;
5217 if (op == O_absent || op == O_illegal)
5219 as_warn (_("zero assumed for missing expression"));
5220 exp->X_add_number = 0;
5223 else if (op == O_big && exp->X_add_number <= 0)
5225 as_bad (_("floating point number invalid"));
5226 exp->X_add_number = 0;
5229 else if (op == O_register)
5231 as_warn (_("register value used as expression"));
5234 else if (op == O_constant
5236 && (exp->X_add_number < 0) == !exp->X_extrabit)
5238 /* We're outputting a signed leb128 and the sign of X_add_number
5239 doesn't reflect the sign of the original value. Convert EXP
5240 to a correctly-extended bignum instead. */
5241 convert_to_bignum (exp, exp->X_extrabit);
5245 if (now_seg == absolute_section)
5247 if (op != O_constant || exp->X_add_number != 0)
5248 as_bad (_("attempt to store value in absolute section"));
5249 abs_section_offset++;
5253 if ((op != O_constant || exp->X_add_number != 0) && in_bss ())
5254 as_bad (_("attempt to store non-zero value in section `%s'"),
5255 segment_name (now_seg));
5257 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
5258 a signal that this is leb128 data. It shouldn't optimize this away. */
5259 nbytes = (unsigned int) -1;
5260 if (check_eh_frame (exp, &nbytes))
5263 /* Let the backend know that subsequent data may be byte aligned. */
5264 #ifdef md_cons_align
5268 if (op == O_constant)
5270 /* If we've got a constant, emit the thing directly right now. */
5272 valueT value = exp->X_add_number;
5276 size = sizeof_leb128 (value, sign);
5277 p = frag_more (size);
5278 output_leb128 (p, value, sign);
5280 else if (op == O_big)
5282 /* O_big is a different sort of constant. */
5287 size = output_big_leb128 (NULL, generic_bignum, exp->X_add_number, sign);
5288 p = frag_more (size);
5289 output_big_leb128 (p, generic_bignum, exp->X_add_number, sign);
5293 /* Otherwise, we have to create a variable sized fragment and
5294 resolve things later. */
5296 frag_var (rs_leb128, sizeof_uleb128 (~(valueT) 0), 0, sign,
5297 make_expr_symbol (exp), 0, (char *) NULL);
5301 /* Parse the .sleb128 and .uleb128 pseudos. */
5308 #ifdef md_flush_pending_output
5309 md_flush_pending_output ();
5315 emit_leb128_expr (&exp, sign);
5317 while (*input_line_pointer++ == ',');
5319 input_line_pointer--;
5320 demand_empty_rest_of_line ();
5324 stringer_append_char (int c, int bitsize)
5327 as_bad (_("attempt to store non-empty string in section `%s'"),
5328 segment_name (now_seg));
5330 if (!target_big_endian)
5331 FRAG_APPEND_1_CHAR (c);
5336 FRAG_APPEND_1_CHAR (0);
5337 FRAG_APPEND_1_CHAR (0);
5338 FRAG_APPEND_1_CHAR (0);
5339 FRAG_APPEND_1_CHAR (0);
5342 FRAG_APPEND_1_CHAR (0);
5343 FRAG_APPEND_1_CHAR (0);
5346 FRAG_APPEND_1_CHAR (0);
5351 /* Called with invalid bitsize argument. */
5355 if (target_big_endian)
5356 FRAG_APPEND_1_CHAR (c);
5359 /* Worker to do .ascii etc statements.
5360 Reads 0 or more ',' separated, double-quoted strings.
5361 Caller should have checked need_pass_2 is FALSE because we don't
5363 Checks for end-of-line.
5364 BITS_APPENDZERO says how many bits are in a target char.
5365 The bottom bit is set if a NUL char should be appended to the strings. */
5368 stringer (int bits_appendzero)
5370 const int bitsize = bits_appendzero & ~7;
5371 const int append_zero = bits_appendzero & 1;
5373 #if !defined(NO_LISTING) && defined (OBJ_ELF)
5377 #ifdef md_flush_pending_output
5378 md_flush_pending_output ();
5381 #ifdef md_cons_align
5385 /* If we have been switched into the abs_section then we
5386 will not have an obstack onto which we can hang strings. */
5387 if (now_seg == absolute_section)
5389 as_bad (_("strings must be placed into a section"));
5390 ignore_rest_of_line ();
5394 /* The following awkward logic is to parse ZERO or more strings,
5395 comma separated. Recall a string expression includes spaces
5396 before the opening '\"' and spaces after the closing '\"'.
5397 We fake a leading ',' if there is (supposed to be)
5398 a 1st, expression. We keep demanding expressions for each ','. */
5399 if (is_it_end_of_statement ())
5401 c = 0; /* Skip loop. */
5402 ++input_line_pointer; /* Compensate for end of loop. */
5406 c = ','; /* Do loop. */
5409 while (c == ',' || c == '<' || c == '"')
5412 switch (*input_line_pointer)
5415 ++input_line_pointer; /*->1st char of string. */
5416 #if !defined(NO_LISTING) && defined (OBJ_ELF)
5417 start = input_line_pointer;
5420 while (is_a_char (c = next_char_of_string ()))
5421 stringer_append_char (c, bitsize);
5424 stringer_append_char (0, bitsize);
5426 know (input_line_pointer[-1] == '\"');
5428 #if !defined(NO_LISTING) && defined (OBJ_ELF)
5429 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
5430 will emit .string with a filename in the .debug section
5431 after a sequence of constants. See the comment in
5432 emit_expr for the sequence. emit_expr will set
5433 dwarf_file_string to non-zero if this string might be a
5434 source file name. */
5435 if (strcmp (segment_name (now_seg), ".debug") != 0)
5436 dwarf_file_string = 0;
5437 else if (dwarf_file_string)
5439 c = input_line_pointer[-1];
5440 input_line_pointer[-1] = '\0';
5441 listing_source_file (start);
5442 input_line_pointer[-1] = c;
5448 input_line_pointer++;
5449 c = get_single_number ();
5450 stringer_append_char (c, bitsize);
5451 if (*input_line_pointer != '>')
5452 as_bad (_("expected <nn>"));
5454 input_line_pointer++;
5457 input_line_pointer++;
5461 c = *input_line_pointer;
5464 demand_empty_rest_of_line ();
5467 /* FIXME-SOMEDAY: I had trouble here on characters with the
5468 high bits set. We'll probably also have trouble with
5469 multibyte chars, wide chars, etc. Also be careful about
5470 returning values bigger than 1 byte. xoxorich. */
5473 next_char_of_string (void)
5477 c = *input_line_pointer++ & CHAR_MASK;
5485 as_warn (_("unterminated string; newline inserted"));
5486 bump_line_counters ();
5489 #ifndef NO_STRING_ESCAPES
5491 switch (c = *input_line_pointer++ & CHAR_MASK)
5519 break; /* As itself. */
5535 for (i = 0, number = 0;
5536 ISDIGIT (c) && i < 3;
5537 c = *input_line_pointer++, i++)
5539 number = number * 8 + c - '0';
5542 c = number & CHAR_MASK;
5544 --input_line_pointer;
5553 c = *input_line_pointer++;
5554 while (ISXDIGIT (c))
5557 number = number * 16 + c - '0';
5558 else if (ISUPPER (c))
5559 number = number * 16 + c - 'A' + 10;
5561 number = number * 16 + c - 'a' + 10;
5562 c = *input_line_pointer++;
5564 c = number & CHAR_MASK;
5565 --input_line_pointer;
5570 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
5571 as_warn (_("unterminated string; newline inserted"));
5573 bump_line_counters ();
5578 #ifdef ONLY_STANDARD_ESCAPES
5579 as_bad (_("bad escaped character in string"));
5581 #endif /* ONLY_STANDARD_ESCAPES */
5586 #endif /* ! defined (NO_STRING_ESCAPES) */
5595 get_segmented_expression (expressionS *expP)
5599 retval = expression (expP);
5600 if (expP->X_op == O_illegal
5601 || expP->X_op == O_absent
5602 || expP->X_op == O_big)
5604 as_bad (_("expected address expression"));
5605 expP->X_op = O_constant;
5606 expP->X_add_number = 0;
5607 retval = absolute_section;
5613 get_known_segmented_expression (expressionS *expP)
5615 segT retval = get_segmented_expression (expP);
5617 if (retval == undefined_section)
5619 /* There is no easy way to extract the undefined symbol from the
5621 if (expP->X_add_symbol != NULL
5622 && S_GET_SEGMENT (expP->X_add_symbol) != expr_section)
5623 as_warn (_("symbol \"%s\" undefined; zero assumed"),
5624 S_GET_NAME (expP->X_add_symbol));
5626 as_warn (_("some symbol undefined; zero assumed"));
5627 retval = absolute_section;
5628 expP->X_op = O_constant;
5629 expP->X_add_number = 0;
5634 char /* Return terminator. */
5635 get_absolute_expression_and_terminator (long *val_pointer /* Return value of expression. */)
5637 /* FIXME: val_pointer should probably be offsetT *. */
5638 *val_pointer = (long) get_absolute_expression ();
5639 return (*input_line_pointer++);
5642 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
5643 Give a warning if that happens. */
5646 demand_copy_C_string (int *len_pointer)
5650 if ((s = demand_copy_string (len_pointer)) != 0)
5654 for (len = *len_pointer; len > 0; len--)
5661 as_bad (_("this string may not contain \'\\0\'"));
5669 /* Demand string, but return a safe (=private) copy of the string.
5670 Return NULL if we can't read a string here. */
5673 demand_copy_string (int *lenP)
5681 if (*input_line_pointer == '\"')
5683 input_line_pointer++; /* Skip opening quote. */
5685 while (is_a_char (c = next_char_of_string ()))
5687 obstack_1grow (¬es, c);
5690 /* JF this next line is so demand_copy_C_string will return a
5691 null terminated string. */
5692 obstack_1grow (¬es, '\0');
5693 retval = (char *) obstack_finish (¬es);
5697 as_bad (_("missing string"));
5699 ignore_rest_of_line ();
5705 /* In: Input_line_pointer->next character.
5707 Do: Skip input_line_pointer over all whitespace.
5709 Out: 1 if input_line_pointer->end-of-line. */
5712 is_it_end_of_statement (void)
5715 return (is_end_of_line[(unsigned char) *input_line_pointer]);
5719 equals (char *sym_name, int reassign)
5724 input_line_pointer++;
5725 if (*input_line_pointer == '=')
5726 input_line_pointer++;
5727 if (reassign < 0 && *input_line_pointer == '=')
5728 input_line_pointer++;
5730 while (*input_line_pointer == ' ' || *input_line_pointer == '\t')
5731 input_line_pointer++;
5734 stop = mri_comment_field (&stopc);
5736 assign_symbol (sym_name, reassign >= 0 ? !reassign : reassign);
5740 demand_empty_rest_of_line ();
5741 mri_comment_end (stop, stopc);
5745 /* .incbin -- include a file verbatim at the current location. */
5748 s_incbin (int x ATTRIBUTE_UNUSED)
5759 #ifdef md_flush_pending_output
5760 md_flush_pending_output ();
5763 #ifdef md_cons_align
5768 filename = demand_copy_string (& len);
5769 if (filename == NULL)
5774 /* Look for optional skip and count. */
5775 if (* input_line_pointer == ',')
5777 ++ input_line_pointer;
5778 skip = get_absolute_expression ();
5782 if (* input_line_pointer == ',')
5784 ++ input_line_pointer;
5786 count = get_absolute_expression ();
5788 as_warn (_(".incbin count zero, ignoring `%s'"), filename);
5794 demand_empty_rest_of_line ();
5796 /* Try opening absolute path first, then try include dirs. */
5797 binfile = fopen (filename, FOPEN_RB);
5798 if (binfile == NULL)
5802 path = (char *) xmalloc ((unsigned long) len + include_dir_maxlen + 5);
5804 for (i = 0; i < include_dir_count; i++)
5806 sprintf (path, "%s/%s", include_dirs[i], filename);
5808 binfile = fopen (path, FOPEN_RB);
5809 if (binfile != NULL)
5813 if (binfile == NULL)
5814 as_bad (_("file not found: %s"), filename);
5817 path = xstrdup (filename);
5823 register_dependency (path);
5825 /* Compute the length of the file. */
5826 if (fseek (binfile, 0, SEEK_END) != 0)
5828 as_bad (_("seek to end of .incbin file failed `%s'"), path);
5831 file_len = ftell (binfile);
5833 /* If a count was not specified use the remainder of the file. */
5835 count = file_len - skip;
5837 if (skip < 0 || count < 0 || file_len < 0 || skip + count > file_len)
5839 as_bad (_("skip (%ld) or count (%ld) invalid for file size (%ld)"),
5840 skip, count, file_len);
5844 if (fseek (binfile, skip, SEEK_SET) != 0)
5846 as_bad (_("could not skip to %ld in file `%s'"), skip, path);
5850 /* Allocate frag space and store file contents in it. */
5851 binfrag = frag_more (count);
5853 bytes = fread (binfrag, 1, count, binfile);
5855 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
5856 path, bytes, count);
5859 if (binfile != NULL)
5865 /* .include -- include a file at this point. */
5868 s_include (int arg ATTRIBUTE_UNUSED)
5877 filename = demand_copy_string (&i);
5878 if (filename == NULL)
5880 /* demand_copy_string has already printed an error and
5881 called ignore_rest_of_line. */
5889 while (!is_end_of_line[(unsigned char) *input_line_pointer]
5890 && *input_line_pointer != ' '
5891 && *input_line_pointer != '\t')
5893 obstack_1grow (¬es, *input_line_pointer);
5894 ++input_line_pointer;
5898 obstack_1grow (¬es, '\0');
5899 filename = (char *) obstack_finish (¬es);
5900 while (!is_end_of_line[(unsigned char) *input_line_pointer])
5901 ++input_line_pointer;
5904 demand_empty_rest_of_line ();
5905 path = (char *) xmalloc ((unsigned long) i
5906 + include_dir_maxlen + 5 /* slop */ );
5908 for (i = 0; i < include_dir_count; i++)
5910 strcpy (path, include_dirs[i]);
5912 strcat (path, filename);
5913 if (0 != (try_file = fopen (path, FOPEN_RT)))
5923 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
5924 register_dependency (path);
5925 input_scrub_insert_file (path);
5929 add_include_dir (char *path)
5933 if (include_dir_count == 0)
5935 include_dirs = (char **) xmalloc (2 * sizeof (*include_dirs));
5936 include_dirs[0] = "."; /* Current dir. */
5937 include_dir_count = 2;
5941 include_dir_count++;
5943 (char **) xrealloc (include_dirs,
5944 include_dir_count * sizeof (*include_dirs));
5947 include_dirs[include_dir_count - 1] = path; /* New one. */
5950 if (i > include_dir_maxlen)
5951 include_dir_maxlen = i;
5954 /* Output debugging information to denote the source file. */
5957 generate_file_debug (void)
5959 if (debug_type == DEBUG_STABS)
5960 stabs_generate_asm_file ();
5963 /* Output line number debugging information for the current source line. */
5966 generate_lineno_debug (void)
5970 case DEBUG_UNSPECIFIED:
5975 stabs_generate_asm_lineno ();
5978 ecoff_generate_asm_lineno ();
5981 /* ??? We could here indicate to dwarf2dbg.c that something
5982 has changed. However, since there is additional backend
5983 support that is required (calling dwarf2_emit_insn), we
5984 let dwarf2dbg.c call as_where on its own. */
5989 /* Output debugging information to mark a function entry point or end point.
5990 END_P is zero for .func, and non-zero for .endfunc. */
5995 do_s_func (end_p, NULL);
5998 /* Subroutine of s_func so targets can choose a different default prefix.
5999 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
6002 do_s_func (int end_p, const char *default_prefix)
6004 /* Record the current function so that we can issue an error message for
6005 misplaced .func,.endfunc, and also so that .endfunc needs no
6007 static char *current_name;
6008 static char *current_label;
6012 if (current_name == NULL)
6014 as_bad (_("missing .func"));
6015 ignore_rest_of_line ();
6019 if (debug_type == DEBUG_STABS)
6020 stabs_generate_asm_endfunc (current_name, current_label);
6022 current_name = current_label = NULL;
6027 char delim1, delim2;
6029 if (current_name != NULL)
6031 as_bad (_(".endfunc missing for previous .func"));
6032 ignore_rest_of_line ();
6036 delim1 = get_symbol_name (& name);
6037 name = xstrdup (name);
6038 *input_line_pointer = delim1;
6039 SKIP_WHITESPACE_AFTER_NAME ();
6040 if (*input_line_pointer != ',')
6044 if (asprintf (&label, "%s%s", default_prefix, name) == -1)
6045 as_fatal ("%s", xstrerror (errno));
6049 char leading_char = bfd_get_symbol_leading_char (stdoutput);
6050 /* Missing entry point, use function's name with the leading
6054 if (asprintf (&label, "%c%s", leading_char, name) == -1)
6055 as_fatal ("%s", xstrerror (errno));
6063 ++input_line_pointer;
6065 delim2 = get_symbol_name (& label);
6066 label = xstrdup (label);
6067 restore_line_pointer (delim2);
6070 if (debug_type == DEBUG_STABS)
6071 stabs_generate_asm_func (name, label);
6073 current_name = name;
6074 current_label = label;
6077 demand_empty_rest_of_line ();
6080 #ifdef HANDLE_BUNDLE
6083 s_bundle_align_mode (int arg ATTRIBUTE_UNUSED)
6085 unsigned int align = get_absolute_expression ();
6087 demand_empty_rest_of_line ();
6089 if (align > (unsigned int) TC_ALIGN_LIMIT)
6090 as_fatal (_(".bundle_align_mode alignment too large (maximum %u)"),
6091 (unsigned int) TC_ALIGN_LIMIT);
6093 if (bundle_lock_frag != NULL)
6095 as_bad (_("cannot change .bundle_align_mode inside .bundle_lock"));
6099 bundle_align_p2 = align;
6103 s_bundle_lock (int arg ATTRIBUTE_UNUSED)
6105 demand_empty_rest_of_line ();
6107 if (bundle_align_p2 == 0)
6109 as_bad (_(".bundle_lock is meaningless without .bundle_align_mode"));
6113 if (bundle_lock_depth == 0)
6115 bundle_lock_frchain = frchain_now;
6116 bundle_lock_frag = start_bundle ();
6118 ++bundle_lock_depth;
6122 s_bundle_unlock (int arg ATTRIBUTE_UNUSED)
6126 demand_empty_rest_of_line ();
6128 if (bundle_lock_frag == NULL)
6130 as_bad (_(".bundle_unlock without preceding .bundle_lock"));
6134 gas_assert (bundle_align_p2 > 0);
6136 gas_assert (bundle_lock_depth > 0);
6137 if (--bundle_lock_depth > 0)
6140 size = pending_bundle_size (bundle_lock_frag);
6142 if (size > (1U << bundle_align_p2))
6143 as_bad (_(".bundle_lock sequence is %u bytes, but bundle size only %u"),
6144 size, 1 << bundle_align_p2);
6146 finish_bundle (bundle_lock_frag, size);
6148 bundle_lock_frag = NULL;
6149 bundle_lock_frchain = NULL;
6152 #endif /* HANDLE_BUNDLE */
6155 s_ignore (int arg ATTRIBUTE_UNUSED)
6157 ignore_rest_of_line ();
6161 read_print_statistics (FILE *file)
6163 hash_print_statistics (file, "pseudo-op table", po_hash);
6166 /* Inserts the given line into the input stream.
6168 This call avoids macro/conditionals nesting checking, since the contents of
6169 the line are assumed to replace the contents of a line already scanned.
6171 An appropriate use of this function would be substitution of input lines when
6172 called by md_start_line_hook(). The given line is assumed to already be
6173 properly scrubbed. */
6176 input_scrub_insert_line (const char *line)
6179 size_t len = strlen (line);
6180 sb_build (&newline, len);
6181 sb_add_buffer (&newline, line, len);
6182 input_scrub_include_sb (&newline, input_line_pointer, 0);
6184 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
6187 /* Insert a file into the input stream; the path must resolve to an actual
6188 file; no include path searching or dependency registering is performed. */
6191 input_scrub_insert_file (char *path)
6193 input_scrub_include_file (path, input_line_pointer);
6194 buffer_limit = input_scrub_next_buffer (&input_line_pointer);
6197 /* Find the end of a line, considering quotation and escaping of quotes. */
6199 #if !defined(TC_SINGLE_QUOTE_STRINGS) && defined(SINGLE_QUOTE_STRINGS)
6200 # define TC_SINGLE_QUOTE_STRINGS 1
6204 _find_end_of_line (char *s, int mri_string, int insn ATTRIBUTE_UNUSED,
6207 char inquote = '\0';
6210 while (!is_end_of_line[(unsigned char) *s]
6211 || (inquote && !ISCNTRL (*s))
6212 || (inquote == '\'' && flag_mri)
6213 #ifdef TC_EOL_IN_INSN
6214 || (insn && TC_EOL_IN_INSN (s))
6216 /* PR 6926: When we are parsing the body of a macro the sequence
6217 \@ is special - it refers to the invocation count. If the @
6218 character happens to be registered as a line-separator character
6219 by the target, then the is_end_of_line[] test above will have
6220 returned true, but we need to ignore the line separating
6221 semantics in this particular case. */
6222 || (in_macro && inescape && *s == '@')
6225 if (mri_string && *s == '\'')
6229 else if (*s == '\\')
6233 #ifdef TC_SINGLE_QUOTE_STRINGS
6234 || (TC_SINGLE_QUOTE_STRINGS && *s == '\'')
6241 as_warn (_("missing closing `%c'"), inquote);
6242 if (inescape && !ignore_input ())
6243 as_warn (_("stray `\\'"));
6248 find_end_of_line (char *s, int mri_string)
6250 return _find_end_of_line (s, mri_string, 0, 0);