1 /* read.c - read a source file -
2 Copyright (C) 1986-2025 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 supposed 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"
41 #include "scfidw2gen.h"
44 #include "filenames.h"
49 #ifndef TC_START_LABEL
50 #define TC_START_LABEL(STR, NUL_CHAR, NEXT_CHAR) (NEXT_CHAR == ':')
53 /* Set by the object-format or the target. */
54 #ifndef TC_IMPLICIT_LCOMM_ALIGNMENT
55 #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) \
60 else if ((SIZE) >= 4) \
62 else if ((SIZE) >= 2) \
70 char *input_line_pointer
; /*->next char of source file to parse. */
71 bool input_from_string
= false;
73 #if BITS_PER_CHAR != 8
74 /* The following table is indexed by[(char)] and will break if
75 a char does not have exactly 256 states (hopefully 0:255!)! */
80 #define LEX_CR LEX_WHITE
82 #define LEX_CR LEX_EOL
90 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
95 /* The Delta 68k assembler permits % inside label names. */
100 /* The PowerPC Windows NT assemblers permits ? inside label names. */
105 /* The IA-64 assembler uses # as a suffix designating a symbol. We include
106 it in the symbol and strip it out in tc_canonicalize_symbol_name. */
115 /* The Delta 68k assembler permits ~ at start of label names. */
119 /* Used by is_... macros. our ctype[]. */
120 char lex_type
[256] = {
121 0x20, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0x20, 0, 0, LEX_CR
, 0, 0, /* @ABCDEFGHIJKLMNO */
122 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
123 8, 0, 0, LEX_HASH
, LEX_DOLLAR
, LEX_PCT
, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
124 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM
, /* 0123456789:;<=>? */
125 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
126 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 3, /* PQRSTUVWXYZ[\]^_ */
127 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
128 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, LEX_TILDE
, 0, /* pqrstuvwxyz{|}~. */
129 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
130 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
131 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
132 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
133 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
134 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
135 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
136 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
139 #ifndef TC_CASE_SENSITIVE
140 char original_case_string
[128];
143 /* Functions private to this file. */
145 static char *buffer
; /* 1st char of each buffer of lines is here. */
146 static char *buffer_limit
; /*->1 + last char in buffer. */
148 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1
149 in the tc-<CPU>.h file. See the "Porting GAS" section of the
151 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
153 /* Variables for handling include file directory table. */
155 /* Table of pointers to directories to search for .include's. */
156 const char **include_dirs
;
158 /* How many are in the table. */
159 size_t include_dir_count
;
161 /* Length of longest in table. */
162 size_t include_dir_maxlen
;
164 #ifndef WORKING_DOT_WORD
165 struct broken_word
*broken_words
;
166 int new_broken_words
;
169 /* The current offset into the absolute section. We don't try to
170 build frags in the absolute section, since no data can be stored
171 there. We just keep track of the current offset. */
172 addressT abs_section_offset
;
174 /* If this line had an MRI style label, it is stored in this variable.
175 This is used by some of the MRI pseudo-ops. */
178 /* This global variable is used to support MRI common sections. We
179 translate such sections into a common symbol. This variable is
180 non-NULL when we are in an MRI common section. */
181 symbolS
*mri_common_symbol
;
183 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
184 need to align to an even byte boundary unless the next pseudo-op is
185 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
187 static int mri_pending_align
;
189 /* Record the current function so that we can issue an error message for
190 misplaced .func,.endfunc, and also so that .endfunc needs no
192 static char *current_name
;
193 static char *current_label
;
197 static int dwarf_file
;
198 static int dwarf_line
;
200 /* This variable is set to be non-zero if the next string we see might
201 be the name of the source file in DWARF debugging information. See
202 the comment in emit_expr for the format we look for. */
203 static int dwarf_file_string
;
207 /* If the target defines the md_frag_max_var hook then we know
208 enough to implement the .bundle_align_mode features. */
209 #ifdef md_frag_max_var
210 # define HANDLE_BUNDLE
214 /* .bundle_align_mode sets this. Normally it's zero. When nonzero,
215 it's the exponent of the bundle size, and aligned instruction bundle
216 mode is in effect. */
217 static unsigned int bundle_align_p2
;
219 /* These are set by .bundle_lock and .bundle_unlock. .bundle_lock sets
220 bundle_lock_frag to frag_now and then starts a new frag with
221 frag_align_code. At the same time, bundle_lock_frain gets frchain_now,
222 so that .bundle_unlock can verify that we didn't change segments.
223 .bundle_unlock resets both to NULL. If we detect a bundling violation,
224 then we reset bundle_lock_frchain to NULL as an indicator that we've
225 already diagnosed the error with as_bad and don't need a cascade of
226 redundant errors, but bundle_lock_frag remains set to indicate that
227 we are expecting to see .bundle_unlock. */
228 static fragS
*bundle_lock_frag
;
229 static frchainS
*bundle_lock_frchain
;
231 /* This is incremented by .bundle_lock and decremented by .bundle_unlock,
233 static unsigned int bundle_lock_depth
;
236 static void do_s_func (int end_p
, const char *default_prefix
);
237 static void s_altmacro (int);
238 static void s_bad_end (int);
239 static void s_errwarn_if (int);
240 static void s_reloc (int);
241 static int hex_float (int, char *);
242 static segT
get_known_segmented_expression (expressionS
* expP
);
243 static void pobegin (void);
244 static void poend (void);
245 static size_t get_macro_line_sb (sb
*);
246 static void generate_file_debug (void);
247 static char *_find_end_of_line (char *, int, int, int);
248 #if defined (TE_PE) && defined (O_secrel)
249 static void s_cv_comp (int sign
);
258 obj_read_begin_hook ();
260 obstack_begin (&cond_obstack
, chunksize
);
262 #ifndef tc_line_separator_chars
263 #define tc_line_separator_chars line_separator_chars
265 /* Use machine dependent syntax. */
266 for (p
= tc_line_separator_chars
; *p
; p
++)
267 lex_type
[(unsigned char) *p
] = LEX_EOS
;
270 lex_type
['?'] = LEX_BEGIN_NAME
| LEX_NAME
;
274 #ifndef WORKING_DOT_WORD
276 new_broken_words
= 0;
279 abs_section_offset
= 0;
282 mri_common_symbol
= NULL
;
283 mri_pending_align
= 0;
286 current_label
= NULL
;
292 dwarf_file_string
= 0;
298 bundle_lock_frag
= NULL
;
299 bundle_lock_frchain
= NULL
;
300 bundle_lock_depth
= 0;
309 _obstack_free (&cond_obstack
, NULL
);
311 free (current_label
);
315 #ifndef TC_ADDRESS_BYTES
316 #define TC_ADDRESS_BYTES address_bytes
321 /* Choose smallest of 1, 2, 4, 8 bytes that is large enough to
322 contain an address. */
323 int n
= (stdoutput
->arch_info
->bits_per_address
- 1) / 8;
331 /* Set up pseudo-op tables. */
333 static htab_t po_hash
;
335 static const pseudo_typeS potable
[] = {
336 {"abort", s_abort
, 0},
337 {"align", s_align_ptwo
, 0},
338 {"altmacro", s_altmacro
, 1},
339 {"ascii", stringer
, 8+0},
340 {"asciz", stringer
, 8+1},
341 {"balign", s_align_bytes
, 0},
342 {"balignw", s_align_bytes
, -2},
343 {"balignl", s_align_bytes
, -4},
344 {"base64", s_base64
, 0},
347 {"bundle_align_mode", s_bundle_align_mode
, 0},
348 {"bundle_lock", s_bundle_lock
, 0},
349 {"bundle_unlock", s_bundle_unlock
, 0},
353 {"common", s_mri_common
, 0},
354 {"common.s", s_mri_common
, 1},
355 #if defined (TE_PE) && defined (O_secrel)
356 {"cv_scomp", s_cv_comp
, 1},
357 {"cv_ucomp", s_cv_comp
, 0},
363 {"dc.d", float_cons
, 'd'},
365 {"dc.s", float_cons
, 'f'},
367 {"dc.x", float_cons
, 'x'},
369 {"dcb.b", s_space
, 1},
370 {"dcb.d", s_float_space
, 'd'},
371 {"dcb.l", s_space
, 4},
372 {"dcb.s", s_float_space
, 'f'},
373 {"dcb.w", s_space
, 2},
374 {"dcb.x", s_float_space
, 'x'},
376 {"ds.b", s_space
, 1},
377 {"ds.d", s_space
, 8},
378 {"ds.l", s_space
, 4},
379 {"ds.p", s_space
, 'p'},
380 {"ds.s", s_space
, 4},
381 {"ds.w", s_space
, 2},
382 {"ds.x", s_space
, 'x'},
383 {"debug", s_ignore
, 0},
388 {"double", float_cons
, 'd'},
390 {"eject", listing_eject
, 0}, /* Formfeed listing. */
392 {"elsec", s_else
, 0},
393 {"elseif", s_elseif
, (int) O_ne
},
395 {"endc", s_endif
, 0},
396 {"endfunc", s_func
, 1},
397 {"endif", s_endif
, 0},
398 {"endm", s_bad_end
, 0},
399 {"endr", s_bad_end
, 1},
405 {"errif", s_errwarn_if
, 1},
406 {"error", s_errwarn
, 1},
407 {"exitm", s_mexit
, 0},
409 {"extern", s_ignore
, 0}, /* We treat all undef as ext. */
413 {"float", float_cons
, 'f'},
414 {"format", s_ignore
, 0},
416 {"global", s_globl
, 0},
417 {"globl", s_globl
, 0},
419 {"if", s_if
, (int) O_ne
},
422 {"ifdef", s_ifdef
, 0},
423 {"ifeq", s_if
, (int) O_eq
},
424 {"ifeqs", s_ifeqs
, 0},
425 {"ifge", s_if
, (int) O_ge
},
426 {"ifgt", s_if
, (int) O_gt
},
427 {"ifle", s_if
, (int) O_le
},
428 {"iflt", s_if
, (int) O_lt
},
431 {"ifndef", s_ifdef
, 1},
432 {"ifne", s_if
, (int) O_ne
},
433 {"ifnes", s_ifeqs
, 1},
434 {"ifnotdef", s_ifdef
, 1},
435 {"incbin", s_incbin
, 0},
436 {"include", s_include
, 0},
442 {"lcomm", s_lcomm
, 0},
443 {"lflags", s_ignore
, 0}, /* Listing flags. */
444 {"linefile", s_linefile
, 0},
445 {"linkonce", s_linkonce
, 0},
446 {"list", listing_list
, 1}, /* Turn listing on. */
447 {"llen", listing_psize
, 1},
450 {"macro", s_macro
, 0},
451 {"mexit", s_mexit
, 0},
453 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
454 {"name", s_ignore
, 0},
455 {"noaltmacro", s_altmacro
, 0},
456 {"noformat", s_ignore
, 0},
457 {"nolist", listing_list
, 0}, /* Turn listing off. */
458 {"nopage", listing_nopage
, 0},
462 {"offset", s_struct
, 0},
464 {"p2align", s_align_ptwo
, 0},
465 {"p2alignw", s_align_ptwo
, -2},
466 {"p2alignl", s_align_ptwo
, -4},
467 {"page", listing_eject
, 0},
468 {"plen", listing_psize
, 0},
469 {"print", s_print
, 0},
470 {"psize", listing_psize
, 0}, /* Set paper size. */
471 {"purgem", s_purgem
, 0},
473 {"reloc", s_reloc
, 0},
477 {"sbttl", listing_title
, 1}, /* Subtitle of listing. */
482 {"single", float_cons
, 'f'},
484 {"space", s_space
, 0},
485 {"skip", s_space
, 0},
486 {"sleb128", s_leb128
, 1},
487 {"spc", s_ignore
, 0},
488 {"stabd", s_stab
, 'd'},
489 {"stabn", s_stab
, 'n'},
490 {"stabs", s_stab
, 's'},
491 {"string", stringer
, 8+1},
492 {"string8", stringer
, 8+1},
493 {"string16", stringer
, 16+1},
494 {"string32", stringer
, 32+1},
495 {"string64", stringer
, 64+1},
496 {"struct", s_struct
, 0},
500 /* This is for gcc to use. It's only just been added (2/94), so gcc
501 won't be able to use it for a while -- probably a year or more.
502 But once this has been released, check with gcc maintainers
503 before deleting it or even changing the spelling. */
504 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
505 /* If we're folding case -- done for some targets, not necessarily
506 all -- the above string in an input file will be converted to
507 this one. Match it either way... */
508 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
510 {"title", listing_title
, 0}, /* Listing title. */
511 {"ttl", listing_title
, 0},
513 {"uleb128", s_leb128
, 0},
517 {"xdef", s_globl
, 0},
518 {"xref", s_ignore
, 0},
519 {"xstabs", s_xstab
, 's'},
520 {"warnif", s_errwarn_if
, 0},
521 {"warning", s_errwarn
, 0},
522 {"weakref", s_weakref
, 0},
524 {"zero", s_space
, 0},
528 {NULL
, NULL
, 0} /* End sentinel. */
532 get_absolute_expr (expressionS
*exp
)
534 expression_and_evaluate (exp
);
536 if (exp
->X_op
!= O_constant
)
538 if (exp
->X_op
!= O_absent
)
539 as_bad (_("bad or irreducible absolute expression"));
540 exp
->X_add_number
= 0;
542 return exp
->X_add_number
;
546 get_absolute_expression (void)
550 return get_absolute_expr (&exp
);
553 static int pop_override_ok
;
554 static const char *pop_table_name
;
557 pop_insert (const pseudo_typeS
*table
)
559 const pseudo_typeS
*pop
;
560 for (pop
= table
; pop
->poc_name
; pop
++)
562 if (str_hash_insert (po_hash
, pop
->poc_name
, pop
, 0) != NULL
)
564 if (!pop_override_ok
)
565 as_fatal (_("error constructing %s pseudo-op table"),
571 #ifndef md_pop_insert
572 #define md_pop_insert() pop_insert(md_pseudo_table)
575 #ifndef obj_pop_insert
576 #define obj_pop_insert() pop_insert(obj_pseudo_table)
579 #ifndef cfi_pop_insert
580 #define cfi_pop_insert() pop_insert(cfi_pseudo_table)
583 #ifndef scfi_pop_insert
584 #define scfi_pop_insert() pop_insert(scfi_pseudo_table)
590 po_hash
= str_htab_create ();
592 /* Do the target-specific pseudo ops. */
593 pop_table_name
= "md";
597 /* Now object specific. Skip any that were in the target table. */
598 pop_table_name
= "obj";
602 /* Now portable ones. Skip any that we've seen already. */
603 pop_table_name
= "standard";
604 pop_insert (potable
);
607 #if defined (TARGET_USE_SCFI) && defined (TARGET_USE_GINSN)
610 pop_table_name
= "scfi";
616 pop_table_name
= "cfi";
624 htab_delete (po_hash
);
627 #define HANDLE_CONDITIONAL_ASSEMBLY(num_read) \
628 if (ignore_input ()) \
630 char *eol = find_end_of_line (input_line_pointer - (num_read), \
632 input_line_pointer = (input_line_pointer <= buffer_limit \
633 && eol >= buffer_limit) \
639 /* Helper function of read_a_source_file, which tries to expand a macro. */
641 try_macro (char term
, const char *line
)
647 if (check_macro (line
, &out
, &err
, ¯o
))
651 *input_line_pointer
++ = term
;
652 input_scrub_include_sb (&out
,
653 input_line_pointer
, expanding_macro
);
656 input_scrub_next_buffer (&input_line_pointer
);
658 md_macro_info (macro
);
666 /* Start a new instruction bundle. Returns the rs_align_code frag that
667 will be used to align the new bundle. */
671 fragS
*frag
= frag_now
;
673 frag_align_code (bundle_align_p2
, 0);
675 while (frag
->fr_type
!= rs_align_code
)
676 frag
= frag
->fr_next
;
678 gas_assert (frag
!= frag_now
);
680 /* Set initial alignment to zero. */
686 /* Calculate the maximum size after relaxation of the region starting
687 at the given frag and extending through frag_now (which is unfinished). */
689 pending_bundle_size (fragS
*frag
)
691 unsigned int offset
= frag
->fr_fix
;
692 unsigned int size
= 0;
694 gas_assert (frag
!= frag_now
);
695 gas_assert (frag
->fr_type
== rs_align_code
);
697 while (frag
!= frag_now
)
699 /* This should only happen in what will later become an error case. */
703 size
+= frag
->fr_fix
;
704 if (frag
->fr_type
== rs_machine_dependent
)
705 size
+= md_frag_max_var (frag
);
707 frag
= frag
->fr_next
;
710 gas_assert (frag
== frag_now
);
711 size
+= frag_now_fix ();
712 if (frag
->fr_type
== rs_machine_dependent
)
713 size
+= md_frag_max_var (frag
);
715 gas_assert (size
>= offset
);
717 return size
- offset
;
720 /* Finish off the frag created to ensure bundle alignment. */
722 finish_bundle (fragS
*frag
, unsigned int size
)
724 gas_assert (bundle_align_p2
> 0);
725 gas_assert (frag
->fr_type
== rs_align_code
);
729 /* If there is more than a single byte, then we need to set up
730 the alignment frag. Otherwise we leave it at its initial
731 state with zero alignment so that it does nothing. */
732 frag
->fr_offset
= bundle_align_p2
;
733 frag
->fr_subtype
= size
- 1;
736 /* We do this every time rather than just in s_bundle_align_mode
737 so that we catch any affected section without needing hooks all
738 over for all paths that do section changes. It's cheap enough. */
739 if (bundle_align_p2
> OCTETS_PER_BYTE_POWER
)
740 record_alignment (now_seg
, bundle_align_p2
- OCTETS_PER_BYTE_POWER
);
743 /* Assemble one instruction. This takes care of the bundle features
744 around calling md_assemble. */
746 assemble_one (char *line
)
748 fragS
*insn_start_frag
= NULL
;
750 if (bundle_lock_frchain
!= NULL
&& bundle_lock_frchain
!= frchain_now
)
752 as_bad (_("cannot change section or subsection inside .bundle_lock"));
753 /* Clearing this serves as a marker that we have already complained. */
754 bundle_lock_frchain
= NULL
;
757 if (bundle_lock_frchain
== NULL
&& bundle_align_p2
> 0)
758 insn_start_frag
= start_bundle ();
762 if (bundle_lock_frchain
!= NULL
)
764 /* Make sure this hasn't pushed the locked sequence
765 past the bundle size. */
766 unsigned int bundle_size
= pending_bundle_size (bundle_lock_frag
);
767 if (bundle_size
> 1U << bundle_align_p2
)
768 as_bad (_ (".bundle_lock sequence at %u bytes, "
769 "but .bundle_align_mode limit is %u bytes"),
770 bundle_size
, 1U << bundle_align_p2
);
772 else if (bundle_align_p2
> 0)
774 unsigned int insn_size
= pending_bundle_size (insn_start_frag
);
776 if (insn_size
> 1U << bundle_align_p2
)
777 as_bad (_("single instruction is %u bytes long, "
778 "but .bundle_align_mode limit is %u bytes"),
779 insn_size
, 1U << bundle_align_p2
);
781 finish_bundle (insn_start_frag
, insn_size
);
785 #else /* !HANDLE_BUNDLE */
787 # define assemble_one(line) md_assemble(line)
789 #endif /* HANDLE_BUNDLE */
794 flagword flags
= bfd_section_flags (now_seg
);
796 return (flags
& SEC_ALLOC
) && !(flags
& (SEC_LOAD
| SEC_HAS_CONTENTS
));
799 /* Guts of .align directive:
800 N is the power of two to which to align. A value of zero is accepted but
801 ignored: the default alignment of the section will be at least this.
802 FILL may be NULL, or it may point to the bytes of the fill pattern.
803 LEN is the length of whatever FILL points to, if anything. If LEN is zero
804 but FILL is not NULL then LEN is treated as if it were one.
805 MAX is the maximum number of characters to skip when doing the alignment,
806 or 0 if there is no maximum. */
809 do_align (unsigned int n
, char *fill
, unsigned int len
, unsigned int max
)
811 if (now_seg
== absolute_section
|| in_bss ())
817 if (now_seg
== absolute_section
)
818 as_warn (_("ignoring fill value in absolute section"));
820 as_warn (_("ignoring fill value in section `%s'"),
821 segment_name (now_seg
));
828 #ifdef md_flush_pending_output
829 md_flush_pending_output ();
833 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
836 /* Only make a frag if we HAVE to... */
837 if ((n
> OCTETS_PER_BYTE_POWER
) && !need_pass_2
)
841 if (subseg_text_p (now_seg
))
842 frag_align_code (n
, max
);
844 frag_align (n
, 0, max
);
847 frag_align (n
, *fill
, max
);
849 frag_align_pattern (n
, fill
, len
, max
);
853 just_record_alignment
: ATTRIBUTE_UNUSED_LABEL
856 if (n
> OCTETS_PER_BYTE_POWER
)
857 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
860 /* Find first <eol><next_char>NO_APP<eol>, if any, in the supplied buffer.
861 Return NULL if there's none, or else the position of <next_char>. */
863 find_no_app (const char *s
, char next_char
)
865 const char *start
= s
;
866 const char srch
[] = { next_char
, 'N', 'O', '_', 'A', 'P', 'P', '\0' };
870 char *ends
= strstr (s
, srch
);
874 if (is_end_of_line (ends
[sizeof (srch
) - 1])
875 && (ends
== start
|| is_end_of_line (ends
[-1])))
877 s
= ends
+ sizeof (srch
) - 1;
883 /* We read the file, putting things into a web that represents what we
884 have been reading. */
886 read_a_source_file (const char *name
)
890 char *s
; /* String of symbol, '\0' appended. */
892 const pseudo_typeS
*pop
;
898 buffer
= input_scrub_new_file (name
);
901 listing_newline (NULL
);
902 register_dependency (name
);
904 /* Generate debugging information before we've read anything in to denote
905 this file as the "main" source file and not a subordinate one
906 (e.g. N_SO vs N_SOL in stabs). */
907 generate_file_debug ();
909 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
910 { /* We have another line to parse. */
912 /* In order to avoid listing macro expansion lines with labels
913 multiple times, keep track of which line was last issued. */
914 char *last_eol
= NULL
;
917 while (input_line_pointer
< buffer_limit
)
920 /* We have more of this buffer to parse. */
922 /* We now have input_line_pointer->1st char of next line.
923 If input_line_pointer [-1] == '\n' then we just
924 scanned another line: so bump line counters. */
925 was_new_line
= lex_type
[(unsigned char) input_line_pointer
[-1]]
926 & (LEX_EOL
| LEX_EOS
);
929 symbol_set_value_now (&dot_symbol
);
930 #ifdef md_start_line_hook
931 md_start_line_hook ();
933 if (input_line_pointer
[-1] == '\n')
934 bump_line_counters ();
938 /* If listing is on, and we are expanding a macro, then give
939 the listing code the contents of the expanded line. */
942 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
944 /* Find the end of the current expanded macro line. */
945 s
= find_end_of_line (input_line_pointer
, flag_m68k_mri
);
948 && !startswith (input_line_pointer
,
949 !flag_m68k_mri
? " .linefile "
956 /* Copy it for safe keeping. Also give an indication of
957 how much macro nesting is involved at this point. */
958 len
= s
- input_line_pointer
;
959 copy
= XNEWVEC (char, len
+ macro_nest
+ 2);
960 memset (copy
, '>', macro_nest
);
961 copy
[macro_nest
] = ' ';
962 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
, len
);
963 copy
[macro_nest
+ 1 + len
] = '\0';
965 /* Install the line with the listing facility. */
966 listing_newline (copy
);
970 listing_newline (NULL
);
974 next_char
= *input_line_pointer
;
975 if ((was_new_line
& LEX_EOL
)
976 && (strchr (line_comment_chars
, '#')
978 : next_char
&& strchr (line_comment_chars
, next_char
)))
980 /* Its a comment. Check for APP followed by NO_APP. */
985 s
= input_line_pointer
+ 1;
986 if (!startswith (s
, "APP") || !is_end_of_line (s
[3]))
988 /* We ignore it. Note: Not ignore_rest_of_line ()! */
989 while (s
<= buffer_limit
)
990 if (is_end_of_line (*s
++))
992 input_line_pointer
= s
;
997 ends
= find_no_app (s
, next_char
);
998 len
= ends
? ends
- s
: buffer_limit
- s
;
1000 sb_build (&sbuf
, len
+ 100);
1001 sb_add_buffer (&sbuf
, s
, len
);
1004 /* The end of the #APP wasn't in this buffer. We
1005 keep reading in buffers until we find the #NO_APP
1006 that goes with this #APP There is one. The specs
1010 buffer_limit
= input_scrub_next_buffer (&buffer
);
1013 ends
= find_no_app (buffer
, next_char
);
1014 len
= ends
? ends
- buffer
: buffer_limit
- buffer
;
1015 sb_add_buffer (&sbuf
, buffer
, len
);
1019 sb_add_char (&sbuf
, '\n');
1021 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1022 input_scrub_include_sb (&sbuf
, input_line_pointer
, expanding_app
);
1024 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1032 if (LABELS_WITHOUT_COLONS
|| flag_m68k_mri
)
1034 next_char
= * input_line_pointer
;
1035 /* Text at the start of a line must be a label, we
1036 run down and stick a colon in. */
1037 if (is_name_beginner (next_char
) || next_char
== '"')
1042 HANDLE_CONDITIONAL_ASSEMBLY (0);
1044 nul_char
= get_symbol_name (& line_start
);
1045 next_char
= (nul_char
== '"' ? input_line_pointer
[1] : nul_char
);
1047 /* In MRI mode, the EQU and MACRO pseudoops must
1048 be handled specially. */
1052 char *rest
= input_line_pointer
+ 1;
1056 if (is_whitespace (*rest
))
1058 if ((strncasecmp (rest
, "EQU", 3) == 0
1059 || strncasecmp (rest
, "SET", 3) == 0)
1060 && is_whitespace (rest
[3]))
1062 input_line_pointer
= rest
+ 3;
1064 strncasecmp (rest
, "SET", 3) == 0);
1067 if (strncasecmp (rest
, "MACRO", 5) == 0
1068 && (is_whitespace (rest
[5])
1069 || is_end_of_stmt (rest
[5])))
1073 /* In MRI mode, we need to handle the MACRO
1074 pseudo-op specially: we don't want to put the
1075 symbol in the symbol table. */
1077 #ifdef TC_START_LABEL_WITHOUT_COLON
1078 && TC_START_LABEL_WITHOUT_COLON (nul_char
, next_char
)
1081 line_label
= colon (line_start
);
1083 line_label
= symbol_create (line_start
,
1085 &zero_address_frag
, 0);
1087 next_char
= restore_line_pointer (nul_char
);
1088 if (next_char
== ':')
1089 input_line_pointer
++;
1094 /* We are at the beginning of a line, or similar place.
1095 We expect a well-formed assembler statement.
1096 A "symbol-name:" is a statement.
1098 Depending on what compiler is used, the order of these tests
1099 may vary to catch most common case 1st.
1100 Each test is independent of all other tests at the (top)
1103 nul_char
= next_char
= *input_line_pointer
++;
1104 while (is_whitespace (next_char
) || next_char
== '\f');
1106 /* C is the 1st significant character.
1107 Input_line_pointer points after that character. */
1108 if (is_name_beginner (next_char
) || next_char
== '"')
1112 /* Want user-defined label or pseudo/opcode. */
1113 HANDLE_CONDITIONAL_ASSEMBLY (1);
1115 --input_line_pointer
;
1116 nul_char
= get_symbol_name (& s
); /* name's delimiter. */
1117 next_char
= (nul_char
== '"' ? input_line_pointer
[1] : nul_char
);
1118 rest
= input_line_pointer
+ (nul_char
== '"' ? 2 : 1);
1120 /* NEXT_CHAR is character after symbol.
1121 The end of symbol in the input line is now '\0'.
1122 S points to the beginning of the symbol.
1123 [In case of pseudo-op, s->'.'.]
1124 Input_line_pointer->'\0' where NUL_CHAR was. */
1125 if (TC_START_LABEL (s
, nul_char
, next_char
))
1129 /* In MRI mode, \tsym: set 0 is permitted. */
1133 if (is_whitespace (*rest
))
1136 if ((strncasecmp (rest
, "EQU", 3) == 0
1137 || strncasecmp (rest
, "SET", 3) == 0)
1138 && is_whitespace (rest
[3]))
1140 input_line_pointer
= rest
+ 3;
1146 line_label
= colon (s
); /* User-defined label. */
1147 restore_line_pointer (nul_char
);
1148 ++ input_line_pointer
;
1149 #ifdef tc_check_label
1150 tc_check_label (line_label
);
1152 /* Input_line_pointer->after ':'. */
1155 else if ((next_char
== '=' && *rest
== '=')
1156 || (is_whitespace (next_char
)
1161 demand_empty_rest_of_line ();
1163 else if ((next_char
== '='
1164 || (is_whitespace (next_char
)
1166 #ifdef TC_EQUAL_IN_INSN
1167 && !TC_EQUAL_IN_INSN (next_char
, s
)
1172 demand_empty_rest_of_line ();
1176 /* Expect pseudo-op or machine instruction. */
1179 #ifndef TC_CASE_SENSITIVE
1183 strncpy (original_case_string
, s2
,
1184 sizeof (original_case_string
) - 1);
1185 original_case_string
[sizeof (original_case_string
) - 1] = 0;
1189 *s2
= TOLOWER (*s2
);
1194 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
1196 /* The MRI assembler uses pseudo-ops without
1198 pop
= str_hash_find (po_hash
, s
);
1199 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
1204 || (!flag_m68k_mri
&& *s
== '.'))
1208 WARNING: next_char may be end-of-line.
1209 We lookup the pseudo-op table with s+1 because we
1210 already know that the pseudo-op begins with a '.'. */
1213 pop
= str_hash_find (po_hash
, s
+ 1);
1214 if (pop
&& !pop
->poc_handler
)
1217 /* In MRI mode, we may need to insert an
1218 automatic alignment directive. What a hack
1220 if (mri_pending_align
1222 || !((pop
->poc_handler
== cons
1223 && pop
->poc_val
== 1)
1224 || (pop
->poc_handler
== s_space
1225 && pop
->poc_val
== 1)
1226 #ifdef tc_conditional_pseudoop
1227 || tc_conditional_pseudoop (pop
)
1229 || pop
->poc_handler
== s_if
1230 || pop
->poc_handler
== s_ifdef
1231 || pop
->poc_handler
== s_ifc
1232 || pop
->poc_handler
== s_ifeqs
1233 || pop
->poc_handler
== s_else
1234 || pop
->poc_handler
== s_endif
1235 || pop
->poc_handler
== s_globl
1236 || pop
->poc_handler
== s_ignore
)))
1238 do_align (1, (char *) NULL
, 0, 0);
1239 mri_pending_align
= 0;
1241 if (line_label
!= NULL
)
1243 symbol_set_frag (line_label
, frag_now
);
1244 S_SET_VALUE (line_label
, frag_now_fix ());
1248 /* Print the error msg now, while we still can. */
1251 char *end
= input_line_pointer
;
1253 (void) restore_line_pointer (nul_char
);
1255 nul_char
= next_char
= *--input_line_pointer
;
1256 *input_line_pointer
= '\0';
1257 if (! macro_defined
|| ! try_macro (next_char
, s
))
1260 as_bad (_("unknown pseudo-op: `%s'"), s
);
1261 *input_line_pointer
++ = nul_char
;
1266 /* Put it back for error messages etc. */
1267 next_char
= restore_line_pointer (nul_char
);
1268 /* The following skip of whitespace is compulsory.
1269 A well shaped space is sometimes all that separates
1270 keyword from operands. */
1271 if (is_whitespace (next_char
))
1272 input_line_pointer
++;
1274 /* Input_line is restored.
1275 Input_line_pointer->1st non-blank char
1276 after pseudo-operation. */
1277 (*pop
->poc_handler
) (pop
->poc_val
);
1279 /* If that was .end, just get out now. */
1280 if (pop
->poc_handler
== s_end
)
1285 /* WARNING: next_char may be end-of-line. */
1286 /* Also: input_line_pointer->`\0` where nul_char was. */
1287 (void) restore_line_pointer (nul_char
);
1288 input_line_pointer
= _find_end_of_line (input_line_pointer
, flag_m68k_mri
, 1, 0);
1289 next_char
= nul_char
= *input_line_pointer
;
1290 *input_line_pointer
= '\0';
1292 generate_lineno_debug ();
1294 if (macro_defined
&& try_macro (next_char
, s
))
1297 if (mri_pending_align
)
1299 do_align (1, (char *) NULL
, 0, 0);
1300 mri_pending_align
= 0;
1301 if (line_label
!= NULL
)
1303 symbol_set_frag (line_label
, frag_now
);
1304 S_SET_VALUE (line_label
, frag_now_fix ());
1308 assemble_one (s
); /* Assemble 1 instruction. */
1310 /* PR 19630: The backend may have set ilp to NULL
1311 if it encountered a catastrophic failure. */
1312 if (input_line_pointer
== NULL
)
1313 as_fatal (_("unable to continue with assembly."));
1315 *input_line_pointer
++ = nul_char
;
1317 /* We resume loop AFTER the end-of-line from
1318 this instruction. */
1324 /* Empty statement? */
1325 if (is_end_of_stmt (next_char
))
1328 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
) && ISDIGIT (next_char
))
1330 /* local label ("4:") */
1331 char *backup
= input_line_pointer
;
1333 HANDLE_CONDITIONAL_ASSEMBLY (1);
1335 temp
= next_char
- '0';
1337 /* Read the whole number. */
1338 while (ISDIGIT (*input_line_pointer
))
1340 const long digit
= *input_line_pointer
- '0';
1342 /* Don't accept labels which look like octal numbers. */
1345 if (temp
> (INT_MAX
- digit
) / 10)
1347 as_bad (_("local label too large near %s"), backup
);
1351 temp
= temp
* 10 + digit
;
1352 ++input_line_pointer
;
1355 /* Overflow: stop processing the label. */
1358 ignore_rest_of_line ();
1362 if (LOCAL_LABELS_DOLLAR
1363 && *input_line_pointer
== '$'
1364 && *(input_line_pointer
+ 1) == ':')
1366 input_line_pointer
+= 2;
1368 if (dollar_label_defined (temp
))
1370 as_fatal (_("label \"%ld$\" redefined"), temp
);
1373 define_dollar_label (temp
);
1374 colon (dollar_label_name (temp
, 0));
1379 && *input_line_pointer
++ == ':')
1381 fb_label_instance_inc (temp
);
1382 colon (fb_label_name (temp
, 0));
1386 input_line_pointer
= backup
;
1389 if (next_char
&& strchr (line_comment_chars
, next_char
))
1391 /* Its a comment, ignore it. Note: Not ignore_rest_of_line ()! */
1392 s
= input_line_pointer
;
1393 while (s
<= buffer_limit
)
1394 if (is_end_of_line (*s
++))
1396 input_line_pointer
= s
;
1400 HANDLE_CONDITIONAL_ASSEMBLY (1);
1402 #ifdef tc_unrecognized_line
1403 if (tc_unrecognized_line (next_char
))
1406 input_line_pointer
--;
1407 /* Report unknown char as error. */
1408 demand_empty_rest_of_line ();
1413 symbol_set_value_now (&dot_symbol
);
1415 #ifdef HANDLE_BUNDLE
1416 if (bundle_lock_frag
!= NULL
)
1418 as_bad_where (bundle_lock_frag
->fr_file
, bundle_lock_frag
->fr_line
,
1419 _(".bundle_lock with no matching .bundle_unlock"));
1420 bundle_lock_frag
= NULL
;
1421 bundle_lock_frchain
= NULL
;
1422 bundle_lock_depth
= 0;
1427 ginsn_data_end (symbol_temp_new_now ());
1432 /* Close the input file. */
1433 input_scrub_close ();
1434 #ifdef WARN_COMMENTS
1436 if (warn_comment
&& found_comment
)
1437 as_warn_where (found_comment_file
, found_comment
,
1438 "first comment found here");
1443 /* Convert O_constant expression EXP into the equivalent O_big
1447 convert_to_bignum (expressionS
*exp
)
1451 bool sign
= !exp
->X_unsigned
&& exp
->X_extrabit
;
1453 value
= exp
->X_add_number
;
1454 for (i
= 0; i
< sizeof (exp
->X_add_number
) / CHARS_PER_LITTLENUM
; i
++)
1456 generic_bignum
[i
] = value
& LITTLENUM_MASK
;
1457 value
>>= LITTLENUM_NUMBER_OF_BITS
;
1459 /* Add a sequence of sign bits if the top bit of X_add_number is not
1460 the sign of the original value. */
1461 if ((exp
->X_add_number
< 0) == !sign
)
1462 generic_bignum
[i
++] = sign
? LITTLENUM_MASK
: 0;
1464 exp
->X_add_number
= i
;
1465 exp
->X_unsigned
= !sign
;
1470 /* For most MRI pseudo-ops, the line actually ends at the first
1471 nonquoted space. This function looks for that point, stuffs a null
1472 in, and sets *STOPCP to the character that used to be there, and
1473 returns the location.
1475 Until I hear otherwise, I am going to assume that this is only true
1476 for the m68k MRI assembler. */
1479 mri_comment_field (char *stopcp
)
1485 know (flag_m68k_mri
);
1487 for (s
= input_line_pointer
;
1488 ((!is_end_of_stmt (*s
) && !is_whitespace (*s
))
1496 for (s
= input_line_pointer
;
1497 !is_end_of_stmt (*s
);
1507 /* Skip to the end of an MRI comment field. */
1510 mri_comment_end (char *stop
, int stopc
)
1514 input_line_pointer
= stop
;
1516 while (!is_end_of_stmt (*input_line_pointer
))
1517 ++input_line_pointer
;
1521 s_abort (int ignore ATTRIBUTE_UNUSED
)
1523 as_fatal (_(".abort detected. Abandoning ship."));
1526 #ifndef TC_ALIGN_LIMIT
1527 #define TC_ALIGN_LIMIT (stdoutput->arch_info->bits_per_address - 1)
1530 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1531 (in bytes). A negative ARG is the negative of the length of the
1532 fill pattern. BYTES_P is non-zero if the alignment value should be
1533 interpreted as the byte boundary, rather than the power of 2. */
1536 s_align (signed int arg
, int bytes_p
)
1538 unsigned int align_limit
= TC_ALIGN_LIMIT
;
1547 stop
= mri_comment_field (&stopc
);
1549 if (is_end_of_stmt (*input_line_pointer
))
1554 align
= arg
; /* Default value from pseudo-op table. */
1558 align
= get_absolute_expression ();
1561 #ifdef TC_ALIGN_ZERO_IS_DEFAULT
1562 if (arg
> 0 && align
== 0)
1569 /* Convert to a power of 2. */
1574 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1577 as_bad (_("alignment not a power of 2"));
1583 if (align
> align_limit
)
1585 align
= align_limit
;
1586 as_warn (_("alignment too large: %u assumed"),
1587 bytes_p
? 1u << align_limit
: align_limit
);
1590 if (*input_line_pointer
!= ',')
1597 ++input_line_pointer
;
1598 if (*input_line_pointer
== ',')
1602 fill
= get_absolute_expression ();
1607 if (*input_line_pointer
!= ',')
1611 ++input_line_pointer
;
1612 offsetT val
= get_absolute_expression ();
1614 if (val
< 0 || max
!= (valueT
) val
)
1616 as_warn (_("ignoring out of range alignment maximum"));
1625 as_warn (_("expected fill pattern missing"));
1626 do_align (align
, (char *) NULL
, 0, max
);
1630 unsigned int fill_len
;
1642 do_align (align
, &fill_char
, fill_len
, max
);
1648 if ((size_t) fill_len
> sizeof ab
)
1650 as_warn (_("fill pattern too long, truncating to %u"),
1651 (unsigned) sizeof ab
);
1652 fill_len
= sizeof ab
;
1655 md_number_to_chars (ab
, fill
, fill_len
);
1656 do_align (align
, ab
, fill_len
, max
);
1660 demand_empty_rest_of_line ();
1663 mri_comment_end (stop
, stopc
);
1666 /* Handle the .align pseudo-op on machines where ".align 4" means
1667 align to a 4 byte boundary. */
1670 s_align_bytes (int arg
)
1675 /* Handle the .align pseudo-op on machines where ".align 4" means align
1676 to a 2**4 boundary. */
1679 s_align_ptwo (int arg
)
1684 /* Switch in and out of alternate macro mode. */
1689 demand_empty_rest_of_line ();
1690 flag_macro_alternate
= on
;
1693 /* Read a symbol name from input_line_pointer.
1695 Stores the symbol name in a buffer and returns a pointer to this buffer.
1696 The buffer is xalloc'ed. It is the caller's responsibility to free
1699 The name is not left in the i_l_p buffer as it may need processing
1700 to handle escape characters.
1702 Advances i_l_p to the next non-whitespace character.
1704 If a symbol name could not be read, the routine issues an error
1705 messages, skips to the end of the line and returns NULL. */
1708 read_symbol_name (void)
1714 c
= *input_line_pointer
++;
1718 #define SYM_NAME_CHUNK_LEN 128
1719 ptrdiff_t len
= SYM_NAME_CHUNK_LEN
;
1723 start
= name
= XNEWVEC (char, len
+ 1);
1725 name_end
= name
+ SYM_NAME_CHUNK_LEN
;
1727 while (is_a_char (C
= next_char_of_string ()))
1729 if (name
>= name_end
)
1733 sofar
= name
- start
;
1734 len
+= SYM_NAME_CHUNK_LEN
;
1735 start
= XRESIZEVEC (char, start
, len
+ 1);
1736 name_end
= start
+ len
;
1737 name
= start
+ sofar
;
1744 /* Since quoted symbol names can contain non-ASCII characters,
1745 check the string and warn if it cannot be recognised by the
1746 current character set. */
1747 /* PR 29447: mbstowcs ignores the third (length) parameter when
1748 the first (destination) parameter is NULL. For clarity sake
1749 therefore we pass 0 rather than 'len' as the third parameter. */
1750 if (mbstowcs (NULL
, name
, 0) == (size_t) -1)
1751 as_warn (_("symbol name not recognised in the current locale"));
1753 else if (is_name_beginner (c
) || (input_from_string
&& c
== FAKE_LABEL_CHAR
))
1757 name
= input_line_pointer
- 1;
1759 /* We accept FAKE_LABEL_CHAR in a name in case this is
1760 being called with a constructed string. */
1761 while (is_part_of_name (c
= *input_line_pointer
++)
1762 || (input_from_string
&& c
== FAKE_LABEL_CHAR
))
1765 len
= (input_line_pointer
- name
) - 1;
1766 start
= XNEWVEC (char, len
+ 1);
1768 memcpy (start
, name
, len
);
1771 /* Skip a name ender char if one is present. */
1772 if (! is_name_ender (c
))
1773 --input_line_pointer
;
1776 name
= start
= NULL
;
1780 as_bad (_("expected symbol name"));
1781 ignore_rest_of_line ();
1793 s_comm_internal (int param
,
1794 symbolS
*(*comm_parse_extra
) (int, symbolS
*, addressT
))
1798 symbolS
*symbolP
= NULL
;
1804 stop
= mri_comment_field (&stopc
);
1806 if ((name
= read_symbol_name ()) == NULL
)
1809 /* Accept an optional comma after the name. The comma used to be
1810 required, but Irix 5 cc does not generate it for .lcomm. */
1811 if (*input_line_pointer
== ',')
1812 input_line_pointer
++;
1814 temp
= get_absolute_expr (&exp
);
1816 size
&= ((addressT
) 2 << (stdoutput
->arch_info
->bits_per_address
- 1)) - 1;
1817 if (exp
.X_op
== O_absent
)
1819 as_bad (_("missing size expression"));
1820 ignore_rest_of_line ();
1823 else if (temp
!= size
|| (!exp
.X_unsigned
&& exp
.X_add_number
< 0))
1825 as_warn (_("size (%ld) out of range, ignored"), (long) temp
);
1826 ignore_rest_of_line ();
1830 symbolP
= symbol_find_or_make (name
);
1831 if ((S_IS_DEFINED (symbolP
) || symbol_equated_p (symbolP
))
1832 && !S_IS_COMMON (symbolP
))
1834 if (!S_IS_VOLATILE (symbolP
))
1837 as_bad (_("symbol `%s' is already defined"), name
);
1838 ignore_rest_of_line ();
1841 symbolP
= symbol_clone (symbolP
, 1);
1842 S_SET_SEGMENT (symbolP
, undefined_section
);
1843 S_SET_VALUE (symbolP
, 0);
1844 symbol_set_frag (symbolP
, &zero_address_frag
);
1845 S_CLEAR_VOLATILE (symbolP
);
1848 size
= S_GET_VALUE (symbolP
);
1851 else if (size
!= temp
)
1852 as_warn (_("size of \"%s\" is already %ld; not changing to %ld"),
1853 name
, (long) size
, (long) temp
);
1855 if (comm_parse_extra
!= NULL
)
1856 symbolP
= (*comm_parse_extra
) (param
, symbolP
, size
);
1859 S_SET_VALUE (symbolP
, (valueT
) size
);
1860 S_SET_EXTERNAL (symbolP
);
1861 S_SET_SEGMENT (symbolP
, bfd_com_section_ptr
);
1864 demand_empty_rest_of_line ();
1867 mri_comment_end (stop
, stopc
);
1875 s_comm_internal (ignore
, NULL
);
1878 /* The MRI COMMON pseudo-op. We handle this by creating a common
1879 symbol with the appropriate name. We make s_space do the right
1880 thing by increasing the size. */
1883 s_mri_common (int small ATTRIBUTE_UNUSED
)
1899 stop
= mri_comment_field (&stopc
);
1903 name
= input_line_pointer
;
1904 if (!ISDIGIT (*name
))
1905 c
= get_symbol_name (& name
);
1910 ++input_line_pointer
;
1912 while (ISDIGIT (*input_line_pointer
));
1914 c
= *input_line_pointer
;
1915 *input_line_pointer
= '\0';
1917 if (line_label
!= NULL
)
1919 alc
= XNEWVEC (char, strlen (S_GET_NAME (line_label
))
1920 + (input_line_pointer
- name
) + 1);
1921 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1926 sym
= symbol_find_or_make (name
);
1927 c
= restore_line_pointer (c
);
1930 if (*input_line_pointer
!= ',')
1934 ++input_line_pointer
;
1935 align
= get_absolute_expression ();
1938 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1940 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (sym
));
1941 mri_comment_end (stop
, stopc
);
1945 S_SET_EXTERNAL (sym
);
1946 S_SET_SEGMENT (sym
, bfd_com_section_ptr
);
1947 mri_common_symbol
= sym
;
1951 S_SET_ALIGN (sym
, align
);
1956 if (line_label
!= NULL
)
1959 exp
.X_op
= O_symbol
;
1960 exp
.X_add_symbol
= sym
;
1961 exp
.X_add_number
= 0;
1962 symbol_set_value_expression (line_label
, &exp
);
1963 symbol_set_frag (line_label
, &zero_address_frag
);
1964 S_SET_SEGMENT (line_label
, expr_section
);
1967 /* FIXME: We just ignore the small argument, which distinguishes
1968 COMMON and COMMON.S. I don't know what we can do about it. */
1970 /* Ignore the type and hptype. */
1971 if (*input_line_pointer
== ',')
1972 input_line_pointer
+= 2;
1973 if (*input_line_pointer
== ',')
1974 input_line_pointer
+= 2;
1976 demand_empty_rest_of_line ();
1978 mri_comment_end (stop
, stopc
);
1982 s_data (int ignore ATTRIBUTE_UNUSED
)
1987 temp
= get_absolute_expression ();
1988 if (flag_readonly_data_in_text
)
1990 section
= text_section
;
1994 section
= data_section
;
1996 subseg_set (section
, (subsegT
) temp
);
1998 demand_empty_rest_of_line ();
2001 /* Handle the .file pseudo-op. This default definition may be overridden by
2002 the object or CPU specific pseudo-ops. */
2005 s_file_string (char *file
)
2009 listing_source_file (file
);
2011 register_dependency (file
);
2013 obj_app_file (file
);
2018 s_file (int ignore ATTRIBUTE_UNUSED
)
2023 /* Some assemblers tolerate immediately following '"'. */
2024 if ((s
= demand_copy_string (&length
)) != 0)
2026 new_logical_line_flags (s
, -1, 1);
2028 /* In MRI mode, the preprocessor may have inserted an extraneous
2031 && *input_line_pointer
== '\''
2032 && is_end_of_stmt (input_line_pointer
[1]))
2033 ++input_line_pointer
;
2035 demand_empty_rest_of_line ();
2041 get_linefile_number (int *flag
)
2047 if (*input_line_pointer
< '0' || *input_line_pointer
> '9')
2050 /* Don't mistakenly interpret octal numbers as line numbers. */
2051 if (*input_line_pointer
== '0')
2054 ++input_line_pointer
;
2058 expression_and_evaluate (&exp
);
2059 if (exp
.X_op
!= O_constant
)
2062 #if defined (BFD64) || LONG_MAX > INT_MAX
2063 if (exp
.X_add_number
< INT_MIN
|| exp
.X_add_number
> INT_MAX
)
2067 *flag
= exp
.X_add_number
;
2072 /* Handle the .linefile pseudo-op. This is automatically generated by
2073 do_scrub_chars when a preprocessor # line comment is seen. This
2074 default definition may be overridden by the object or CPU specific
2078 s_linefile (int ignore ATTRIBUTE_UNUSED
)
2081 int linenum
, flags
= 0;
2083 /* The given number is that of the next line. */
2084 if (!get_linefile_number (&linenum
))
2086 ignore_rest_of_line ();
2091 /* Some of the back ends can't deal with non-positive line numbers.
2092 Besides, it's silly. GCC however will generate a line number of
2093 zero when it is pre-processing builtins for assembler-with-cpp files:
2097 We do not want to barf on this, especially since such files are used
2098 in the GCC and GDB testsuites. So we check for negative line numbers
2099 rather than non-positive line numbers. */
2100 as_warn (_("line numbers must be positive; line number %d rejected"),
2108 if (*input_line_pointer
== '"')
2109 file
= demand_copy_string (&length
);
2110 else if (*input_line_pointer
== '.')
2112 /* buffer_and_nest() may insert this form. */
2113 ++input_line_pointer
;
2121 while (get_linefile_number (&this_flag
))
2124 /* From GCC's cpp documentation:
2125 1: start of a new file.
2126 2: returning to a file after having included another file.
2127 3: following text comes from a system header file.
2128 4: following text should be treated as extern "C".
2130 4 is nonsensical for the assembler; 3, we don't care about,
2131 so we ignore it just in case a system header file is
2132 included while preprocessing assembly. So 1 and 2 are all
2133 we care about, and they are mutually incompatible.
2134 new_logical_line_flags() demands this. */
2137 if (flags
&& flags
!= (1 << this_flag
))
2138 as_warn (_("incompatible flag %i in line directive"),
2141 flags
|= 1 << this_flag
;
2146 /* We ignore these. */
2150 as_warn (_("unsupported flag %i in line directive"),
2155 if (!is_end_of_stmt (*input_line_pointer
))
2161 demand_empty_rest_of_line ();
2163 /* read_a_source_file() will bump the line number only if the line
2164 is terminated by '\n'. */
2165 if (input_line_pointer
[-1] == '\n')
2168 new_logical_line_flags (file
, linenum
, flags
);
2171 listing_source_line (linenum
);
2176 ignore_rest_of_line ();
2179 /* Handle the .end pseudo-op. Actually, the real work is done in
2180 read_a_source_file. */
2183 s_end (int ignore ATTRIBUTE_UNUSED
)
2187 /* The MRI assembler permits the start symbol to follow .end,
2188 but we don't support that. */
2190 if (!is_end_of_stmt (*input_line_pointer
)
2191 && *input_line_pointer
!= '*'
2192 && *input_line_pointer
!= '!')
2193 as_warn (_("start address not supported"));
2197 /* Handle the .err pseudo-op. */
2200 s_err (int ignore ATTRIBUTE_UNUSED
)
2202 as_bad (_(".err encountered"));
2203 demand_empty_rest_of_line ();
2206 /* Handle the .error and .warning pseudo-ops. */
2212 /* The purpose for the conditional assignment is not to
2213 internationalize the directive itself, but that we need a
2214 self-contained message, one that can be passed like the
2215 demand_copy_C_string return value, and with no assumption on the
2216 location of the name of the directive within the message. */
2218 = (err
? _(".error directive invoked in source file")
2219 : _(".warning directive invoked in source file"));
2221 if (!is_it_end_of_statement ())
2223 if (*input_line_pointer
!= '\"')
2225 as_bad (_("%s argument must be a string"),
2226 err
? ".error" : ".warning");
2227 ignore_rest_of_line ();
2231 msg
= demand_copy_C_string (&len
);
2239 as_warn ("%s", msg
);
2240 demand_empty_rest_of_line ();
2243 /* Handle the .errif and .warnif pseudo-ops. */
2245 static struct deferred_diag
{
2246 struct deferred_diag
*next
;
2248 unsigned int lineno
;
2251 } *deferred_diags
, *last_deferred_diag
;
2254 s_errwarn_if (int err
)
2256 struct deferred_diag
*diag
= XNEW (struct deferred_diag
);
2257 int errcnt
= had_errors ();
2259 deferred_expression (&diag
->exp
);
2260 if (errcnt
!= had_errors ())
2262 ignore_rest_of_line ();
2267 diag
->file
= as_where (&diag
->lineno
);
2269 if ( deferred_diags
== NULL
)
2270 deferred_diags
= diag
;
2272 last_deferred_diag
->next
= diag
;
2273 last_deferred_diag
= diag
;
2275 demand_empty_rest_of_line ();
2279 evaluate_deferred_diags (void)
2281 struct deferred_diag
*diag
;
2283 for (diag
= deferred_diags
; diag
!= NULL
; diag
= diag
->next
)
2285 if (!resolve_expression (&diag
->exp
) || diag
->exp
.X_op
!= O_constant
)
2286 as_warn_where (diag
->file
, diag
->lineno
,
2287 _("expression does not evaluate to a constant"));
2288 else if (diag
->exp
.X_add_number
== 0)
2291 as_bad_where (diag
->file
, diag
->lineno
,
2292 _(".errif expression evaluates to true"));
2294 as_warn_where (diag
->file
, diag
->lineno
,
2295 _(".warnif expression evaluates to true"));
2299 /* Handle the MRI fail pseudo-op. */
2302 s_fail (int ignore ATTRIBUTE_UNUSED
)
2309 stop
= mri_comment_field (&stopc
);
2311 temp
= get_absolute_expression ();
2313 as_warn (_(".fail %ld encountered"), (long) temp
);
2315 as_bad (_(".fail %ld encountered"), (long) temp
);
2317 demand_empty_rest_of_line ();
2320 mri_comment_end (stop
, stopc
);
2324 s_fill (int ignore ATTRIBUTE_UNUSED
)
2326 expressionS rep_exp
;
2331 #ifdef md_flush_pending_output
2332 md_flush_pending_output ();
2335 #ifdef md_cons_align
2339 expression (&rep_exp
);
2340 if (*input_line_pointer
== ',')
2342 input_line_pointer
++;
2343 size
= get_absolute_expression ();
2344 if (*input_line_pointer
== ',')
2346 input_line_pointer
++;
2347 fill
= get_absolute_expression ();
2351 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
2352 #define BSD_FILL_SIZE_CROCK_8 (8)
2353 if (size
> BSD_FILL_SIZE_CROCK_8
)
2355 as_warn (_(".fill size clamped to %d"), BSD_FILL_SIZE_CROCK_8
);
2356 size
= BSD_FILL_SIZE_CROCK_8
;
2360 as_warn (_("size negative; .fill ignored"));
2363 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
2365 if (rep_exp
.X_add_number
< 0)
2366 as_warn (_("repeat < 0; .fill ignored"));
2369 else if (size
&& !need_pass_2
)
2371 if (now_seg
== absolute_section
&& rep_exp
.X_op
!= O_constant
)
2373 as_bad (_("non-constant fill count for absolute section"));
2376 else if (now_seg
== absolute_section
&& fill
&& rep_exp
.X_add_number
!= 0)
2378 as_bad (_("attempt to fill absolute section with non-zero value"));
2382 && (rep_exp
.X_op
!= O_constant
|| rep_exp
.X_add_number
!= 0)
2385 as_bad (_("attempt to fill section `%s' with non-zero value"),
2386 segment_name (now_seg
));
2391 if (size
&& !need_pass_2
)
2393 if (now_seg
== absolute_section
)
2394 abs_section_offset
+= (valueT
) rep_exp
.X_add_number
* size
;
2396 if (rep_exp
.X_op
== O_constant
)
2398 p
= frag_var (rs_fill
, (int) size
, (int) size
,
2399 (relax_substateT
) 0, (symbolS
*) 0,
2400 (offsetT
) rep_exp
.X_add_number
,
2405 /* We don't have a constant repeat count, so we can't use
2406 rs_fill. We can get the same results out of rs_space,
2407 but its argument is in bytes, so we must multiply the
2408 repeat count by size. */
2411 rep_sym
= make_expr_symbol (&rep_exp
);
2414 expressionS size_exp
;
2415 size_exp
.X_op
= O_constant
;
2416 size_exp
.X_add_number
= size
;
2418 rep_exp
.X_op
= O_multiply
;
2419 rep_exp
.X_add_symbol
= rep_sym
;
2420 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
2421 rep_exp
.X_add_number
= 0;
2422 rep_sym
= make_expr_symbol (&rep_exp
);
2425 p
= frag_var (rs_space
, (int) size
, (int) size
,
2426 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
2429 memset (p
, 0, (unsigned int) size
);
2431 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
2432 flavoured AS. The following bizarre behaviour is to be
2433 compatible with above. I guess they tried to take up to 8
2434 bytes from a 4-byte expression and they forgot to sign
2436 #define BSD_FILL_SIZE_CROCK_4 (4)
2437 md_number_to_chars (p
, fill
,
2438 (size
> BSD_FILL_SIZE_CROCK_4
2439 ? BSD_FILL_SIZE_CROCK_4
2441 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
2442 but emits no error message because it seems a legal thing to do.
2443 It is a degenerate case of .fill but could be emitted by a
2446 demand_empty_rest_of_line ();
2450 s_globl (int ignore ATTRIBUTE_UNUSED
)
2459 stop
= mri_comment_field (&stopc
);
2463 if ((name
= read_symbol_name ()) == NULL
)
2466 symbolP
= symbol_find_or_make (name
);
2467 S_SET_EXTERNAL (symbolP
);
2470 c
= *input_line_pointer
;
2473 input_line_pointer
++;
2475 if (is_end_of_stmt (*input_line_pointer
))
2483 demand_empty_rest_of_line ();
2486 mri_comment_end (stop
, stopc
);
2489 /* Handle the MRI IRP and IRPC pseudo-ops. */
2501 file
= as_where (&line
);
2503 eol
= find_end_of_line (input_line_pointer
, 0);
2504 sb_build (&s
, eol
- input_line_pointer
);
2505 sb_add_buffer (&s
, input_line_pointer
, eol
- input_line_pointer
);
2506 input_line_pointer
= eol
;
2510 err
= expand_irp (irpc
, 0, &s
, &out
, get_macro_line_sb
);
2512 as_bad_where (file
, line
, "%s", err
);
2516 input_scrub_include_sb (&out
, input_line_pointer
, expanding_repeat
);
2518 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2521 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
2522 the section to only be linked once. However, this is not supported
2523 by most object file formats. This takes an optional argument,
2524 which is what to do about duplicates. */
2527 s_linkonce (int ignore ATTRIBUTE_UNUSED
)
2529 enum linkonce_type type
;
2533 type
= LINKONCE_DISCARD
;
2535 if (!is_end_of_stmt (*input_line_pointer
))
2540 c
= get_symbol_name (& s
);
2541 if (strcasecmp (s
, "discard") == 0)
2542 type
= LINKONCE_DISCARD
;
2543 else if (strcasecmp (s
, "one_only") == 0)
2544 type
= LINKONCE_ONE_ONLY
;
2545 else if (strcasecmp (s
, "same_size") == 0)
2546 type
= LINKONCE_SAME_SIZE
;
2547 else if (strcasecmp (s
, "same_contents") == 0)
2548 type
= LINKONCE_SAME_CONTENTS
;
2550 as_warn (_("unrecognized .linkonce type `%s'"), s
);
2552 (void) restore_line_pointer (c
);
2555 #ifdef obj_handle_link_once
2556 obj_handle_link_once (type
);
2557 #else /* ! defined (obj_handle_link_once) */
2561 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
2562 as_warn (_(".linkonce is not supported for this object file format"));
2564 flags
= bfd_section_flags (now_seg
);
2565 flags
|= SEC_LINK_ONCE
;
2570 case LINKONCE_DISCARD
:
2571 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
2573 case LINKONCE_ONE_ONLY
:
2574 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
2576 case LINKONCE_SAME_SIZE
:
2577 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
2579 case LINKONCE_SAME_CONTENTS
:
2580 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
2583 if (!bfd_set_section_flags (now_seg
, flags
))
2584 as_bad (_("bfd_set_section_flags: %s"),
2585 bfd_errmsg (bfd_get_error ()));
2587 #endif /* ! defined (obj_handle_link_once) */
2589 demand_empty_rest_of_line ();
2593 bss_alloc (symbolS
*symbolP
, addressT size
, unsigned int align
)
2596 segT current_seg
= now_seg
;
2597 subsegT current_subseg
= now_subseg
;
2598 segT bss_seg
= bss_section
;
2600 #if defined (TC_MIPS) || defined (TC_ALPHA)
2601 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
2602 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
2604 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
2605 if (size
<= bfd_get_gp_size (stdoutput
))
2607 bss_seg
= subseg_new (".sbss", 1);
2608 seg_info (bss_seg
)->bss
= 1;
2609 if (!bfd_set_section_flags (bss_seg
, SEC_ALLOC
| SEC_SMALL_DATA
))
2610 as_warn (_("error setting flags for \".sbss\": %s"),
2611 bfd_errmsg (bfd_get_error ()));
2615 subseg_set (bss_seg
, 1);
2617 if (align
> OCTETS_PER_BYTE_POWER
)
2619 record_alignment (bss_seg
, align
);
2620 frag_align (align
, 0, 0);
2623 /* Detach from old frag. */
2624 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2625 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2627 symbol_set_frag (symbolP
, frag_now
);
2628 pfrag
= frag_var (rs_org
, 1, 1, 0, symbolP
, size
* OCTETS_PER_BYTE
, NULL
);
2632 S_SET_SIZE (symbolP
, size
);
2634 S_SET_SEGMENT (symbolP
, bss_seg
);
2637 /* The symbol may already have been created with a preceding
2638 ".globl" directive -- be careful not to step on storage class
2639 in that case. Otherwise, set it to static. */
2640 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2641 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2642 #endif /* OBJ_COFF */
2644 subseg_set (current_seg
, current_subseg
);
2648 parse_align (int align_bytes
)
2654 if (*input_line_pointer
!= ',')
2657 as_bad (_("expected alignment after size"));
2658 ignore_rest_of_line ();
2662 input_line_pointer
++;
2665 align
= get_absolute_expr (&exp
);
2666 if (exp
.X_op
== O_absent
)
2669 if (!exp
.X_unsigned
&& exp
.X_add_number
< 0)
2671 as_warn (_("alignment negative; 0 assumed"));
2675 if (align_bytes
&& align
!= 0)
2677 /* convert to a power of 2 alignment */
2678 unsigned int alignp2
= 0;
2679 while ((align
& 1) == 0)
2680 align
>>= 1, ++alignp2
;
2683 as_bad (_("alignment not a power of 2"));
2684 ignore_rest_of_line ();
2692 /* Called from s_comm_internal after symbol name and size have been
2693 parsed. NEEDS_ALIGN is 0 if it was an ".lcomm" (2 args only),
2694 1 if this was a ".bss" directive which has a 3rd argument
2695 (alignment as a power of 2), or 2 if this was a ".bss" directive
2696 with alignment in bytes. */
2699 s_lcomm_internal (int needs_align
, symbolS
*symbolP
, addressT size
)
2705 align
= parse_align (needs_align
- 1);
2706 if (align
== (addressT
) -1)
2710 /* Assume some objects may require alignment on some systems. */
2711 TC_IMPLICIT_LCOMM_ALIGNMENT (size
, align
);
2713 bss_alloc (symbolP
, size
, align
);
2718 s_lcomm (int needs_align
)
2720 s_comm_internal (needs_align
, s_lcomm_internal
);
2724 s_lcomm_bytes (int needs_align
)
2726 s_comm_internal (needs_align
* 2, s_lcomm_internal
);
2730 s_lsym (int ignore ATTRIBUTE_UNUSED
)
2736 /* We permit ANY defined expression: BSD4.2 demands constants. */
2737 if ((name
= read_symbol_name ()) == NULL
)
2740 if (*input_line_pointer
!= ',')
2742 as_bad (_("expected comma after \"%s\""), name
);
2746 input_line_pointer
++;
2747 expression_and_evaluate (&exp
);
2749 if (exp
.X_op
!= O_constant
2750 && exp
.X_op
!= O_register
)
2752 as_bad (_("bad expression"));
2756 symbolP
= symbol_find_or_make (name
);
2758 if (S_GET_SEGMENT (symbolP
) == undefined_section
)
2760 /* The name might be an undefined .global symbol; be sure to
2761 keep the "external" bit. */
2762 S_SET_SEGMENT (symbolP
,
2763 (exp
.X_op
== O_constant
2766 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2770 as_bad (_("symbol `%s' is already defined"), name
);
2773 demand_empty_rest_of_line ();
2778 ignore_rest_of_line ();
2783 /* Read a line into an sb. Returns the character that ended the line
2784 or zero if there are no more lines. */
2787 get_line_sb (sb
*line
, int in_macro
)
2791 if (input_line_pointer
[-1] == '\n')
2792 bump_line_counters ();
2794 if (input_line_pointer
>= buffer_limit
)
2796 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2797 if (buffer_limit
== 0)
2801 eol
= _find_end_of_line (input_line_pointer
, flag_m68k_mri
, 0, in_macro
);
2802 sb_add_buffer (line
, input_line_pointer
, eol
- input_line_pointer
);
2803 input_line_pointer
= eol
;
2805 /* Don't skip multiple end-of-line characters, because that breaks support
2806 for the IA-64 stop bit (;;) which looks like two consecutive end-of-line
2807 characters but isn't. Instead just skip one end of line character and
2808 return the character skipped so that the caller can re-insert it if
2810 return *input_line_pointer
++;
2814 get_non_macro_line_sb (sb
*line
)
2816 return get_line_sb (line
, 0);
2820 get_macro_line_sb (sb
*line
)
2822 return get_line_sb (line
, 1);
2825 /* Define a macro. This is an interface to macro.c. */
2828 s_macro (int ignore ATTRIBUTE_UNUSED
)
2834 eol
= find_end_of_line (input_line_pointer
, 0);
2835 sb_build (&s
, eol
- input_line_pointer
);
2836 sb_add_buffer (&s
, input_line_pointer
, eol
- input_line_pointer
);
2837 input_line_pointer
= eol
;
2839 if (line_label
!= NULL
)
2845 name
= S_GET_NAME (line_label
);
2846 len
= strlen (name
);
2847 sb_build (&label
, len
);
2848 sb_add_buffer (&label
, name
, len
);
2849 macro
= define_macro (&s
, &label
, get_macro_line_sb
);
2853 macro
= define_macro (&s
, NULL
, get_macro_line_sb
);
2856 if (line_label
!= NULL
)
2858 S_SET_SEGMENT (line_label
, absolute_section
);
2859 S_SET_VALUE (line_label
, 0);
2860 symbol_set_frag (line_label
, &zero_address_frag
);
2863 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2864 && str_hash_find (po_hash
, macro
->name
) != NULL
)
2866 && macro
->name
[0] == '.'
2867 && str_hash_find (po_hash
, macro
->name
+ 1) != NULL
))
2869 as_warn_where (macro
->file
, macro
->line
,
2870 _("attempt to redefine pseudo-op `%s' ignored"),
2872 str_hash_delete (macro_hash
, macro
->name
);
2879 /* Handle the .mexit pseudo-op, which immediately exits a macro
2883 s_mexit (int ignore ATTRIBUTE_UNUSED
)
2887 cond_exit_macro (macro_nest
);
2888 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2891 as_warn (_("ignoring macro exit outside a macro definition."));
2894 /* Switch in and out of MRI mode. */
2897 s_mri (int ignore ATTRIBUTE_UNUSED
)
2900 #ifdef MRI_MODE_CHANGE
2904 on
= get_absolute_expression ();
2905 #ifdef MRI_MODE_CHANGE
2906 old_flag
= flag_mri
;
2914 lex_type
['?'] = LEX_BEGIN_NAME
| LEX_NAME
;
2922 lex_type
['?'] = LEX_QM
;
2925 /* Operator precedence changes in m68k MRI mode, so we need to
2926 update the operator rankings. */
2927 expr_set_precedence ();
2929 #ifdef MRI_MODE_CHANGE
2931 MRI_MODE_CHANGE (on
);
2934 demand_empty_rest_of_line ();
2937 /* Handle changing the location counter. */
2940 do_org (segT segment
, expressionS
*exp
, int fill
)
2942 if (segment
!= now_seg
2943 && segment
!= absolute_section
2944 && segment
!= expr_section
)
2945 as_bad (_("invalid segment \"%s\""), segment_name (segment
));
2947 if (now_seg
== absolute_section
)
2950 as_warn (_("ignoring fill value in absolute section"));
2951 if (exp
->X_op
!= O_constant
)
2953 as_bad (_("only constant offsets supported in absolute section"));
2954 exp
->X_add_number
= 0;
2956 abs_section_offset
= exp
->X_add_number
;
2961 symbolS
*sym
= exp
->X_add_symbol
;
2962 offsetT off
= exp
->X_add_number
* OCTETS_PER_BYTE
;
2964 if (fill
&& in_bss ())
2965 as_warn (_("ignoring fill value in section `%s'"),
2966 segment_name (now_seg
));
2968 if (exp
->X_op
!= O_constant
&& exp
->X_op
!= O_symbol
)
2970 /* Handle complex expressions. */
2971 sym
= make_expr_symbol (exp
);
2975 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, sym
, off
, (char *) 0);
2981 s_org (int ignore ATTRIBUTE_UNUSED
)
2987 #ifdef md_flush_pending_output
2988 md_flush_pending_output ();
2991 /* The m68k MRI assembler has a different meaning for .org. It
2992 means to create an absolute section at a given address. We can't
2993 support that--use a linker script instead. */
2996 as_bad (_("MRI style ORG pseudo-op not supported"));
2997 ignore_rest_of_line ();
3001 /* Don't believe the documentation of BSD 4.2 AS. There is no such
3002 thing as a sub-segment-relative origin. Any absolute origin is
3003 given a warning, then assumed to be segment-relative. Any
3004 segmented origin expression ("foo+42") had better be in the right
3005 segment or the .org is ignored.
3007 BSD 4.2 AS warns if you try to .org backwards. We cannot because
3008 we never know sub-segment sizes when we are reading code. BSD
3009 will crash trying to emit negative numbers of filler bytes in
3010 certain .orgs. We don't crash, but see as-write for that code.
3012 Don't make frag if need_pass_2==1. */
3013 segment
= get_known_segmented_expression (&exp
);
3014 if (*input_line_pointer
== ',')
3016 input_line_pointer
++;
3017 temp_fill
= get_absolute_expression ();
3023 do_org (segment
, &exp
, temp_fill
);
3025 demand_empty_rest_of_line ();
3028 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
3029 called by the obj-format routine which handles section changing
3030 when in MRI mode. It will create a new section, and return it. It
3031 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
3032 'M' (mixed), or 'R' (romable). The flags will be set in the section. */
3035 s_mri_sect (char *type ATTRIBUTE_UNUSED
)
3045 name
= input_line_pointer
;
3046 if (!ISDIGIT (*name
))
3047 c
= get_symbol_name (& name
);
3052 ++input_line_pointer
;
3054 while (ISDIGIT (*input_line_pointer
));
3056 c
= *input_line_pointer
;
3057 *input_line_pointer
= '\0';
3060 name
= xstrdup (name
);
3062 c
= restore_line_pointer (c
);
3064 seg
= subseg_new (name
, 0);
3070 ++input_line_pointer
;
3071 align
= get_absolute_expression ();
3072 record_alignment (seg
, align
);
3076 if (*input_line_pointer
== ',')
3078 c
= *++input_line_pointer
;
3080 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
3083 as_bad (_("unrecognized section type"));
3084 ++input_line_pointer
;
3089 flags
= SEC_NO_FLAGS
;
3091 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
3092 else if (*type
== 'D' || *type
== 'M')
3093 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
3094 else if (*type
== 'R')
3095 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
3096 if (flags
!= SEC_NO_FLAGS
)
3098 if (!bfd_set_section_flags (seg
, flags
))
3099 as_warn (_("error setting flags for \"%s\": %s"),
3100 bfd_section_name (seg
),
3101 bfd_errmsg (bfd_get_error ()));
3106 /* Ignore the HP type. */
3107 if (*input_line_pointer
== ',')
3108 input_line_pointer
+= 2;
3110 demand_empty_rest_of_line ();
3112 #else /* ! TC_M68K */
3113 /* The MRI assembler seems to use different forms of .sect for
3114 different targets. */
3115 as_bad ("MRI mode not supported for this target");
3116 ignore_rest_of_line ();
3117 #endif /* ! TC_M68K */
3120 /* Handle the .print pseudo-op. */
3123 s_print (int ignore ATTRIBUTE_UNUSED
)
3128 s
= demand_copy_C_string (&len
);
3131 demand_empty_rest_of_line ();
3134 /* Handle the .purgem pseudo-op. */
3137 s_purgem (int ignore ATTRIBUTE_UNUSED
)
3139 if (is_it_end_of_statement ())
3141 demand_empty_rest_of_line ();
3151 c
= get_symbol_name (& name
);
3152 delete_macro (name
);
3153 restore_line_pointer (c
);
3156 while (*input_line_pointer
++ == ',');
3158 --input_line_pointer
;
3159 demand_empty_rest_of_line ();
3162 /* Handle the .endm/.endr pseudo-ops. */
3165 s_bad_end (int endr
)
3167 as_warn (_(".end%c encountered without preceding %s"),
3169 endr
? ".rept, .irp, or .irpc" : ".macro");
3170 demand_empty_rest_of_line ();
3173 /* Handle the .rept pseudo-op. */
3176 s_rept (int expand_count
)
3180 count
= (size_t) get_absolute_expression ();
3182 do_repeat (count
, "REPT", "ENDR", expand_count
? "" : NULL
);
3185 /* This function provides a generic repeat block implementation. It allows
3186 different directives to be used as the start/end keys. Any text matching
3187 the optional EXPANDER in the block is replaced by the remaining iteration
3188 count. Except when EXPANDER is the empty string, in which case \+ will
3189 be looked for (as also recognized in macros as well as .irp and .irpc),
3190 where the replacement will be the number of iterations done so far. */
3193 do_repeat (size_t count
, const char *start
, const char *end
,
3194 const char *expander
)
3199 if (count
> 0x7fffffff)
3201 as_bad (_("excessive count %zu for %s - ignored"), count
, start
);
3206 if (!buffer_and_nest (start
, end
, &one
, get_non_macro_line_sb
))
3208 as_bad (_("%s without %s"), start
, end
);
3213 sb_terminate (&one
);
3215 if (expander
!= NULL
&& !*expander
&& strstr (one
.ptr
, "\\+") != NULL
)
3217 /* The 3 here and below are arbitrary, added in an attempt to limit
3218 re-allocation needs in sb_add_...() for moderate repeat counts. */
3219 sb_build (&many
, count
* (one
.len
+ 3));
3221 for (size_t done
= 0; count
-- > 0; ++done
)
3223 const char *ptr
, *bs
;
3226 sb_build (&processed
, one
.len
+ 3);
3228 for (ptr
= one
.ptr
; (bs
= strchr (ptr
, '\\')) != NULL
; )
3230 sb_add_buffer (&processed
, ptr
, bs
- ptr
);
3236 sb_add_char (&processed
, '\\');
3237 sb_add_char (&processed
, bs
[1]);
3242 as_warn (_("`\\' at end of line/statement; ignored"));
3247 sb_add_char (&processed
, '\\');
3252 snprintf (scratch
, ARRAY_SIZE (scratch
), "%zu", done
);
3253 sb_add_string (&processed
, scratch
);
3259 sb_add_string (&processed
, ptr
);
3261 sb_add_sb (&many
, &processed
);
3262 sb_kill (&processed
);
3265 else if (expander
== NULL
|| !*expander
|| strstr (one
.ptr
, expander
) == NULL
)
3267 sb_build (&many
, count
* one
.len
);
3269 sb_add_sb (&many
, &one
);
3275 while (count
-- > 0)
3281 sb_build (& processed
, one
.len
);
3282 sb_add_sb (& processed
, & one
);
3283 sub
= strstr (processed
.ptr
, expander
);
3284 len
= sprintf (sub
, "%lu", (unsigned long) count
);
3285 gas_assert (len
< 8);
3286 memmove (sub
+ len
, sub
+ 8,
3287 processed
.ptr
+ processed
.len
- (sub
+ 8));
3288 processed
.len
-= (8 - len
);
3289 sb_add_sb (& many
, & processed
);
3290 sb_kill (& processed
);
3296 input_scrub_include_sb (&many
, input_line_pointer
, expanding_repeat
);
3298 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
3301 /* Skip to end of current repeat loop; EXTRA indicates how many additional
3302 input buffers to skip. Assumes that conditionals preceding the loop end
3303 are properly nested.
3305 This function makes it easier to implement a premature "break" out of the
3306 loop. The EXTRA arg accounts for other buffers we might have inserted,
3307 such as line substitutions. */
3310 end_repeat (int extra
)
3312 cond_exit_macro (macro_nest
);
3313 while (extra
-- >= 0)
3314 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
3318 assign_symbol (char *name
, int mode
)
3322 if (name
[0] == '.' && name
[1] == '\0')
3324 /* Turn '. = mumble' into a .org mumble. */
3328 segment
= get_known_segmented_expression (&exp
);
3331 do_org (segment
, &exp
, 0);
3336 if ((symbolP
= symbol_find (name
)) == NULL
3337 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
3339 symbolP
= symbol_find_or_make (name
);
3341 /* When doing symbol listings, play games with dummy fragments living
3342 outside the normal fragment chain to record the file and line info
3344 if (listing
& LISTING_SYMBOLS
)
3346 fragS
*dummy_frag
= notes_calloc (1, sizeof (*dummy_frag
));
3347 dummy_frag
->line
= listing_tail
;
3348 dummy_frag
->fr_symbol
= symbolP
;
3349 symbol_set_frag (symbolP
, dummy_frag
);
3352 #ifdef obj_assign_symbol
3353 obj_assign_symbol (symbolP
);
3357 if (S_IS_DEFINED (symbolP
) || symbol_equated_p (symbolP
))
3359 if ((mode
!= 0 || !S_IS_VOLATILE (symbolP
))
3360 && !S_CAN_BE_REDEFINED (symbolP
))
3362 as_bad (_("symbol `%s' is already defined"), name
);
3363 ignore_rest_of_line ();
3364 input_line_pointer
--;
3367 /* If the symbol is volatile, copy the symbol and replace the
3368 original with the copy, so that previous uses of the symbol will
3369 retain the value of the symbol at the point of use. */
3370 else if (S_IS_VOLATILE (symbolP
))
3371 symbolP
= symbol_clone (symbolP
, 1);
3372 S_CLEAR_WEAKREFR (symbolP
);
3376 S_SET_VOLATILE (symbolP
);
3378 S_SET_FORWARD_REF (symbolP
);
3380 pseudo_set (symbolP
);
3383 /* Handle the .equ, .equiv, .eqv, and .set directives. If EQUIV is 1,
3384 then this is .equiv, and it is an error if the symbol is already
3385 defined. If EQUIV is -1, the symbol additionally is a forward
3393 /* Especial apologies for the random logic:
3394 this just grew, and could be parsed much more simply!
3396 if ((name
= read_symbol_name ()) == NULL
)
3399 if (*input_line_pointer
!= ',')
3401 as_bad (_("expected comma after \"%s\""), name
);
3402 ignore_rest_of_line ();
3407 input_line_pointer
++;
3408 assign_symbol (name
, equiv
);
3409 demand_empty_rest_of_line ();
3423 #ifdef md_flush_pending_output
3424 md_flush_pending_output ();
3431 # ifndef P_PRECISION
3432 # define P_PRECISION X_PRECISION
3433 # define P_PRECISION_PAD X_PRECISION_PAD
3435 mult
= (X_PRECISION
+ X_PRECISION_PAD
) * sizeof (LITTLENUM_TYPE
);
3443 mult
= (P_PRECISION
+ P_PRECISION_PAD
) * sizeof (LITTLENUM_TYPE
);
3450 #ifdef md_cons_align
3455 stop
= mri_comment_field (&stopc
);
3457 /* In m68k MRI mode, we need to align to a word boundary, unless
3459 if (flag_m68k_mri
&& mult
> 1)
3461 if (now_seg
== absolute_section
)
3463 abs_section_offset
+= abs_section_offset
& 1;
3464 if (line_label
!= NULL
)
3465 S_SET_VALUE (line_label
, abs_section_offset
);
3467 else if (mri_common_symbol
!= NULL
)
3471 mri_val
= S_GET_VALUE (mri_common_symbol
);
3472 if ((mri_val
& 1) != 0)
3474 S_SET_VALUE (mri_common_symbol
, mri_val
+ 1);
3475 if (line_label
!= NULL
)
3477 expressionS
*symexp
;
3479 symexp
= symbol_get_value_expression (line_label
);
3480 know (symexp
->X_op
== O_symbol
);
3481 know (symexp
->X_add_symbol
== mri_common_symbol
);
3482 symexp
->X_add_number
+= 1;
3488 do_align (1, (char *) NULL
, 0, 0);
3489 if (line_label
!= NULL
)
3491 symbol_set_frag (line_label
, frag_now
);
3492 S_SET_VALUE (line_label
, frag_now_fix ());
3502 if (*input_line_pointer
== ',')
3504 ++input_line_pointer
;
3509 val
.X_op
= O_constant
;
3510 val
.X_add_number
= 0;
3513 if ((val
.X_op
!= O_constant
3514 || val
.X_add_number
< - 0x80
3515 || val
.X_add_number
> 0xff
3516 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
3517 && (now_seg
!= absolute_section
&& !in_bss ()))
3519 resolve_expression (&exp
);
3520 if (exp
.X_op
!= O_constant
)
3521 as_bad (_("unsupported variable size or fill value"));
3526 /* PR 20901: Check for excessive values.
3527 FIXME: 1<<10 is an arbitrary limit. Maybe use maxpagesize instead ? */
3528 if (exp
.X_add_number
< 0 || exp
.X_add_number
> (1 << 10))
3529 as_bad (_("size value for space directive too large: %lx"),
3530 (long) exp
.X_add_number
);
3535 bytes
= mult
* exp
.X_add_number
;
3537 for (i
= 0; i
< exp
.X_add_number
; i
++)
3538 emit_expr (&val
, mult
);
3544 if (now_seg
== absolute_section
|| mri_common_symbol
!= NULL
)
3545 resolve_expression (&exp
);
3547 if (exp
.X_op
== O_constant
)
3549 addressT repeat
= exp
.X_add_number
;
3553 if ((offsetT
) repeat
< 0)
3555 as_warn (_(".space repeat count is negative, ignored"));
3561 as_warn (_(".space repeat count is zero, ignored"));
3564 if ((unsigned int) mult
<= 1)
3566 else if (gas_mul_overflow (repeat
, mult
, &total
)
3567 || (offsetT
) total
< 0)
3569 as_warn (_(".space repeat count overflow, ignored"));
3574 /* If we are in the absolute section, just bump the offset. */
3575 if (now_seg
== absolute_section
)
3577 if (val
.X_op
!= O_constant
|| val
.X_add_number
!= 0)
3578 as_warn (_("ignoring fill value in absolute section"));
3579 abs_section_offset
+= total
;
3583 /* If we are secretly in an MRI common section, then
3584 creating space just increases the size of the common
3586 if (mri_common_symbol
!= NULL
)
3588 S_SET_VALUE (mri_common_symbol
,
3589 S_GET_VALUE (mri_common_symbol
) + total
);
3594 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
3595 (offsetT
) total
, (char *) 0);
3599 if (now_seg
== absolute_section
)
3601 as_bad (_("space allocation too complex in absolute section"));
3602 subseg_set (text_section
, 0);
3605 if (mri_common_symbol
!= NULL
)
3607 as_bad (_("space allocation too complex in common section"));
3608 mri_common_symbol
= NULL
;
3612 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
3613 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
3616 if ((val
.X_op
!= O_constant
|| val
.X_add_number
!= 0) && in_bss ())
3617 as_warn (_("ignoring fill value in section `%s'"),
3618 segment_name (now_seg
));
3620 *p
= val
.X_add_number
;
3625 /* In MRI mode, after an odd number of bytes, we must align to an
3626 even word boundary, unless the next instruction is a dc.b, ds.b
3628 if (flag_mri
&& (bytes
& 1) != 0)
3629 mri_pending_align
= 1;
3631 demand_empty_rest_of_line ();
3634 mri_comment_end (stop
, stopc
);
3638 s_nop (int ignore ATTRIBUTE_UNUSED
)
3645 #ifdef md_flush_pending_output
3646 md_flush_pending_output ();
3651 demand_empty_rest_of_line ();
3654 start_off
= frag_now_fix ();
3657 #ifdef md_emit_single_noop
3658 md_emit_single_noop
;
3662 #ifndef md_single_noop_insn
3663 #define md_single_noop_insn "nop"
3665 /* md_assemble might modify its argument, so
3666 we must pass it a string that is writable. */
3667 nop
= xasprintf ("%s", md_single_noop_insn
);
3669 /* Some targets assume that they can update input_line_pointer
3670 inside md_assemble, and, worse, that they can leave it
3671 assigned to the string pointer that was provided as an
3672 argument. So preserve ilp here. */
3673 char *saved_ilp
= input_line_pointer
;
3675 input_line_pointer
= saved_ilp
;
3678 #ifdef md_flush_pending_output
3679 md_flush_pending_output ();
3681 } while (exp
.X_op
== O_constant
3682 && exp
.X_add_number
> 0
3683 && frag_offset_ignore_align_p (start
, frag_now
, &frag_off
)
3684 && frag_off
+ frag_now_fix () < start_off
+ exp
.X_add_number
);
3687 /* Use this to specify the amount of memory allocated for representing
3688 the nops. Needs to be large enough to hold any fixed size prologue
3689 plus the replicating portion. */
3690 #ifndef MAX_MEM_FOR_RS_SPACE_NOP
3691 # define MAX_MEM_FOR_RS_SPACE_NOP 1
3695 s_nops (int ignore ATTRIBUTE_UNUSED
)
3700 #ifdef md_flush_pending_output
3701 md_flush_pending_output ();
3706 /* Note - this expression is tested for an absolute value in
3707 write.c:relax_segment(). */
3710 if (*input_line_pointer
== ',')
3712 ++input_line_pointer
;
3717 val
.X_op
= O_constant
;
3718 val
.X_add_number
= 0;
3721 if (val
.X_op
!= O_constant
)
3723 as_bad (_("unsupported variable nop control in .nops directive"));
3724 val
.X_op
= O_constant
;
3725 val
.X_add_number
= 0;
3727 else if (val
.X_add_number
< 0)
3729 as_warn (_("negative nop control byte, ignored"));
3730 val
.X_add_number
= 0;
3733 demand_empty_rest_of_line ();
3736 /* Ignore this directive if we are going to perform a second pass. */
3739 /* Store the no-op instruction control byte in the first byte of frag. */
3741 symbolS
*sym
= make_expr_symbol (&exp
);
3742 p
= frag_var (rs_space_nop
, MAX_MEM_FOR_RS_SPACE_NOP
, 1, 0, sym
, 0, NULL
);
3743 *p
= val
.X_add_number
;
3746 /* Obtain the size of a floating point number, given a type. */
3749 float_length (int float_type
, int *pad_p
)
3751 int length
, pad
= 0;
3779 length
= X_PRECISION
* sizeof (LITTLENUM_TYPE
);
3780 pad
= X_PRECISION_PAD
* sizeof (LITTLENUM_TYPE
);
3789 length
= P_PRECISION
* sizeof (LITTLENUM_TYPE
);
3790 pad
= P_PRECISION_PAD
* sizeof (LITTLENUM_TYPE
);
3797 as_bad (_("unknown floating type '%c'"), float_type
);
3809 parse_one_float (int float_type
, char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
])
3815 /* Skip any 0{letter} that may be present. Don't even check if the
3816 letter is legal. Someone may invent a "z" format and this routine
3817 has no use for such information. Lusers beware: you get
3818 diagnostics if your input is ill-conditioned. */
3819 if (input_line_pointer
[0] == '0'
3820 && ISALPHA (input_line_pointer
[1]))
3821 input_line_pointer
+= 2;
3823 /* Accept :xxxx, where the x's are hex digits, for a floating point
3824 with the exact digits specified. */
3825 if (input_line_pointer
[0] == ':')
3827 ++input_line_pointer
;
3828 length
= hex_float (float_type
, temp
);
3831 ignore_rest_of_line ();
3839 err
= md_atof (float_type
, temp
, &length
);
3840 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3841 know (err
!= NULL
|| length
> 0);
3844 as_bad (_("bad floating literal: %s"), err
);
3845 ignore_rest_of_line ();
3853 /* This is like s_space, but the value is a floating point number with
3854 the given precision. This is for the MRI dcb.s pseudo-op and
3858 s_float_space (int float_type
)
3862 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3866 #ifdef md_cons_align
3871 stop
= mri_comment_field (&stopc
);
3873 count
= get_absolute_expression ();
3876 if (*input_line_pointer
!= ',')
3880 flen
= float_length (float_type
, &pad
);
3882 memset (temp
, 0, flen
+= pad
);
3886 ++input_line_pointer
;
3888 flen
= parse_one_float (float_type
, temp
);
3894 mri_comment_end (stop
, stopc
);
3898 while (--count
>= 0)
3902 p
= frag_more (flen
);
3903 memcpy (p
, temp
, (unsigned int) flen
);
3906 demand_empty_rest_of_line ();
3909 mri_comment_end (stop
, stopc
);
3912 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3915 s_struct (int ignore ATTRIBUTE_UNUSED
)
3921 stop
= mri_comment_field (&stopc
);
3922 abs_section_offset
= get_absolute_expression ();
3923 #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
3924 /* The ELF backend needs to know that we are changing sections, so
3925 that .previous works correctly. */
3927 obj_elf_section_change_hook ();
3929 subseg_set (absolute_section
, 0);
3930 demand_empty_rest_of_line ();
3932 mri_comment_end (stop
, stopc
);
3936 s_text (int ignore ATTRIBUTE_UNUSED
)
3940 temp
= get_absolute_expression ();
3941 subseg_set (text_section
, (subsegT
) temp
);
3942 demand_empty_rest_of_line ();
3945 /* .weakref x, y sets x as an alias to y that, as long as y is not
3946 referenced directly, will cause y to become a weak symbol. */
3948 s_weakref (int ignore ATTRIBUTE_UNUSED
)
3955 if ((name
= read_symbol_name ()) == NULL
)
3958 symbolP
= symbol_find_or_make (name
);
3960 if (S_IS_DEFINED (symbolP
) || symbol_equated_p (symbolP
))
3962 if (!S_IS_VOLATILE (symbolP
))
3964 as_bad (_("symbol `%s' is already defined"), name
);
3967 symbolP
= symbol_clone (symbolP
, 1);
3968 S_CLEAR_VOLATILE (symbolP
);
3973 if (*input_line_pointer
!= ',')
3975 as_bad (_("expected comma after \"%s\""), name
);
3979 input_line_pointer
++;
3984 if ((name
= read_symbol_name ()) == NULL
)
3987 if ((symbolP2
= symbol_find_noref (name
, 1)) == NULL
3988 && (symbolP2
= md_undefined_symbol (name
)) == NULL
)
3990 symbolP2
= symbol_find_or_make (name
);
3991 S_SET_WEAKREFD (symbolP2
);
3995 symbolS
*symp
= symbolP2
;
3997 while (S_IS_WEAKREFR (symp
) && symp
!= symbolP
)
3999 expressionS
*expP
= symbol_get_value_expression (symp
);
4001 gas_assert (expP
->X_op
== O_symbol
4002 && expP
->X_add_number
== 0);
4003 symp
= expP
->X_add_symbol
;
4005 if (symp
== symbolP
)
4009 loop
= concat (S_GET_NAME (symbolP
),
4010 " => ", S_GET_NAME (symbolP2
), (const char *) NULL
);
4013 while (symp
!= symbolP
)
4015 char *old_loop
= loop
;
4017 symp
= symbol_get_value_expression (symp
)->X_add_symbol
;
4018 loop
= concat (loop
, " => ", S_GET_NAME (symp
),
4019 (const char *) NULL
);
4023 as_bad (_("%s: would close weakref loop: %s"),
4024 S_GET_NAME (symbolP
), loop
);
4028 ignore_rest_of_line ();
4032 /* Short-circuiting instead of just checking here might speed
4033 things up a tiny little bit, but loop error messages would
4034 miss intermediate links. */
4035 /* symbolP2 = symp; */
4038 memset (&exp
, 0, sizeof (exp
));
4039 exp
.X_op
= O_symbol
;
4040 exp
.X_add_symbol
= symbolP2
;
4042 S_SET_SEGMENT (symbolP
, undefined_section
);
4043 symbol_set_value_expression (symbolP
, &exp
);
4044 symbol_set_frag (symbolP
, &zero_address_frag
);
4045 S_SET_WEAKREFR (symbolP
);
4047 demand_empty_rest_of_line ();
4052 ignore_rest_of_line ();
4058 /* Verify that we are at the end of a line. If not, issue an error and
4059 skip to EOL. This function may leave input_line_pointer one past
4060 buffer_limit, so should not be called from places that may
4061 dereference input_line_pointer unconditionally. Note that when the
4062 gas parser is switched to handling a string (where buffer_limit
4063 should be the size of the string excluding the NUL terminator) this
4064 will be one past the NUL; is_end_of_line(0) returns true. */
4067 demand_empty_rest_of_line (void)
4070 if (input_line_pointer
> buffer_limit
)
4072 if (is_end_of_stmt (*input_line_pointer
))
4073 input_line_pointer
++;
4076 if (ISPRINT (*input_line_pointer
))
4077 as_bad (_("junk at end of line, first unrecognized character is `%c'"),
4078 *input_line_pointer
);
4080 as_bad (_("junk at end of line, first unrecognized character valued 0x%x"),
4081 *input_line_pointer
);
4082 ignore_rest_of_line ();
4084 /* Return pointing just after end-of-line. */
4087 /* Silently advance to the end of a statement. Use this after already having
4088 issued an error about something bad. Like demand_empty_rest_of_line,
4089 this function may leave input_line_pointer one after buffer_limit;
4090 Don't call it from within expression parsing code in an attempt to
4091 silence further errors. */
4094 ignore_rest_of_line (void)
4096 while (input_line_pointer
<= buffer_limit
)
4097 if (is_end_of_stmt (*input_line_pointer
++))
4099 /* Return pointing just after end-of-statement. */
4102 /* Sets frag for given symbol to zero_address_frag, except when the
4103 symbol frag is already set to a dummy listing frag. */
4106 set_zero_frag (symbolS
*symbolP
)
4108 if (symbol_get_frag (symbolP
)->fr_type
!= rs_dummy
)
4109 symbol_set_frag (symbolP
, &zero_address_frag
);
4112 /* In: Pointer to a symbol.
4113 Input_line_pointer->expression.
4115 Out: Input_line_pointer->just after any whitespace after expression.
4116 Tried to set symbol to value of expression.
4117 Will change symbols type, value, and frag; */
4120 pseudo_set (symbolS
*symbolP
)
4125 know (symbolP
); /* NULL pointer is logic error. */
4127 if (!S_IS_FORWARD_REF (symbolP
))
4128 (void) expression (&exp
);
4130 (void) expr (0, &exp
, expr_defer_incl_dot
);
4132 if (exp
.X_op
== O_illegal
)
4133 as_bad (_("illegal expression"));
4134 else if (exp
.X_op
== O_absent
)
4135 as_bad (_("missing expression"));
4136 else if (exp
.X_op
== O_big
)
4138 if (exp
.X_add_number
> 0)
4139 as_bad (_("bignum invalid"));
4141 as_bad (_("floating point number invalid"));
4143 else if (exp
.X_op
== O_subtract
4144 && !S_IS_FORWARD_REF (symbolP
)
4145 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
4146 && (symbol_get_frag (exp
.X_add_symbol
)
4147 == symbol_get_frag (exp
.X_op_symbol
)))
4149 exp
.X_op
= O_constant
;
4150 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
4151 - S_GET_VALUE (exp
.X_op_symbol
));
4154 if (symbol_section_p (symbolP
))
4156 as_bad ("attempt to set value of section symbol");
4165 exp
.X_add_number
= 0;
4168 S_SET_SEGMENT (symbolP
, absolute_section
);
4169 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
4170 set_zero_frag (symbolP
);
4174 #ifndef TC_GLOBAL_REGISTER_SYMBOL_OK
4175 if (S_IS_EXTERNAL (symbolP
))
4177 as_bad ("can't equate global symbol `%s' with register name",
4178 S_GET_NAME (symbolP
));
4182 /* Make sure symbol_equated_p() recognizes the symbol as an equate. */
4183 exp
.X_add_symbol
= make_expr_symbol (&exp
);
4184 exp
.X_add_number
= 0;
4185 exp
.X_op
= O_symbol
;
4186 symbol_set_value_expression (symbolP
, &exp
);
4187 S_SET_SEGMENT (symbolP
, reg_section
);
4188 set_zero_frag (symbolP
);
4192 seg
= S_GET_SEGMENT (exp
.X_add_symbol
);
4193 if (seg
== expr_section
)
4195 /* For x=undef+const, create an expression symbol.
4196 For x=x+const, just update x except when x is an undefined symbol
4197 For x=defined+const, evaluate x. */
4198 if (symbolP
== exp
.X_add_symbol
4199 && (seg
!= undefined_section
4200 || !symbol_constant_p (symbolP
)))
4202 *symbol_X_add_number (symbolP
) += exp
.X_add_number
;
4205 else if (!S_IS_FORWARD_REF (symbolP
) && seg
!= undefined_section
)
4207 symbolS
*s
= exp
.X_add_symbol
;
4209 if (S_IS_COMMON (s
))
4210 as_bad (_("`%s' can't be equated to common symbol `%s'"),
4211 S_GET_NAME (symbolP
), S_GET_NAME (s
));
4213 S_SET_SEGMENT (symbolP
, seg
);
4214 S_SET_VALUE (symbolP
, exp
.X_add_number
+ S_GET_VALUE (s
));
4215 symbol_set_frag (symbolP
, symbol_get_frag (s
));
4216 copy_symbol_attributes (symbolP
, s
);
4219 S_SET_SEGMENT (symbolP
, undefined_section
);
4220 symbol_set_value_expression (symbolP
, &exp
);
4221 copy_symbol_attributes (symbolP
, exp
.X_add_symbol
);
4222 set_zero_frag (symbolP
);
4227 /* The value is some complex expression. */
4228 S_SET_SEGMENT (symbolP
, expr_section
);
4229 symbol_set_value_expression (symbolP
, &exp
);
4230 set_zero_frag (symbolP
);
4237 CONStruct more frag of .bytes, or .words etc.
4238 Should need_pass_2 be 1 then emit no frag(s).
4239 This understands EXPRESSIONS.
4243 This has a split personality. We use expression() to read the
4244 value. We can detect if the value won't fit in a byte or word.
4245 But we can't detect if expression() discarded significant digits
4246 in the case of a long. Not worth the crocks required to fix it. */
4248 /* Select a parser for cons expressions. */
4250 /* Some targets need to parse the expression in various fancy ways.
4251 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
4252 (for example, the HPPA does this). Otherwise, you can define
4253 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
4254 are defined, which is the normal case, then only simple expressions
4259 parse_mri_cons (expressionS
*exp
, unsigned int nbytes
);
4262 /* This function is used by .cfi_* directive handling, and hence must not
4263 invoke parse_repeat_cons(). */
4265 TC_PARSE_CONS_RETURN_TYPE
4266 do_parse_cons_expression (expressionS
*exp
,
4267 int nbytes ATTRIBUTE_UNUSED
)
4269 #ifdef TC_PARSE_CONS_EXPRESSION
4270 return TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
4273 return TC_PARSE_CONS_RETURN_NONE
;
4277 #ifndef TC_PARSE_CONS_EXPRESSION
4278 #ifdef REPEAT_CONS_EXPRESSIONS
4279 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) \
4280 (parse_repeat_cons (EXP, NBYTES), TC_PARSE_CONS_RETURN_NONE)
4282 parse_repeat_cons (expressionS
*exp
, unsigned int nbytes
);
4285 /* If we haven't gotten one yet, just call expression. */
4286 #ifndef TC_PARSE_CONS_EXPRESSION
4287 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) \
4288 (expression (EXP), TC_PARSE_CONS_RETURN_NONE)
4292 /* Worker to do .byte etc statements.
4293 Clobbers input_line_pointer and checks end-of-line. */
4296 cons_worker (int nbytes
, /* 1=.byte, 2=.word, 4=.long. */
4304 #ifdef md_flush_pending_output
4305 md_flush_pending_output ();
4309 stop
= mri_comment_field (&stopc
);
4311 if (is_it_end_of_statement ())
4313 demand_empty_rest_of_line ();
4315 mri_comment_end (stop
, stopc
);
4320 nbytes
= TC_ADDRESS_BYTES ();
4322 #ifdef md_cons_align
4323 md_cons_align (nbytes
);
4329 TC_PARSE_CONS_RETURN_TYPE ret
= TC_PARSE_CONS_RETURN_NONE
;
4330 #ifdef TC_CONS_FIX_CHECK
4331 fixS
**cur_fix
= &frchain_now
->fix_tail
;
4333 if (*cur_fix
!= NULL
)
4334 cur_fix
= &(*cur_fix
)->fx_next
;
4339 parse_mri_cons (&exp
, (unsigned int) nbytes
);
4344 if (*input_line_pointer
== '"')
4346 as_bad (_("unexpected `\"' in expression"));
4347 ignore_rest_of_line ();
4351 ret
= TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
4356 if (exp
.X_op
== O_symbol
)
4357 exp
.X_op
= O_symbol_rva
;
4359 as_fatal (_("rva without symbol"));
4361 emit_expr_with_reloc (&exp
, (unsigned int) nbytes
, ret
);
4362 #ifdef TC_CONS_FIX_CHECK
4363 TC_CONS_FIX_CHECK (&exp
, nbytes
, *cur_fix
);
4367 while (*input_line_pointer
++ == ',');
4369 /* In MRI mode, after an odd number of bytes, we must align to an
4370 even word boundary, unless the next instruction is a dc.b, ds.b
4372 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
4373 mri_pending_align
= 1;
4375 input_line_pointer
--; /* Put terminator back into stream. */
4377 demand_empty_rest_of_line ();
4380 mri_comment_end (stop
, stopc
);
4382 /* Disallow hand-crafting instructions using .byte. FIXME - what about
4383 .word, .long etc ? */
4384 if (flag_synth_cfi
&& frchain_now
&& frchain_now
->frch_ginsn_data
4386 as_bad (_("SCFI: hand-crafting instructions not supported"));
4392 cons_worker (size
, 0);
4398 cons_worker (size
, 1);
4401 /* .reloc offset, reloc_name, symbol+addend. */
4404 s_reloc (int ignore ATTRIBUTE_UNUSED
)
4411 struct reloc_list
*reloc
;
4412 struct _bfd_rel
{ const char * name
; bfd_reloc_code_real_type code
; };
4413 static const struct _bfd_rel bfd_relocs
[] =
4415 { "NONE", BFD_RELOC_NONE
},
4416 { "8", BFD_RELOC_8
},
4417 { "16", BFD_RELOC_16
},
4418 { "32", BFD_RELOC_32
},
4419 { "64", BFD_RELOC_64
}
4422 reloc
= notes_alloc (sizeof (*reloc
));
4425 stop
= mri_comment_field (&stopc
);
4434 as_bad (_("missing or bad offset expression"));
4437 exp
.X_add_symbol
= section_symbol (now_seg
);
4438 /* Mark the section symbol used in relocation so that it will be
4439 included in the symbol table. */
4440 symbol_mark_used_in_reloc (exp
.X_add_symbol
);
4441 exp
.X_op
= O_symbol
;
4444 if (exp
.X_add_number
== 0)
4446 reloc
->u
.a
.offset_sym
= exp
.X_add_symbol
;
4451 reloc
->u
.a
.offset_sym
= make_expr_symbol (&exp
);
4456 if (*input_line_pointer
!= ',')
4458 as_bad (_("missing reloc type"));
4462 ++input_line_pointer
;
4464 c
= get_symbol_name (& r_name
);
4465 if (strncasecmp (r_name
, "BFD_RELOC_", 10) == 0)
4469 for (reloc
->u
.a
.howto
= NULL
, i
= 0; i
< ARRAY_SIZE (bfd_relocs
); i
++)
4470 if (strcasecmp (r_name
+ 10, bfd_relocs
[i
].name
) == 0)
4472 reloc
->u
.a
.howto
= bfd_reloc_type_lookup (stdoutput
,
4473 bfd_relocs
[i
].code
);
4478 reloc
->u
.a
.howto
= bfd_reloc_name_lookup (stdoutput
, r_name
);
4479 restore_line_pointer (c
);
4480 if (reloc
->u
.a
.howto
== NULL
)
4482 as_bad (_("unrecognized reloc type"));
4486 exp
.X_op
= O_absent
;
4488 if (*input_line_pointer
== ',')
4490 ++input_line_pointer
;
4498 as_bad (_("bad reloc expression"));
4500 ignore_rest_of_line ();
4502 mri_comment_end (stop
, stopc
);
4505 reloc
->u
.a
.sym
= NULL
;
4506 reloc
->u
.a
.addend
= 0;
4509 reloc
->u
.a
.sym
= NULL
;
4510 reloc
->u
.a
.addend
= exp
.X_add_number
;
4513 reloc
->u
.a
.sym
= exp
.X_add_symbol
;
4514 reloc
->u
.a
.addend
= exp
.X_add_number
;
4517 reloc
->u
.a
.sym
= make_expr_symbol (&exp
);
4518 reloc
->u
.a
.addend
= 0;
4522 reloc
->file
= as_where (&reloc
->line
);
4523 reloc
->next
= reloc_list
;
4526 demand_empty_rest_of_line ();
4528 mri_comment_end (stop
, stopc
);
4531 /* Put the contents of expression EXP into the object file using
4532 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
4535 emit_expr (expressionS
*exp
, unsigned int nbytes
)
4537 emit_expr_with_reloc (exp
, nbytes
, TC_PARSE_CONS_RETURN_NONE
);
4541 emit_expr_with_reloc (expressionS
*exp
,
4542 unsigned int nbytes
,
4543 TC_PARSE_CONS_RETURN_TYPE reloc
)
4547 valueT extra_digit
= 0;
4549 /* Don't do anything if we are going to make another pass. */
4554 symbol_set_value_now (&dot_symbol
);
4558 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
4559 appear as a four byte positive constant in the .line section,
4560 followed by a 2 byte 0xffff. Look for that case here. */
4561 if (strcmp (segment_name (now_seg
), ".line") != 0)
4563 else if (dwarf_line
>= 0
4565 && exp
->X_op
== O_constant
4566 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
4567 listing_source_line ((unsigned int) dwarf_line
);
4568 else if (nbytes
== 4
4569 && exp
->X_op
== O_constant
4570 && exp
->X_add_number
>= 0)
4571 dwarf_line
= exp
->X_add_number
;
4575 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
4576 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
4577 AT_sibling (0x12) followed by a four byte address of the sibling
4578 followed by a 2 byte AT_name (0x38) followed by the name of the
4579 file. We look for that case here. */
4580 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4582 else if (dwarf_file
== 0
4584 && exp
->X_op
== O_constant
4585 && exp
->X_add_number
== 0x11)
4587 else if (dwarf_file
== 1
4589 && exp
->X_op
== O_constant
4590 && exp
->X_add_number
== 0x12)
4592 else if (dwarf_file
== 2
4595 else if (dwarf_file
== 3
4597 && exp
->X_op
== O_constant
4598 && exp
->X_add_number
== 0x38)
4603 /* The variable dwarf_file_string tells stringer that the string
4604 may be the name of the source file. */
4605 if (dwarf_file
== 4)
4606 dwarf_file_string
= 1;
4608 dwarf_file_string
= 0;
4612 if (check_eh_frame (exp
, &nbytes
))
4617 /* Handle a negative bignum. */
4619 && exp
->X_add_number
== 0
4620 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
4621 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
4624 unsigned long carry
;
4626 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
4628 /* Negate the bignum: one's complement each digit and add 1. */
4630 for (i
= 0; i
< exp
->X_add_number
; i
++)
4634 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
4637 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
4638 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
4641 /* We can ignore any carry out, because it will be handled by
4642 extra_digit if it is needed. */
4644 extra_digit
= (valueT
) -1;
4648 if (op
== O_absent
|| op
== O_illegal
)
4650 as_warn (_("zero assumed for missing expression"));
4651 exp
->X_add_number
= 0;
4654 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4656 as_bad (_("floating point number invalid"));
4657 exp
->X_add_number
= 0;
4660 else if (op
== O_register
)
4662 as_warn (_("register value used as expression"));
4666 /* Allow `.word 0' in the absolute section. */
4667 if (now_seg
== absolute_section
)
4669 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
4670 as_bad (_("attempt to store value in absolute section"));
4671 abs_section_offset
+= nbytes
;
4675 /* Allow `.word 0' in BSS style sections. */
4676 if ((op
!= O_constant
|| exp
->X_add_number
!= 0) && in_bss ())
4677 as_bad (_("attempt to store non-zero value in section `%s'"),
4678 segment_name (now_seg
));
4680 p
= frag_more ((int) nbytes
);
4682 if (reloc
!= TC_PARSE_CONS_RETURN_NONE
)
4684 emit_expr_fix (exp
, nbytes
, frag_now
, p
, reloc
);
4688 #ifndef WORKING_DOT_WORD
4689 /* If we have the difference of two symbols in a word, save it on
4690 the broken_words list. See the code in write.c. */
4691 if (op
== O_subtract
&& nbytes
== 2)
4693 struct broken_word
*x
;
4695 x
= XNEW (struct broken_word
);
4696 x
->next_broken_word
= broken_words
;
4699 x
->subseg
= now_subseg
;
4701 x
->word_goes_here
= p
;
4703 x
->add
= exp
->X_add_symbol
;
4704 x
->sub
= exp
->X_op_symbol
;
4705 x
->addnum
= exp
->X_add_number
;
4713 /* If we have an integer, but the number of bytes is too large to
4714 pass to md_number_to_chars, handle it as a bignum. */
4715 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
4717 extra_digit
= -convert_to_bignum (exp
);
4721 if (op
== O_constant
)
4728 /* JF << of >= number of bits in the object is undefined. In
4729 particular SPARC (Sun 4) has problems. */
4730 if (nbytes
>= sizeof (valueT
))
4732 know (nbytes
== sizeof (valueT
));
4737 /* Don't store these bits. */
4738 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
4741 unmask
= ~mask
; /* Do store these bits. */
4744 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
4745 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
4748 get
= exp
->X_add_number
;
4750 if ((get
& mask
) != 0 && (-get
& mask
) != 0)
4752 /* Leading bits contain both 0s & 1s. */
4753 as_warn (_("value 0x%" PRIx64
" truncated to 0x%" PRIx64
),
4754 (uint64_t) get
, (uint64_t) use
);
4756 /* Put bytes in right order. */
4757 md_number_to_chars (p
, use
, (int) nbytes
);
4759 else if (op
== O_big
)
4762 LITTLENUM_TYPE
*nums
;
4764 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
4767 int i
= nbytes
/ CHARS_PER_LITTLENUM
;
4771 LITTLENUM_TYPE sign
= 0;
4772 if ((generic_bignum
[--i
]
4773 & (1 << (LITTLENUM_NUMBER_OF_BITS
- 1))) != 0)
4774 sign
= ~(LITTLENUM_TYPE
) 0;
4776 while (++i
< exp
->X_add_number
)
4777 if (generic_bignum
[i
] != sign
)
4780 else if (nbytes
== 1)
4782 /* We have nbytes == 1 and CHARS_PER_LITTLENUM == 2 (probably).
4783 Check that bits 8.. of generic_bignum[0] match bit 7
4784 and that they match all of generic_bignum[1..exp->X_add_number]. */
4785 LITTLENUM_TYPE sign
= (generic_bignum
[0] & (1 << 7)) ? -1 : 0;
4786 LITTLENUM_TYPE himask
= LITTLENUM_MASK
& ~ 0xFF;
4788 if ((generic_bignum
[0] & himask
) == (sign
& himask
))
4790 while (++i
< exp
->X_add_number
)
4791 if (generic_bignum
[i
] != sign
)
4796 if (i
< exp
->X_add_number
)
4797 as_warn (ngettext ("bignum truncated to %d byte",
4798 "bignum truncated to %d bytes",
4806 md_number_to_chars (p
, (valueT
) generic_bignum
[0], 1);
4809 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
4811 if (target_big_endian
)
4813 while (nbytes
> size
)
4815 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
4816 nbytes
-= CHARS_PER_LITTLENUM
;
4817 p
+= CHARS_PER_LITTLENUM
;
4820 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
4821 while (size
>= CHARS_PER_LITTLENUM
)
4824 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
4825 size
-= CHARS_PER_LITTLENUM
;
4826 p
+= CHARS_PER_LITTLENUM
;
4831 nums
= generic_bignum
;
4832 while (size
>= CHARS_PER_LITTLENUM
)
4834 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
4836 size
-= CHARS_PER_LITTLENUM
;
4837 p
+= CHARS_PER_LITTLENUM
;
4838 nbytes
-= CHARS_PER_LITTLENUM
;
4841 while (nbytes
>= CHARS_PER_LITTLENUM
)
4843 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
4844 nbytes
-= CHARS_PER_LITTLENUM
;
4845 p
+= CHARS_PER_LITTLENUM
;
4850 emit_expr_fix (exp
, nbytes
, frag_now
, p
, TC_PARSE_CONS_RETURN_NONE
);
4854 emit_expr_fix (expressionS
*exp
, unsigned int nbytes
, fragS
*frag
, char *p
,
4855 TC_PARSE_CONS_RETURN_TYPE r ATTRIBUTE_UNUSED
)
4858 unsigned int size
= nbytes
;
4860 memset (p
, 0, size
);
4862 /* Generate a fixS to record the symbol value. */
4864 #ifdef TC_CONS_FIX_NEW
4865 TC_CONS_FIX_NEW (frag
, p
- frag
->fr_literal
+ offset
, size
, exp
, r
);
4867 if (r
!= TC_PARSE_CONS_RETURN_NONE
)
4869 reloc_howto_type
*reloc_howto
;
4871 reloc_howto
= bfd_reloc_type_lookup (stdoutput
, r
);
4872 size
= bfd_get_reloc_size (reloc_howto
);
4876 as_bad (ngettext ("%s relocations do not fit in %u byte",
4877 "%s relocations do not fit in %u bytes",
4879 reloc_howto
->name
, nbytes
);
4882 else if (target_big_endian
)
4883 offset
= nbytes
- size
;
4904 as_bad (_("unsupported BFD relocation size %u"), size
);
4907 fix_new_exp (frag
, p
- frag
->fr_literal
+ offset
, size
,
4912 /* Handle an MRI style string expression. */
4916 parse_mri_cons (expressionS
*exp
, unsigned int nbytes
)
4918 if (*input_line_pointer
!= '\''
4919 && (input_line_pointer
[1] != '\''
4920 || (*input_line_pointer
!= 'A'
4921 && *input_line_pointer
!= 'E')))
4922 (void) TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
4926 unsigned int result
= 0;
4928 /* An MRI style string. Cut into as many bytes as will fit into
4929 a nbyte chunk, left justify if necessary, and separate with
4930 commas so we can try again later. */
4931 if (*input_line_pointer
== 'A')
4932 ++input_line_pointer
;
4933 else if (*input_line_pointer
== 'E')
4935 as_bad (_("EBCDIC constants are not supported"));
4936 ++input_line_pointer
;
4939 input_line_pointer
++;
4940 for (scan
= 0; scan
< nbytes
; scan
++)
4942 if (*input_line_pointer
== '\'')
4944 if (input_line_pointer
[1] == '\'')
4946 input_line_pointer
++;
4951 result
= (result
<< 8) | (*input_line_pointer
++);
4955 while (scan
< nbytes
)
4961 /* Create correct expression. */
4962 exp
->X_op
= O_constant
;
4963 exp
->X_add_number
= result
;
4965 /* Fake it so that we can read the next char too. */
4966 if (input_line_pointer
[0] != '\'' ||
4967 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
4969 input_line_pointer
-= 2;
4970 input_line_pointer
[0] = ',';
4971 input_line_pointer
[1] = '\'';
4974 input_line_pointer
++;
4977 #endif /* TC_M68K */
4979 #ifdef REPEAT_CONS_EXPRESSIONS
4981 /* Parse a repeat expression for cons. This is used by the MIPS
4982 assembler. The format is NUMBER:COUNT; NUMBER appears in the
4983 object file COUNT times.
4985 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
4988 parse_repeat_cons (expressionS
*exp
, unsigned int nbytes
)
4995 if (*input_line_pointer
!= ':')
4997 /* No repeat count. */
5001 ++input_line_pointer
;
5002 expression (&count
);
5003 if (count
.X_op
!= O_constant
5004 || count
.X_add_number
<= 0)
5006 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
5010 /* The cons function is going to output this expression once. So we
5011 output it count - 1 times. */
5012 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
5013 emit_expr (exp
, nbytes
);
5016 #endif /* REPEAT_CONS_EXPRESSIONS */
5018 /* Parse a floating point number represented as a hex constant. This
5019 permits users to specify the exact bits they want in the floating
5023 hex_float (int float_type
, char *bytes
)
5025 int pad
, length
= float_length (float_type
, &pad
);
5031 /* It would be nice if we could go through expression to parse the
5032 hex constant, but if we get a bignum it's a pain to sort it into
5033 the buffer correctly. */
5035 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
5039 /* The MRI assembler accepts arbitrary underscores strewn about
5040 through the hex constant, so we ignore them as well. */
5041 if (*input_line_pointer
== '_')
5043 ++input_line_pointer
;
5049 as_warn (_("floating point constant too large"));
5052 d
= hex_value (*input_line_pointer
) << 4;
5053 ++input_line_pointer
;
5054 while (*input_line_pointer
== '_')
5055 ++input_line_pointer
;
5056 if (hex_p (*input_line_pointer
))
5058 d
+= hex_value (*input_line_pointer
);
5059 ++input_line_pointer
;
5061 if (target_big_endian
)
5064 bytes
[length
- i
- 1] = d
;
5070 if (target_big_endian
)
5071 memset (bytes
+ i
, 0, length
- i
);
5073 memset (bytes
, 0, length
- i
);
5076 memset (bytes
+ length
, 0, pad
);
5078 return length
+ pad
;
5083 CONStruct some more frag chars of .floats .ffloats etc.
5084 Makes 0 or more new frags.
5085 If need_pass_2 == 1, no frags are emitted.
5086 This understands only floating literals, not expressions. Sorry.
5088 A floating constant is defined by atof_generic(), except it is preceded
5089 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
5090 reading, I decided to be incompatible. This always tries to give you
5091 rounded bits to the precision of the pseudo-op. Former AS did premature
5092 truncation, restored noisy bits instead of trailing 0s AND gave you
5093 a choice of 2 flavours of noise according to which of 2 floating-point
5094 scanners you directed AS to use.
5096 In: input_line_pointer->whitespace before, or '0' of flonum. */
5099 float_cons (/* Clobbers input_line-pointer, checks end-of-line. */
5100 int float_type
/* 'f':.ffloat ... 'F':.float ... */)
5103 int length
; /* Number of chars in an object. */
5104 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
5106 if (is_it_end_of_statement ())
5108 demand_empty_rest_of_line ();
5112 if (now_seg
== absolute_section
)
5114 as_bad (_("attempt to store float in absolute section"));
5115 ignore_rest_of_line ();
5121 as_bad (_("attempt to store float in section `%s'"),
5122 segment_name (now_seg
));
5123 ignore_rest_of_line ();
5127 #ifdef md_flush_pending_output
5128 md_flush_pending_output ();
5131 #ifdef md_cons_align
5137 length
= parse_one_float (float_type
, temp
);
5147 #ifdef REPEAT_CONS_EXPRESSIONS
5148 if (*input_line_pointer
== ':')
5150 expressionS count_exp
;
5152 ++input_line_pointer
;
5153 expression (&count_exp
);
5155 if (count_exp
.X_op
!= O_constant
5156 || count_exp
.X_add_number
<= 0)
5157 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
5159 count
= count_exp
.X_add_number
;
5163 while (--count
>= 0)
5165 p
= frag_more (length
);
5166 memcpy (p
, temp
, (unsigned int) length
);
5171 while (*input_line_pointer
++ == ',');
5173 /* Put terminator back into stream. */
5174 --input_line_pointer
;
5175 demand_empty_rest_of_line ();
5180 Note - we are using the DWARF standard's definition of LEB128 encoding
5181 where each 7-bit value is a stored in a byte, *not* an octet. This
5182 means that on targets where a byte contains multiple octets there is
5183 a *huge waste of space*. (This also means that we do not have to
5184 have special versions of these functions for when OCTETS_PER_BYTE_POWER
5187 If the 7-bit values were to be packed into N-bit bytes (where N > 8)
5188 we would then have to consider whether multiple, successive LEB128
5189 values should be packed into the bytes without padding (bad idea) or
5190 whether each LEB128 number is padded out to a whole number of bytes.
5191 Plus you have to decide on the endianness of packing octets into a
5194 /* Return the size of a LEB128 value in bytes. */
5196 static inline unsigned int
5197 sizeof_sleb128 (offsetT value
)
5204 byte
= (value
& 0x7f);
5205 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
5206 Fortunately, we can structure things so that the extra work reduces
5207 to a noop on systems that do things "properly". */
5208 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
5211 while (!(((value
== 0) && ((byte
& 0x40) == 0))
5212 || ((value
== -1) && ((byte
& 0x40) != 0))));
5217 static inline unsigned int
5218 sizeof_uleb128 (valueT value
)
5233 sizeof_leb128 (valueT value
, int sign
)
5236 return sizeof_sleb128 ((offsetT
) value
);
5238 return sizeof_uleb128 (value
);
5241 /* Output a LEB128 value. Returns the number of bytes used. */
5243 static inline unsigned int
5244 output_sleb128 (char *p
, offsetT value
)
5251 unsigned byte
= (value
& 0x7f);
5253 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
5254 Fortunately, we can structure things so that the extra work reduces
5255 to a noop on systems that do things "properly". */
5256 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
5258 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
5259 || ((value
== -1) && ((byte
& 0x40) != 0))));
5270 static inline unsigned int
5271 output_uleb128 (char *p
, valueT value
)
5277 unsigned byte
= (value
& 0x7f);
5281 /* More bytes to follow. */
5292 output_leb128 (char *p
, valueT value
, int sign
)
5295 return output_sleb128 (p
, (offsetT
) value
);
5297 return output_uleb128 (p
, value
);
5300 /* Do the same for bignums. We combine sizeof with output here in that
5301 we don't output for NULL values of P. It isn't really as critical as
5302 for "normal" values that this be streamlined. Returns the number of
5305 static inline unsigned int
5306 output_big_sleb128 (char *p
, LITTLENUM_TYPE
*bignum
, unsigned int size
)
5313 /* Strip leading sign extensions off the bignum. */
5315 && bignum
[size
- 1] == LITTLENUM_MASK
5316 && bignum
[size
- 2] > LITTLENUM_MASK
/ 2)
5321 /* OR in the next part of the littlenum. */
5322 val
|= (*bignum
<< loaded
);
5323 loaded
+= LITTLENUM_NUMBER_OF_BITS
;
5327 /* Add bytes until there are less than 7 bits left in VAL
5328 or until every non-sign bit has been written. */
5335 || val
!= ((byte
& 0x40) == 0 ? 0 : ((valueT
) 1 << loaded
) - 1))
5342 while ((byte
& 0x80) != 0 && loaded
>= 7);
5346 /* Mop up any left-over bits (of which there will be less than 7). */
5347 if ((byte
& 0x80) != 0)
5349 /* Sign-extend VAL. */
5350 if (val
& (1 << (loaded
- 1)))
5351 val
|= ~0U << loaded
;
5360 static inline unsigned int
5361 output_big_uleb128 (char *p
, LITTLENUM_TYPE
*bignum
, unsigned int size
)
5368 /* Strip leading zeros off the bignum. */
5369 /* XXX: Is this needed? */
5370 while (size
> 0 && bignum
[size
- 1] == 0)
5375 if (loaded
< 7 && size
> 0)
5377 val
|= (*bignum
<< loaded
);
5378 loaded
+= 8 * CHARS_PER_LITTLENUM
;
5387 if (size
> 0 || val
)
5394 while (byte
& 0x80);
5400 output_big_leb128 (char *p
, LITTLENUM_TYPE
*bignum
, unsigned int size
, int sign
)
5403 return output_big_sleb128 (p
, bignum
, size
);
5405 return output_big_uleb128 (p
, bignum
, size
);
5408 /* Generate the appropriate fragments for a given expression to emit a
5409 leb128 value. SIGN is 1 for sleb, 0 for uleb. */
5412 emit_leb128_expr (expressionS
*exp
, int sign
)
5414 operatorT op
= exp
->X_op
;
5415 unsigned int nbytes
;
5417 if (op
== O_absent
|| op
== O_illegal
)
5419 as_warn (_("zero assumed for missing expression"));
5420 exp
->X_add_number
= 0;
5423 else if (op
== O_big
&& exp
->X_add_number
<= 0)
5425 as_bad (_("floating point number invalid"));
5426 exp
->X_add_number
= 0;
5429 else if (op
== O_register
)
5431 as_warn (_("register value used as expression"));
5434 else if (op
== O_constant
5437 ? exp
->X_add_number
< 0
5438 : (exp
->X_add_number
< 0) != exp
->X_extrabit
))
5440 /* We're outputting a signed leb128 and the sign of X_add_number
5441 doesn't reflect the sign of the original value. Convert EXP
5442 to a correctly-extended bignum instead. */
5443 convert_to_bignum (exp
);
5447 if (now_seg
== absolute_section
)
5449 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
5450 as_bad (_("attempt to store value in absolute section"));
5451 abs_section_offset
++;
5455 if ((op
!= O_constant
|| exp
->X_add_number
!= 0) && in_bss ())
5456 as_bad (_("attempt to store non-zero value in section `%s'"),
5457 segment_name (now_seg
));
5459 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
5460 a signal that this is leb128 data. It shouldn't optimize this away. */
5461 nbytes
= (unsigned int) -1;
5462 if (check_eh_frame (exp
, &nbytes
))
5465 /* Let the backend know that subsequent data may be byte aligned. */
5466 #ifdef md_cons_align
5470 if (op
== O_constant
)
5472 /* If we've got a constant, emit the thing directly right now. */
5474 valueT value
= exp
->X_add_number
;
5478 size
= sizeof_leb128 (value
, sign
);
5479 p
= frag_more (size
);
5480 if (output_leb128 (p
, value
, sign
) > size
)
5483 else if (op
== O_big
)
5485 /* O_big is a different sort of constant. */
5486 int nbr_digits
= exp
->X_add_number
;
5490 /* If the leading littenum is 0xffff, prepend a 0 to avoid confusion with
5491 a signed number. Unary operators like - or ~ always extend the
5492 bignum to its largest size. */
5494 && nbr_digits
< SIZE_OF_LARGE_NUMBER
5495 && generic_bignum
[nbr_digits
- 1] == LITTLENUM_MASK
)
5496 generic_bignum
[nbr_digits
++] = 0;
5498 size
= output_big_leb128 (NULL
, generic_bignum
, nbr_digits
, sign
);
5499 p
= frag_more (size
);
5500 if (output_big_leb128 (p
, generic_bignum
, nbr_digits
, sign
) > size
)
5505 /* Otherwise, we have to create a variable sized fragment and
5506 resolve things later. */
5508 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
5509 make_expr_symbol (exp
), 0, (char *) NULL
);
5513 /* Parse the .sleb128 and .uleb128 pseudos. */
5520 #ifdef md_flush_pending_output
5521 md_flush_pending_output ();
5527 emit_leb128_expr (&exp
, sign
);
5529 while (*input_line_pointer
++ == ',');
5531 input_line_pointer
--;
5532 demand_empty_rest_of_line ();
5535 #if defined (TE_PE) && defined (O_secrel)
5537 /* Generate the appropriate fragments for a given expression to emit a
5538 cv_comp value. SIGN is 1 for cv_scomp, 0 for cv_ucomp. */
5541 emit_cv_comp_expr (expressionS
*exp
, int sign
)
5543 operatorT op
= exp
->X_op
;
5545 if (op
== O_absent
|| op
== O_illegal
)
5547 as_warn (_("zero assumed for missing expression"));
5548 exp
->X_add_number
= 0;
5551 else if (op
== O_big
)
5553 as_bad (_("number invalid"));
5554 exp
->X_add_number
= 0;
5557 else if (op
== O_register
)
5559 as_warn (_("register value used as expression"));
5563 if (now_seg
== absolute_section
)
5565 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
5566 as_bad (_("attempt to store value in absolute section"));
5567 abs_section_offset
++;
5571 if ((op
!= O_constant
|| exp
->X_add_number
!= 0) && in_bss ())
5572 as_bad (_("attempt to store non-zero value in section `%s'"),
5573 segment_name (now_seg
));
5575 /* Let the backend know that subsequent data may be byte aligned. */
5576 #ifdef md_cons_align
5580 if (op
== O_constant
)
5582 offsetT value
= exp
->X_add_number
;
5586 /* If we've got a constant, emit the thing directly right now. */
5588 size
= sizeof_cv_comp (value
, sign
);
5589 p
= frag_more (size
);
5590 if (output_cv_comp (p
, value
, sign
) > size
)
5595 /* Otherwise, we have to create a variable sized fragment and
5596 resolve things later. */
5598 frag_var (rs_cv_comp
, 4, 0, sign
, make_expr_symbol (exp
), 0, NULL
);
5602 /* Parse the .cv_ucomp and .cv_scomp pseudos. */
5605 s_cv_comp (int sign
)
5609 #ifdef md_flush_pending_output
5610 md_flush_pending_output ();
5616 emit_cv_comp_expr (&exp
, sign
);
5618 while (*input_line_pointer
++ == ',');
5620 input_line_pointer
--;
5621 demand_empty_rest_of_line ();
5624 #endif /* TE_PE && O_secrel */
5626 /* Code for handling base64 encoded strings.
5627 Based upon code in sharutils' lib/base64.c source file, written by
5628 Simon Josefsson. Which was partially adapted from GNU MailUtils
5629 (mailbox/filter_trans.c, as of 2004-11-28) and improved by review
5630 from Paul Eggert, Bruno Haible, and Stepan Kasal. */
5699 static const signed char b64
[0x100] =
5701 B64 (0), B64 (1), B64 (2), B64 (3),
5702 B64 (4), B64 (5), B64 (6), B64 (7),
5703 B64 (8), B64 (9), B64 (10), B64 (11),
5704 B64 (12), B64 (13), B64 (14), B64 (15),
5705 B64 (16), B64 (17), B64 (18), B64 (19),
5706 B64 (20), B64 (21), B64 (22), B64 (23),
5707 B64 (24), B64 (25), B64 (26), B64 (27),
5708 B64 (28), B64 (29), B64 (30), B64 (31),
5709 B64 (32), B64 (33), B64 (34), B64 (35),
5710 B64 (36), B64 (37), B64 (38), B64 (39),
5711 B64 (40), B64 (41), B64 (42), B64 (43),
5712 B64 (44), B64 (45), B64 (46), B64 (47),
5713 B64 (48), B64 (49), B64 (50), B64 (51),
5714 B64 (52), B64 (53), B64 (54), B64 (55),
5715 B64 (56), B64 (57), B64 (58), B64 (59),
5716 B64 (60), B64 (61), B64 (62), B64 (63),
5717 B64 (64), B64 (65), B64 (66), B64 (67),
5718 B64 (68), B64 (69), B64 (70), B64 (71),
5719 B64 (72), B64 (73), B64 (74), B64 (75),
5720 B64 (76), B64 (77), B64 (78), B64 (79),
5721 B64 (80), B64 (81), B64 (82), B64 (83),
5722 B64 (84), B64 (85), B64 (86), B64 (87),
5723 B64 (88), B64 (89), B64 (90), B64 (91),
5724 B64 (92), B64 (93), B64 (94), B64 (95),
5725 B64 (96), B64 (97), B64 (98), B64 (99),
5726 B64 (100), B64 (101), B64 (102), B64 (103),
5727 B64 (104), B64 (105), B64 (106), B64 (107),
5728 B64 (108), B64 (109), B64 (110), B64 (111),
5729 B64 (112), B64 (113), B64 (114), B64 (115),
5730 B64 (116), B64 (117), B64 (118), B64 (119),
5731 B64 (120), B64 (121), B64 (122), B64 (123),
5732 B64 (124), B64 (125), B64 (126), B64 (127),
5733 B64 (128), B64 (129), B64 (130), B64 (131),
5734 B64 (132), B64 (133), B64 (134), B64 (135),
5735 B64 (136), B64 (137), B64 (138), B64 (139),
5736 B64 (140), B64 (141), B64 (142), B64 (143),
5737 B64 (144), B64 (145), B64 (146), B64 (147),
5738 B64 (148), B64 (149), B64 (150), B64 (151),
5739 B64 (152), B64 (153), B64 (154), B64 (155),
5740 B64 (156), B64 (157), B64 (158), B64 (159),
5741 B64 (160), B64 (161), B64 (162), B64 (163),
5742 B64 (164), B64 (165), B64 (166), B64 (167),
5743 B64 (168), B64 (169), B64 (170), B64 (171),
5744 B64 (172), B64 (173), B64 (174), B64 (175),
5745 B64 (176), B64 (177), B64 (178), B64 (179),
5746 B64 (180), B64 (181), B64 (182), B64 (183),
5747 B64 (184), B64 (185), B64 (186), B64 (187),
5748 B64 (188), B64 (189), B64 (190), B64 (191),
5749 B64 (192), B64 (193), B64 (194), B64 (195),
5750 B64 (196), B64 (197), B64 (198), B64 (199),
5751 B64 (200), B64 (201), B64 (202), B64 (203),
5752 B64 (204), B64 (205), B64 (206), B64 (207),
5753 B64 (208), B64 (209), B64 (210), B64 (211),
5754 B64 (212), B64 (213), B64 (214), B64 (215),
5755 B64 (216), B64 (217), B64 (218), B64 (219),
5756 B64 (220), B64 (221), B64 (222), B64 (223),
5757 B64 (224), B64 (225), B64 (226), B64 (227),
5758 B64 (228), B64 (229), B64 (230), B64 (231),
5759 B64 (232), B64 (233), B64 (234), B64 (235),
5760 B64 (236), B64 (237), B64 (238), B64 (239),
5761 B64 (240), B64 (241), B64 (242), B64 (243),
5762 B64 (244), B64 (245), B64 (246), B64 (247),
5763 B64 (248), B64 (249), B64 (250), B64 (251),
5764 B64 (252), B64 (253), B64 (254), B64 (255)
5768 is_base64_char (unsigned int c
)
5770 return (c
< 0x100) && (b64
[c
] != -1);
5774 decode_base64_and_append (unsigned int b
[4], int len
)
5776 gas_assert (len
> 1);
5778 FRAG_APPEND_1_CHAR ((b64
[b
[0]] << 2) | (b64
[b
[1]] >> 4));
5781 return; /* FIXME: Check for unused bits in b[1] ? */
5783 FRAG_APPEND_1_CHAR (((b64
[b
[1]] << 4) & 0xf0) | (b64
[b
[2]] >> 2));
5786 return; /* FIXME: Check for unused bits in b[2] ? */
5788 FRAG_APPEND_1_CHAR (((b64
[b
[2]] << 6) & 0xc0) | b64
[b
[3]]);
5791 /* Accept one or more comma separated, base64 encoded strings. Decode them
5792 and store them at the current point in the current section. The strings
5793 must be enclosed in double quotes. Line breaks, quoted characters and
5794 escaped characters are not allowed. Only the characters "A-Za-z0-9+/" are
5795 accepted inside the string. The string must be a multiple of four
5796 characters in length. If the encoded string does not fit this requirement
5797 it may use one or more '=' characters at the end as padding. */
5800 s_base64 (int dummy ATTRIBUTE_UNUSED
)
5803 unsigned long num_octets
= 0;
5805 /* If we have been switched into the abs_section then we
5806 will not have an obstack onto which we can hang strings. */
5807 if (now_seg
== absolute_section
)
5809 as_bad (_("base64 strings must be placed into a section"));
5810 ignore_rest_of_line ();
5814 if (is_it_end_of_statement ())
5816 as_bad (_("a string must follow the .base64 pseudo-op"));
5820 #ifdef md_flush_pending_output
5821 md_flush_pending_output ();
5824 #ifdef md_cons_align
5830 SKIP_ALL_WHITESPACE ();
5832 c
= * input_line_pointer
++;
5836 as_bad (_("expected double quote enclosed string as argument to .base64 pseudo-op"));
5837 ignore_rest_of_line ();
5841 /* Read a block of four base64 encoded characters. */
5844 bool seen_equals
= false;
5847 for (i
= 0; i
< 4; i
++)
5849 c
= * input_line_pointer
++;
5851 if (c
>= 256 || is_end_of_stmt (c
))
5853 as_bad (_("end of line encountered inside .base64 string"));
5854 ignore_rest_of_line ();
5860 /* We allow this. But only if there were enough
5861 characters to form a valid base64 encoding. */
5864 as_warn (_(".base64 string terminated early"));
5865 -- input_line_pointer
;
5869 as_bad (_(".base64 string terminated unexpectedly"));
5870 ignore_rest_of_line ();
5874 if (seen_equals
&& c
!= '=')
5876 as_bad (_("equals character only allowed at end of .base64 string"));
5877 ignore_rest_of_line ();
5885 as_bad (_("the equals character cannot start a block of four base64 encoded bytes"));
5886 ignore_rest_of_line ();
5891 as_bad (_("the equals character cannot be the second character in a block of four base64 encoded bytes"));
5892 ignore_rest_of_line ();
5898 else if (! is_base64_char (c
))
5901 as_bad (_("invalid character '%c' found inside .base64 string"), c
);
5903 as_bad (_("invalid character %#x found inside .base64 string"), c
);
5904 ignore_rest_of_line ();
5911 if (seen_equals
&& i
== 4)
5918 /* We have a block of up to four valid base64 encoded bytes. */
5919 decode_base64_and_append (b
, i
);
5920 num_octets
+= (i
- 1);
5922 /* Check the next character. */
5923 c
= * input_line_pointer
++;
5925 if (is_base64_char (c
))
5929 as_bad (_("no base64 characters expected after '=' padding characters"));
5930 ignore_rest_of_line ();
5934 -- input_line_pointer
;
5939 as_bad (_(".base64 string must have a terminating double quote character"));
5940 ignore_rest_of_line ();
5944 SKIP_ALL_WHITESPACE ();
5946 c
= * input_line_pointer
++;
5950 /* Make sure that we have not skipped the EOL marker. */
5951 -- input_line_pointer
;
5953 while (num_octets
% OCTETS_PER_BYTE
)
5955 /* We have finished emiting the octets for this .base64 pseudo-op, but
5956 we have not filled up enough bytes for the target architecture. So
5957 we emit padding octets here. This is done after all of the arguments
5958 to the pseudo-op have been processed, rather than at the end of each
5959 argument, as it is likely that the user wants the arguments to be
5961 FRAG_APPEND_1_CHAR (0);
5965 demand_empty_rest_of_line ();
5969 stringer_append_char (int c
, int bitsize
)
5972 as_bad (_("attempt to store non-empty string in section `%s'"),
5973 segment_name (now_seg
));
5975 if (!target_big_endian
)
5976 FRAG_APPEND_1_CHAR (c
);
5981 FRAG_APPEND_1_CHAR (0);
5982 FRAG_APPEND_1_CHAR (0);
5983 FRAG_APPEND_1_CHAR (0);
5984 FRAG_APPEND_1_CHAR (0);
5987 FRAG_APPEND_1_CHAR (0);
5988 FRAG_APPEND_1_CHAR (0);
5991 FRAG_APPEND_1_CHAR (0);
5996 /* Called with invalid bitsize argument. */
6000 if (target_big_endian
)
6001 FRAG_APPEND_1_CHAR (c
);
6004 /* Worker to do .ascii etc statements.
6005 Reads 0 or more ',' separated, double-quoted strings.
6006 Caller should have checked need_pass_2 is FALSE because we don't
6008 Checks for end-of-line.
6009 BITS_APPENDZERO says how many bits are in a target char.
6010 The bottom bit is set if a NUL char should be appended to the strings. */
6013 stringer (int bits_appendzero
)
6015 const int bitsize
= bits_appendzero
& ~7;
6016 const int append_zero
= bits_appendzero
& 1;
6018 #if !defined(NO_LISTING) && defined (OBJ_ELF)
6022 #ifdef md_flush_pending_output
6023 md_flush_pending_output ();
6026 #ifdef md_cons_align
6030 /* If we have been switched into the abs_section then we
6031 will not have an obstack onto which we can hang strings. */
6032 if (now_seg
== absolute_section
)
6034 as_bad (_("strings must be placed into a section"));
6035 ignore_rest_of_line ();
6039 /* The following awkward logic is to parse ZERO or more strings,
6040 comma separated. Recall a string expression includes spaces
6041 before the opening '\"' and spaces after the closing '\"'.
6042 We fake a leading ',' if there is (supposed to be)
6043 a 1st, expression. We keep demanding expressions for each ','. */
6044 if (is_it_end_of_statement ())
6046 c
= 0; /* Skip loop. */
6047 ++input_line_pointer
; /* Compensate for end of loop. */
6051 c
= ','; /* Do loop. */
6054 while (c
== ',' || c
== '<' || c
== '"')
6057 switch (*input_line_pointer
)
6060 ++input_line_pointer
; /*->1st char of string. */
6061 #if !defined(NO_LISTING) && defined (OBJ_ELF)
6062 start
= input_line_pointer
;
6065 while (is_a_char (c
= next_char_of_string ()))
6066 stringer_append_char (c
, bitsize
);
6068 /* Treat "a" "b" as "ab". Even if we are appending zeros. */
6069 SKIP_ALL_WHITESPACE ();
6070 if (*input_line_pointer
== '"')
6074 stringer_append_char (0, bitsize
);
6076 #if !defined(NO_LISTING) && defined (OBJ_ELF)
6077 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
6078 will emit .string with a filename in the .debug section
6079 after a sequence of constants. See the comment in
6080 emit_expr for the sequence. emit_expr will set
6081 dwarf_file_string to non-zero if this string might be a
6082 source file name. */
6083 if (strcmp (segment_name (now_seg
), ".debug") != 0)
6084 dwarf_file_string
= 0;
6085 else if (dwarf_file_string
)
6087 c
= input_line_pointer
[-1];
6088 input_line_pointer
[-1] = '\0';
6089 listing_source_file (start
);
6090 input_line_pointer
[-1] = c
;
6096 input_line_pointer
++;
6097 c
= get_single_number ();
6098 stringer_append_char (c
, bitsize
);
6099 if (*input_line_pointer
!= '>')
6101 as_bad (_("expected <nn>"));
6102 ignore_rest_of_line ();
6105 input_line_pointer
++;
6108 input_line_pointer
++;
6112 c
= *input_line_pointer
;
6115 demand_empty_rest_of_line ();
6118 /* FIXME-SOMEDAY: I had trouble here on characters with the
6119 high bits set. We'll probably also have trouble with
6120 multibyte chars, wide chars, etc. Also be careful about
6121 returning values bigger than 1 byte. xoxorich. */
6124 next_char_of_string (void)
6128 c
= *input_line_pointer
++ & CHAR_MASK
;
6132 /* PR 20902: Do not advance past the end of the buffer. */
6133 -- input_line_pointer
;
6142 as_warn (_("unterminated string; newline inserted"));
6143 bump_line_counters ();
6147 if (!TC_STRING_ESCAPES
)
6149 switch (c
= *input_line_pointer
++ & CHAR_MASK
)
6177 break; /* As itself. */
6193 for (i
= 0, number
= 0;
6194 ISDIGIT (c
) && i
< 3;
6195 c
= *input_line_pointer
++, i
++)
6197 number
= number
* 8 + c
- '0';
6200 c
= number
& CHAR_MASK
;
6202 --input_line_pointer
;
6211 c
= *input_line_pointer
++;
6212 while (ISXDIGIT (c
))
6215 number
= number
* 16 + c
- '0';
6216 else if (ISUPPER (c
))
6217 number
= number
* 16 + c
- 'A' + 10;
6219 number
= number
* 16 + c
- 'a' + 10;
6220 c
= *input_line_pointer
++;
6222 c
= number
& CHAR_MASK
;
6223 --input_line_pointer
;
6228 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
6229 as_warn (_("unterminated string; newline inserted"));
6231 bump_line_counters ();
6235 /* Do not advance past the end of the buffer. */
6236 -- input_line_pointer
;
6242 #ifdef ONLY_STANDARD_ESCAPES
6243 as_bad (_("bad escaped character in string"));
6245 #endif /* ONLY_STANDARD_ESCAPES */
6258 get_segmented_expression (expressionS
*expP
)
6262 retval
= expression (expP
);
6263 if (expP
->X_op
== O_illegal
6264 || expP
->X_op
== O_absent
6265 || expP
->X_op
== O_big
)
6267 as_bad (_("expected address expression"));
6268 expP
->X_op
= O_constant
;
6269 expP
->X_add_number
= 0;
6270 retval
= absolute_section
;
6276 get_known_segmented_expression (expressionS
*expP
)
6278 segT retval
= get_segmented_expression (expP
);
6280 if (retval
== undefined_section
)
6282 /* There is no easy way to extract the undefined symbol from the
6284 if (expP
->X_add_symbol
!= NULL
6285 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
6286 as_warn (_("symbol \"%s\" undefined; zero assumed"),
6287 S_GET_NAME (expP
->X_add_symbol
));
6289 as_warn (_("some symbol undefined; zero assumed"));
6290 retval
= absolute_section
;
6291 expP
->X_op
= O_constant
;
6292 expP
->X_add_number
= 0;
6297 char /* Return terminator. */
6298 get_absolute_expression_and_terminator (long *val_pointer
/* Return value of expression. */)
6300 /* FIXME: val_pointer should probably be offsetT *. */
6301 *val_pointer
= (long) get_absolute_expression ();
6302 return (*input_line_pointer
++);
6305 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
6306 Give a warning if that happens. */
6309 demand_copy_C_string (int *len_pointer
)
6313 if ((s
= demand_copy_string (len_pointer
)) != 0)
6317 for (len
= *len_pointer
; len
> 0; len
--)
6319 if (s
[len
- 1] == 0)
6323 as_bad (_("this string may not contain \'\\0\'"));
6332 /* Demand string, but return a safe (=private) copy of the string.
6333 Return NULL if we can't read a string here. */
6336 demand_copy_string (int *lenP
)
6344 if (*input_line_pointer
== '\"')
6346 input_line_pointer
++; /* Skip opening quote. */
6348 while (is_a_char (c
= next_char_of_string ()))
6350 obstack_1grow (¬es
, c
);
6353 /* JF this next line is so demand_copy_C_string will return a
6354 null terminated string. */
6355 obstack_1grow (¬es
, '\0');
6356 retval
= (char *) obstack_finish (¬es
);
6360 as_bad (_("missing string"));
6362 ignore_rest_of_line ();
6368 /* In: Input_line_pointer->next character.
6370 Do: Skip input_line_pointer over all whitespace.
6372 Out: 1 if input_line_pointer->end-of-line. */
6375 is_it_end_of_statement (void)
6378 return is_end_of_stmt (*input_line_pointer
);
6382 equals (char *sym_name
, int reassign
)
6387 input_line_pointer
++;
6388 if (*input_line_pointer
== '=')
6389 input_line_pointer
++;
6390 if (reassign
< 0 && *input_line_pointer
== '=')
6391 input_line_pointer
++;
6393 while (is_whitespace (*input_line_pointer
))
6394 input_line_pointer
++;
6397 stop
= mri_comment_field (&stopc
);
6399 assign_symbol (sym_name
, reassign
>= 0 ? !reassign
: reassign
);
6403 demand_empty_rest_of_line ();
6404 mri_comment_end (stop
, stopc
);
6408 /* Open FILENAME, first trying the unadorned file name, then if that
6409 fails and the file name is not an absolute path, attempt to open
6410 the file in current -I include paths. PATH is a preallocated
6411 buffer which will be set to the file opened, or FILENAME if no file
6415 search_and_open (const char *filename
, char *path
)
6417 FILE *f
= fopen (filename
, FOPEN_RB
);
6418 if (f
== NULL
&& !IS_ABSOLUTE_PATH (filename
))
6420 for (size_t i
= 0; i
< include_dir_count
; i
++)
6422 sprintf (path
, "%s/%s", include_dirs
[i
], filename
);
6423 f
= fopen (path
, FOPEN_RB
);
6428 strcpy (path
, filename
);
6432 /* .incbin -- include a file verbatim at the current location. */
6435 s_incbin (int x ATTRIBUTE_UNUSED
)
6446 #ifdef md_flush_pending_output
6447 md_flush_pending_output ();
6450 #ifdef md_cons_align
6455 filename
= demand_copy_string (& len
);
6456 if (filename
== NULL
)
6461 /* Look for optional skip and count. */
6462 if (* input_line_pointer
== ',')
6464 ++ input_line_pointer
;
6465 skip
= get_absolute_expression ();
6469 if (* input_line_pointer
== ',')
6471 ++ input_line_pointer
;
6473 count
= get_absolute_expression ();
6475 as_warn (_(".incbin count zero, ignoring `%s'"), filename
);
6481 demand_empty_rest_of_line ();
6483 path
= XNEWVEC (char, len
+ include_dir_maxlen
+ 2);
6484 binfile
= search_and_open (filename
, path
);
6486 if (binfile
== NULL
)
6487 as_bad (_("file not found: %s"), filename
);
6491 struct stat filestat
;
6493 if (fstat (fileno (binfile
), &filestat
) != 0
6494 || ! S_ISREG (filestat
.st_mode
)
6495 || S_ISDIR (filestat
.st_mode
))
6497 as_bad (_("unable to include `%s'"), path
);
6501 register_dependency (path
);
6503 /* Compute the length of the file. */
6504 if (fseek (binfile
, 0, SEEK_END
) != 0)
6506 as_bad (_("seek to end of .incbin file failed `%s'"), path
);
6509 file_len
= ftell (binfile
);
6511 /* If a count was not specified use the remainder of the file. */
6513 count
= file_len
- skip
;
6515 if (skip
< 0 || count
< 0 || file_len
< 0 || skip
+ count
> file_len
)
6517 as_bad (_("skip (%ld) or count (%ld) invalid for file size (%ld)"),
6518 skip
, count
, file_len
);
6522 if (fseek (binfile
, skip
, SEEK_SET
) != 0)
6524 as_bad (_("could not skip to %ld in file `%s'"), skip
, path
);
6528 /* Allocate frag space and store file contents in it. */
6529 binfrag
= frag_more (count
);
6531 bytes
= fread (binfrag
, 1, count
, binfile
);
6533 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
6534 path
, bytes
, count
);
6537 if (binfile
!= NULL
)
6542 /* .include -- include a file at this point. */
6545 s_include (int arg ATTRIBUTE_UNUSED
)
6554 filename
= demand_copy_string (&i
);
6555 if (filename
== NULL
)
6557 /* demand_copy_string has already printed an error and
6558 called ignore_rest_of_line. */
6566 while (!is_end_of_stmt (*input_line_pointer
)
6567 && !is_whitespace (*input_line_pointer
))
6569 obstack_1grow (¬es
, *input_line_pointer
);
6570 ++input_line_pointer
;
6574 obstack_1grow (¬es
, '\0');
6575 filename
= (char *) obstack_finish (¬es
);
6576 while (!is_end_of_stmt (*input_line_pointer
))
6577 ++input_line_pointer
;
6580 demand_empty_rest_of_line ();
6582 path
= notes_alloc (i
+ include_dir_maxlen
+ 2);
6583 try_file
= search_and_open (filename
, path
);
6587 register_dependency (path
);
6588 input_scrub_insert_file (path
);
6592 init_include_dir (void)
6594 include_dirs
= XNEWVEC (const char *, 1);
6595 include_dirs
[0] = "."; /* Current dir. */
6596 include_dir_count
= 1;
6597 include_dir_maxlen
= 1;
6601 add_include_dir (char *path
)
6603 include_dir_count
++;
6604 include_dirs
= XRESIZEVEC (const char *, include_dirs
, include_dir_count
);
6605 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
6607 size_t i
= strlen (path
);
6608 if (i
> include_dir_maxlen
)
6609 include_dir_maxlen
= i
;
6612 /* Output debugging information to denote the source file. */
6615 generate_file_debug (void)
6617 if (debug_type
== DEBUG_STABS
)
6618 stabs_generate_asm_file ();
6621 /* Output line number debugging information for the current source line. */
6624 generate_lineno_debug (void)
6628 case DEBUG_UNSPECIFIED
:
6633 stabs_generate_asm_lineno ();
6636 ecoff_generate_asm_lineno ();
6639 /* ??? We could here indicate to dwarf2dbg.c that something
6640 has changed. However, since there is additional backend
6641 support that is required (calling dwarf2_emit_insn), we
6642 let dwarf2dbg.c call as_where on its own. */
6644 case DEBUG_CODEVIEW
:
6645 codeview_generate_asm_lineno ();
6650 /* Output debugging information to mark a function entry point or end point.
6651 END_P is zero for .func, and non-zero for .endfunc. */
6656 do_s_func (end_p
, NULL
);
6659 /* Subroutine of s_func so targets can choose a different default prefix.
6660 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
6663 do_s_func (int end_p
, const char *default_prefix
)
6667 if (current_name
== NULL
)
6669 as_bad (_("missing .func"));
6670 ignore_rest_of_line ();
6674 if (debug_type
== DEBUG_STABS
)
6675 stabs_generate_asm_endfunc (current_name
, current_label
);
6677 free (current_name
);
6678 free (current_label
);
6679 current_name
= current_label
= NULL
;
6684 char delim1
, delim2
;
6686 if (current_name
!= NULL
)
6688 as_bad (_(".endfunc missing for previous .func"));
6689 ignore_rest_of_line ();
6693 delim1
= get_symbol_name (& name
);
6694 name
= xstrdup (name
);
6695 restore_line_pointer (delim1
);
6697 if (*input_line_pointer
!= ',')
6700 label
= xasprintf ("%s%s", default_prefix
, name
);
6703 char leading_char
= bfd_get_symbol_leading_char (stdoutput
);
6704 /* Missing entry point, use function's name with the leading
6707 label
= xasprintf ("%c%s", leading_char
, name
);
6709 label
= xstrdup (name
);
6714 ++input_line_pointer
;
6716 delim2
= get_symbol_name (& label
);
6717 label
= xstrdup (label
);
6718 restore_line_pointer (delim2
);
6721 if (debug_type
== DEBUG_STABS
)
6722 stabs_generate_asm_func (name
, label
);
6724 current_name
= name
;
6725 current_label
= label
;
6728 demand_empty_rest_of_line ();
6731 #ifdef HANDLE_BUNDLE
6734 s_bundle_align_mode (int arg ATTRIBUTE_UNUSED
)
6736 unsigned int align
= get_absolute_expression ();
6738 demand_empty_rest_of_line ();
6740 if (align
> (unsigned int) TC_ALIGN_LIMIT
)
6741 as_fatal (_(".bundle_align_mode alignment too large (maximum %u)"),
6742 (unsigned int) TC_ALIGN_LIMIT
);
6744 if (bundle_lock_frag
!= NULL
)
6746 as_bad (_("cannot change .bundle_align_mode inside .bundle_lock"));
6750 bundle_align_p2
= align
;
6754 s_bundle_lock (int arg ATTRIBUTE_UNUSED
)
6756 demand_empty_rest_of_line ();
6758 if (bundle_align_p2
== 0)
6760 as_bad (_(".bundle_lock is meaningless without .bundle_align_mode"));
6764 if (bundle_lock_depth
== 0)
6766 bundle_lock_frchain
= frchain_now
;
6767 bundle_lock_frag
= start_bundle ();
6769 ++bundle_lock_depth
;
6773 s_bundle_unlock (int arg ATTRIBUTE_UNUSED
)
6777 demand_empty_rest_of_line ();
6779 if (bundle_lock_frag
== NULL
)
6781 as_bad (_(".bundle_unlock without preceding .bundle_lock"));
6785 gas_assert (bundle_align_p2
> 0);
6787 gas_assert (bundle_lock_depth
> 0);
6788 if (--bundle_lock_depth
> 0)
6791 size
= pending_bundle_size (bundle_lock_frag
);
6793 if (size
> 1U << bundle_align_p2
)
6794 as_bad (_(".bundle_lock sequence is %u bytes, "
6795 "but bundle size is only %u bytes"),
6796 size
, 1u << bundle_align_p2
);
6798 finish_bundle (bundle_lock_frag
, size
);
6800 bundle_lock_frag
= NULL
;
6801 bundle_lock_frchain
= NULL
;
6804 #endif /* HANDLE_BUNDLE */
6807 s_ignore (int arg ATTRIBUTE_UNUSED
)
6809 ignore_rest_of_line ();
6813 read_print_statistics (FILE *file
)
6815 htab_print_statistics (file
, "pseudo-op table", po_hash
);
6818 /* Inserts the given line into the input stream.
6820 This call avoids macro/conditionals nesting checking, since the contents of
6821 the line are assumed to replace the contents of a line already scanned.
6823 An appropriate use of this function would be substitution of input lines when
6824 called by md_start_line_hook(). The given line is assumed to already be
6825 properly scrubbed. */
6828 input_scrub_insert_line (const char *line
)
6831 size_t len
= strlen (line
);
6832 sb_build (&newline
, len
);
6833 sb_add_buffer (&newline
, line
, len
);
6834 input_scrub_include_sb (&newline
, input_line_pointer
, expanding_none
);
6836 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
6839 /* Insert a file into the input stream; the path must resolve to an actual
6840 file; no include path searching or dependency registering is performed. */
6843 input_scrub_insert_file (char *path
)
6845 input_scrub_include_file (path
, input_line_pointer
);
6846 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
6849 /* Find the end of a line, considering quotation and escaping of quotes. */
6851 #if !defined(TC_SINGLE_QUOTE_STRINGS) && defined(SINGLE_QUOTE_STRINGS)
6852 # define TC_SINGLE_QUOTE_STRINGS 1
6856 _find_end_of_line (char *s
, int mri_string
, int insn ATTRIBUTE_UNUSED
,
6859 char inquote
= '\0';
6862 while (!is_end_of_stmt (*s
)
6863 || (inquote
&& !ISCNTRL (*s
))
6864 || (inquote
== '\'' && flag_mri
)
6865 #ifdef TC_EOL_IN_INSN
6866 || (insn
&& TC_EOL_IN_INSN (s
))
6868 /* PR 6926: When we are parsing the body of a macro the sequence
6869 \@ is special - it refers to the invocation count. If the @
6870 character happens to be registered as a line-separator character
6871 by the target, then the is_end_of_stmt() test above will have
6872 returned true, but we need to ignore the line separating
6873 semantics in this particular case. */
6874 || (in_macro
&& inescape
&& *s
== '@')
6877 if (mri_string
&& *s
== '\'')
6881 else if (*s
== '\\')
6885 #ifdef TC_SINGLE_QUOTE_STRINGS
6886 || (TC_SINGLE_QUOTE_STRINGS
&& *s
== '\'')
6893 as_warn (_("missing closing `%c'"), inquote
);
6894 if (inescape
&& !ignore_input ())
6895 as_warn (_("stray `\\'"));
6900 find_end_of_line (char *s
, int mri_string
)
6902 return _find_end_of_line (s
, mri_string
, 0, 0);
6905 static char *saved_ilp
;
6906 static char *saved_limit
;
6908 /* Use BUF as a temporary input pointer for calling other functions in this
6909 file. BUF must be a C string, so that its end can be found by strlen.
6910 Also sets the buffer_limit variable (local to this file) so that buffer
6911 overruns should not occur. Saves the current input line pointer so that
6912 it can be restored by calling restore_ilp().
6914 Does not support recursion. */
6917 temp_ilp (char *buf
)
6919 gas_assert (saved_ilp
== NULL
);
6920 gas_assert (buf
!= NULL
);
6922 saved_ilp
= input_line_pointer
;
6923 saved_limit
= buffer_limit
;
6924 /* Prevent the assert in restore_ilp from triggering if
6925 the input_line_pointer has not yet been initialised. */
6926 if (saved_ilp
== NULL
)
6927 saved_limit
= saved_ilp
= (char *) "";
6929 input_line_pointer
= buf
;
6930 buffer_limit
= buf
+ strlen (buf
);
6931 input_from_string
= true;
6934 /* Restore a saved input line pointer. */
6939 gas_assert (saved_ilp
!= NULL
);
6941 input_line_pointer
= saved_ilp
;
6942 buffer_limit
= saved_limit
;
6943 input_from_string
= false;