1 /* read.c - read a source file -
2 Copyright 1986-2013 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(x,y,z) (x == ':')
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 /* Use machine dependent syntax. */
267 for (p
= line_separator_chars
; *p
; p
++)
268 is_end_of_line
[(unsigned char) *p
] = 2;
269 /* Use more. FIXME-SOMEDAY. */
275 #ifndef TC_ADDRESS_BYTES
276 #define TC_ADDRESS_BYTES address_bytes
281 /* Choose smallest of 1, 2, 4, 8 bytes that is large enough to
282 contain an address. */
283 int n
= (stdoutput
->arch_info
->bits_per_address
- 1) / 8;
291 /* Set up pseudo-op tables. */
293 static struct hash_control
*po_hash
;
295 static const pseudo_typeS potable
[] = {
296 {"abort", s_abort
, 0},
297 {"align", s_align_ptwo
, 0},
298 {"altmacro", s_altmacro
, 1},
299 {"ascii", stringer
, 8+0},
300 {"asciz", stringer
, 8+1},
301 {"balign", s_align_bytes
, 0},
302 {"balignw", s_align_bytes
, -2},
303 {"balignl", s_align_bytes
, -4},
306 {"bundle_align_mode", s_bundle_align_mode
, 0},
307 {"bundle_lock", s_bundle_lock
, 0},
308 {"bundle_unlock", s_bundle_unlock
, 0},
312 {"common", s_mri_common
, 0},
313 {"common.s", s_mri_common
, 1},
316 #ifdef TC_ADDRESS_BYTES
320 {"dc.d", float_cons
, 'd'},
322 {"dc.s", float_cons
, 'f'},
324 {"dc.x", float_cons
, 'x'},
326 {"dcb.b", s_space
, 1},
327 {"dcb.d", s_float_space
, 'd'},
328 {"dcb.l", s_space
, 4},
329 {"dcb.s", s_float_space
, 'f'},
330 {"dcb.w", s_space
, 2},
331 {"dcb.x", s_float_space
, 'x'},
333 {"ds.b", s_space
, 1},
334 {"ds.d", s_space
, 8},
335 {"ds.l", s_space
, 4},
336 {"ds.p", s_space
, 12},
337 {"ds.s", s_space
, 4},
338 {"ds.w", s_space
, 2},
339 {"ds.x", s_space
, 12},
340 {"debug", s_ignore
, 0},
345 {"double", float_cons
, 'd'},
347 {"eject", listing_eject
, 0}, /* Formfeed listing. */
349 {"elsec", s_else
, 0},
350 {"elseif", s_elseif
, (int) O_ne
},
352 {"endc", s_endif
, 0},
353 {"endfunc", s_func
, 1},
354 {"endif", s_endif
, 0},
355 {"endm", s_bad_end
, 0},
356 {"endr", s_bad_end
, 1},
362 {"error", s_errwarn
, 1},
363 {"exitm", s_mexit
, 0},
365 {"extern", s_ignore
, 0}, /* We treat all undef as ext. */
366 {"appfile", s_app_file
, 1},
367 {"appline", s_app_line
, 1},
369 {"file", s_app_file
, 0},
371 {"float", float_cons
, 'f'},
372 {"format", s_ignore
, 0},
374 {"global", s_globl
, 0},
375 {"globl", s_globl
, 0},
377 {"if", s_if
, (int) O_ne
},
380 {"ifdef", s_ifdef
, 0},
381 {"ifeq", s_if
, (int) O_eq
},
382 {"ifeqs", s_ifeqs
, 0},
383 {"ifge", s_if
, (int) O_ge
},
384 {"ifgt", s_if
, (int) O_gt
},
385 {"ifle", s_if
, (int) O_le
},
386 {"iflt", s_if
, (int) O_lt
},
389 {"ifndef", s_ifdef
, 1},
390 {"ifne", s_if
, (int) O_ne
},
391 {"ifnes", s_ifeqs
, 1},
392 {"ifnotdef", s_ifdef
, 1},
393 {"incbin", s_incbin
, 0},
394 {"include", s_include
, 0},
400 {"lcomm", s_lcomm
, 0},
401 {"lflags", s_ignore
, 0}, /* Listing flags. */
402 {"linefile", s_app_line
, 0},
403 {"linkonce", s_linkonce
, 0},
404 {"list", listing_list
, 1}, /* Turn listing on. */
405 {"llen", listing_psize
, 1},
408 {"macro", s_macro
, 0},
409 {"mexit", s_mexit
, 0},
411 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
412 {"name", s_ignore
, 0},
413 {"noaltmacro", s_altmacro
, 0},
414 {"noformat", s_ignore
, 0},
415 {"nolist", listing_list
, 0}, /* Turn listing off. */
416 {"nopage", listing_nopage
, 0},
418 {"offset", s_struct
, 0},
420 {"p2align", s_align_ptwo
, 0},
421 {"p2alignw", s_align_ptwo
, -2},
422 {"p2alignl", s_align_ptwo
, -4},
423 {"page", listing_eject
, 0},
424 {"plen", listing_psize
, 0},
425 {"print", s_print
, 0},
426 {"psize", listing_psize
, 0}, /* Set paper size. */
427 {"purgem", s_purgem
, 0},
429 {"reloc", s_reloc
, 0},
433 {"sbttl", listing_title
, 1}, /* Subtitle of listing. */
438 {"single", float_cons
, 'f'},
440 {"space", s_space
, 0},
441 {"skip", s_space
, 0},
442 {"sleb128", s_leb128
, 1},
443 {"spc", s_ignore
, 0},
444 {"stabd", s_stab
, 'd'},
445 {"stabn", s_stab
, 'n'},
446 {"stabs", s_stab
, 's'},
447 {"string", stringer
, 8+1},
448 {"string8", stringer
, 8+1},
449 {"string16", stringer
, 16+1},
450 {"string32", stringer
, 32+1},
451 {"string64", stringer
, 64+1},
452 {"struct", s_struct
, 0},
456 /* This is for gcc to use. It's only just been added (2/94), so gcc
457 won't be able to use it for a while -- probably a year or more.
458 But once this has been released, check with gcc maintainers
459 before deleting it or even changing the spelling. */
460 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
461 /* If we're folding case -- done for some targets, not necessarily
462 all -- the above string in an input file will be converted to
463 this one. Match it either way... */
464 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
466 {"title", listing_title
, 0}, /* Listing title. */
467 {"ttl", listing_title
, 0},
469 {"uleb128", s_leb128
, 0},
473 {"xdef", s_globl
, 0},
474 {"xref", s_ignore
, 0},
475 {"xstabs", s_xstab
, 's'},
476 {"warning", s_errwarn
, 0},
477 {"weakref", s_weakref
, 0},
479 {"zero", s_space
, 0},
480 {NULL
, NULL
, 0} /* End sentinel. */
484 get_absolute_expr (expressionS
*exp
)
486 expression_and_evaluate (exp
);
487 if (exp
->X_op
!= O_constant
)
489 if (exp
->X_op
!= O_absent
)
490 as_bad (_("bad or irreducible absolute expression"));
491 exp
->X_add_number
= 0;
493 return exp
->X_add_number
;
497 get_absolute_expression (void)
501 return get_absolute_expr (&exp
);
504 static int pop_override_ok
= 0;
505 static const char *pop_table_name
;
508 pop_insert (const pseudo_typeS
*table
)
511 const pseudo_typeS
*pop
;
512 for (pop
= table
; pop
->poc_name
; pop
++)
514 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
515 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
516 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name
,
521 #ifndef md_pop_insert
522 #define md_pop_insert() pop_insert(md_pseudo_table)
525 #ifndef obj_pop_insert
526 #define obj_pop_insert() pop_insert(obj_pseudo_table)
529 #ifndef cfi_pop_insert
530 #define cfi_pop_insert() pop_insert(cfi_pseudo_table)
536 po_hash
= hash_new ();
538 /* Do the target-specific pseudo ops. */
539 pop_table_name
= "md";
542 /* Now object specific. Skip any that were in the target table. */
543 pop_table_name
= "obj";
547 /* Now portable ones. Skip any that we've seen already. */
548 pop_table_name
= "standard";
549 pop_insert (potable
);
552 pop_table_name
= "cfi";
557 #define HANDLE_CONDITIONAL_ASSEMBLY() \
558 if (ignore_input ()) \
560 char *eol = find_end_of_line (input_line_pointer, flag_m68k_mri); \
561 input_line_pointer = (input_line_pointer <= buffer_limit \
562 && eol >= buffer_limit) \
568 /* This function is used when scrubbing the characters between #APP
571 static char *scrub_string
;
572 static char *scrub_string_end
;
575 scrub_from_string (char *buf
, size_t buflen
)
579 copy
= scrub_string_end
- scrub_string
;
582 memcpy (buf
, scrub_string
, copy
);
583 scrub_string
+= copy
;
587 /* Helper function of read_a_source_file, which tries to expand a macro. */
589 try_macro (char term
, const char *line
)
595 if (check_macro (line
, &out
, &err
, ¯o
))
599 *input_line_pointer
++ = term
;
600 input_scrub_include_sb (&out
,
601 input_line_pointer
, 1);
604 input_scrub_next_buffer (&input_line_pointer
);
606 md_macro_info (macro
);
614 /* Start a new instruction bundle. Returns the rs_align_code frag that
615 will be used to align the new bundle. */
619 fragS
*frag
= frag_now
;
621 frag_align_code (0, 0);
623 while (frag
->fr_type
!= rs_align_code
)
624 frag
= frag
->fr_next
;
626 gas_assert (frag
!= frag_now
);
631 /* Calculate the maximum size after relaxation of the region starting
632 at the given frag and extending through frag_now (which is unfinished). */
634 pending_bundle_size (fragS
*frag
)
636 unsigned int offset
= frag
->fr_fix
;
637 unsigned int size
= 0;
639 gas_assert (frag
!= frag_now
);
640 gas_assert (frag
->fr_type
== rs_align_code
);
642 while (frag
!= frag_now
)
644 /* This should only happen in what will later become an error case. */
648 size
+= frag
->fr_fix
;
649 if (frag
->fr_type
== rs_machine_dependent
)
650 size
+= md_frag_max_var (frag
);
652 frag
= frag
->fr_next
;
655 gas_assert (frag
== frag_now
);
656 size
+= frag_now_fix ();
657 if (frag
->fr_type
== rs_machine_dependent
)
658 size
+= md_frag_max_var (frag
);
660 gas_assert (size
>= offset
);
662 return size
- offset
;
665 /* Finish off the frag created to ensure bundle alignment. */
667 finish_bundle (fragS
*frag
, unsigned int size
)
669 gas_assert (bundle_align_p2
> 0);
670 gas_assert (frag
->fr_type
== rs_align_code
);
674 /* If there is more than a single byte, then we need to set up the
675 alignment frag. Otherwise we leave it at its initial state from
676 calling frag_align_code (0, 0), so that it does nothing. */
677 frag
->fr_offset
= bundle_align_p2
;
678 frag
->fr_subtype
= size
- 1;
681 /* We do this every time rather than just in s_bundle_align_mode
682 so that we catch any affected section without needing hooks all
683 over for all paths that do section changes. It's cheap enough. */
684 record_alignment (now_seg
, bundle_align_p2
- OCTETS_PER_BYTE_POWER
);
687 /* Assemble one instruction. This takes care of the bundle features
688 around calling md_assemble. */
690 assemble_one (char *line
)
692 fragS
*insn_start_frag
= NULL
;
694 if (bundle_lock_frchain
!= NULL
&& bundle_lock_frchain
!= frchain_now
)
696 as_bad (_("cannot change section or subsection inside .bundle_lock"));
697 /* Clearing this serves as a marker that we have already complained. */
698 bundle_lock_frchain
= NULL
;
701 if (bundle_lock_frchain
== NULL
&& bundle_align_p2
> 0)
702 insn_start_frag
= start_bundle ();
706 if (bundle_lock_frchain
!= NULL
)
708 /* Make sure this hasn't pushed the locked sequence
709 past the bundle size. */
710 unsigned int bundle_size
= pending_bundle_size (bundle_lock_frag
);
711 if (bundle_size
> (1U << bundle_align_p2
))
713 .bundle_lock sequence at %u bytes but .bundle_align_mode limit is %u bytes"),
714 bundle_size
, 1U << bundle_align_p2
);
716 else if (bundle_align_p2
> 0)
718 unsigned int insn_size
= pending_bundle_size (insn_start_frag
);
720 if (insn_size
> (1U << bundle_align_p2
))
722 single instruction is %u bytes long but .bundle_align_mode limit is %u"),
723 (unsigned int) insn_size
, 1U << bundle_align_p2
);
725 finish_bundle (insn_start_frag
, insn_size
);
729 #else /* !HANDLE_BUNDLE */
731 # define assemble_one(line) md_assemble(line)
733 #endif /* HANDLE_BUNDLE */
735 /* We read the file, putting things into a web that represents what we
736 have been reading. */
738 read_a_source_file (char *name
)
741 char *s
; /* String of symbol, '\0' appended. */
749 buffer
= input_scrub_new_file (name
);
752 listing_newline (NULL
);
753 register_dependency (name
);
755 /* Generate debugging information before we've read anything in to denote
756 this file as the "main" source file and not a subordinate one
757 (e.g. N_SO vs N_SOL in stabs). */
758 generate_file_debug ();
760 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
761 { /* We have another line to parse. */
763 /* In order to avoid listing macro expansion lines with labels
764 multiple times, keep track of which line was last issued. */
765 static char *last_eol
;
769 while (input_line_pointer
< buffer_limit
)
771 bfd_boolean was_new_line
;
772 /* We have more of this buffer to parse. */
774 /* We now have input_line_pointer->1st char of next line.
775 If input_line_pointer [-1] == '\n' then we just
776 scanned another line: so bump line counters. */
777 was_new_line
= is_end_of_line
[(unsigned char) input_line_pointer
[-1]];
780 symbol_set_value_now (&dot_symbol
);
781 #ifdef md_start_line_hook
782 md_start_line_hook ();
784 if (input_line_pointer
[-1] == '\n')
785 bump_line_counters ();
789 /* If listing is on, and we are expanding a macro, then give
790 the listing code the contents of the expanded line. */
793 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
795 /* Find the end of the current expanded macro line. */
796 s
= find_end_of_line (input_line_pointer
, flag_m68k_mri
);
804 /* Copy it for safe keeping. Also give an indication of
805 how much macro nesting is involved at this point. */
806 len
= s
- input_line_pointer
;
807 copy
= (char *) xmalloc (len
+ macro_nest
+ 2);
808 memset (copy
, '>', macro_nest
);
809 copy
[macro_nest
] = ' ';
810 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
, len
);
811 copy
[macro_nest
+ 1 + len
] = '\0';
813 /* Install the line with the listing facility. */
814 listing_newline (copy
);
818 listing_newline (NULL
);
825 if (LABELS_WITHOUT_COLONS
|| flag_m68k_mri
)
827 /* Text at the start of a line must be a label, we
828 run down and stick a colon in. */
829 if (is_name_beginner (*input_line_pointer
))
831 char *line_start
= input_line_pointer
;
834 HANDLE_CONDITIONAL_ASSEMBLY ();
836 c
= get_symbol_end ();
838 /* In MRI mode, the EQU and MACRO pseudoops must
839 be handled specially. */
843 char *rest
= input_line_pointer
+ 1;
847 if (*rest
== ' ' || *rest
== '\t')
849 if ((strncasecmp (rest
, "EQU", 3) == 0
850 || strncasecmp (rest
, "SET", 3) == 0)
851 && (rest
[3] == ' ' || rest
[3] == '\t'))
853 input_line_pointer
= rest
+ 3;
855 strncasecmp (rest
, "SET", 3) == 0);
858 if (strncasecmp (rest
, "MACRO", 5) == 0
861 || is_end_of_line
[(unsigned char) rest
[5]]))
865 /* In MRI mode, we need to handle the MACRO
866 pseudo-op specially: we don't want to put the
867 symbol in the symbol table. */
869 #ifdef TC_START_LABEL_WITHOUT_COLON
870 && TC_START_LABEL_WITHOUT_COLON(c
,
874 line_label
= colon (line_start
);
876 line_label
= symbol_create (line_start
,
881 *input_line_pointer
= c
;
883 input_line_pointer
++;
888 /* We are at the beginning of a line, or similar place.
889 We expect a well-formed assembler statement.
890 A "symbol-name:" is a statement.
892 Depending on what compiler is used, the order of these tests
893 may vary to catch most common case 1st.
894 Each test is independent of all other tests at the (top)
897 c
= *input_line_pointer
++;
898 while (c
== '\t' || c
== ' ' || c
== '\f');
900 /* C is the 1st significant character.
901 Input_line_pointer points after that character. */
902 if (is_name_beginner (c
))
904 /* Want user-defined label or pseudo/opcode. */
905 HANDLE_CONDITIONAL_ASSEMBLY ();
907 s
= --input_line_pointer
;
908 c
= get_symbol_end (); /* name's delimiter. */
910 /* C is character after symbol.
911 That character's place in the input line is now '\0'.
912 S points to the beginning of the symbol.
913 [In case of pseudo-op, s->'.'.]
914 Input_line_pointer->'\0' where c was. */
915 if (TC_START_LABEL (c
, s
, input_line_pointer
))
919 char *rest
= input_line_pointer
+ 1;
921 /* In MRI mode, \tsym: set 0 is permitted. */
925 if (*rest
== ' ' || *rest
== '\t')
928 if ((strncasecmp (rest
, "EQU", 3) == 0
929 || strncasecmp (rest
, "SET", 3) == 0)
930 && (rest
[3] == ' ' || rest
[3] == '\t'))
932 input_line_pointer
= rest
+ 3;
938 line_label
= colon (s
); /* User-defined label. */
939 /* Put ':' back for error messages' sake. */
940 *input_line_pointer
++ = ':';
941 #ifdef tc_check_label
942 tc_check_label (line_label
);
944 /* Input_line_pointer->after ':'. */
947 else if ((c
== '=' && input_line_pointer
[1] == '=')
948 || ((c
== ' ' || c
== '\t')
949 && input_line_pointer
[1] == '='
950 && input_line_pointer
[2] == '='))
953 demand_empty_rest_of_line ();
956 || ((c
== ' ' || c
== '\t')
957 && input_line_pointer
[1] == '='))
958 #ifdef TC_EQUAL_IN_INSN
959 && !TC_EQUAL_IN_INSN (c
, s
)
964 demand_empty_rest_of_line ();
968 /* Expect pseudo-op or machine instruction. */
971 #ifndef TC_CASE_SENSITIVE
975 strncpy (original_case_string
, s2
, sizeof (original_case_string
));
976 original_case_string
[sizeof (original_case_string
) - 1] = 0;
985 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
987 /* The MRI assembler uses pseudo-ops without
989 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
990 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
995 || (!flag_m68k_mri
&& *s
== '.'))
999 WARNING: c has next char, which may be end-of-line.
1000 We lookup the pseudo-op table with s+1 because we
1001 already know that the pseudo-op begins with a '.'. */
1004 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
1005 if (pop
&& !pop
->poc_handler
)
1008 /* In MRI mode, we may need to insert an
1009 automatic alignment directive. What a hack
1011 if (mri_pending_align
1013 || !((pop
->poc_handler
== cons
1014 && pop
->poc_val
== 1)
1015 || (pop
->poc_handler
== s_space
1016 && pop
->poc_val
== 1)
1017 #ifdef tc_conditional_pseudoop
1018 || tc_conditional_pseudoop (pop
)
1020 || pop
->poc_handler
== s_if
1021 || pop
->poc_handler
== s_ifdef
1022 || pop
->poc_handler
== s_ifc
1023 || pop
->poc_handler
== s_ifeqs
1024 || pop
->poc_handler
== s_else
1025 || pop
->poc_handler
== s_endif
1026 || pop
->poc_handler
== s_globl
1027 || pop
->poc_handler
== s_ignore
)))
1029 do_align (1, (char *) NULL
, 0, 0);
1030 mri_pending_align
= 0;
1032 if (line_label
!= NULL
)
1034 symbol_set_frag (line_label
, frag_now
);
1035 S_SET_VALUE (line_label
, frag_now_fix ());
1039 /* Print the error msg now, while we still can. */
1042 char *end
= input_line_pointer
;
1044 *input_line_pointer
= c
;
1046 c
= *--input_line_pointer
;
1047 *input_line_pointer
= '\0';
1048 if (! macro_defined
|| ! try_macro (c
, s
))
1051 as_bad (_("unknown pseudo-op: `%s'"), s
);
1052 *input_line_pointer
++ = c
;
1057 /* Put it back for error messages etc. */
1058 *input_line_pointer
= c
;
1059 /* The following skip of whitespace is compulsory.
1060 A well shaped space is sometimes all that separates
1061 keyword from operands. */
1062 if (c
== ' ' || c
== '\t')
1063 input_line_pointer
++;
1065 /* Input_line is restored.
1066 Input_line_pointer->1st non-blank char
1067 after pseudo-operation. */
1068 (*pop
->poc_handler
) (pop
->poc_val
);
1070 /* If that was .end, just get out now. */
1071 if (pop
->poc_handler
== s_end
)
1076 /* WARNING: c has char, which may be end-of-line. */
1077 /* Also: input_line_pointer->`\0` where c was. */
1078 *input_line_pointer
= c
;
1079 input_line_pointer
= _find_end_of_line (input_line_pointer
, flag_m68k_mri
, 1, 0);
1080 c
= *input_line_pointer
;
1081 *input_line_pointer
= '\0';
1083 generate_lineno_debug ();
1085 if (macro_defined
&& try_macro (c
, s
))
1088 if (mri_pending_align
)
1090 do_align (1, (char *) NULL
, 0, 0);
1091 mri_pending_align
= 0;
1092 if (line_label
!= NULL
)
1094 symbol_set_frag (line_label
, frag_now
);
1095 S_SET_VALUE (line_label
, frag_now_fix ());
1099 assemble_one (s
); /* Assemble 1 instruction. */
1101 *input_line_pointer
++ = c
;
1103 /* We resume loop AFTER the end-of-line from
1104 this instruction. */
1110 /* Empty statement? */
1111 if (is_end_of_line
[(unsigned char) c
])
1114 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
) && ISDIGIT (c
))
1116 /* local label ("4:") */
1117 char *backup
= input_line_pointer
;
1119 HANDLE_CONDITIONAL_ASSEMBLY ();
1123 /* Read the whole number. */
1124 while (ISDIGIT (*input_line_pointer
))
1126 temp
= (temp
* 10) + *input_line_pointer
- '0';
1127 ++input_line_pointer
;
1130 if (LOCAL_LABELS_DOLLAR
1131 && *input_line_pointer
== '$'
1132 && *(input_line_pointer
+ 1) == ':')
1134 input_line_pointer
+= 2;
1136 if (dollar_label_defined (temp
))
1138 as_fatal (_("label \"%d$\" redefined"), temp
);
1141 define_dollar_label (temp
);
1142 colon (dollar_label_name (temp
, 0));
1147 && *input_line_pointer
++ == ':')
1149 fb_label_instance_inc (temp
);
1150 colon (fb_label_name (temp
, 0));
1154 input_line_pointer
= backup
;
1155 } /* local label ("4:") */
1157 if (c
&& strchr (line_comment_chars
, c
))
1158 { /* Its a comment. Better say APP or NO_APP. */
1163 unsigned int new_length
;
1166 s
= input_line_pointer
;
1167 if (strncmp (s
, "APP\n", 4))
1170 ignore_rest_of_line ();
1173 bump_line_counters ();
1176 ends
= strstr (s
, "#NO_APP\n");
1180 unsigned int tmp_len
;
1183 /* The end of the #APP wasn't in this buffer. We
1184 keep reading in buffers until we find the #NO_APP
1185 that goes with this #APP There is one. The specs
1187 tmp_len
= buffer_limit
- s
;
1188 tmp_buf
= (char *) xmalloc (tmp_len
+ 1);
1189 memcpy (tmp_buf
, s
, tmp_len
);
1192 new_tmp
= input_scrub_next_buffer (&buffer
);
1196 buffer_limit
= new_tmp
;
1197 input_line_pointer
= buffer
;
1198 ends
= strstr (buffer
, "#NO_APP\n");
1200 num
= ends
- buffer
;
1202 num
= buffer_limit
- buffer
;
1204 tmp_buf
= (char *) xrealloc (tmp_buf
, tmp_len
+ num
);
1205 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
1210 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1218 input_line_pointer
= ends
+ 8;
1222 scrub_string_end
= ends
;
1224 new_length
= ends
- s
;
1225 new_buf
= (char *) xmalloc (new_length
);
1232 space
= (new_buf
+ new_length
) - new_tmp
;
1233 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
1241 new_buf
= (char *) xrealloc (new_buf
, new_length
+ 100);
1242 new_tmp
= new_buf
+ new_length
;
1249 /* We've "scrubbed" input to the preferred format. In the
1250 process we may have consumed the whole of the remaining
1251 file (and included files). We handle this formatted
1252 input similar to that of macro expansion, letting
1253 actual macro expansion (possibly nested) and other
1254 input expansion work. Beware that in messages, line
1255 numbers and possibly file names will be incorrect. */
1256 new_length
= strlen (new_buf
);
1257 sb_build (&sbuf
, new_length
);
1258 sb_add_buffer (&sbuf
, new_buf
, new_length
);
1259 input_scrub_include_sb (&sbuf
, input_line_pointer
, 0);
1261 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1266 HANDLE_CONDITIONAL_ASSEMBLY ();
1268 #ifdef tc_unrecognized_line
1269 if (tc_unrecognized_line (c
))
1272 input_line_pointer
--;
1273 /* Report unknown char as error. */
1274 demand_empty_rest_of_line ();
1279 symbol_set_value_now (&dot_symbol
);
1281 #ifdef HANDLE_BUNDLE
1282 if (bundle_lock_frag
!= NULL
)
1284 as_bad_where (bundle_lock_frag
->fr_file
, bundle_lock_frag
->fr_line
,
1285 _(".bundle_lock with no matching .bundle_unlock"));
1286 bundle_lock_frag
= NULL
;
1287 bundle_lock_frchain
= NULL
;
1288 bundle_lock_depth
= 0;
1295 /* Close the input file. */
1296 input_scrub_close ();
1297 #ifdef WARN_COMMENTS
1299 if (warn_comment
&& found_comment
)
1300 as_warn_where (found_comment_file
, found_comment
,
1301 "first comment found here");
1306 /* Convert O_constant expression EXP into the equivalent O_big representation.
1307 Take the sign of the number from SIGN rather than X_add_number. */
1310 convert_to_bignum (expressionS
*exp
, int sign
)
1315 value
= exp
->X_add_number
;
1316 for (i
= 0; i
< sizeof (exp
->X_add_number
) / CHARS_PER_LITTLENUM
; i
++)
1318 generic_bignum
[i
] = value
& LITTLENUM_MASK
;
1319 value
>>= LITTLENUM_NUMBER_OF_BITS
;
1321 /* Add a sequence of sign bits if the top bit of X_add_number is not
1322 the sign of the original value. */
1323 if ((exp
->X_add_number
< 0) == !sign
)
1324 generic_bignum
[i
++] = sign
? LITTLENUM_MASK
: 0;
1326 exp
->X_add_number
= i
;
1329 /* For most MRI pseudo-ops, the line actually ends at the first
1330 nonquoted space. This function looks for that point, stuffs a null
1331 in, and sets *STOPCP to the character that used to be there, and
1332 returns the location.
1334 Until I hear otherwise, I am going to assume that this is only true
1335 for the m68k MRI assembler. */
1338 mri_comment_field (char *stopcp
)
1344 know (flag_m68k_mri
);
1346 for (s
= input_line_pointer
;
1347 ((!is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1355 for (s
= input_line_pointer
;
1356 !is_end_of_line
[(unsigned char) *s
];
1366 /* Skip to the end of an MRI comment field. */
1369 mri_comment_end (char *stop
, int stopc
)
1373 input_line_pointer
= stop
;
1375 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1376 ++input_line_pointer
;
1380 s_abort (int ignore ATTRIBUTE_UNUSED
)
1382 as_fatal (_(".abort detected. Abandoning ship."));
1385 /* Guts of .align directive. N is the power of two to which to align.
1386 FILL may be NULL, or it may point to the bytes of the fill pattern.
1387 LEN is the length of whatever FILL points to, if anything. MAX is
1388 the maximum number of characters to skip when doing the alignment,
1389 or 0 if there is no maximum. */
1392 do_align (int n
, char *fill
, int len
, int max
)
1394 if (now_seg
== absolute_section
)
1398 if (*fill
++ != '\0')
1400 as_warn (_("ignoring fill value in absolute section"));
1407 #ifdef md_flush_pending_output
1408 md_flush_pending_output ();
1411 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1414 /* Only make a frag if we HAVE to... */
1415 if (n
!= 0 && !need_pass_2
)
1419 if (subseg_text_p (now_seg
))
1420 frag_align_code (n
, max
);
1422 frag_align (n
, 0, max
);
1425 frag_align (n
, *fill
, max
);
1427 frag_align_pattern (n
, fill
, len
, max
);
1431 just_record_alignment
: ATTRIBUTE_UNUSED_LABEL
1434 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
1437 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1438 (in bytes). A negative ARG is the negative of the length of the
1439 fill pattern. BYTES_P is non-zero if the alignment value should be
1440 interpreted as the byte boundary, rather than the power of 2. */
1441 #ifndef TC_ALIGN_LIMIT
1442 #define TC_ALIGN_LIMIT (stdoutput->arch_info->bits_per_address - 1)
1446 s_align (int arg
, int bytes_p
)
1448 unsigned int align_limit
= TC_ALIGN_LIMIT
;
1457 stop
= mri_comment_field (&stopc
);
1459 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1464 align
= arg
; /* Default value from pseudo-op table. */
1468 align
= get_absolute_expression ();
1474 /* Convert to a power of 2. */
1479 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1482 as_bad (_("alignment not a power of 2"));
1488 if (align
> align_limit
)
1490 align
= align_limit
;
1491 as_warn (_("alignment too large: %u assumed"), align
);
1494 if (*input_line_pointer
!= ',')
1501 ++input_line_pointer
;
1502 if (*input_line_pointer
== ',')
1506 fill
= get_absolute_expression ();
1511 if (*input_line_pointer
!= ',')
1515 ++input_line_pointer
;
1516 max
= get_absolute_expression ();
1523 as_warn (_("expected fill pattern missing"));
1524 do_align (align
, (char *) NULL
, 0, max
);
1539 do_align (align
, &fill_char
, fill_len
, max
);
1545 if ((size_t) fill_len
> sizeof ab
)
1547 md_number_to_chars (ab
, fill
, fill_len
);
1548 do_align (align
, ab
, fill_len
, max
);
1552 demand_empty_rest_of_line ();
1555 mri_comment_end (stop
, stopc
);
1558 /* Handle the .align pseudo-op on machines where ".align 4" means
1559 align to a 4 byte boundary. */
1562 s_align_bytes (int arg
)
1567 /* Handle the .align pseudo-op on machines where ".align 4" means align
1568 to a 2**4 boundary. */
1571 s_align_ptwo (int arg
)
1576 /* Switch in and out of alternate macro mode. */
1581 demand_empty_rest_of_line ();
1582 macro_set_alternate (on
);
1585 /* Read a symbol name from input_line_pointer.
1587 Stores the symbol name in a buffer and returns a pointer to this buffer.
1588 The buffer is xalloc'ed. It is the caller's responsibility to free
1591 The name is not left in the i_l_p buffer as it may need processing
1592 to handle escape characters.
1594 Advances i_l_p to the next non-whitespace character.
1596 If a symbol name could not be read, the routine issues an error
1597 messages, skips to the end of the line and returns NULL. */
1600 read_symbol_name (void)
1606 c
= *input_line_pointer
++;
1610 #define SYM_NAME_CHUNK_LEN 128
1611 ptrdiff_t len
= SYM_NAME_CHUNK_LEN
;
1615 start
= name
= xmalloc (len
+ 1);
1617 name_end
= name
+ SYM_NAME_CHUNK_LEN
;
1619 while (is_a_char (C
= next_char_of_string ()))
1621 if (name
>= name_end
)
1625 sofar
= name
- start
;
1626 len
+= SYM_NAME_CHUNK_LEN
;
1627 start
= xrealloc (start
, len
+ 1);
1628 name_end
= start
+ len
;
1629 name
= start
+ sofar
;
1636 /* Since quoted symbol names can contain non-ASCII characters,
1637 check the string and warn if it cannot be recognised by the
1638 current character set. */
1639 if (mbstowcs (NULL
, name
, len
) == (size_t) -1)
1640 as_warn (_("symbol name not recognised in the current locale"));
1642 else if (is_name_beginner (c
) || c
== '\001')
1646 name
= input_line_pointer
- 1;
1648 /* We accept \001 in a name in case this is
1649 being called with a constructed string. */
1650 while (is_part_of_name (c
= *input_line_pointer
++)
1654 len
= (input_line_pointer
- name
) - 1;
1655 start
= xmalloc (len
+ 1);
1657 memcpy (start
, name
, len
);
1660 /* Skip a name ender char if one is present. */
1661 if (! is_name_ender (c
))
1662 --input_line_pointer
;
1665 name
= start
= NULL
;
1669 as_bad (_("expected symbol name"));
1670 ignore_rest_of_line ();
1681 s_comm_internal (int param
,
1682 symbolS
*(*comm_parse_extra
) (int, symbolS
*, addressT
))
1686 symbolS
*symbolP
= NULL
;
1692 stop
= mri_comment_field (&stopc
);
1694 if ((name
= read_symbol_name ()) == NULL
)
1697 /* Accept an optional comma after the name. The comma used to be
1698 required, but Irix 5 cc does not generate it for .lcomm. */
1699 if (*input_line_pointer
== ',')
1700 input_line_pointer
++;
1702 temp
= get_absolute_expr (&exp
);
1704 size
&= ((offsetT
) 2 << (stdoutput
->arch_info
->bits_per_address
- 1)) - 1;
1705 if (exp
.X_op
== O_absent
)
1707 as_bad (_("missing size expression"));
1708 ignore_rest_of_line ();
1711 else if (temp
!= size
|| !exp
.X_unsigned
)
1713 as_warn (_("size (%ld) out of range, ignored"), (long) temp
);
1714 ignore_rest_of_line ();
1718 symbolP
= symbol_find_or_make (name
);
1719 if ((S_IS_DEFINED (symbolP
) || symbol_equated_p (symbolP
))
1720 && !S_IS_COMMON (symbolP
))
1722 if (!S_IS_VOLATILE (symbolP
))
1725 as_bad (_("symbol `%s' is already defined"), name
);
1726 ignore_rest_of_line ();
1729 symbolP
= symbol_clone (symbolP
, 1);
1730 S_SET_SEGMENT (symbolP
, undefined_section
);
1731 S_SET_VALUE (symbolP
, 0);
1732 symbol_set_frag (symbolP
, &zero_address_frag
);
1733 S_CLEAR_VOLATILE (symbolP
);
1736 size
= S_GET_VALUE (symbolP
);
1739 else if (size
!= temp
)
1740 as_warn (_("size of \"%s\" is already %ld; not changing to %ld"),
1741 name
, (long) size
, (long) temp
);
1743 if (comm_parse_extra
!= NULL
)
1744 symbolP
= (*comm_parse_extra
) (param
, symbolP
, size
);
1747 S_SET_VALUE (symbolP
, (valueT
) size
);
1748 S_SET_EXTERNAL (symbolP
);
1749 S_SET_SEGMENT (symbolP
, bfd_com_section_ptr
);
1752 demand_empty_rest_of_line ();
1755 mri_comment_end (stop
, stopc
);
1764 s_comm_internal (ignore
, NULL
);
1767 /* The MRI COMMON pseudo-op. We handle this by creating a common
1768 symbol with the appropriate name. We make s_space do the right
1769 thing by increasing the size. */
1772 s_mri_common (int small ATTRIBUTE_UNUSED
)
1788 stop
= mri_comment_field (&stopc
);
1792 name
= input_line_pointer
;
1793 if (!ISDIGIT (*name
))
1794 c
= get_symbol_end ();
1799 ++input_line_pointer
;
1801 while (ISDIGIT (*input_line_pointer
));
1803 c
= *input_line_pointer
;
1804 *input_line_pointer
= '\0';
1806 if (line_label
!= NULL
)
1808 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1809 + (input_line_pointer
- name
)
1811 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1816 sym
= symbol_find_or_make (name
);
1817 *input_line_pointer
= c
;
1821 if (*input_line_pointer
!= ',')
1825 ++input_line_pointer
;
1826 align
= get_absolute_expression ();
1829 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1831 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (sym
));
1832 ignore_rest_of_line ();
1833 mri_comment_end (stop
, stopc
);
1837 S_SET_EXTERNAL (sym
);
1838 S_SET_SEGMENT (sym
, bfd_com_section_ptr
);
1839 mri_common_symbol
= sym
;
1843 S_SET_ALIGN (sym
, align
);
1848 if (line_label
!= NULL
)
1851 exp
.X_op
= O_symbol
;
1852 exp
.X_add_symbol
= sym
;
1853 exp
.X_add_number
= 0;
1854 symbol_set_value_expression (line_label
, &exp
);
1855 symbol_set_frag (line_label
, &zero_address_frag
);
1856 S_SET_SEGMENT (line_label
, expr_section
);
1859 /* FIXME: We just ignore the small argument, which distinguishes
1860 COMMON and COMMON.S. I don't know what we can do about it. */
1862 /* Ignore the type and hptype. */
1863 if (*input_line_pointer
== ',')
1864 input_line_pointer
+= 2;
1865 if (*input_line_pointer
== ',')
1866 input_line_pointer
+= 2;
1868 demand_empty_rest_of_line ();
1870 mri_comment_end (stop
, stopc
);
1874 s_data (int ignore ATTRIBUTE_UNUSED
)
1879 temp
= get_absolute_expression ();
1880 if (flag_readonly_data_in_text
)
1882 section
= text_section
;
1886 section
= data_section
;
1888 subseg_set (section
, (subsegT
) temp
);
1890 demand_empty_rest_of_line ();
1893 /* Handle the .appfile pseudo-op. This is automatically generated by
1894 do_scrub_chars when a preprocessor # line comment is seen with a
1895 file name. This default definition may be overridden by the object
1896 or CPU specific pseudo-ops. This function is also the default
1897 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1901 s_app_file_string (char *file
, int appfile ATTRIBUTE_UNUSED
)
1905 listing_source_file (file
);
1907 register_dependency (file
);
1909 obj_app_file (file
, appfile
);
1914 s_app_file (int appfile
)
1919 /* Some assemblers tolerate immediately following '"'. */
1920 if ((s
= demand_copy_string (&length
)) != 0)
1923 = (!new_logical_line_flags (s
, -1, 1) && appfile
);
1925 /* In MRI mode, the preprocessor may have inserted an extraneous
1928 && *input_line_pointer
== '\''
1929 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1930 ++input_line_pointer
;
1932 demand_empty_rest_of_line ();
1934 s_app_file_string (s
, appfile
);
1939 get_linefile_number (int *flag
)
1943 if (*input_line_pointer
< '0' || *input_line_pointer
> '9')
1946 *flag
= get_absolute_expression ();
1951 /* Handle the .appline pseudo-op. This is automatically generated by
1952 do_scrub_chars when a preprocessor # line comment is seen. This
1953 default definition may be overridden by the object or CPU specific
1957 s_app_line (int appline
)
1962 /* The given number is that of the next line. */
1964 l
= get_absolute_expression ();
1965 else if (!get_linefile_number (&l
))
1967 ignore_rest_of_line ();
1974 /* Some of the back ends can't deal with non-positive line numbers.
1975 Besides, it's silly. GCC however will generate a line number of
1976 zero when it is pre-processing builtins for assembler-with-cpp files:
1980 We do not want to barf on this, especially since such files are used
1981 in the GCC and GDB testsuites. So we check for negative line numbers
1982 rather than non-positive line numbers. */
1983 as_warn (_("line numbers must be positive; line number %d rejected"),
1994 if (*input_line_pointer
== '"')
1995 file
= demand_copy_string (&length
);
2001 while (get_linefile_number (&this_flag
))
2004 /* From GCC's cpp documentation:
2005 1: start of a new file.
2006 2: returning to a file after having included
2008 3: following text comes from a system header file.
2009 4: following text should be treated as extern "C".
2011 4 is nonsensical for the assembler; 3, we don't
2012 care about, so we ignore it just in case a
2013 system header file is included while
2014 preprocessing assembly. So 1 and 2 are all we
2015 care about, and they are mutually incompatible.
2016 new_logical_line_flags() demands this. */
2019 if (flags
&& flags
!= (1 << this_flag
))
2020 as_warn (_("incompatible flag %i in line directive"),
2023 flags
|= 1 << this_flag
;
2028 /* We ignore these. */
2032 as_warn (_("unsupported flag %i in line directive"),
2037 if (!is_end_of_line
[(unsigned char)*input_line_pointer
])
2042 if (appline
|| file
)
2044 new_logical_line_flags (file
, l
, flags
);
2047 listing_source_line (l
);
2051 if (appline
|| file
)
2052 demand_empty_rest_of_line ();
2054 ignore_rest_of_line ();
2057 /* Handle the .end pseudo-op. Actually, the real work is done in
2058 read_a_source_file. */
2061 s_end (int ignore ATTRIBUTE_UNUSED
)
2065 /* The MRI assembler permits the start symbol to follow .end,
2066 but we don't support that. */
2068 if (!is_end_of_line
[(unsigned char) *input_line_pointer
]
2069 && *input_line_pointer
!= '*'
2070 && *input_line_pointer
!= '!')
2071 as_warn (_("start address not supported"));
2075 /* Handle the .err pseudo-op. */
2078 s_err (int ignore ATTRIBUTE_UNUSED
)
2080 as_bad (_(".err encountered"));
2081 demand_empty_rest_of_line ();
2084 /* Handle the .error and .warning pseudo-ops. */
2090 /* The purpose for the conditional assignment is not to
2091 internationalize the directive itself, but that we need a
2092 self-contained message, one that can be passed like the
2093 demand_copy_C_string return value, and with no assumption on the
2094 location of the name of the directive within the message. */
2096 = (err
? _(".error directive invoked in source file")
2097 : _(".warning directive invoked in source file"));
2099 if (!is_it_end_of_statement ())
2101 if (*input_line_pointer
!= '\"')
2103 as_bad (_("%s argument must be a string"),
2104 err
? ".error" : ".warning");
2105 ignore_rest_of_line ();
2109 msg
= demand_copy_C_string (&len
);
2117 as_warn ("%s", msg
);
2118 demand_empty_rest_of_line ();
2121 /* Handle the MRI fail pseudo-op. */
2124 s_fail (int ignore ATTRIBUTE_UNUSED
)
2131 stop
= mri_comment_field (&stopc
);
2133 temp
= get_absolute_expression ();
2135 as_warn (_(".fail %ld encountered"), (long) temp
);
2137 as_bad (_(".fail %ld encountered"), (long) temp
);
2139 demand_empty_rest_of_line ();
2142 mri_comment_end (stop
, stopc
);
2146 s_fill (int ignore ATTRIBUTE_UNUSED
)
2148 expressionS rep_exp
;
2153 #ifdef md_flush_pending_output
2154 md_flush_pending_output ();
2157 #ifdef md_cons_align
2161 get_known_segmented_expression (&rep_exp
);
2162 if (*input_line_pointer
== ',')
2164 input_line_pointer
++;
2165 size
= get_absolute_expression ();
2166 if (*input_line_pointer
== ',')
2168 input_line_pointer
++;
2169 fill
= get_absolute_expression ();
2173 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
2174 #define BSD_FILL_SIZE_CROCK_8 (8)
2175 if (size
> BSD_FILL_SIZE_CROCK_8
)
2177 as_warn (_(".fill size clamped to %d"), BSD_FILL_SIZE_CROCK_8
);
2178 size
= BSD_FILL_SIZE_CROCK_8
;
2182 as_warn (_("size negative; .fill ignored"));
2185 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
2187 if (rep_exp
.X_add_number
< 0)
2188 as_warn (_("repeat < 0; .fill ignored"));
2192 if (size
&& !need_pass_2
)
2194 if (rep_exp
.X_op
== O_constant
)
2196 p
= frag_var (rs_fill
, (int) size
, (int) size
,
2197 (relax_substateT
) 0, (symbolS
*) 0,
2198 (offsetT
) rep_exp
.X_add_number
,
2203 /* We don't have a constant repeat count, so we can't use
2204 rs_fill. We can get the same results out of rs_space,
2205 but its argument is in bytes, so we must multiply the
2206 repeat count by size. */
2209 rep_sym
= make_expr_symbol (&rep_exp
);
2212 expressionS size_exp
;
2213 size_exp
.X_op
= O_constant
;
2214 size_exp
.X_add_number
= size
;
2216 rep_exp
.X_op
= O_multiply
;
2217 rep_exp
.X_add_symbol
= rep_sym
;
2218 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
2219 rep_exp
.X_add_number
= 0;
2220 rep_sym
= make_expr_symbol (&rep_exp
);
2223 p
= frag_var (rs_space
, (int) size
, (int) size
,
2224 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
2227 memset (p
, 0, (unsigned int) size
);
2229 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
2230 flavoured AS. The following bizarre behaviour is to be
2231 compatible with above. I guess they tried to take up to 8
2232 bytes from a 4-byte expression and they forgot to sign
2234 #define BSD_FILL_SIZE_CROCK_4 (4)
2235 md_number_to_chars (p
, (valueT
) fill
,
2236 (size
> BSD_FILL_SIZE_CROCK_4
2237 ? BSD_FILL_SIZE_CROCK_4
2239 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
2240 but emits no error message because it seems a legal thing to do.
2241 It is a degenerate case of .fill but could be emitted by a
2244 demand_empty_rest_of_line ();
2248 s_globl (int ignore ATTRIBUTE_UNUSED
)
2257 stop
= mri_comment_field (&stopc
);
2261 if ((name
= read_symbol_name ()) == NULL
)
2264 symbolP
= symbol_find_or_make (name
);
2265 S_SET_EXTERNAL (symbolP
);
2268 c
= *input_line_pointer
;
2271 input_line_pointer
++;
2273 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
2281 demand_empty_rest_of_line ();
2284 mri_comment_end (stop
, stopc
);
2287 /* Handle the MRI IRP and IRPC pseudo-ops. */
2298 as_where (&file
, &line
);
2300 eol
= find_end_of_line (input_line_pointer
, 0);
2301 sb_build (&s
, eol
- input_line_pointer
);
2302 sb_add_buffer (&s
, input_line_pointer
, eol
- input_line_pointer
);
2303 input_line_pointer
= eol
;
2307 err
= expand_irp (irpc
, 0, &s
, &out
, get_non_macro_line_sb
);
2309 as_bad_where (file
, line
, "%s", err
);
2313 input_scrub_include_sb (&out
, input_line_pointer
, 1);
2315 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2318 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
2319 the section to only be linked once. However, this is not supported
2320 by most object file formats. This takes an optional argument,
2321 which is what to do about duplicates. */
2324 s_linkonce (int ignore ATTRIBUTE_UNUSED
)
2326 enum linkonce_type type
;
2330 type
= LINKONCE_DISCARD
;
2332 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2337 s
= input_line_pointer
;
2338 c
= get_symbol_end ();
2339 if (strcasecmp (s
, "discard") == 0)
2340 type
= LINKONCE_DISCARD
;
2341 else if (strcasecmp (s
, "one_only") == 0)
2342 type
= LINKONCE_ONE_ONLY
;
2343 else if (strcasecmp (s
, "same_size") == 0)
2344 type
= LINKONCE_SAME_SIZE
;
2345 else if (strcasecmp (s
, "same_contents") == 0)
2346 type
= LINKONCE_SAME_CONTENTS
;
2348 as_warn (_("unrecognized .linkonce type `%s'"), s
);
2350 *input_line_pointer
= c
;
2353 #ifdef obj_handle_link_once
2354 obj_handle_link_once (type
);
2355 #else /* ! defined (obj_handle_link_once) */
2359 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
2360 as_warn (_(".linkonce is not supported for this object file format"));
2362 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
2363 flags
|= SEC_LINK_ONCE
;
2368 case LINKONCE_DISCARD
:
2369 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
2371 case LINKONCE_ONE_ONLY
:
2372 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
2374 case LINKONCE_SAME_SIZE
:
2375 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
2377 case LINKONCE_SAME_CONTENTS
:
2378 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
2381 if (!bfd_set_section_flags (stdoutput
, now_seg
, flags
))
2382 as_bad (_("bfd_set_section_flags: %s"),
2383 bfd_errmsg (bfd_get_error ()));
2385 #endif /* ! defined (obj_handle_link_once) */
2387 demand_empty_rest_of_line ();
2391 bss_alloc (symbolS
*symbolP
, addressT size
, int align
)
2394 segT current_seg
= now_seg
;
2395 subsegT current_subseg
= now_subseg
;
2396 segT bss_seg
= bss_section
;
2398 #if defined (TC_MIPS) || defined (TC_ALPHA)
2399 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
2400 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
2402 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
2403 if (size
<= bfd_get_gp_size (stdoutput
))
2405 bss_seg
= subseg_new (".sbss", 1);
2406 seg_info (bss_seg
)->bss
= 1;
2407 if (!bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
2408 as_warn (_("error setting flags for \".sbss\": %s"),
2409 bfd_errmsg (bfd_get_error ()));
2413 subseg_set (bss_seg
, 1);
2417 record_alignment (bss_seg
, align
);
2418 frag_align (align
, 0, 0);
2421 /* Detach from old frag. */
2422 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2423 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2425 symbol_set_frag (symbolP
, frag_now
);
2426 pfrag
= frag_var (rs_org
, 1, 1, 0, symbolP
, size
, NULL
);
2430 S_SET_SIZE (symbolP
, size
);
2432 S_SET_SEGMENT (symbolP
, bss_seg
);
2435 /* The symbol may already have been created with a preceding
2436 ".globl" directive -- be careful not to step on storage class
2437 in that case. Otherwise, set it to static. */
2438 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2439 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2440 #endif /* OBJ_COFF */
2442 subseg_set (current_seg
, current_subseg
);
2446 parse_align (int align_bytes
)
2452 if (*input_line_pointer
!= ',')
2455 as_bad (_("expected alignment after size"));
2456 ignore_rest_of_line ();
2460 input_line_pointer
++;
2463 align
= get_absolute_expr (&exp
);
2464 if (exp
.X_op
== O_absent
)
2467 if (!exp
.X_unsigned
)
2469 as_warn (_("alignment negative; 0 assumed"));
2473 if (align_bytes
&& align
!= 0)
2475 /* convert to a power of 2 alignment */
2476 unsigned int alignp2
= 0;
2477 while ((align
& 1) == 0)
2478 align
>>= 1, ++alignp2
;
2481 as_bad (_("alignment not a power of 2"));
2482 ignore_rest_of_line ();
2490 /* Called from s_comm_internal after symbol name and size have been
2491 parsed. NEEDS_ALIGN is 0 if it was an ".lcomm" (2 args only),
2492 1 if this was a ".bss" directive which has a 3rd argument
2493 (alignment as a power of 2), or 2 if this was a ".bss" directive
2494 with alignment in bytes. */
2497 s_lcomm_internal (int needs_align
, symbolS
*symbolP
, addressT size
)
2503 align
= parse_align (needs_align
- 1);
2504 if (align
== (addressT
) -1)
2508 /* Assume some objects may require alignment on some systems. */
2509 TC_IMPLICIT_LCOMM_ALIGNMENT (size
, align
);
2511 bss_alloc (symbolP
, size
, align
);
2516 s_lcomm (int needs_align
)
2518 s_comm_internal (needs_align
, s_lcomm_internal
);
2522 s_lcomm_bytes (int needs_align
)
2524 s_comm_internal (needs_align
* 2, s_lcomm_internal
);
2528 s_lsym (int ignore ATTRIBUTE_UNUSED
)
2534 /* We permit ANY defined expression: BSD4.2 demands constants. */
2535 if ((name
= read_symbol_name ()) == NULL
)
2538 if (*input_line_pointer
!= ',')
2540 as_bad (_("expected comma after \"%s\""), name
);
2544 input_line_pointer
++;
2545 expression_and_evaluate (&exp
);
2547 if (exp
.X_op
!= O_constant
2548 && exp
.X_op
!= O_register
)
2550 as_bad (_("bad expression"));
2554 symbolP
= symbol_find_or_make (name
);
2556 if (S_GET_SEGMENT (symbolP
) == undefined_section
)
2558 /* The name might be an undefined .global symbol; be sure to
2559 keep the "external" bit. */
2560 S_SET_SEGMENT (symbolP
,
2561 (exp
.X_op
== O_constant
2564 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2568 as_bad (_("symbol `%s' is already defined"), name
);
2571 demand_empty_rest_of_line ();
2576 ignore_rest_of_line ();
2581 /* Read a line into an sb. Returns the character that ended the line
2582 or zero if there are no more lines. */
2585 get_line_sb (sb
*line
, int in_macro
)
2589 if (input_line_pointer
[-1] == '\n')
2590 bump_line_counters ();
2592 if (input_line_pointer
>= buffer_limit
)
2594 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2595 if (buffer_limit
== 0)
2599 eol
= _find_end_of_line (input_line_pointer
, flag_m68k_mri
, 0, in_macro
);
2600 sb_add_buffer (line
, input_line_pointer
, eol
- input_line_pointer
);
2601 input_line_pointer
= eol
;
2603 /* Don't skip multiple end-of-line characters, because that breaks support
2604 for the IA-64 stop bit (;;) which looks like two consecutive end-of-line
2605 characters but isn't. Instead just skip one end of line character and
2606 return the character skipped so that the caller can re-insert it if
2608 return *input_line_pointer
++;
2612 get_non_macro_line_sb (sb
*line
)
2614 return get_line_sb (line
, 0);
2618 get_macro_line_sb (sb
*line
)
2620 return get_line_sb (line
, 1);
2623 /* Define a macro. This is an interface to macro.c. */
2626 s_macro (int ignore ATTRIBUTE_UNUSED
)
2634 as_where (&file
, &line
);
2636 eol
= find_end_of_line (input_line_pointer
, 0);
2637 sb_build (&s
, eol
- input_line_pointer
);
2638 sb_add_buffer (&s
, input_line_pointer
, eol
- input_line_pointer
);
2639 input_line_pointer
= eol
;
2641 if (line_label
!= NULL
)
2646 name
= S_GET_NAME (line_label
);
2647 len
= strlen (name
);
2648 sb_build (&label
, len
);
2649 sb_add_buffer (&label
, name
, len
);
2650 err
= define_macro (0, &s
, &label
, get_macro_line_sb
, file
, line
, &name
);
2654 err
= define_macro (0, &s
, NULL
, get_macro_line_sb
, file
, line
, &name
);
2656 as_bad_where (file
, line
, err
, name
);
2659 if (line_label
!= NULL
)
2661 S_SET_SEGMENT (line_label
, absolute_section
);
2662 S_SET_VALUE (line_label
, 0);
2663 symbol_set_frag (line_label
, &zero_address_frag
);
2666 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2667 && hash_find (po_hash
, name
) != NULL
)
2670 && hash_find (po_hash
, name
+ 1) != NULL
))
2671 as_warn_where (file
,
2673 _("attempt to redefine pseudo-op `%s' ignored"),
2680 /* Handle the .mexit pseudo-op, which immediately exits a macro
2684 s_mexit (int ignore ATTRIBUTE_UNUSED
)
2688 cond_exit_macro (macro_nest
);
2689 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2692 as_warn (_("ignoring macro exit outside a macro definition."));
2695 /* Switch in and out of MRI mode. */
2698 s_mri (int ignore ATTRIBUTE_UNUSED
)
2701 #ifdef MRI_MODE_CHANGE
2705 on
= get_absolute_expression ();
2706 #ifdef MRI_MODE_CHANGE
2707 old_flag
= flag_mri
;
2726 /* Operator precedence changes in m68k MRI mode, so we need to
2727 update the operator rankings. */
2728 expr_set_precedence ();
2730 #ifdef MRI_MODE_CHANGE
2732 MRI_MODE_CHANGE (on
);
2735 demand_empty_rest_of_line ();
2738 /* Handle changing the location counter. */
2741 do_org (segT segment
, expressionS
*exp
, int fill
)
2743 if (segment
!= now_seg
2744 && segment
!= absolute_section
2745 && segment
!= expr_section
)
2746 as_bad (_("invalid segment \"%s\""), segment_name (segment
));
2748 if (now_seg
== absolute_section
)
2751 as_warn (_("ignoring fill value in absolute section"));
2752 if (exp
->X_op
!= O_constant
)
2754 as_bad (_("only constant offsets supported in absolute section"));
2755 exp
->X_add_number
= 0;
2757 abs_section_offset
= exp
->X_add_number
;
2762 symbolS
*sym
= exp
->X_add_symbol
;
2763 offsetT off
= exp
->X_add_number
* OCTETS_PER_BYTE
;
2765 if (exp
->X_op
!= O_constant
&& exp
->X_op
!= O_symbol
)
2767 /* Handle complex expressions. */
2768 sym
= make_expr_symbol (exp
);
2772 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, sym
, off
, (char *) 0);
2778 s_org (int ignore ATTRIBUTE_UNUSED
)
2784 #ifdef md_flush_pending_output
2785 md_flush_pending_output ();
2788 /* The m68k MRI assembler has a different meaning for .org. It
2789 means to create an absolute section at a given address. We can't
2790 support that--use a linker script instead. */
2793 as_bad (_("MRI style ORG pseudo-op not supported"));
2794 ignore_rest_of_line ();
2798 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2799 thing as a sub-segment-relative origin. Any absolute origin is
2800 given a warning, then assumed to be segment-relative. Any
2801 segmented origin expression ("foo+42") had better be in the right
2802 segment or the .org is ignored.
2804 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2805 we never know sub-segment sizes when we are reading code. BSD
2806 will crash trying to emit negative numbers of filler bytes in
2807 certain .orgs. We don't crash, but see as-write for that code.
2809 Don't make frag if need_pass_2==1. */
2810 segment
= get_known_segmented_expression (&exp
);
2811 if (*input_line_pointer
== ',')
2813 input_line_pointer
++;
2814 temp_fill
= get_absolute_expression ();
2820 do_org (segment
, &exp
, temp_fill
);
2822 demand_empty_rest_of_line ();
2825 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2826 called by the obj-format routine which handles section changing
2827 when in MRI mode. It will create a new section, and return it. It
2828 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2829 'M' (mixed), or 'R' (romable). The flags will be set in the section. */
2832 s_mri_sect (char *type ATTRIBUTE_UNUSED
)
2842 name
= input_line_pointer
;
2843 if (!ISDIGIT (*name
))
2844 c
= get_symbol_end ();
2849 ++input_line_pointer
;
2851 while (ISDIGIT (*input_line_pointer
));
2853 c
= *input_line_pointer
;
2854 *input_line_pointer
= '\0';
2857 name
= xstrdup (name
);
2859 *input_line_pointer
= c
;
2861 seg
= subseg_new (name
, 0);
2863 if (*input_line_pointer
== ',')
2867 ++input_line_pointer
;
2868 align
= get_absolute_expression ();
2869 record_alignment (seg
, align
);
2873 if (*input_line_pointer
== ',')
2875 c
= *++input_line_pointer
;
2877 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2880 as_bad (_("unrecognized section type"));
2881 ++input_line_pointer
;
2886 flags
= SEC_NO_FLAGS
;
2888 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2889 else if (*type
== 'D' || *type
== 'M')
2890 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2891 else if (*type
== 'R')
2892 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2893 if (flags
!= SEC_NO_FLAGS
)
2895 if (!bfd_set_section_flags (stdoutput
, seg
, flags
))
2896 as_warn (_("error setting flags for \"%s\": %s"),
2897 bfd_section_name (stdoutput
, seg
),
2898 bfd_errmsg (bfd_get_error ()));
2903 /* Ignore the HP type. */
2904 if (*input_line_pointer
== ',')
2905 input_line_pointer
+= 2;
2907 demand_empty_rest_of_line ();
2909 #else /* ! TC_M68K */
2918 name
= input_line_pointer
;
2919 c
= get_symbol_end ();
2921 name
= xstrdup (name
);
2923 *input_line_pointer
= c
;
2925 seg
= subseg_new (name
, 0);
2927 if (*input_line_pointer
!= ',')
2933 ++input_line_pointer
;
2935 sectype
= input_line_pointer
;
2936 c
= get_symbol_end ();
2937 if (*sectype
== '\0')
2939 else if (strcasecmp (sectype
, "text") == 0)
2941 else if (strcasecmp (sectype
, "data") == 0)
2943 else if (strcasecmp (sectype
, "romdata") == 0)
2946 as_warn (_("unrecognized section type `%s'"), sectype
);
2947 *input_line_pointer
= c
;
2950 if (*input_line_pointer
== ',')
2954 ++input_line_pointer
;
2956 seccmd
= input_line_pointer
;
2957 c
= get_symbol_end ();
2958 if (strcasecmp (seccmd
, "absolute") == 0)
2960 as_bad (_("absolute sections are not supported"));
2961 *input_line_pointer
= c
;
2962 ignore_rest_of_line ();
2965 else if (strcasecmp (seccmd
, "align") == 0)
2969 *input_line_pointer
= c
;
2970 align
= get_absolute_expression ();
2971 record_alignment (seg
, align
);
2975 as_warn (_("unrecognized section command `%s'"), seccmd
);
2976 *input_line_pointer
= c
;
2980 demand_empty_rest_of_line ();
2982 #else /* ! TC_I960 */
2983 /* The MRI assembler seems to use different forms of .sect for
2984 different targets. */
2985 as_bad ("MRI mode not supported for this target");
2986 ignore_rest_of_line ();
2987 #endif /* ! TC_I960 */
2988 #endif /* ! TC_M68K */
2991 /* Handle the .print pseudo-op. */
2994 s_print (int ignore ATTRIBUTE_UNUSED
)
2999 s
= demand_copy_C_string (&len
);
3002 demand_empty_rest_of_line ();
3005 /* Handle the .purgem pseudo-op. */
3008 s_purgem (int ignore ATTRIBUTE_UNUSED
)
3010 if (is_it_end_of_statement ())
3012 demand_empty_rest_of_line ();
3022 name
= input_line_pointer
;
3023 c
= get_symbol_end ();
3024 delete_macro (name
);
3025 *input_line_pointer
= c
;
3028 while (*input_line_pointer
++ == ',');
3030 --input_line_pointer
;
3031 demand_empty_rest_of_line ();
3034 /* Handle the .endm/.endr pseudo-ops. */
3037 s_bad_end (int endr
)
3039 as_warn (_(".end%c encountered without preceding %s"),
3041 endr
? ".rept, .irp, or .irpc" : ".macro");
3042 demand_empty_rest_of_line ();
3045 /* Handle the .rept pseudo-op. */
3048 s_rept (int ignore ATTRIBUTE_UNUSED
)
3052 count
= get_absolute_expression ();
3054 do_repeat (count
, "REPT", "ENDR");
3057 /* This function provides a generic repeat block implementation. It allows
3058 different directives to be used as the start/end keys. */
3061 do_repeat (int count
, const char *start
, const char *end
)
3067 if (!buffer_and_nest (start
, end
, &one
, get_non_macro_line_sb
))
3069 as_bad (_("%s without %s"), start
, end
);
3073 sb_build (&many
, count
* one
.len
);
3075 sb_add_sb (&many
, &one
);
3079 input_scrub_include_sb (&many
, input_line_pointer
, 1);
3081 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
3084 /* Like do_repeat except that any text matching EXPANDER in the
3085 block is replaced by the itteration count. */
3088 do_repeat_with_expander (int count
,
3091 const char * expander
)
3097 if (!buffer_and_nest (start
, end
, &one
, get_non_macro_line_sb
))
3099 as_bad (_("%s without %s"), start
, end
);
3105 if (expander
!= NULL
&& strstr (one
.ptr
, expander
) != NULL
)
3107 while (count
-- > 0)
3113 sb_build (& processed
, one
.len
);
3114 sb_add_sb (& processed
, & one
);
3115 sub
= strstr (processed
.ptr
, expander
);
3116 len
= sprintf (sub
, "%d", count
);
3117 gas_assert (len
< 8);
3118 strcpy (sub
+ len
, sub
+ 8);
3119 processed
.len
-= (8 - len
);
3120 sb_add_sb (& many
, & processed
);
3121 sb_kill (& processed
);
3126 sb_add_sb (&many
, &one
);
3130 input_scrub_include_sb (&many
, input_line_pointer
, 1);
3132 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
3135 /* Skip to end of current repeat loop; EXTRA indicates how many additional
3136 input buffers to skip. Assumes that conditionals preceding the loop end
3137 are properly nested.
3139 This function makes it easier to implement a premature "break" out of the
3140 loop. The EXTRA arg accounts for other buffers we might have inserted,
3141 such as line substitutions. */
3144 end_repeat (int extra
)
3146 cond_exit_macro (macro_nest
);
3147 while (extra
-- >= 0)
3148 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
3152 assign_symbol (char *name
, int mode
)
3156 if (name
[0] == '.' && name
[1] == '\0')
3158 /* Turn '. = mumble' into a .org mumble. */
3162 segment
= get_known_segmented_expression (&exp
);
3165 do_org (segment
, &exp
, 0);
3170 if ((symbolP
= symbol_find (name
)) == NULL
3171 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
3173 symbolP
= symbol_find_or_make (name
);
3175 /* When doing symbol listings, play games with dummy fragments living
3176 outside the normal fragment chain to record the file and line info
3178 if (listing
& LISTING_SYMBOLS
)
3180 extern struct list_info_struct
*listing_tail
;
3181 fragS
*dummy_frag
= (fragS
*) xcalloc (1, sizeof (fragS
));
3182 dummy_frag
->line
= listing_tail
;
3183 dummy_frag
->fr_symbol
= symbolP
;
3184 symbol_set_frag (symbolP
, dummy_frag
);
3188 /* "set" symbols are local unless otherwise specified. */
3189 SF_SET_LOCAL (symbolP
);
3193 if (S_IS_DEFINED (symbolP
) || symbol_equated_p (symbolP
))
3195 if ((mode
!= 0 || !S_IS_VOLATILE (symbolP
))
3196 && !S_CAN_BE_REDEFINED (symbolP
))
3198 as_bad (_("symbol `%s' is already defined"), name
);
3199 symbolP
= symbol_clone (symbolP
, 0);
3201 /* If the symbol is volatile, copy the symbol and replace the
3202 original with the copy, so that previous uses of the symbol will
3203 retain the value of the symbol at the point of use. */
3204 else if (S_IS_VOLATILE (symbolP
))
3205 symbolP
= symbol_clone (symbolP
, 1);
3209 S_SET_VOLATILE (symbolP
);
3211 S_SET_FORWARD_REF (symbolP
);
3213 pseudo_set (symbolP
);
3216 /* Handle the .equ, .equiv, .eqv, and .set directives. If EQUIV is 1,
3217 then this is .equiv, and it is an error if the symbol is already
3218 defined. If EQUIV is -1, the symbol additionally is a forward
3226 /* Especial apologies for the random logic:
3227 this just grew, and could be parsed much more simply!
3229 if ((name
= read_symbol_name ()) == NULL
)
3232 if (*input_line_pointer
!= ',')
3234 as_bad (_("expected comma after \"%s\""), name
);
3235 ignore_rest_of_line ();
3240 input_line_pointer
++;
3241 assign_symbol (name
, equiv
);
3242 demand_empty_rest_of_line ();
3256 #ifdef md_flush_pending_output
3257 md_flush_pending_output ();
3260 #ifdef md_cons_align
3265 stop
= mri_comment_field (&stopc
);
3267 /* In m68k MRI mode, we need to align to a word boundary, unless
3269 if (flag_m68k_mri
&& mult
> 1)
3271 if (now_seg
== absolute_section
)
3273 abs_section_offset
+= abs_section_offset
& 1;
3274 if (line_label
!= NULL
)
3275 S_SET_VALUE (line_label
, abs_section_offset
);
3277 else if (mri_common_symbol
!= NULL
)
3281 mri_val
= S_GET_VALUE (mri_common_symbol
);
3282 if ((mri_val
& 1) != 0)
3284 S_SET_VALUE (mri_common_symbol
, mri_val
+ 1);
3285 if (line_label
!= NULL
)
3287 expressionS
*symexp
;
3289 symexp
= symbol_get_value_expression (line_label
);
3290 know (symexp
->X_op
== O_symbol
);
3291 know (symexp
->X_add_symbol
== mri_common_symbol
);
3292 symexp
->X_add_number
+= 1;
3298 do_align (1, (char *) NULL
, 0, 0);
3299 if (line_label
!= NULL
)
3301 symbol_set_frag (line_label
, frag_now
);
3302 S_SET_VALUE (line_label
, frag_now_fix ());
3312 if (*input_line_pointer
== ',')
3314 ++input_line_pointer
;
3319 val
.X_op
= O_constant
;
3320 val
.X_add_number
= 0;
3323 if (val
.X_op
!= O_constant
3324 || val
.X_add_number
< - 0x80
3325 || val
.X_add_number
> 0xff
3326 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
3328 resolve_expression (&exp
);
3329 if (exp
.X_op
!= O_constant
)
3330 as_bad (_("unsupported variable size or fill value"));
3337 bytes
= mult
* exp
.X_add_number
;
3338 for (i
= 0; i
< exp
.X_add_number
; i
++)
3339 emit_expr (&val
, mult
);
3344 if (now_seg
== absolute_section
|| mri_common_symbol
!= NULL
)
3345 resolve_expression (&exp
);
3347 if (exp
.X_op
== O_constant
)
3351 repeat
= exp
.X_add_number
;
3358 as_warn (_(".space repeat count is zero, ignored"));
3359 else if (repeat
< 0)
3360 as_warn (_(".space repeat count is negative, ignored"));
3364 /* If we are in the absolute section, just bump the offset. */
3365 if (now_seg
== absolute_section
)
3367 abs_section_offset
+= repeat
;
3371 /* If we are secretly in an MRI common section, then
3372 creating space just increases the size of the common
3374 if (mri_common_symbol
!= NULL
)
3376 S_SET_VALUE (mri_common_symbol
,
3377 S_GET_VALUE (mri_common_symbol
) + repeat
);
3382 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
3383 (offsetT
) repeat
, (char *) 0);
3387 if (now_seg
== absolute_section
)
3389 as_bad (_("space allocation too complex in absolute section"));
3390 subseg_set (text_section
, 0);
3393 if (mri_common_symbol
!= NULL
)
3395 as_bad (_("space allocation too complex in common section"));
3396 mri_common_symbol
= NULL
;
3400 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
3401 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
3405 *p
= val
.X_add_number
;
3410 /* In MRI mode, after an odd number of bytes, we must align to an
3411 even word boundary, unless the next instruction is a dc.b, ds.b
3413 if (flag_mri
&& (bytes
& 1) != 0)
3414 mri_pending_align
= 1;
3416 demand_empty_rest_of_line ();
3419 mri_comment_end (stop
, stopc
);
3422 /* This is like s_space, but the value is a floating point number with
3423 the given precision. This is for the MRI dcb.s pseudo-op and
3427 s_float_space (int float_type
)
3431 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3435 #ifdef md_cons_align
3440 stop
= mri_comment_field (&stopc
);
3442 count
= get_absolute_expression ();
3445 if (*input_line_pointer
!= ',')
3447 as_bad (_("missing value"));
3448 ignore_rest_of_line ();
3450 mri_comment_end (stop
, stopc
);
3454 ++input_line_pointer
;
3458 /* Skip any 0{letter} that may be present. Don't even check if the
3459 * letter is legal. */
3460 if (input_line_pointer
[0] == '0'
3461 && ISALPHA (input_line_pointer
[1]))
3462 input_line_pointer
+= 2;
3464 /* Accept :xxxx, where the x's are hex digits, for a floating point
3465 with the exact digits specified. */
3466 if (input_line_pointer
[0] == ':')
3468 flen
= hex_float (float_type
, temp
);
3471 ignore_rest_of_line ();
3473 mri_comment_end (stop
, stopc
);
3481 err
= md_atof (float_type
, temp
, &flen
);
3482 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3483 know (err
!= NULL
|| flen
> 0);
3486 as_bad (_("bad floating literal: %s"), err
);
3487 ignore_rest_of_line ();
3489 mri_comment_end (stop
, stopc
);
3494 while (--count
>= 0)
3498 p
= frag_more (flen
);
3499 memcpy (p
, temp
, (unsigned int) flen
);
3502 demand_empty_rest_of_line ();
3505 mri_comment_end (stop
, stopc
);
3508 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3511 s_struct (int ignore ATTRIBUTE_UNUSED
)
3517 stop
= mri_comment_field (&stopc
);
3518 abs_section_offset
= get_absolute_expression ();
3519 #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
3520 /* The ELF backend needs to know that we are changing sections, so
3521 that .previous works correctly. */
3523 obj_elf_section_change_hook ();
3525 subseg_set (absolute_section
, 0);
3526 demand_empty_rest_of_line ();
3528 mri_comment_end (stop
, stopc
);
3532 s_text (int ignore ATTRIBUTE_UNUSED
)
3536 temp
= get_absolute_expression ();
3537 subseg_set (text_section
, (subsegT
) temp
);
3538 demand_empty_rest_of_line ();
3541 /* .weakref x, y sets x as an alias to y that, as long as y is not
3542 referenced directly, will cause y to become a weak symbol. */
3544 s_weakref (int ignore ATTRIBUTE_UNUSED
)
3551 if ((name
= read_symbol_name ()) == NULL
)
3554 symbolP
= symbol_find_or_make (name
);
3556 if (S_IS_DEFINED (symbolP
) || symbol_equated_p (symbolP
))
3558 if (!S_IS_VOLATILE (symbolP
))
3560 as_bad (_("symbol `%s' is already defined"), name
);
3563 symbolP
= symbol_clone (symbolP
, 1);
3564 S_CLEAR_VOLATILE (symbolP
);
3569 if (*input_line_pointer
!= ',')
3571 as_bad (_("expected comma after \"%s\""), name
);
3575 input_line_pointer
++;
3580 if ((name
= read_symbol_name ()) == NULL
)
3583 if ((symbolP2
= symbol_find_noref (name
, 1)) == NULL
3584 && (symbolP2
= md_undefined_symbol (name
)) == NULL
)
3586 symbolP2
= symbol_find_or_make (name
);
3587 S_SET_WEAKREFD (symbolP2
);
3591 symbolS
*symp
= symbolP2
;
3593 while (S_IS_WEAKREFR (symp
) && symp
!= symbolP
)
3595 expressionS
*expP
= symbol_get_value_expression (symp
);
3597 gas_assert (expP
->X_op
== O_symbol
3598 && expP
->X_add_number
== 0);
3599 symp
= expP
->X_add_symbol
;
3601 if (symp
== symbolP
)
3605 loop
= concat (S_GET_NAME (symbolP
),
3606 " => ", S_GET_NAME (symbolP2
), (const char *) NULL
);
3609 while (symp
!= symbolP
)
3611 char *old_loop
= loop
;
3613 symp
= symbol_get_value_expression (symp
)->X_add_symbol
;
3614 loop
= concat (loop
, " => ", S_GET_NAME (symp
),
3615 (const char *) NULL
);
3619 as_bad (_("%s: would close weakref loop: %s"),
3620 S_GET_NAME (symbolP
), loop
);
3624 ignore_rest_of_line ();
3628 /* Short-circuiting instead of just checking here might speed
3629 things up a tiny little bit, but loop error messages would
3630 miss intermediate links. */
3631 /* symbolP2 = symp; */
3634 memset (&exp
, 0, sizeof (exp
));
3635 exp
.X_op
= O_symbol
;
3636 exp
.X_add_symbol
= symbolP2
;
3638 S_SET_SEGMENT (symbolP
, undefined_section
);
3639 symbol_set_value_expression (symbolP
, &exp
);
3640 symbol_set_frag (symbolP
, &zero_address_frag
);
3641 S_SET_WEAKREFR (symbolP
);
3643 demand_empty_rest_of_line ();
3648 ignore_rest_of_line ();
3654 /* Verify that we are at the end of a line. If not, issue an error and
3658 demand_empty_rest_of_line (void)
3661 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3662 input_line_pointer
++;
3665 if (ISPRINT (*input_line_pointer
))
3666 as_bad (_("junk at end of line, first unrecognized character is `%c'"),
3667 *input_line_pointer
);
3669 as_bad (_("junk at end of line, first unrecognized character valued 0x%x"),
3670 *input_line_pointer
);
3671 ignore_rest_of_line ();
3674 /* Return pointing just after end-of-line. */
3675 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3678 /* Silently advance to the end of line. Use this after already having
3679 issued an error about something bad. */
3682 ignore_rest_of_line (void)
3684 while (input_line_pointer
< buffer_limit
3685 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3686 input_line_pointer
++;
3688 input_line_pointer
++;
3690 /* Return pointing just after end-of-line. */
3691 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3694 /* Sets frag for given symbol to zero_address_frag, except when the
3695 symbol frag is already set to a dummy listing frag. */
3698 set_zero_frag (symbolS
*symbolP
)
3700 if (symbol_get_frag (symbolP
)->fr_type
!= rs_dummy
)
3701 symbol_set_frag (symbolP
, &zero_address_frag
);
3704 /* In: Pointer to a symbol.
3705 Input_line_pointer->expression.
3707 Out: Input_line_pointer->just after any whitespace after expression.
3708 Tried to set symbol to value of expression.
3709 Will change symbols type, value, and frag; */
3712 pseudo_set (symbolS
*symbolP
)
3717 know (symbolP
); /* NULL pointer is logic error. */
3719 if (!S_IS_FORWARD_REF (symbolP
))
3720 (void) expression (&exp
);
3722 (void) deferred_expression (&exp
);
3724 if (exp
.X_op
== O_illegal
)
3725 as_bad (_("illegal expression"));
3726 else if (exp
.X_op
== O_absent
)
3727 as_bad (_("missing expression"));
3728 else if (exp
.X_op
== O_big
)
3730 if (exp
.X_add_number
> 0)
3731 as_bad (_("bignum invalid"));
3733 as_bad (_("floating point number invalid"));
3735 else if (exp
.X_op
== O_subtract
3736 && !S_IS_FORWARD_REF (symbolP
)
3737 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3738 && (symbol_get_frag (exp
.X_add_symbol
)
3739 == symbol_get_frag (exp
.X_op_symbol
)))
3741 exp
.X_op
= O_constant
;
3742 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3743 - S_GET_VALUE (exp
.X_op_symbol
));
3746 if (symbol_section_p (symbolP
))
3748 as_bad ("attempt to set value of section symbol");
3757 exp
.X_add_number
= 0;
3760 S_SET_SEGMENT (symbolP
, absolute_section
);
3761 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3762 set_zero_frag (symbolP
);
3766 #ifndef TC_GLOBAL_REGISTER_SYMBOL_OK
3767 if (S_IS_EXTERNAL (symbolP
))
3769 as_bad ("can't equate global symbol `%s' with register name",
3770 S_GET_NAME (symbolP
));
3774 S_SET_SEGMENT (symbolP
, reg_section
);
3775 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3776 set_zero_frag (symbolP
);
3777 symbol_get_value_expression (symbolP
)->X_op
= O_register
;
3781 seg
= S_GET_SEGMENT (exp
.X_add_symbol
);
3782 /* For x=undef+const, create an expression symbol.
3783 For x=x+const, just update x except when x is an undefined symbol
3784 For x=defined+const, evaluate x. */
3785 if (symbolP
== exp
.X_add_symbol
3786 && (seg
!= undefined_section
3787 || !symbol_constant_p (symbolP
)))
3789 *symbol_X_add_number (symbolP
) += exp
.X_add_number
;
3792 else if (!S_IS_FORWARD_REF (symbolP
) && seg
!= undefined_section
)
3794 symbolS
*s
= exp
.X_add_symbol
;
3796 if (S_IS_COMMON (s
))
3797 as_bad (_("`%s' can't be equated to common symbol '%s'"),
3798 S_GET_NAME (symbolP
), S_GET_NAME (s
));
3800 S_SET_SEGMENT (symbolP
, seg
);
3801 S_SET_VALUE (symbolP
, exp
.X_add_number
+ S_GET_VALUE (s
));
3802 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3803 copy_symbol_attributes (symbolP
, s
);
3806 S_SET_SEGMENT (symbolP
, undefined_section
);
3807 symbol_set_value_expression (symbolP
, &exp
);
3808 copy_symbol_attributes (symbolP
, exp
.X_add_symbol
);
3809 set_zero_frag (symbolP
);
3813 /* The value is some complex expression. */
3814 S_SET_SEGMENT (symbolP
, expr_section
);
3815 symbol_set_value_expression (symbolP
, &exp
);
3816 set_zero_frag (symbolP
);
3823 CONStruct more frag of .bytes, or .words etc.
3824 Should need_pass_2 be 1 then emit no frag(s).
3825 This understands EXPRESSIONS.
3829 This has a split personality. We use expression() to read the
3830 value. We can detect if the value won't fit in a byte or word.
3831 But we can't detect if expression() discarded significant digits
3832 in the case of a long. Not worth the crocks required to fix it. */
3834 /* Select a parser for cons expressions. */
3836 /* Some targets need to parse the expression in various fancy ways.
3837 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3838 (for example, the HPPA does this). Otherwise, you can define
3839 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3840 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3841 are defined, which is the normal case, then only simple expressions
3846 parse_mri_cons (expressionS
*exp
, unsigned int nbytes
);
3849 #ifndef TC_PARSE_CONS_EXPRESSION
3850 #ifdef BITFIELD_CONS_EXPRESSIONS
3851 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3853 parse_bitfield_cons (expressionS
*exp
, unsigned int nbytes
);
3855 #ifdef REPEAT_CONS_EXPRESSIONS
3856 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3858 parse_repeat_cons (expressionS
*exp
, unsigned int nbytes
);
3861 /* If we haven't gotten one yet, just call expression. */
3862 #ifndef TC_PARSE_CONS_EXPRESSION
3863 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3868 do_parse_cons_expression (expressionS
*exp
,
3869 int nbytes ATTRIBUTE_UNUSED
)
3871 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3875 /* Worker to do .byte etc statements.
3876 Clobbers input_line_pointer and checks end-of-line. */
3879 cons_worker (int nbytes
, /* 1=.byte, 2=.word, 4=.long. */
3887 #ifdef md_flush_pending_output
3888 md_flush_pending_output ();
3892 stop
= mri_comment_field (&stopc
);
3894 if (is_it_end_of_statement ())
3896 demand_empty_rest_of_line ();
3898 mri_comment_end (stop
, stopc
);
3902 #ifdef TC_ADDRESS_BYTES
3904 nbytes
= TC_ADDRESS_BYTES ();
3907 #ifdef md_cons_align
3908 md_cons_align (nbytes
);
3916 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3920 if (*input_line_pointer
== '"')
3922 as_bad (_("unexpected `\"' in expression"));
3923 ignore_rest_of_line ();
3926 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3931 if (exp
.X_op
== O_symbol
)
3932 exp
.X_op
= O_symbol_rva
;
3934 as_fatal (_("rva without symbol"));
3936 emit_expr (&exp
, (unsigned int) nbytes
);
3939 while (*input_line_pointer
++ == ',');
3941 /* In MRI mode, after an odd number of bytes, we must align to an
3942 even word boundary, unless the next instruction is a dc.b, ds.b
3944 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3945 mri_pending_align
= 1;
3947 input_line_pointer
--; /* Put terminator back into stream. */
3949 demand_empty_rest_of_line ();
3952 mri_comment_end (stop
, stopc
);
3958 cons_worker (size
, 0);
3964 cons_worker (size
, 1);
3967 /* .reloc offset, reloc_name, symbol+addend. */
3970 s_reloc (int ignore ATTRIBUTE_UNUSED
)
3977 struct reloc_list
*reloc
;
3979 reloc
= (struct reloc_list
*) xmalloc (sizeof (*reloc
));
3982 stop
= mri_comment_field (&stopc
);
3991 as_bad (_("missing or bad offset expression"));
3994 exp
.X_add_symbol
= section_symbol (now_seg
);
3995 exp
.X_op
= O_symbol
;
3998 if (exp
.X_add_number
== 0)
4000 reloc
->u
.a
.offset_sym
= exp
.X_add_symbol
;
4005 reloc
->u
.a
.offset_sym
= make_expr_symbol (&exp
);
4010 if (*input_line_pointer
!= ',')
4012 as_bad (_("missing reloc type"));
4016 ++input_line_pointer
;
4018 r_name
= input_line_pointer
;
4019 c
= get_symbol_end ();
4020 reloc
->u
.a
.howto
= bfd_reloc_name_lookup (stdoutput
, r_name
);
4021 *input_line_pointer
= c
;
4022 if (reloc
->u
.a
.howto
== NULL
)
4024 as_bad (_("unrecognized reloc type"));
4028 exp
.X_op
= O_absent
;
4030 if (*input_line_pointer
== ',')
4032 ++input_line_pointer
;
4040 as_bad (_("bad reloc expression"));
4042 ignore_rest_of_line ();
4045 mri_comment_end (stop
, stopc
);
4048 reloc
->u
.a
.sym
= NULL
;
4049 reloc
->u
.a
.addend
= 0;
4052 reloc
->u
.a
.sym
= NULL
;
4053 reloc
->u
.a
.addend
= exp
.X_add_number
;
4056 reloc
->u
.a
.sym
= exp
.X_add_symbol
;
4057 reloc
->u
.a
.addend
= exp
.X_add_number
;
4060 reloc
->u
.a
.sym
= make_expr_symbol (&exp
);
4061 reloc
->u
.a
.addend
= 0;
4065 as_where (&reloc
->file
, &reloc
->line
);
4066 reloc
->next
= reloc_list
;
4069 demand_empty_rest_of_line ();
4071 mri_comment_end (stop
, stopc
);
4074 /* Put the contents of expression EXP into the object file using
4075 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
4078 emit_expr (expressionS
*exp
, unsigned int nbytes
)
4082 valueT extra_digit
= 0;
4084 /* Don't do anything if we are going to make another pass. */
4089 dot_value
= frag_now_fix ();
4090 dot_frag
= frag_now
;
4094 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
4095 appear as a four byte positive constant in the .line section,
4096 followed by a 2 byte 0xffff. Look for that case here. */
4098 static int dwarf_line
= -1;
4100 if (strcmp (segment_name (now_seg
), ".line") != 0)
4102 else if (dwarf_line
>= 0
4104 && exp
->X_op
== O_constant
4105 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
4106 listing_source_line ((unsigned int) dwarf_line
);
4107 else if (nbytes
== 4
4108 && exp
->X_op
== O_constant
4109 && exp
->X_add_number
>= 0)
4110 dwarf_line
= exp
->X_add_number
;
4115 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
4116 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
4117 AT_sibling (0x12) followed by a four byte address of the sibling
4118 followed by a 2 byte AT_name (0x38) followed by the name of the
4119 file. We look for that case here. */
4121 static int dwarf_file
= 0;
4123 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4125 else if (dwarf_file
== 0
4127 && exp
->X_op
== O_constant
4128 && exp
->X_add_number
== 0x11)
4130 else if (dwarf_file
== 1
4132 && exp
->X_op
== O_constant
4133 && exp
->X_add_number
== 0x12)
4135 else if (dwarf_file
== 2
4138 else if (dwarf_file
== 3
4140 && exp
->X_op
== O_constant
4141 && exp
->X_add_number
== 0x38)
4146 /* The variable dwarf_file_string tells stringer that the string
4147 may be the name of the source file. */
4148 if (dwarf_file
== 4)
4149 dwarf_file_string
= 1;
4151 dwarf_file_string
= 0;
4156 if (check_eh_frame (exp
, &nbytes
))
4161 /* Allow `.word 0' in the absolute section. */
4162 if (now_seg
== absolute_section
)
4164 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
4165 as_bad (_("attempt to store value in absolute section"));
4166 abs_section_offset
+= nbytes
;
4170 /* Handle a negative bignum. */
4172 && exp
->X_add_number
== 0
4173 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
4174 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
4177 unsigned long carry
;
4179 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
4181 /* Negate the bignum: one's complement each digit and add 1. */
4183 for (i
= 0; i
< exp
->X_add_number
; i
++)
4187 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
4190 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
4191 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
4194 /* We can ignore any carry out, because it will be handled by
4195 extra_digit if it is needed. */
4197 extra_digit
= (valueT
) -1;
4201 if (op
== O_absent
|| op
== O_illegal
)
4203 as_warn (_("zero assumed for missing expression"));
4204 exp
->X_add_number
= 0;
4207 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4209 as_bad (_("floating point number invalid"));
4210 exp
->X_add_number
= 0;
4213 else if (op
== O_register
)
4215 as_warn (_("register value used as expression"));
4219 p
= frag_more ((int) nbytes
);
4221 #ifndef WORKING_DOT_WORD
4222 /* If we have the difference of two symbols in a word, save it on
4223 the broken_words list. See the code in write.c. */
4224 if (op
== O_subtract
&& nbytes
== 2)
4226 struct broken_word
*x
;
4228 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
4229 x
->next_broken_word
= broken_words
;
4232 x
->subseg
= now_subseg
;
4234 x
->word_goes_here
= p
;
4236 x
->add
= exp
->X_add_symbol
;
4237 x
->sub
= exp
->X_op_symbol
;
4238 x
->addnum
= exp
->X_add_number
;
4246 /* If we have an integer, but the number of bytes is too large to
4247 pass to md_number_to_chars, handle it as a bignum. */
4248 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
4250 extra_digit
= exp
->X_unsigned
? 0 : -1;
4251 convert_to_bignum (exp
, !exp
->X_unsigned
);
4255 if (op
== O_constant
)
4263 /* JF << of >= number of bits in the object is undefined. In
4264 particular SPARC (Sun 4) has problems. */
4265 if (nbytes
>= sizeof (valueT
))
4268 if (nbytes
> sizeof (valueT
))
4271 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
4275 /* Don't store these bits. */
4276 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
4277 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
4280 unmask
= ~mask
; /* Do store these bits. */
4283 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
4284 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
4287 get
= exp
->X_add_number
;
4289 if ((get
& mask
) != 0
4290 && ((get
& mask
) != mask
4291 || (get
& hibit
) == 0))
4292 { /* Leading bits contain both 0s & 1s. */
4293 #if defined (BFD64) && BFD_HOST_64BIT_LONG_LONG
4295 as_warn (_("value 0x%llx truncated to 0x%llx"),
4296 (unsigned long long) get
, (unsigned long long) use
);
4298 as_warn (_("value 0x%I64x truncated to 0x%I64x"),
4299 (unsigned long long) get
, (unsigned long long) use
);
4302 as_warn (_("value 0x%lx truncated to 0x%lx"),
4303 (unsigned long) get
, (unsigned long) use
);
4306 /* Put bytes in right order. */
4307 md_number_to_chars (p
, use
, (int) nbytes
);
4309 else if (op
== O_big
)
4312 LITTLENUM_TYPE
*nums
;
4314 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
4317 int i
= nbytes
/ CHARS_PER_LITTLENUM
;
4320 LITTLENUM_TYPE sign
= 0;
4321 if ((generic_bignum
[--i
]
4322 & (1 << (LITTLENUM_NUMBER_OF_BITS
- 1))) != 0)
4323 sign
= ~(LITTLENUM_TYPE
) 0;
4324 while (++i
< exp
->X_add_number
)
4325 if (generic_bignum
[i
] != sign
)
4328 if (i
< exp
->X_add_number
)
4329 as_warn (_("bignum truncated to %d bytes"), nbytes
);
4335 md_number_to_chars (p
, (valueT
) generic_bignum
[0], 1);
4338 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
4340 if (target_big_endian
)
4342 while (nbytes
> size
)
4344 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
4345 nbytes
-= CHARS_PER_LITTLENUM
;
4346 p
+= CHARS_PER_LITTLENUM
;
4349 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
4350 while (size
>= CHARS_PER_LITTLENUM
)
4353 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
4354 size
-= CHARS_PER_LITTLENUM
;
4355 p
+= CHARS_PER_LITTLENUM
;
4360 nums
= generic_bignum
;
4361 while (size
>= CHARS_PER_LITTLENUM
)
4363 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
4365 size
-= CHARS_PER_LITTLENUM
;
4366 p
+= CHARS_PER_LITTLENUM
;
4367 nbytes
-= CHARS_PER_LITTLENUM
;
4370 while (nbytes
>= CHARS_PER_LITTLENUM
)
4372 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
4373 nbytes
-= CHARS_PER_LITTLENUM
;
4374 p
+= CHARS_PER_LITTLENUM
;
4379 emit_expr_fix (exp
, nbytes
, frag_now
, p
);
4383 emit_expr_fix (expressionS
*exp
, unsigned int nbytes
, fragS
*frag
, char *p
)
4385 memset (p
, 0, nbytes
);
4387 /* Generate a fixS to record the symbol value. */
4389 #ifdef TC_CONS_FIX_NEW
4390 TC_CONS_FIX_NEW (frag
, p
- frag
->fr_literal
, nbytes
, exp
);
4393 bfd_reloc_code_real_type r
;
4413 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
4417 fix_new_exp (frag
, p
- frag
->fr_literal
, (int) nbytes
, exp
,
4423 #ifdef BITFIELD_CONS_EXPRESSIONS
4425 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
4426 w:x,y:z, where w and y are bitwidths and x and y are values. They
4427 then pack them all together. We do a little better in that we allow
4428 them in words, longs, etc. and we'll pack them in target byte order
4431 The rules are: pack least significant bit first, if a field doesn't
4432 entirely fit, put it in the next unit. Overflowing the bitfield is
4433 explicitly *not* even a warning. The bitwidth should be considered
4436 To use this function the tc-XXX.h file should define
4437 BITFIELD_CONS_EXPRESSIONS. */
4440 parse_bitfield_cons (exp
, nbytes
)
4442 unsigned int nbytes
;
4444 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
4445 char *hold
= input_line_pointer
;
4447 (void) expression (exp
);
4449 if (*input_line_pointer
== ':')
4456 unsigned long width
;
4458 if (*input_line_pointer
!= ':')
4460 input_line_pointer
= hold
;
4462 } /* Next piece is not a bitfield. */
4464 /* In the general case, we can't allow
4465 full expressions with symbol
4466 differences and such. The relocation
4467 entries for symbols not defined in this
4468 assembly would require arbitrary field
4469 widths, positions, and masks which most
4470 of our current object formats don't
4473 In the specific case where a symbol
4474 *is* defined in this assembly, we
4475 *could* build fixups and track it, but
4476 this could lead to confusion for the
4477 backends. I'm lazy. I'll take any
4478 SEG_ABSOLUTE. I think that means that
4479 you can use a previous .set or
4480 .equ type symbol. xoxorich. */
4482 if (exp
->X_op
== O_absent
)
4484 as_warn (_("using a bit field width of zero"));
4485 exp
->X_add_number
= 0;
4486 exp
->X_op
= O_constant
;
4487 } /* Implied zero width bitfield. */
4489 if (exp
->X_op
!= O_constant
)
4491 *input_line_pointer
= '\0';
4492 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
4493 *input_line_pointer
= ':';
4494 demand_empty_rest_of_line ();
4496 } /* Too complex. */
4498 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
4500 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
4501 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
4502 width
= BITS_PER_CHAR
* nbytes
;
4505 if (width
> bits_available
)
4507 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
4508 input_line_pointer
= hold
;
4509 exp
->X_add_number
= value
;
4514 hold
= ++input_line_pointer
;
4516 (void) expression (exp
);
4517 if (exp
->X_op
!= O_constant
)
4519 char cache
= *input_line_pointer
;
4521 *input_line_pointer
= '\0';
4522 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
4523 *input_line_pointer
= cache
;
4524 demand_empty_rest_of_line ();
4526 } /* Too complex. */
4528 value
|= ((~(-1 << width
) & exp
->X_add_number
)
4529 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
4531 if ((bits_available
-= width
) == 0
4532 || is_it_end_of_statement ()
4533 || *input_line_pointer
!= ',')
4536 } /* All the bitfields we're gonna get. */
4538 hold
= ++input_line_pointer
;
4539 (void) expression (exp
);
4542 exp
->X_add_number
= value
;
4543 exp
->X_op
= O_constant
;
4544 exp
->X_unsigned
= 1;
4545 exp
->X_extrabit
= 0;
4549 #endif /* BITFIELD_CONS_EXPRESSIONS */
4551 /* Handle an MRI style string expression. */
4555 parse_mri_cons (exp
, nbytes
)
4557 unsigned int nbytes
;
4559 if (*input_line_pointer
!= '\''
4560 && (input_line_pointer
[1] != '\''
4561 || (*input_line_pointer
!= 'A'
4562 && *input_line_pointer
!= 'E')))
4563 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
4567 unsigned int result
= 0;
4569 /* An MRI style string. Cut into as many bytes as will fit into
4570 a nbyte chunk, left justify if necessary, and separate with
4571 commas so we can try again later. */
4572 if (*input_line_pointer
== 'A')
4573 ++input_line_pointer
;
4574 else if (*input_line_pointer
== 'E')
4576 as_bad (_("EBCDIC constants are not supported"));
4577 ++input_line_pointer
;
4580 input_line_pointer
++;
4581 for (scan
= 0; scan
< nbytes
; scan
++)
4583 if (*input_line_pointer
== '\'')
4585 if (input_line_pointer
[1] == '\'')
4587 input_line_pointer
++;
4592 result
= (result
<< 8) | (*input_line_pointer
++);
4596 while (scan
< nbytes
)
4602 /* Create correct expression. */
4603 exp
->X_op
= O_constant
;
4604 exp
->X_add_number
= result
;
4606 /* Fake it so that we can read the next char too. */
4607 if (input_line_pointer
[0] != '\'' ||
4608 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
4610 input_line_pointer
-= 2;
4611 input_line_pointer
[0] = ',';
4612 input_line_pointer
[1] = '\'';
4615 input_line_pointer
++;
4618 #endif /* TC_M68K */
4620 #ifdef REPEAT_CONS_EXPRESSIONS
4622 /* Parse a repeat expression for cons. This is used by the MIPS
4623 assembler. The format is NUMBER:COUNT; NUMBER appears in the
4624 object file COUNT times.
4626 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
4629 parse_repeat_cons (exp
, nbytes
)
4631 unsigned int nbytes
;
4638 if (*input_line_pointer
!= ':')
4640 /* No repeat count. */
4644 ++input_line_pointer
;
4645 expression (&count
);
4646 if (count
.X_op
!= O_constant
4647 || count
.X_add_number
<= 0)
4649 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4653 /* The cons function is going to output this expression once. So we
4654 output it count - 1 times. */
4655 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
4656 emit_expr (exp
, nbytes
);
4659 #endif /* REPEAT_CONS_EXPRESSIONS */
4661 /* Parse a floating point number represented as a hex constant. This
4662 permits users to specify the exact bits they want in the floating
4666 hex_float (int float_type
, char *bytes
)
4698 as_bad (_("unknown floating type type '%c'"), float_type
);
4702 /* It would be nice if we could go through expression to parse the
4703 hex constant, but if we get a bignum it's a pain to sort it into
4704 the buffer correctly. */
4706 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
4710 /* The MRI assembler accepts arbitrary underscores strewn about
4711 through the hex constant, so we ignore them as well. */
4712 if (*input_line_pointer
== '_')
4714 ++input_line_pointer
;
4720 as_warn (_("floating point constant too large"));
4723 d
= hex_value (*input_line_pointer
) << 4;
4724 ++input_line_pointer
;
4725 while (*input_line_pointer
== '_')
4726 ++input_line_pointer
;
4727 if (hex_p (*input_line_pointer
))
4729 d
+= hex_value (*input_line_pointer
);
4730 ++input_line_pointer
;
4732 if (target_big_endian
)
4735 bytes
[length
- i
- 1] = d
;
4741 if (target_big_endian
)
4742 memset (bytes
+ i
, 0, length
- i
);
4744 memset (bytes
, 0, length
- i
);
4752 CONStruct some more frag chars of .floats .ffloats etc.
4753 Makes 0 or more new frags.
4754 If need_pass_2 == 1, no frags are emitted.
4755 This understands only floating literals, not expressions. Sorry.
4757 A floating constant is defined by atof_generic(), except it is preceded
4758 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4759 reading, I decided to be incompatible. This always tries to give you
4760 rounded bits to the precision of the pseudo-op. Former AS did premature
4761 truncation, restored noisy bits instead of trailing 0s AND gave you
4762 a choice of 2 flavours of noise according to which of 2 floating-point
4763 scanners you directed AS to use.
4765 In: input_line_pointer->whitespace before, or '0' of flonum. */
4768 float_cons (/* Clobbers input_line-pointer, checks end-of-line. */
4769 int float_type
/* 'f':.ffloat ... 'F':.float ... */)
4772 int length
; /* Number of chars in an object. */
4773 char *err
; /* Error from scanning floating literal. */
4774 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4776 if (is_it_end_of_statement ())
4778 demand_empty_rest_of_line ();
4782 #ifdef md_flush_pending_output
4783 md_flush_pending_output ();
4786 #ifdef md_cons_align
4792 /* input_line_pointer->1st char of a flonum (we hope!). */
4795 /* Skip any 0{letter} that may be present. Don't even check if the
4796 letter is legal. Someone may invent a "z" format and this routine
4797 has no use for such information. Lusers beware: you get
4798 diagnostics if your input is ill-conditioned. */
4799 if (input_line_pointer
[0] == '0'
4800 && ISALPHA (input_line_pointer
[1]))
4801 input_line_pointer
+= 2;
4803 /* Accept :xxxx, where the x's are hex digits, for a floating
4804 point with the exact digits specified. */
4805 if (input_line_pointer
[0] == ':')
4807 ++input_line_pointer
;
4808 length
= hex_float (float_type
, temp
);
4811 ignore_rest_of_line ();
4817 err
= md_atof (float_type
, temp
, &length
);
4818 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4819 know (err
!= NULL
|| length
> 0);
4822 as_bad (_("bad floating literal: %s"), err
);
4823 ignore_rest_of_line ();
4834 #ifdef REPEAT_CONS_EXPRESSIONS
4835 if (*input_line_pointer
== ':')
4837 expressionS count_exp
;
4839 ++input_line_pointer
;
4840 expression (&count_exp
);
4842 if (count_exp
.X_op
!= O_constant
4843 || count_exp
.X_add_number
<= 0)
4844 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4846 count
= count_exp
.X_add_number
;
4850 while (--count
>= 0)
4852 p
= frag_more (length
);
4853 memcpy (p
, temp
, (unsigned int) length
);
4858 while (*input_line_pointer
++ == ',');
4860 /* Put terminator back into stream. */
4861 --input_line_pointer
;
4862 demand_empty_rest_of_line ();
4865 /* Return the size of a LEB128 value. */
4868 sizeof_sleb128 (offsetT value
)
4875 byte
= (value
& 0x7f);
4876 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4877 Fortunately, we can structure things so that the extra work reduces
4878 to a noop on systems that do things "properly". */
4879 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4882 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4883 || ((value
== -1) && ((byte
& 0x40) != 0))));
4889 sizeof_uleb128 (valueT value
)
4904 sizeof_leb128 (valueT value
, int sign
)
4907 return sizeof_sleb128 ((offsetT
) value
);
4909 return sizeof_uleb128 (value
);
4912 /* Output a LEB128 value. */
4915 output_sleb128 (char *p
, offsetT value
)
4922 unsigned byte
= (value
& 0x7f);
4924 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4925 Fortunately, we can structure things so that the extra work reduces
4926 to a noop on systems that do things "properly". */
4927 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4929 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4930 || ((value
== -1) && ((byte
& 0x40) != 0))));
4942 output_uleb128 (char *p
, valueT value
)
4948 unsigned byte
= (value
& 0x7f);
4951 /* More bytes to follow. */
4962 output_leb128 (char *p
, valueT value
, int sign
)
4965 return output_sleb128 (p
, (offsetT
) value
);
4967 return output_uleb128 (p
, value
);
4970 /* Do the same for bignums. We combine sizeof with output here in that
4971 we don't output for NULL values of P. It isn't really as critical as
4972 for "normal" values that this be streamlined. */
4975 output_big_sleb128 (char *p
, LITTLENUM_TYPE
*bignum
, int size
)
4982 /* Strip leading sign extensions off the bignum. */
4984 && bignum
[size
- 1] == LITTLENUM_MASK
4985 && bignum
[size
- 2] > LITTLENUM_MASK
/ 2)
4990 /* OR in the next part of the littlenum. */
4991 val
|= (*bignum
<< loaded
);
4992 loaded
+= LITTLENUM_NUMBER_OF_BITS
;
4996 /* Add bytes until there are less than 7 bits left in VAL
4997 or until every non-sign bit has been written. */
5004 || val
!= ((byte
& 0x40) == 0 ? 0 : ((valueT
) 1 << loaded
) - 1))
5011 while ((byte
& 0x80) != 0 && loaded
>= 7);
5015 /* Mop up any left-over bits (of which there will be less than 7). */
5016 if ((byte
& 0x80) != 0)
5018 /* Sign-extend VAL. */
5019 if (val
& (1 << (loaded
- 1)))
5020 val
|= ~0 << loaded
;
5030 output_big_uleb128 (char *p
, LITTLENUM_TYPE
*bignum
, int size
)
5037 /* Strip leading zeros off the bignum. */
5038 /* XXX: Is this needed? */
5039 while (size
> 0 && bignum
[size
- 1] == 0)
5044 if (loaded
< 7 && size
> 0)
5046 val
|= (*bignum
<< loaded
);
5047 loaded
+= 8 * CHARS_PER_LITTLENUM
;
5056 if (size
> 0 || val
)
5063 while (byte
& 0x80);
5069 output_big_leb128 (char *p
, LITTLENUM_TYPE
*bignum
, int size
, int sign
)
5072 return output_big_sleb128 (p
, bignum
, size
);
5074 return output_big_uleb128 (p
, bignum
, size
);
5077 /* Generate the appropriate fragments for a given expression to emit a
5081 emit_leb128_expr (expressionS
*exp
, int sign
)
5083 operatorT op
= exp
->X_op
;
5084 unsigned int nbytes
;
5086 if (op
== O_absent
|| op
== O_illegal
)
5088 as_warn (_("zero assumed for missing expression"));
5089 exp
->X_add_number
= 0;
5092 else if (op
== O_big
&& exp
->X_add_number
<= 0)
5094 as_bad (_("floating point number invalid"));
5095 exp
->X_add_number
= 0;
5098 else if (op
== O_register
)
5100 as_warn (_("register value used as expression"));
5103 else if (op
== O_constant
5105 && (exp
->X_add_number
< 0) == !exp
->X_extrabit
)
5107 /* We're outputting a signed leb128 and the sign of X_add_number
5108 doesn't reflect the sign of the original value. Convert EXP
5109 to a correctly-extended bignum instead. */
5110 convert_to_bignum (exp
, exp
->X_extrabit
);
5114 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
5115 a signal that this is leb128 data. It shouldn't optimize this away. */
5116 nbytes
= (unsigned int) -1;
5117 if (check_eh_frame (exp
, &nbytes
))
5120 /* Let the backend know that subsequent data may be byte aligned. */
5121 #ifdef md_cons_align
5125 if (op
== O_constant
)
5127 /* If we've got a constant, emit the thing directly right now. */
5129 valueT value
= exp
->X_add_number
;
5133 size
= sizeof_leb128 (value
, sign
);
5134 p
= frag_more (size
);
5135 output_leb128 (p
, value
, sign
);
5137 else if (op
== O_big
)
5139 /* O_big is a different sort of constant. */
5144 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
5145 p
= frag_more (size
);
5146 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
5150 /* Otherwise, we have to create a variable sized fragment and
5151 resolve things later. */
5153 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
5154 make_expr_symbol (exp
), 0, (char *) NULL
);
5158 /* Parse the .sleb128 and .uleb128 pseudos. */
5165 #ifdef md_flush_pending_output
5166 md_flush_pending_output ();
5172 emit_leb128_expr (&exp
, sign
);
5174 while (*input_line_pointer
++ == ',');
5176 input_line_pointer
--;
5177 demand_empty_rest_of_line ();
5181 stringer_append_char (int c
, int bitsize
)
5183 if (!target_big_endian
)
5184 FRAG_APPEND_1_CHAR (c
);
5189 FRAG_APPEND_1_CHAR (0);
5190 FRAG_APPEND_1_CHAR (0);
5191 FRAG_APPEND_1_CHAR (0);
5192 FRAG_APPEND_1_CHAR (0);
5195 FRAG_APPEND_1_CHAR (0);
5196 FRAG_APPEND_1_CHAR (0);
5199 FRAG_APPEND_1_CHAR (0);
5204 /* Called with invalid bitsize argument. */
5208 if (target_big_endian
)
5209 FRAG_APPEND_1_CHAR (c
);
5212 /* Worker to do .ascii etc statements.
5213 Reads 0 or more ',' separated, double-quoted strings.
5214 Caller should have checked need_pass_2 is FALSE because we don't
5216 Checks for end-of-line.
5217 BITS_APPENDZERO says how many bits are in a target char.
5218 The bottom bit is set if a NUL char should be appended to the strings. */
5221 stringer (int bits_appendzero
)
5223 const int bitsize
= bits_appendzero
& ~7;
5224 const int append_zero
= bits_appendzero
& 1;
5226 #if !defined(NO_LISTING) && defined (OBJ_ELF)
5230 #ifdef md_flush_pending_output
5231 md_flush_pending_output ();
5234 #ifdef md_cons_align
5238 /* The following awkward logic is to parse ZERO or more strings,
5239 comma separated. Recall a string expression includes spaces
5240 before the opening '\"' and spaces after the closing '\"'.
5241 We fake a leading ',' if there is (supposed to be)
5242 a 1st, expression. We keep demanding expressions for each ','. */
5243 if (is_it_end_of_statement ())
5245 c
= 0; /* Skip loop. */
5246 ++input_line_pointer
; /* Compensate for end of loop. */
5250 c
= ','; /* Do loop. */
5252 /* If we have been switched into the abs_section then we
5253 will not have an obstack onto which we can hang strings. */
5254 if (now_seg
== absolute_section
)
5256 as_bad (_("strings must be placed into a section"));
5258 ignore_rest_of_line ();
5261 while (c
== ',' || c
== '<' || c
== '"')
5264 switch (*input_line_pointer
)
5267 ++input_line_pointer
; /*->1st char of string. */
5268 #if !defined(NO_LISTING) && defined (OBJ_ELF)
5269 start
= input_line_pointer
;
5272 while (is_a_char (c
= next_char_of_string ()))
5273 stringer_append_char (c
, bitsize
);
5276 stringer_append_char (0, bitsize
);
5278 know (input_line_pointer
[-1] == '\"');
5280 #if !defined(NO_LISTING) && defined (OBJ_ELF)
5281 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
5282 will emit .string with a filename in the .debug section
5283 after a sequence of constants. See the comment in
5284 emit_expr for the sequence. emit_expr will set
5285 dwarf_file_string to non-zero if this string might be a
5286 source file name. */
5287 if (strcmp (segment_name (now_seg
), ".debug") != 0)
5288 dwarf_file_string
= 0;
5289 else if (dwarf_file_string
)
5291 c
= input_line_pointer
[-1];
5292 input_line_pointer
[-1] = '\0';
5293 listing_source_file (start
);
5294 input_line_pointer
[-1] = c
;
5300 input_line_pointer
++;
5301 c
= get_single_number ();
5302 stringer_append_char (c
, bitsize
);
5303 if (*input_line_pointer
!= '>')
5304 as_bad (_("expected <nn>"));
5306 input_line_pointer
++;
5309 input_line_pointer
++;
5313 c
= *input_line_pointer
;
5316 demand_empty_rest_of_line ();
5319 /* FIXME-SOMEDAY: I had trouble here on characters with the
5320 high bits set. We'll probably also have trouble with
5321 multibyte chars, wide chars, etc. Also be careful about
5322 returning values bigger than 1 byte. xoxorich. */
5325 next_char_of_string (void)
5329 c
= *input_line_pointer
++ & CHAR_MASK
;
5337 as_warn (_("unterminated string; newline inserted"));
5338 bump_line_counters ();
5341 #ifndef NO_STRING_ESCAPES
5343 switch (c
= *input_line_pointer
++)
5371 break; /* As itself. */
5387 for (i
= 0, number
= 0;
5388 ISDIGIT (c
) && i
< 3;
5389 c
= *input_line_pointer
++, i
++)
5391 number
= number
* 8 + c
- '0';
5396 --input_line_pointer
;
5405 c
= *input_line_pointer
++;
5406 while (ISXDIGIT (c
))
5409 number
= number
* 16 + c
- '0';
5410 else if (ISUPPER (c
))
5411 number
= number
* 16 + c
- 'A' + 10;
5413 number
= number
* 16 + c
- 'a' + 10;
5414 c
= *input_line_pointer
++;
5417 --input_line_pointer
;
5422 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
5423 as_warn (_("unterminated string; newline inserted"));
5425 bump_line_counters ();
5430 #ifdef ONLY_STANDARD_ESCAPES
5431 as_bad (_("bad escaped character in string"));
5433 #endif /* ONLY_STANDARD_ESCAPES */
5438 #endif /* ! defined (NO_STRING_ESCAPES) */
5447 get_segmented_expression (expressionS
*expP
)
5451 retval
= expression (expP
);
5452 if (expP
->X_op
== O_illegal
5453 || expP
->X_op
== O_absent
5454 || expP
->X_op
== O_big
)
5456 as_bad (_("expected address expression"));
5457 expP
->X_op
= O_constant
;
5458 expP
->X_add_number
= 0;
5459 retval
= absolute_section
;
5465 get_known_segmented_expression (expressionS
*expP
)
5467 segT retval
= get_segmented_expression (expP
);
5469 if (retval
== undefined_section
)
5471 /* There is no easy way to extract the undefined symbol from the
5473 if (expP
->X_add_symbol
!= NULL
5474 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
5475 as_warn (_("symbol \"%s\" undefined; zero assumed"),
5476 S_GET_NAME (expP
->X_add_symbol
));
5478 as_warn (_("some symbol undefined; zero assumed"));
5479 retval
= absolute_section
;
5480 expP
->X_op
= O_constant
;
5481 expP
->X_add_number
= 0;
5486 char /* Return terminator. */
5487 get_absolute_expression_and_terminator (long *val_pointer
/* Return value of expression. */)
5489 /* FIXME: val_pointer should probably be offsetT *. */
5490 *val_pointer
= (long) get_absolute_expression ();
5491 return (*input_line_pointer
++);
5494 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
5495 Give a warning if that happens. */
5498 demand_copy_C_string (int *len_pointer
)
5502 if ((s
= demand_copy_string (len_pointer
)) != 0)
5506 for (len
= *len_pointer
; len
> 0; len
--)
5513 as_bad (_("this string may not contain \'\\0\'"));
5521 /* Demand string, but return a safe (=private) copy of the string.
5522 Return NULL if we can't read a string here. */
5525 demand_copy_string (int *lenP
)
5533 if (*input_line_pointer
== '\"')
5535 input_line_pointer
++; /* Skip opening quote. */
5537 while (is_a_char (c
= next_char_of_string ()))
5539 obstack_1grow (¬es
, c
);
5542 /* JF this next line is so demand_copy_C_string will return a
5543 null terminated string. */
5544 obstack_1grow (¬es
, '\0');
5545 retval
= (char *) obstack_finish (¬es
);
5549 as_bad (_("missing string"));
5551 ignore_rest_of_line ();
5557 /* In: Input_line_pointer->next character.
5559 Do: Skip input_line_pointer over all whitespace.
5561 Out: 1 if input_line_pointer->end-of-line. */
5564 is_it_end_of_statement (void)
5567 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
5571 equals (char *sym_name
, int reassign
)
5576 input_line_pointer
++;
5577 if (*input_line_pointer
== '=')
5578 input_line_pointer
++;
5579 if (reassign
< 0 && *input_line_pointer
== '=')
5580 input_line_pointer
++;
5582 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
5583 input_line_pointer
++;
5586 stop
= mri_comment_field (&stopc
);
5588 assign_symbol (sym_name
, reassign
>= 0 ? !reassign
: reassign
);
5592 demand_empty_rest_of_line ();
5593 mri_comment_end (stop
, stopc
);
5597 /* .incbin -- include a file verbatim at the current location. */
5600 s_incbin (int x ATTRIBUTE_UNUSED
)
5611 #ifdef md_flush_pending_output
5612 md_flush_pending_output ();
5615 #ifdef md_cons_align
5620 filename
= demand_copy_string (& len
);
5621 if (filename
== NULL
)
5626 /* Look for optional skip and count. */
5627 if (* input_line_pointer
== ',')
5629 ++ input_line_pointer
;
5630 skip
= get_absolute_expression ();
5634 if (* input_line_pointer
== ',')
5636 ++ input_line_pointer
;
5638 count
= get_absolute_expression ();
5640 as_warn (_(".incbin count zero, ignoring `%s'"), filename
);
5646 demand_empty_rest_of_line ();
5648 /* Try opening absolute path first, then try include dirs. */
5649 binfile
= fopen (filename
, FOPEN_RB
);
5650 if (binfile
== NULL
)
5654 path
= (char *) xmalloc ((unsigned long) len
+ include_dir_maxlen
+ 5);
5656 for (i
= 0; i
< include_dir_count
; i
++)
5658 sprintf (path
, "%s/%s", include_dirs
[i
], filename
);
5660 binfile
= fopen (path
, FOPEN_RB
);
5661 if (binfile
!= NULL
)
5665 if (binfile
== NULL
)
5666 as_bad (_("file not found: %s"), filename
);
5669 path
= xstrdup (filename
);
5675 register_dependency (path
);
5677 /* Compute the length of the file. */
5678 if (fseek (binfile
, 0, SEEK_END
) != 0)
5680 as_bad (_("seek to end of .incbin file failed `%s'"), path
);
5683 file_len
= ftell (binfile
);
5685 /* If a count was not specified use the remainder of the file. */
5687 count
= file_len
- skip
;
5689 if (skip
< 0 || count
< 0 || file_len
< 0 || skip
+ count
> file_len
)
5691 as_bad (_("skip (%ld) or count (%ld) invalid for file size (%ld)"),
5692 skip
, count
, file_len
);
5696 if (fseek (binfile
, skip
, SEEK_SET
) != 0)
5698 as_bad (_("could not skip to %ld in file `%s'"), skip
, path
);
5702 /* Allocate frag space and store file contents in it. */
5703 binfrag
= frag_more (count
);
5705 bytes
= fread (binfrag
, 1, count
, binfile
);
5707 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
5708 path
, bytes
, count
);
5711 if (binfile
!= NULL
)
5717 /* .include -- include a file at this point. */
5720 s_include (int arg ATTRIBUTE_UNUSED
)
5729 filename
= demand_copy_string (&i
);
5730 if (filename
== NULL
)
5732 /* demand_copy_string has already printed an error and
5733 called ignore_rest_of_line. */
5741 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
5742 && *input_line_pointer
!= ' '
5743 && *input_line_pointer
!= '\t')
5745 obstack_1grow (¬es
, *input_line_pointer
);
5746 ++input_line_pointer
;
5750 obstack_1grow (¬es
, '\0');
5751 filename
= (char *) obstack_finish (¬es
);
5752 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5753 ++input_line_pointer
;
5756 demand_empty_rest_of_line ();
5757 path
= (char *) xmalloc ((unsigned long) i
5758 + include_dir_maxlen
+ 5 /* slop */ );
5760 for (i
= 0; i
< include_dir_count
; i
++)
5762 strcpy (path
, include_dirs
[i
]);
5764 strcat (path
, filename
);
5765 if (0 != (try_file
= fopen (path
, FOPEN_RT
)))
5775 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
5776 register_dependency (path
);
5777 input_scrub_insert_file (path
);
5781 add_include_dir (char *path
)
5785 if (include_dir_count
== 0)
5787 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
5788 include_dirs
[0] = "."; /* Current dir. */
5789 include_dir_count
= 2;
5793 include_dir_count
++;
5795 (char **) xrealloc (include_dirs
,
5796 include_dir_count
* sizeof (*include_dirs
));
5799 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
5802 if (i
> include_dir_maxlen
)
5803 include_dir_maxlen
= i
;
5806 /* Output debugging information to denote the source file. */
5809 generate_file_debug (void)
5811 if (debug_type
== DEBUG_STABS
)
5812 stabs_generate_asm_file ();
5815 /* Output line number debugging information for the current source line. */
5818 generate_lineno_debug (void)
5822 case DEBUG_UNSPECIFIED
:
5827 stabs_generate_asm_lineno ();
5830 ecoff_generate_asm_lineno ();
5833 /* ??? We could here indicate to dwarf2dbg.c that something
5834 has changed. However, since there is additional backend
5835 support that is required (calling dwarf2_emit_insn), we
5836 let dwarf2dbg.c call as_where on its own. */
5841 /* Output debugging information to mark a function entry point or end point.
5842 END_P is zero for .func, and non-zero for .endfunc. */
5847 do_s_func (end_p
, NULL
);
5850 /* Subroutine of s_func so targets can choose a different default prefix.
5851 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5854 do_s_func (int end_p
, const char *default_prefix
)
5856 /* Record the current function so that we can issue an error message for
5857 misplaced .func,.endfunc, and also so that .endfunc needs no
5859 static char *current_name
;
5860 static char *current_label
;
5864 if (current_name
== NULL
)
5866 as_bad (_("missing .func"));
5867 ignore_rest_of_line ();
5871 if (debug_type
== DEBUG_STABS
)
5872 stabs_generate_asm_endfunc (current_name
, current_label
);
5874 current_name
= current_label
= NULL
;
5879 char delim1
, delim2
;
5881 if (current_name
!= NULL
)
5883 as_bad (_(".endfunc missing for previous .func"));
5884 ignore_rest_of_line ();
5888 name
= input_line_pointer
;
5889 delim1
= get_symbol_end ();
5890 name
= xstrdup (name
);
5891 *input_line_pointer
= delim1
;
5893 if (*input_line_pointer
!= ',')
5897 if (asprintf (&label
, "%s%s", default_prefix
, name
) == -1)
5898 as_fatal ("%s", xstrerror (errno
));
5902 char leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5903 /* Missing entry point, use function's name with the leading
5907 if (asprintf (&label
, "%c%s", leading_char
, name
) == -1)
5908 as_fatal ("%s", xstrerror (errno
));
5916 ++input_line_pointer
;
5918 label
= input_line_pointer
;
5919 delim2
= get_symbol_end ();
5920 label
= xstrdup (label
);
5921 *input_line_pointer
= delim2
;
5924 if (debug_type
== DEBUG_STABS
)
5925 stabs_generate_asm_func (name
, label
);
5927 current_name
= name
;
5928 current_label
= label
;
5931 demand_empty_rest_of_line ();
5934 #ifdef HANDLE_BUNDLE
5937 s_bundle_align_mode (int arg ATTRIBUTE_UNUSED
)
5939 unsigned int align
= get_absolute_expression ();
5941 demand_empty_rest_of_line ();
5943 if (align
> (unsigned int) TC_ALIGN_LIMIT
)
5944 as_fatal (_(".bundle_align_mode alignment too large (maximum %u)"),
5945 (unsigned int) TC_ALIGN_LIMIT
);
5947 if (bundle_lock_frag
!= NULL
)
5949 as_bad (_("cannot change .bundle_align_mode inside .bundle_lock"));
5953 bundle_align_p2
= align
;
5957 s_bundle_lock (int arg ATTRIBUTE_UNUSED
)
5959 demand_empty_rest_of_line ();
5961 if (bundle_align_p2
== 0)
5963 as_bad (_(".bundle_lock is meaningless without .bundle_align_mode"));
5967 if (bundle_lock_depth
== 0)
5969 bundle_lock_frchain
= frchain_now
;
5970 bundle_lock_frag
= start_bundle ();
5972 ++bundle_lock_depth
;
5976 s_bundle_unlock (int arg ATTRIBUTE_UNUSED
)
5980 demand_empty_rest_of_line ();
5982 if (bundle_lock_frag
== NULL
)
5984 as_bad (_(".bundle_unlock without preceding .bundle_lock"));
5988 gas_assert (bundle_align_p2
> 0);
5990 gas_assert (bundle_lock_depth
> 0);
5991 if (--bundle_lock_depth
> 0)
5994 size
= pending_bundle_size (bundle_lock_frag
);
5996 if (size
> (1U << bundle_align_p2
))
5997 as_bad (_(".bundle_lock sequence is %u bytes, but bundle size only %u"),
5998 size
, 1 << bundle_align_p2
);
6000 finish_bundle (bundle_lock_frag
, size
);
6002 bundle_lock_frag
= NULL
;
6003 bundle_lock_frchain
= NULL
;
6006 #endif /* HANDLE_BUNDLE */
6009 s_ignore (int arg ATTRIBUTE_UNUSED
)
6011 ignore_rest_of_line ();
6015 read_print_statistics (FILE *file
)
6017 hash_print_statistics (file
, "pseudo-op table", po_hash
);
6020 /* Inserts the given line into the input stream.
6022 This call avoids macro/conditionals nesting checking, since the contents of
6023 the line are assumed to replace the contents of a line already scanned.
6025 An appropriate use of this function would be substitution of input lines when
6026 called by md_start_line_hook(). The given line is assumed to already be
6027 properly scrubbed. */
6030 input_scrub_insert_line (const char *line
)
6033 size_t len
= strlen (line
);
6034 sb_build (&newline
, len
);
6035 sb_add_buffer (&newline
, line
, len
);
6036 input_scrub_include_sb (&newline
, input_line_pointer
, 0);
6038 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
6041 /* Insert a file into the input stream; the path must resolve to an actual
6042 file; no include path searching or dependency registering is performed. */
6045 input_scrub_insert_file (char *path
)
6047 input_scrub_include_file (path
, input_line_pointer
);
6048 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
6051 /* Find the end of a line, considering quotation and escaping of quotes. */
6053 #if !defined(TC_SINGLE_QUOTE_STRINGS) && defined(SINGLE_QUOTE_STRINGS)
6054 # define TC_SINGLE_QUOTE_STRINGS 1
6058 _find_end_of_line (char *s
, int mri_string
, int insn ATTRIBUTE_UNUSED
,
6061 char inquote
= '\0';
6064 while (!is_end_of_line
[(unsigned char) *s
]
6065 || (inquote
&& !ISCNTRL (*s
))
6066 || (inquote
== '\'' && flag_mri
)
6067 #ifdef TC_EOL_IN_INSN
6068 || (insn
&& TC_EOL_IN_INSN (s
))
6070 /* PR 6926: When we are parsing the body of a macro the sequence
6071 \@ is special - it refers to the invocation count. If the @
6072 character happens to be registered as a line-separator character
6073 by the target, then the is_end_of_line[] test above will have
6074 returned true, but we need to ignore the line separating
6075 semantics in this particular case. */
6076 || (in_macro
&& inescape
&& *s
== '@')
6079 if (mri_string
&& *s
== '\'')
6083 else if (*s
== '\\')
6087 #ifdef TC_SINGLE_QUOTE_STRINGS
6088 || (TC_SINGLE_QUOTE_STRINGS
&& *s
== '\'')
6095 as_warn (_("missing closing `%c'"), inquote
);
6097 as_warn (_("stray `\\'"));
6102 find_end_of_line (char *s
, int mri_string
)
6104 return _find_end_of_line (s
, mri_string
, 0, 0);