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 valueT offset
= frag
->fr_fix
;
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
|| now_seg
== absolute_section
);
717 return size
- offset
;
720 /* Finish off the frag created to ensure bundle alignment. */
722 finish_bundle (fragS
*frag
, valueT 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 valueT bundle_size
= pending_bundle_size (bundle_lock_frag
);
767 if (bundle_size
> (valueT
) 1 << bundle_align_p2
)
768 as_bad (_ (".bundle_lock sequence at %" PRIu64
" bytes, "
769 "but .bundle_align_mode limit is %" PRIu64
" bytes"),
770 (uint64_t) bundle_size
, (uint64_t) 1 << bundle_align_p2
);
772 else if (bundle_align_p2
> 0)
774 valueT insn_size
= pending_bundle_size (insn_start_frag
);
776 if (insn_size
> (valueT
) 1 << bundle_align_p2
)
777 as_bad (_("single instruction is %" PRIu64
" bytes long, "
778 "but .bundle_align_mode limit is %" PRIu64
" bytes"),
779 (uint64_t) insn_size
, (uint64_t) 1 << 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 set_identify_name (name
);
900 buffer
= input_scrub_new_file (name
);
903 listing_newline (NULL
);
904 register_dependency (name
);
906 /* Generate debugging information before we've read anything in to denote
907 this file as the "main" source file and not a subordinate one
908 (e.g. N_SO vs N_SOL in stabs). */
909 generate_file_debug ();
911 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
912 { /* We have another line to parse. */
914 /* In order to avoid listing macro expansion lines with labels
915 multiple times, keep track of which line was last issued. */
916 char *last_eol
= NULL
;
919 while (input_line_pointer
< buffer_limit
)
922 /* We have more of this buffer to parse. */
924 /* We now have input_line_pointer->1st char of next line.
925 If input_line_pointer [-1] == '\n' then we just
926 scanned another line: so bump line counters. */
927 was_new_line
= lex_type
[(unsigned char) input_line_pointer
[-1]]
928 & (LEX_EOL
| LEX_EOS
);
931 symbol_set_value_now (&dot_symbol
);
932 #ifdef md_start_line_hook
933 md_start_line_hook ();
935 if (input_line_pointer
[-1] == '\n')
936 bump_line_counters ();
940 /* If listing is on, and we are expanding a macro, then give
941 the listing code the contents of the expanded line. */
944 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
946 /* Find the end of the current expanded macro line. */
947 s
= find_end_of_line (input_line_pointer
, flag_m68k_mri
);
950 && !startswith (input_line_pointer
,
951 !flag_m68k_mri
? " .linefile "
958 /* Copy it for safe keeping. Also give an indication of
959 how much macro nesting is involved at this point. */
960 len
= s
- input_line_pointer
;
961 copy
= XNEWVEC (char, len
+ macro_nest
+ 2);
962 memset (copy
, '>', macro_nest
);
963 copy
[macro_nest
] = ' ';
964 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
, len
);
965 copy
[macro_nest
+ 1 + len
] = '\0';
967 /* Install the line with the listing facility. */
968 listing_newline (copy
);
972 listing_newline (NULL
);
976 next_char
= *input_line_pointer
;
977 if ((was_new_line
& LEX_EOL
)
978 && (strchr (line_comment_chars
, '#')
980 : next_char
&& strchr (line_comment_chars
, next_char
)))
982 /* Its a comment. Check for APP followed by NO_APP. */
987 s
= input_line_pointer
+ 1;
988 if (!startswith (s
, "APP") || !is_end_of_line (s
[3]))
990 /* We ignore it. Note: Not ignore_rest_of_line ()! */
991 while (s
<= buffer_limit
)
992 if (is_end_of_line (*s
++))
994 input_line_pointer
= s
;
999 ends
= find_no_app (s
, next_char
);
1000 len
= ends
? ends
- s
: buffer_limit
- s
;
1002 sb_build (&sbuf
, len
+ 100);
1003 sb_add_buffer (&sbuf
, s
, len
);
1006 /* The end of the #APP wasn't in this buffer. We
1007 keep reading in buffers until we find the #NO_APP
1008 that goes with this #APP There is one. The specs
1012 buffer_limit
= input_scrub_next_buffer (&buffer
);
1015 ends
= find_no_app (buffer
, next_char
);
1016 len
= ends
? ends
- buffer
: buffer_limit
- buffer
;
1017 sb_add_buffer (&sbuf
, buffer
, len
);
1021 sb_add_char (&sbuf
, '\n');
1023 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1024 input_scrub_include_sb (&sbuf
, input_line_pointer
, expanding_app
);
1026 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1034 if (LABELS_WITHOUT_COLONS
|| flag_m68k_mri
)
1036 next_char
= * input_line_pointer
;
1037 /* Text at the start of a line must be a label, we
1038 run down and stick a colon in. */
1039 if (is_name_beginner (next_char
) || next_char
== '"')
1044 HANDLE_CONDITIONAL_ASSEMBLY (0);
1046 nul_char
= get_symbol_name (& line_start
);
1047 next_char
= (nul_char
== '"' ? input_line_pointer
[1] : nul_char
);
1049 /* In MRI mode, the EQU and MACRO pseudoops must
1050 be handled specially. */
1054 char *rest
= input_line_pointer
+ 1;
1058 if (is_whitespace (*rest
))
1060 if ((strncasecmp (rest
, "EQU", 3) == 0
1061 || strncasecmp (rest
, "SET", 3) == 0)
1062 && is_whitespace (rest
[3]))
1064 input_line_pointer
= rest
+ 3;
1066 strncasecmp (rest
, "SET", 3) == 0);
1069 if (strncasecmp (rest
, "MACRO", 5) == 0
1070 && (is_whitespace (rest
[5])
1071 || is_end_of_stmt (rest
[5])))
1075 /* In MRI mode, we need to handle the MACRO
1076 pseudo-op specially: we don't want to put the
1077 symbol in the symbol table. */
1079 #ifdef TC_START_LABEL_WITHOUT_COLON
1080 && TC_START_LABEL_WITHOUT_COLON (nul_char
, next_char
)
1083 line_label
= colon (line_start
);
1085 line_label
= symbol_create (line_start
,
1087 &zero_address_frag
, 0);
1089 next_char
= restore_line_pointer (nul_char
);
1090 if (next_char
== ':')
1091 input_line_pointer
++;
1096 /* We are at the beginning of a line, or similar place.
1097 We expect a well-formed assembler statement.
1098 A "symbol-name:" is a statement.
1100 Depending on what compiler is used, the order of these tests
1101 may vary to catch most common case 1st.
1102 Each test is independent of all other tests at the (top)
1105 nul_char
= next_char
= *input_line_pointer
++;
1106 while (is_whitespace (next_char
) || next_char
== '\f');
1108 /* C is the 1st significant character.
1109 Input_line_pointer points after that character. */
1110 if (is_name_beginner (next_char
) || next_char
== '"')
1114 /* Want user-defined label or pseudo/opcode. */
1115 HANDLE_CONDITIONAL_ASSEMBLY (1);
1117 --input_line_pointer
;
1118 nul_char
= get_symbol_name (& s
); /* name's delimiter. */
1119 next_char
= (nul_char
== '"' ? input_line_pointer
[1] : nul_char
);
1120 rest
= input_line_pointer
+ (nul_char
== '"' ? 2 : 1);
1122 /* NEXT_CHAR is character after symbol.
1123 The end of symbol in the input line is now '\0'.
1124 S points to the beginning of the symbol.
1125 [In case of pseudo-op, s->'.'.]
1126 Input_line_pointer->'\0' where NUL_CHAR was. */
1127 if (TC_START_LABEL (s
, nul_char
, next_char
))
1131 /* In MRI mode, \tsym: set 0 is permitted. */
1135 if (is_whitespace (*rest
))
1138 if ((strncasecmp (rest
, "EQU", 3) == 0
1139 || strncasecmp (rest
, "SET", 3) == 0)
1140 && is_whitespace (rest
[3]))
1142 input_line_pointer
= rest
+ 3;
1148 line_label
= colon (s
); /* User-defined label. */
1149 restore_line_pointer (nul_char
);
1150 ++ input_line_pointer
;
1151 #ifdef tc_check_label
1152 tc_check_label (line_label
);
1154 /* Input_line_pointer->after ':'. */
1157 else if ((next_char
== '=' && *rest
== '=')
1158 || (is_whitespace (next_char
)
1163 demand_empty_rest_of_line ();
1165 else if ((next_char
== '='
1166 || (is_whitespace (next_char
)
1168 #ifdef TC_EQUAL_IN_INSN
1169 && !TC_EQUAL_IN_INSN (next_char
, s
)
1174 demand_empty_rest_of_line ();
1178 /* Expect pseudo-op or machine instruction. */
1181 #ifndef TC_CASE_SENSITIVE
1185 strncpy (original_case_string
, s2
,
1186 sizeof (original_case_string
) - 1);
1187 original_case_string
[sizeof (original_case_string
) - 1] = 0;
1191 *s2
= TOLOWER (*s2
);
1196 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
1198 /* The MRI assembler uses pseudo-ops without
1200 pop
= str_hash_find (po_hash
, s
);
1201 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
1206 || (!flag_m68k_mri
&& *s
== '.'))
1210 WARNING: next_char may be end-of-line.
1211 We lookup the pseudo-op table with s+1 because we
1212 already know that the pseudo-op begins with a '.'. */
1215 pop
= str_hash_find (po_hash
, s
+ 1);
1216 if (pop
&& !pop
->poc_handler
)
1219 /* In MRI mode, we may need to insert an
1220 automatic alignment directive. What a hack
1222 if (mri_pending_align
1224 || !((pop
->poc_handler
== cons
1225 && pop
->poc_val
== 1)
1226 || (pop
->poc_handler
== s_space
1227 && pop
->poc_val
== 1)
1228 #ifdef tc_conditional_pseudoop
1229 || tc_conditional_pseudoop (pop
)
1231 || pop
->poc_handler
== s_if
1232 || pop
->poc_handler
== s_ifdef
1233 || pop
->poc_handler
== s_ifc
1234 || pop
->poc_handler
== s_ifeqs
1235 || pop
->poc_handler
== s_else
1236 || pop
->poc_handler
== s_endif
1237 || pop
->poc_handler
== s_globl
1238 || pop
->poc_handler
== s_ignore
)))
1240 do_align (1, NULL
, 0, 0);
1241 mri_pending_align
= 0;
1243 if (line_label
!= NULL
)
1245 symbol_set_frag (line_label
, frag_now
);
1246 S_SET_VALUE (line_label
, frag_now_fix ());
1250 /* Print the error msg now, while we still can. */
1253 char *end
= input_line_pointer
;
1255 (void) restore_line_pointer (nul_char
);
1257 nul_char
= next_char
= *--input_line_pointer
;
1258 *input_line_pointer
= '\0';
1259 if (! macro_defined
|| ! try_macro (next_char
, s
))
1262 as_bad (_("unknown pseudo-op: `%s'"), s
);
1263 *input_line_pointer
++ = nul_char
;
1268 /* Put it back for error messages etc. */
1269 next_char
= restore_line_pointer (nul_char
);
1270 /* The following skip of whitespace is compulsory.
1271 A well shaped space is sometimes all that separates
1272 keyword from operands. */
1273 if (is_whitespace (next_char
))
1274 input_line_pointer
++;
1276 /* Input_line is restored.
1277 Input_line_pointer->1st non-blank char
1278 after pseudo-operation. */
1279 (*pop
->poc_handler
) (pop
->poc_val
);
1281 /* If that was .end, just get out now. */
1282 if (pop
->poc_handler
== s_end
)
1287 /* WARNING: next_char may be end-of-line. */
1288 /* Also: input_line_pointer->`\0` where nul_char was. */
1289 (void) restore_line_pointer (nul_char
);
1290 input_line_pointer
= _find_end_of_line (input_line_pointer
, flag_m68k_mri
, 1, 0);
1291 next_char
= nul_char
= *input_line_pointer
;
1292 *input_line_pointer
= '\0';
1294 generate_lineno_debug ();
1296 if (macro_defined
&& try_macro (next_char
, s
))
1299 if (mri_pending_align
)
1301 do_align (1, NULL
, 0, 0);
1302 mri_pending_align
= 0;
1303 if (line_label
!= NULL
)
1305 symbol_set_frag (line_label
, frag_now
);
1306 S_SET_VALUE (line_label
, frag_now_fix ());
1310 assemble_one (s
); /* Assemble 1 instruction. */
1312 /* PR 19630: The backend may have set ilp to NULL
1313 if it encountered a catastrophic failure. */
1314 if (input_line_pointer
== NULL
)
1315 as_fatal (_("unable to continue with assembly."));
1317 *input_line_pointer
++ = nul_char
;
1319 /* We resume loop AFTER the end-of-line from
1320 this instruction. */
1326 /* Empty statement? */
1327 if (is_end_of_stmt (next_char
))
1330 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
) && ISDIGIT (next_char
))
1332 /* local label ("4:") */
1333 char *backup
= input_line_pointer
;
1335 HANDLE_CONDITIONAL_ASSEMBLY (1);
1337 temp
= next_char
- '0';
1339 /* Read the whole number. */
1340 while (ISDIGIT (*input_line_pointer
))
1342 const long digit
= *input_line_pointer
- '0';
1344 /* Don't accept labels which look like octal numbers. */
1347 if (temp
> (INT_MAX
- digit
) / 10)
1349 as_bad (_("local label too large near %s"), backup
);
1353 temp
= temp
* 10 + digit
;
1354 ++input_line_pointer
;
1357 /* Overflow: stop processing the label. */
1360 ignore_rest_of_line ();
1364 if (LOCAL_LABELS_DOLLAR
1365 && *input_line_pointer
== '$'
1366 && *(input_line_pointer
+ 1) == ':')
1368 input_line_pointer
+= 2;
1370 if (dollar_label_defined (temp
))
1372 as_fatal (_("label \"%ld$\" redefined"), temp
);
1375 define_dollar_label (temp
);
1376 colon (dollar_label_name (temp
, 0));
1381 && *input_line_pointer
++ == ':')
1383 fb_label_instance_inc (temp
);
1384 colon (fb_label_name (temp
, 0));
1388 input_line_pointer
= backup
;
1391 if (next_char
&& strchr (line_comment_chars
, next_char
))
1393 /* Its a comment, ignore it. Note: Not ignore_rest_of_line ()! */
1394 s
= input_line_pointer
;
1395 while (s
<= buffer_limit
)
1396 if (is_end_of_line (*s
++))
1398 input_line_pointer
= s
;
1402 HANDLE_CONDITIONAL_ASSEMBLY (1);
1404 #ifdef tc_unrecognized_line
1405 if (tc_unrecognized_line (next_char
))
1408 input_line_pointer
--;
1409 /* Report unknown char as error. */
1410 demand_empty_rest_of_line ();
1415 symbol_set_value_now (&dot_symbol
);
1417 #ifdef HANDLE_BUNDLE
1418 if (bundle_lock_frag
!= NULL
)
1420 as_bad_where (bundle_lock_frag
->fr_file
, bundle_lock_frag
->fr_line
,
1421 _(".bundle_lock with no matching .bundle_unlock"));
1422 bundle_lock_frag
= NULL
;
1423 bundle_lock_frchain
= NULL
;
1424 bundle_lock_depth
= 0;
1429 ginsn_data_end (symbol_temp_new_now ());
1434 /* Close the input file. */
1435 input_scrub_close ();
1436 #ifdef WARN_COMMENTS
1438 if (warn_comment
&& found_comment
)
1439 as_warn_where (found_comment_file
, found_comment
,
1440 "first comment found here");
1445 /* Convert O_constant expression EXP into the equivalent O_big
1449 convert_to_bignum (expressionS
*exp
)
1453 bool sign
= !exp
->X_unsigned
&& exp
->X_extrabit
;
1455 value
= exp
->X_add_number
;
1456 for (i
= 0; i
< sizeof (exp
->X_add_number
) / CHARS_PER_LITTLENUM
; i
++)
1458 generic_bignum
[i
] = value
& LITTLENUM_MASK
;
1459 value
>>= LITTLENUM_NUMBER_OF_BITS
;
1461 /* Add a sequence of sign bits if the top bit of X_add_number is not
1462 the sign of the original value. */
1463 if ((exp
->X_add_number
< 0) == !sign
)
1464 generic_bignum
[i
++] = sign
? LITTLENUM_MASK
: 0;
1466 exp
->X_add_number
= i
;
1467 exp
->X_unsigned
= !sign
;
1472 /* For most MRI pseudo-ops, the line actually ends at the first
1473 nonquoted space. This function looks for that point, stuffs a null
1474 in, and sets *STOPCP to the character that used to be there, and
1475 returns the location.
1477 Until I hear otherwise, I am going to assume that this is only true
1478 for the m68k MRI assembler. */
1481 mri_comment_field (char *stopcp
)
1487 know (flag_m68k_mri
);
1489 for (s
= input_line_pointer
;
1490 ((!is_end_of_stmt (*s
) && !is_whitespace (*s
))
1498 for (s
= input_line_pointer
;
1499 !is_end_of_stmt (*s
);
1509 /* Skip to the end of an MRI comment field. */
1512 mri_comment_end (char *stop
, int stopc
)
1516 input_line_pointer
= stop
;
1518 while (!is_end_of_stmt (*input_line_pointer
))
1519 ++input_line_pointer
;
1523 s_abort (int ignore ATTRIBUTE_UNUSED
)
1525 as_fatal (_(".abort detected. Abandoning ship."));
1528 #ifndef TC_ALIGN_LIMIT
1529 #define TC_ALIGN_LIMIT (stdoutput->arch_info->bits_per_address - 1)
1532 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1533 (in bytes). A negative ARG is the negative of the length of the
1534 fill pattern. BYTES_P is non-zero if the alignment value should be
1535 interpreted as the byte boundary, rather than the power of 2. */
1538 s_align (signed int arg
, int bytes_p
)
1540 unsigned int align_limit
= TC_ALIGN_LIMIT
;
1549 stop
= mri_comment_field (&stopc
);
1551 if (is_end_of_stmt (*input_line_pointer
))
1556 align
= arg
; /* Default value from pseudo-op table. */
1560 align
= get_absolute_expression ();
1563 #ifdef TC_ALIGN_ZERO_IS_DEFAULT
1564 if (arg
> 0 && align
== 0)
1571 /* Convert to a power of 2. */
1576 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1579 as_bad (_("alignment not a power of 2"));
1585 if (align
> align_limit
)
1587 align
= align_limit
;
1588 as_warn (_("alignment too large: %u assumed"),
1589 bytes_p
? 1u << align_limit
: align_limit
);
1592 if (*input_line_pointer
!= ',')
1599 ++input_line_pointer
;
1600 if (*input_line_pointer
== ',')
1604 fill
= get_absolute_expression ();
1609 if (*input_line_pointer
!= ',')
1613 ++input_line_pointer
;
1614 offsetT val
= get_absolute_expression ();
1616 if (val
< 0 || max
!= (valueT
) val
)
1618 as_warn (_("ignoring out of range alignment maximum"));
1627 as_warn (_("expected fill pattern missing"));
1628 do_align (align
, NULL
, 0, max
);
1632 unsigned int fill_len
;
1644 do_align (align
, &fill_char
, fill_len
, max
);
1650 if ((size_t) fill_len
> sizeof ab
)
1652 as_warn (_("fill pattern too long, truncating to %u"),
1653 (unsigned) sizeof ab
);
1654 fill_len
= sizeof ab
;
1657 md_number_to_chars (ab
, fill
, fill_len
);
1658 do_align (align
, ab
, fill_len
, max
);
1662 demand_empty_rest_of_line ();
1665 mri_comment_end (stop
, stopc
);
1668 /* Handle the .align pseudo-op on machines where ".align 4" means
1669 align to a 4 byte boundary. */
1672 s_align_bytes (int arg
)
1677 /* Handle the .align pseudo-op on machines where ".align 4" means align
1678 to a 2**4 boundary. */
1681 s_align_ptwo (int arg
)
1686 /* Switch in and out of alternate macro mode. */
1691 demand_empty_rest_of_line ();
1692 flag_macro_alternate
= on
;
1695 /* Read a symbol name from input_line_pointer.
1697 Stores the symbol name in a buffer and returns a pointer to this buffer.
1698 The buffer is xalloc'ed. It is the caller's responsibility to free
1701 The name is not left in the i_l_p buffer as it may need processing
1702 to handle escape characters.
1704 Advances i_l_p to the next non-whitespace character.
1706 If a symbol name could not be read, the routine issues an error
1707 messages, skips to the end of the line and returns NULL. */
1710 read_symbol_name (void)
1716 c
= *input_line_pointer
++;
1720 #define SYM_NAME_CHUNK_LEN 128
1721 ptrdiff_t len
= SYM_NAME_CHUNK_LEN
;
1725 start
= name
= XNEWVEC (char, len
+ 1);
1727 name_end
= name
+ SYM_NAME_CHUNK_LEN
;
1729 while (is_a_char (C
= next_char_of_string ()))
1731 if (name
>= name_end
)
1735 sofar
= name
- start
;
1736 len
+= SYM_NAME_CHUNK_LEN
;
1737 start
= XRESIZEVEC (char, start
, len
+ 1);
1738 name_end
= start
+ len
;
1739 name
= start
+ sofar
;
1746 /* Since quoted symbol names can contain non-ASCII characters,
1747 check the string and warn if it cannot be recognised by the
1748 current character set. */
1749 /* PR 29447: mbstowcs ignores the third (length) parameter when
1750 the first (destination) parameter is NULL. For clarity sake
1751 therefore we pass 0 rather than 'len' as the third parameter. */
1752 if (mbstowcs (NULL
, name
, 0) == (size_t) -1)
1753 as_warn (_("symbol name not recognised in the current locale"));
1755 else if (is_name_beginner (c
) || (input_from_string
&& c
== FAKE_LABEL_CHAR
))
1759 name
= input_line_pointer
- 1;
1761 /* We accept FAKE_LABEL_CHAR in a name in case this is
1762 being called with a constructed string. */
1763 while (is_part_of_name (c
= *input_line_pointer
++)
1764 || (input_from_string
&& c
== FAKE_LABEL_CHAR
))
1767 len
= (input_line_pointer
- name
) - 1;
1768 start
= XNEWVEC (char, len
+ 1);
1770 memcpy (start
, name
, len
);
1773 /* Skip a name ender char if one is present. */
1774 if (! is_name_ender (c
))
1775 --input_line_pointer
;
1778 name
= start
= NULL
;
1782 as_bad (_("expected symbol name"));
1783 ignore_rest_of_line ();
1795 s_comm_internal (int param
,
1796 symbolS
*(*comm_parse_extra
) (int, symbolS
*, addressT
))
1800 symbolS
*symbolP
= NULL
;
1806 stop
= mri_comment_field (&stopc
);
1808 if ((name
= read_symbol_name ()) == NULL
)
1811 /* Accept an optional comma after the name. The comma used to be
1812 required, but Irix 5 cc does not generate it for .lcomm. */
1813 if (*input_line_pointer
== ',')
1814 input_line_pointer
++;
1816 temp
= get_absolute_expr (&exp
);
1818 size
&= ((addressT
) 2 << (stdoutput
->arch_info
->bits_per_address
- 1)) - 1;
1819 if (exp
.X_op
== O_absent
)
1821 as_bad (_("missing size expression"));
1822 ignore_rest_of_line ();
1825 else if (temp
!= size
|| (!exp
.X_unsigned
&& exp
.X_add_number
< 0))
1827 as_warn (_("size (%ld) out of range, ignored"), (long) temp
);
1828 ignore_rest_of_line ();
1832 symbolP
= symbol_find_or_make (name
);
1833 if ((S_IS_DEFINED (symbolP
) || symbol_equated_p (symbolP
))
1834 && !S_IS_COMMON (symbolP
))
1836 if (!S_IS_VOLATILE (symbolP
))
1839 as_bad (_("symbol `%s' is already defined"), name
);
1840 ignore_rest_of_line ();
1843 symbolP
= symbol_clone (symbolP
, 1);
1844 S_SET_SEGMENT (symbolP
, undefined_section
);
1845 S_SET_VALUE (symbolP
, 0);
1846 symbol_set_frag (symbolP
, &zero_address_frag
);
1847 S_CLEAR_VOLATILE (symbolP
);
1850 size
= S_GET_VALUE (symbolP
);
1853 else if (size
!= temp
)
1854 as_warn (_("size of \"%s\" is already %ld; not changing to %ld"),
1855 name
, (long) size
, (long) temp
);
1857 if (comm_parse_extra
!= NULL
)
1858 symbolP
= (*comm_parse_extra
) (param
, symbolP
, size
);
1861 S_SET_VALUE (symbolP
, size
);
1862 S_SET_EXTERNAL (symbolP
);
1863 S_SET_SEGMENT (symbolP
, bfd_com_section_ptr
);
1866 demand_empty_rest_of_line ();
1869 mri_comment_end (stop
, stopc
);
1877 s_comm_internal (ignore
, NULL
);
1880 /* The MRI COMMON pseudo-op. We handle this by creating a common
1881 symbol with the appropriate name. We make s_space do the right
1882 thing by increasing the size. */
1885 s_mri_common (int small ATTRIBUTE_UNUSED
)
1901 stop
= mri_comment_field (&stopc
);
1905 name
= input_line_pointer
;
1906 if (!ISDIGIT (*name
))
1907 c
= get_symbol_name (& name
);
1912 ++input_line_pointer
;
1914 while (ISDIGIT (*input_line_pointer
));
1916 c
= *input_line_pointer
;
1917 *input_line_pointer
= '\0';
1919 if (line_label
!= NULL
)
1921 alc
= XNEWVEC (char, strlen (S_GET_NAME (line_label
))
1922 + (input_line_pointer
- name
) + 1);
1923 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1928 sym
= symbol_find_or_make (name
);
1929 c
= restore_line_pointer (c
);
1932 if (*input_line_pointer
!= ',')
1936 ++input_line_pointer
;
1937 align
= get_absolute_expression ();
1940 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1942 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (sym
));
1943 mri_comment_end (stop
, stopc
);
1947 S_SET_EXTERNAL (sym
);
1948 S_SET_SEGMENT (sym
, bfd_com_section_ptr
);
1949 mri_common_symbol
= sym
;
1953 S_SET_ALIGN (sym
, align
);
1958 if (line_label
!= NULL
)
1961 exp
.X_op
= O_symbol
;
1962 exp
.X_add_symbol
= sym
;
1963 exp
.X_add_number
= 0;
1964 symbol_set_value_expression (line_label
, &exp
);
1965 symbol_set_frag (line_label
, &zero_address_frag
);
1966 S_SET_SEGMENT (line_label
, expr_section
);
1969 /* FIXME: We just ignore the small argument, which distinguishes
1970 COMMON and COMMON.S. I don't know what we can do about it. */
1972 /* Ignore the type and hptype. */
1973 if (*input_line_pointer
== ',')
1974 input_line_pointer
+= 2;
1975 if (*input_line_pointer
== ',')
1976 input_line_pointer
+= 2;
1978 demand_empty_rest_of_line ();
1980 mri_comment_end (stop
, stopc
);
1984 s_data (int ignore ATTRIBUTE_UNUSED
)
1989 temp
= get_absolute_expression ();
1990 if (flag_readonly_data_in_text
)
1992 section
= text_section
;
1996 section
= data_section
;
1998 subseg_set (section
, temp
);
2000 demand_empty_rest_of_line ();
2003 /* Handle the .file pseudo-op. This default definition may be overridden by
2004 the object or CPU specific pseudo-ops. */
2007 s_file_string (char *file
)
2011 listing_source_file (file
);
2013 register_dependency (file
);
2015 obj_app_file (file
);
2020 s_file (int ignore ATTRIBUTE_UNUSED
)
2025 /* Some assemblers tolerate immediately following '"'. */
2026 if ((s
= demand_copy_string (&length
)) != 0)
2028 new_logical_line_flags (s
, -1, 1);
2030 /* In MRI mode, the preprocessor may have inserted an extraneous
2033 && *input_line_pointer
== '\''
2034 && is_end_of_stmt (input_line_pointer
[1]))
2035 ++input_line_pointer
;
2037 demand_empty_rest_of_line ();
2043 get_linefile_number (int *flag
)
2049 if (*input_line_pointer
< '0' || *input_line_pointer
> '9')
2052 /* Don't mistakenly interpret octal numbers as line numbers. */
2053 if (*input_line_pointer
== '0')
2056 ++input_line_pointer
;
2060 expression_and_evaluate (&exp
);
2061 if (exp
.X_op
!= O_constant
)
2064 #if defined (BFD64) || LONG_MAX > INT_MAX
2065 if (exp
.X_add_number
< INT_MIN
|| exp
.X_add_number
> INT_MAX
)
2069 *flag
= exp
.X_add_number
;
2074 /* Handle the .linefile pseudo-op. This is automatically generated by
2075 do_scrub_chars when a preprocessor # line comment is seen. This
2076 default definition may be overridden by the object or CPU specific
2080 s_linefile (int ignore ATTRIBUTE_UNUSED
)
2083 int linenum
, flags
= 0;
2085 /* The given number is that of the next line. */
2086 if (!get_linefile_number (&linenum
))
2088 ignore_rest_of_line ();
2093 /* Some of the back ends can't deal with non-positive line numbers.
2094 Besides, it's silly. GCC however will generate a line number of
2095 zero when it is pre-processing builtins for assembler-with-cpp files:
2099 We do not want to barf on this, especially since such files are used
2100 in the GCC and GDB testsuites. So we check for negative line numbers
2101 rather than non-positive line numbers. */
2102 as_warn (_("line numbers must be positive; line number %d rejected"),
2110 if (*input_line_pointer
== '"')
2111 file
= demand_copy_string (&length
);
2112 else if (*input_line_pointer
== '.')
2114 /* buffer_and_nest() may insert this form. */
2115 ++input_line_pointer
;
2123 while (get_linefile_number (&this_flag
))
2126 /* From GCC's cpp documentation:
2127 1: start of a new file.
2128 2: returning to a file after having included another file.
2129 3: following text comes from a system header file.
2130 4: following text should be treated as extern "C".
2132 4 is nonsensical for the assembler; 3, we don't care about,
2133 so we ignore it just in case a system header file is
2134 included while preprocessing assembly. So 1 and 2 are all
2135 we care about, and they are mutually incompatible.
2136 new_logical_line_flags() demands this. */
2139 if (flags
&& flags
!= (1 << this_flag
))
2140 as_warn (_("incompatible flag %i in line directive"),
2143 flags
|= 1 << this_flag
;
2148 /* We ignore these. */
2152 as_warn (_("unsupported flag %i in line directive"),
2157 if (!is_end_of_stmt (*input_line_pointer
))
2163 demand_empty_rest_of_line ();
2165 /* read_a_source_file() will bump the line number only if the line
2166 is terminated by '\n'. */
2167 if (input_line_pointer
[-1] == '\n')
2170 new_logical_line_flags (file
, linenum
, flags
);
2173 listing_source_line (linenum
);
2178 ignore_rest_of_line ();
2181 /* Handle the .end pseudo-op. Actually, the real work is done in
2182 read_a_source_file. */
2185 s_end (int ignore ATTRIBUTE_UNUSED
)
2189 /* The MRI assembler permits the start symbol to follow .end,
2190 but we don't support that. */
2192 if (!is_end_of_stmt (*input_line_pointer
)
2193 && *input_line_pointer
!= '*'
2194 && *input_line_pointer
!= '!')
2195 as_warn (_("start address not supported"));
2199 /* Handle the .err pseudo-op. */
2202 s_err (int ignore ATTRIBUTE_UNUSED
)
2204 as_bad (_(".err encountered"));
2205 demand_empty_rest_of_line ();
2208 /* Handle the .error and .warning pseudo-ops. */
2214 /* The purpose for the conditional assignment is not to
2215 internationalize the directive itself, but that we need a
2216 self-contained message, one that can be passed like the
2217 demand_copy_C_string return value, and with no assumption on the
2218 location of the name of the directive within the message. */
2220 = (err
? _(".error directive invoked in source file")
2221 : _(".warning directive invoked in source file"));
2223 if (!is_it_end_of_statement ())
2225 if (*input_line_pointer
!= '\"')
2227 as_bad (_("%s argument must be a string"),
2228 err
? ".error" : ".warning");
2229 ignore_rest_of_line ();
2233 msg
= demand_copy_C_string (&len
);
2241 as_warn ("%s", msg
);
2242 demand_empty_rest_of_line ();
2245 /* Handle the .errif and .warnif pseudo-ops. */
2247 static struct deferred_diag
{
2248 struct deferred_diag
*next
;
2250 unsigned int lineno
;
2253 } *deferred_diag_head
, **deferred_diag_tail
= &deferred_diag_head
;
2256 s_errwarn_if (int err
)
2258 struct deferred_diag
*diag
= XNEW (struct deferred_diag
);
2259 int errcnt
= had_errors ();
2261 deferred_expression (&diag
->exp
);
2262 if (errcnt
!= had_errors ())
2264 ignore_rest_of_line ();
2270 diag
->file
= as_where (&diag
->lineno
);
2272 *deferred_diag_tail
= diag
;
2273 deferred_diag_tail
= &diag
->next
;
2275 demand_empty_rest_of_line ();
2279 evaluate_deferred_diags (void)
2281 struct deferred_diag
*diag
;
2283 while ((diag
= deferred_diag_head
) != NULL
)
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"));
2296 deferred_diag_head
= diag
->next
;
2299 deferred_diag_tail
= &deferred_diag_head
;
2302 /* Handle the MRI fail pseudo-op. */
2305 s_fail (int ignore ATTRIBUTE_UNUSED
)
2312 stop
= mri_comment_field (&stopc
);
2314 temp
= get_absolute_expression ();
2316 as_warn (_(".fail %ld encountered"), (long) temp
);
2318 as_bad (_(".fail %ld encountered"), (long) temp
);
2320 demand_empty_rest_of_line ();
2323 mri_comment_end (stop
, stopc
);
2327 s_fill (int ignore ATTRIBUTE_UNUSED
)
2329 expressionS rep_exp
;
2334 #ifdef md_flush_pending_output
2335 md_flush_pending_output ();
2338 #ifdef md_cons_align
2342 expression (&rep_exp
);
2343 if (*input_line_pointer
== ',')
2345 input_line_pointer
++;
2346 size
= get_absolute_expression ();
2347 if (*input_line_pointer
== ',')
2349 input_line_pointer
++;
2350 fill
= get_absolute_expression ();
2354 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
2355 #define BSD_FILL_SIZE_CROCK_8 (8)
2356 if (size
> BSD_FILL_SIZE_CROCK_8
)
2358 as_warn (_(".fill size clamped to %d"), BSD_FILL_SIZE_CROCK_8
);
2359 size
= BSD_FILL_SIZE_CROCK_8
;
2363 as_warn (_("size negative; .fill ignored"));
2366 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
2368 if (rep_exp
.X_add_number
< 0)
2369 as_warn (_("repeat < 0; .fill ignored"));
2372 else if (size
&& !need_pass_2
)
2374 if (now_seg
== absolute_section
&& rep_exp
.X_op
!= O_constant
)
2376 as_bad (_("non-constant fill count for absolute section"));
2379 else if (now_seg
== absolute_section
&& fill
&& rep_exp
.X_add_number
!= 0)
2381 as_bad (_("attempt to fill absolute section with non-zero value"));
2385 && (rep_exp
.X_op
!= O_constant
|| rep_exp
.X_add_number
!= 0)
2388 as_bad (_("attempt to fill section `%s' with non-zero value"),
2389 segment_name (now_seg
));
2394 if (size
&& !need_pass_2
)
2396 if (now_seg
== absolute_section
)
2397 abs_section_offset
+= (valueT
) rep_exp
.X_add_number
* size
;
2399 if (rep_exp
.X_op
== O_constant
)
2401 p
= frag_var (rs_fill
, size
, size
, 0, NULL
,
2402 rep_exp
.X_add_number
, NULL
);
2406 /* We don't have a constant repeat count, so we can't use
2407 rs_fill. We can get the same results out of rs_space,
2408 but its argument is in bytes, so we must multiply the
2409 repeat count by size. */
2412 rep_sym
= make_expr_symbol (&rep_exp
);
2415 expressionS size_exp
;
2416 size_exp
.X_op
= O_constant
;
2417 size_exp
.X_add_number
= size
;
2419 rep_exp
.X_op
= O_multiply
;
2420 rep_exp
.X_add_symbol
= rep_sym
;
2421 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
2422 rep_exp
.X_add_number
= 0;
2423 rep_sym
= make_expr_symbol (&rep_exp
);
2426 p
= frag_var (rs_space
, size
, size
, 0, rep_sym
, 0, NULL
);
2429 memset (p
, 0, 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
, 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, 0, sym
, off
, NULL
);
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
= 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, 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, 0, NULL
, total
, NULL
);
3598 if (now_seg
== absolute_section
)
3600 as_bad (_("space allocation too complex in absolute section"));
3601 subseg_set (text_section
, 0);
3604 if (mri_common_symbol
!= NULL
)
3606 as_bad (_("space allocation too complex in common section"));
3607 mri_common_symbol
= NULL
;
3611 p
= frag_var (rs_space
, 1, 1, 0, make_expr_symbol (&exp
), 0, NULL
);
3614 if ((val
.X_op
!= O_constant
|| val
.X_add_number
!= 0) && in_bss ())
3615 as_warn (_("ignoring fill value in section `%s'"),
3616 segment_name (now_seg
));
3618 *p
= val
.X_add_number
;
3623 /* In MRI mode, after an odd number of bytes, we must align to an
3624 even word boundary, unless the next instruction is a dc.b, ds.b
3626 if (flag_mri
&& (bytes
& 1) != 0)
3627 mri_pending_align
= 1;
3629 demand_empty_rest_of_line ();
3632 mri_comment_end (stop
, stopc
);
3636 s_nop (int ignore ATTRIBUTE_UNUSED
)
3643 #ifdef md_flush_pending_output
3644 md_flush_pending_output ();
3649 demand_empty_rest_of_line ();
3652 start_off
= frag_now_fix ();
3655 #ifdef md_emit_single_noop
3656 md_emit_single_noop
;
3660 #ifndef md_single_noop_insn
3661 #define md_single_noop_insn "nop"
3663 /* md_assemble might modify its argument, so
3664 we must pass it a string that is writable. */
3665 nop
= xasprintf ("%s", md_single_noop_insn
);
3667 /* Some targets assume that they can update input_line_pointer
3668 inside md_assemble, and, worse, that they can leave it
3669 assigned to the string pointer that was provided as an
3670 argument. So preserve ilp here. */
3671 char *saved_ilp
= input_line_pointer
;
3673 input_line_pointer
= saved_ilp
;
3676 #ifdef md_flush_pending_output
3677 md_flush_pending_output ();
3679 } while (exp
.X_op
== O_constant
3680 && exp
.X_add_number
> 0
3681 && frag_offset_ignore_align_p (start
, frag_now
, &frag_off
)
3682 && frag_off
+ frag_now_fix () < start_off
+ exp
.X_add_number
);
3685 /* Use this to specify the amount of memory allocated for representing
3686 the nops. Needs to be large enough to hold any fixed size prologue
3687 plus the replicating portion. */
3688 #ifndef MAX_MEM_FOR_RS_SPACE_NOP
3689 # define MAX_MEM_FOR_RS_SPACE_NOP 1
3693 s_nops (int ignore ATTRIBUTE_UNUSED
)
3698 #ifdef md_flush_pending_output
3699 md_flush_pending_output ();
3704 /* Note - this expression is tested for an absolute value in
3705 write.c:relax_segment(). */
3708 if (*input_line_pointer
== ',')
3710 ++input_line_pointer
;
3715 val
.X_op
= O_constant
;
3716 val
.X_add_number
= 0;
3719 if (val
.X_op
!= O_constant
)
3721 as_bad (_("unsupported variable nop control in .nops directive"));
3722 val
.X_op
= O_constant
;
3723 val
.X_add_number
= 0;
3725 else if (val
.X_add_number
< 0)
3727 as_warn (_("negative nop control byte, ignored"));
3728 val
.X_add_number
= 0;
3731 demand_empty_rest_of_line ();
3734 /* Ignore this directive if we are going to perform a second pass. */
3737 /* Store the no-op instruction control byte in the first byte of frag. */
3739 symbolS
*sym
= make_expr_symbol (&exp
);
3740 p
= frag_var (rs_space_nop
, MAX_MEM_FOR_RS_SPACE_NOP
, 1, 0, sym
, 0, NULL
);
3741 *p
= val
.X_add_number
;
3744 /* Obtain the size of a floating point number, given a type. */
3747 float_length (int float_type
, int *pad_p
)
3749 int length
, pad
= 0;
3777 length
= X_PRECISION
* sizeof (LITTLENUM_TYPE
);
3778 pad
= X_PRECISION_PAD
* sizeof (LITTLENUM_TYPE
);
3787 length
= P_PRECISION
* sizeof (LITTLENUM_TYPE
);
3788 pad
= P_PRECISION_PAD
* sizeof (LITTLENUM_TYPE
);
3795 as_bad (_("unknown floating type '%c'"), float_type
);
3807 parse_one_float (int float_type
, char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
])
3813 /* Skip any 0{letter} that may be present. Don't even check if the
3814 letter is legal. Someone may invent a "z" format and this routine
3815 has no use for such information. Lusers beware: you get
3816 diagnostics if your input is ill-conditioned. */
3817 if (input_line_pointer
[0] == '0'
3818 && ISALPHA (input_line_pointer
[1]))
3819 input_line_pointer
+= 2;
3821 /* Accept :xxxx, where the x's are hex digits, for a floating point
3822 with the exact digits specified. */
3823 if (input_line_pointer
[0] == ':')
3825 ++input_line_pointer
;
3826 length
= hex_float (float_type
, temp
);
3829 ignore_rest_of_line ();
3837 err
= md_atof (float_type
, temp
, &length
);
3838 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3839 know (err
!= NULL
|| length
> 0);
3842 as_bad (_("bad floating literal: %s"), err
);
3843 ignore_rest_of_line ();
3851 /* This is like s_space, but the value is a floating point number with
3852 the given precision. This is for the MRI dcb.s pseudo-op and
3856 s_float_space (int float_type
)
3860 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3864 #ifdef md_cons_align
3869 stop
= mri_comment_field (&stopc
);
3871 count
= get_absolute_expression ();
3874 if (*input_line_pointer
!= ',')
3878 flen
= float_length (float_type
, &pad
);
3880 memset (temp
, 0, flen
+= pad
);
3884 ++input_line_pointer
;
3886 flen
= parse_one_float (float_type
, temp
);
3892 mri_comment_end (stop
, stopc
);
3896 while (--count
>= 0)
3900 p
= frag_more (flen
);
3901 memcpy (p
, temp
, flen
);
3904 demand_empty_rest_of_line ();
3907 mri_comment_end (stop
, stopc
);
3910 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3913 s_struct (int ignore ATTRIBUTE_UNUSED
)
3919 stop
= mri_comment_field (&stopc
);
3920 abs_section_offset
= get_absolute_expression ();
3921 #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
3922 /* The ELF backend needs to know that we are changing sections, so
3923 that .previous works correctly. */
3925 obj_elf_section_change_hook ();
3927 subseg_set (absolute_section
, 0);
3928 demand_empty_rest_of_line ();
3930 mri_comment_end (stop
, stopc
);
3934 s_text (int ignore ATTRIBUTE_UNUSED
)
3938 temp
= get_absolute_expression ();
3939 subseg_set (text_section
, temp
);
3940 demand_empty_rest_of_line ();
3943 /* .weakref x, y sets x as an alias to y that, as long as y is not
3944 referenced directly, will cause y to become a weak symbol. */
3946 s_weakref (int ignore ATTRIBUTE_UNUSED
)
3953 if ((name
= read_symbol_name ()) == NULL
)
3956 symbolP
= symbol_find_or_make (name
);
3958 if (S_IS_DEFINED (symbolP
) || symbol_equated_p (symbolP
))
3960 if (!S_IS_VOLATILE (symbolP
))
3962 as_bad (_("symbol `%s' is already defined"), name
);
3965 symbolP
= symbol_clone (symbolP
, 1);
3966 S_CLEAR_VOLATILE (symbolP
);
3971 if (*input_line_pointer
!= ',')
3973 as_bad (_("expected comma after \"%s\""), name
);
3977 input_line_pointer
++;
3982 if ((name
= read_symbol_name ()) == NULL
)
3985 if ((symbolP2
= symbol_find_noref (name
, 1)) == NULL
3986 && (symbolP2
= md_undefined_symbol (name
)) == NULL
)
3988 symbolP2
= symbol_find_or_make (name
);
3989 S_SET_WEAKREFD (symbolP2
);
3993 symbolS
*symp
= symbolP2
;
3995 while (S_IS_WEAKREFR (symp
) && symp
!= symbolP
)
3997 expressionS
*expP
= symbol_get_value_expression (symp
);
3999 gas_assert (expP
->X_op
== O_symbol
4000 && expP
->X_add_number
== 0);
4001 symp
= expP
->X_add_symbol
;
4003 if (symp
== symbolP
)
4007 loop
= concat (S_GET_NAME (symbolP
),
4008 " => ", S_GET_NAME (symbolP2
), (const char *) NULL
);
4011 while (symp
!= symbolP
)
4013 char *old_loop
= loop
;
4015 symp
= symbol_get_value_expression (symp
)->X_add_symbol
;
4016 loop
= concat (loop
, " => ", S_GET_NAME (symp
),
4017 (const char *) NULL
);
4021 as_bad (_("%s: would close weakref loop: %s"),
4022 S_GET_NAME (symbolP
), loop
);
4026 ignore_rest_of_line ();
4030 /* Short-circuiting instead of just checking here might speed
4031 things up a tiny little bit, but loop error messages would
4032 miss intermediate links. */
4033 /* symbolP2 = symp; */
4036 memset (&exp
, 0, sizeof (exp
));
4037 exp
.X_op
= O_symbol
;
4038 exp
.X_add_symbol
= symbolP2
;
4040 S_SET_SEGMENT (symbolP
, undefined_section
);
4041 symbol_set_value_expression (symbolP
, &exp
);
4042 symbol_set_frag (symbolP
, &zero_address_frag
);
4043 S_SET_WEAKREFR (symbolP
);
4045 demand_empty_rest_of_line ();
4050 ignore_rest_of_line ();
4056 /* Verify that we are at the end of a line. If not, issue an error and
4057 skip to EOL. This function may leave input_line_pointer one past
4058 buffer_limit, so should not be called from places that may
4059 dereference input_line_pointer unconditionally. Note that when the
4060 gas parser is switched to handling a string (where buffer_limit
4061 should be the size of the string excluding the NUL terminator) this
4062 will be one past the NUL; is_end_of_line(0) returns true. */
4065 demand_empty_rest_of_line (void)
4068 if (input_line_pointer
> buffer_limit
)
4070 if (is_end_of_stmt (*input_line_pointer
))
4071 input_line_pointer
++;
4074 if (ISPRINT (*input_line_pointer
))
4075 as_bad (_("junk at end of line, first unrecognized character is `%c'"),
4076 *input_line_pointer
);
4078 as_bad (_("junk at end of line, first unrecognized character valued 0x%x"),
4079 *input_line_pointer
);
4080 ignore_rest_of_line ();
4082 /* Return pointing just after end-of-line. */
4085 /* Silently advance to the end of a statement. Use this after already having
4086 issued an error about something bad. Like demand_empty_rest_of_line,
4087 this function may leave input_line_pointer one after buffer_limit;
4088 Don't call it from within expression parsing code in an attempt to
4089 silence further errors. */
4092 ignore_rest_of_line (void)
4094 while (input_line_pointer
<= buffer_limit
)
4095 if (is_end_of_stmt (*input_line_pointer
++))
4097 /* Return pointing just after end-of-statement. */
4100 /* Sets frag for given symbol to zero_address_frag, except when the
4101 symbol frag is already set to a dummy listing frag. */
4104 set_zero_frag (symbolS
*symbolP
)
4106 if (symbol_get_frag (symbolP
)->fr_type
!= rs_dummy
)
4107 symbol_set_frag (symbolP
, &zero_address_frag
);
4110 /* In: Pointer to a symbol.
4111 Input_line_pointer->expression.
4113 Out: Input_line_pointer->just after any whitespace after expression.
4114 Tried to set symbol to value of expression.
4115 Will change symbols type, value, and frag; */
4118 pseudo_set (symbolS
*symbolP
)
4123 know (symbolP
); /* NULL pointer is logic error. */
4125 if (!S_IS_FORWARD_REF (symbolP
))
4126 (void) expression (&exp
);
4128 (void) expr (0, &exp
, expr_defer_incl_dot
);
4130 if (exp
.X_op
== O_illegal
)
4131 as_bad (_("illegal expression"));
4132 else if (exp
.X_op
== O_absent
)
4133 as_bad (_("missing expression"));
4134 else if (exp
.X_op
== O_big
)
4136 if (exp
.X_add_number
> 0)
4137 as_bad (_("bignum invalid"));
4139 as_bad (_("floating point number invalid"));
4141 else if (exp
.X_op
== O_subtract
4142 && !S_IS_FORWARD_REF (symbolP
)
4143 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
4144 && (symbol_get_frag (exp
.X_add_symbol
)
4145 == symbol_get_frag (exp
.X_op_symbol
)))
4147 exp
.X_op
= O_constant
;
4148 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
4149 - S_GET_VALUE (exp
.X_op_symbol
));
4152 if (symbol_section_p (symbolP
))
4154 as_bad ("attempt to set value of section symbol");
4163 exp
.X_add_number
= 0;
4166 S_SET_SEGMENT (symbolP
, absolute_section
);
4167 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
4168 set_zero_frag (symbolP
);
4172 #ifndef TC_GLOBAL_REGISTER_SYMBOL_OK
4173 if (S_IS_EXTERNAL (symbolP
))
4175 as_bad ("can't equate global symbol `%s' with register name",
4176 S_GET_NAME (symbolP
));
4180 /* Make sure symbol_equated_p() recognizes the symbol as an equate. */
4181 exp
.X_add_symbol
= make_expr_symbol (&exp
);
4182 exp
.X_add_number
= 0;
4183 exp
.X_op
= O_symbol
;
4184 symbol_set_value_expression (symbolP
, &exp
);
4185 S_SET_SEGMENT (symbolP
, reg_section
);
4186 set_zero_frag (symbolP
);
4190 seg
= S_GET_SEGMENT (exp
.X_add_symbol
);
4191 if (seg
== expr_section
)
4193 /* For x=undef+const, create an expression symbol.
4194 For x=x+const, just update x except when x is an undefined symbol
4195 For x=defined+const, evaluate x. */
4196 if (symbolP
== exp
.X_add_symbol
4197 && (seg
!= undefined_section
4198 || !symbol_constant_p (symbolP
)))
4200 *symbol_X_add_number (symbolP
) += exp
.X_add_number
;
4203 else if (!S_IS_FORWARD_REF (symbolP
) && seg
!= undefined_section
)
4205 symbolS
*s
= exp
.X_add_symbol
;
4207 if (S_IS_COMMON (s
))
4208 as_bad (_("`%s' can't be equated to common symbol `%s'"),
4209 S_GET_NAME (symbolP
), S_GET_NAME (s
));
4211 S_SET_SEGMENT (symbolP
, seg
);
4212 S_SET_VALUE (symbolP
, exp
.X_add_number
+ S_GET_VALUE (s
));
4213 symbol_set_frag (symbolP
, symbol_get_frag (s
));
4214 copy_symbol_attributes (symbolP
, s
);
4217 S_SET_SEGMENT (symbolP
, undefined_section
);
4218 symbol_set_value_expression (symbolP
, &exp
);
4219 copy_symbol_attributes (symbolP
, exp
.X_add_symbol
);
4220 set_zero_frag (symbolP
);
4225 /* The value is some complex expression. */
4226 S_SET_SEGMENT (symbolP
, expr_section
);
4227 symbol_set_value_expression (symbolP
, &exp
);
4228 set_zero_frag (symbolP
);
4235 CONStruct more frag of .bytes, or .words etc.
4236 Should need_pass_2 be 1 then emit no frag(s).
4237 This understands EXPRESSIONS.
4241 This has a split personality. We use expression() to read the
4242 value. We can detect if the value won't fit in a byte or word.
4243 But we can't detect if expression() discarded significant digits
4244 in the case of a long. Not worth the crocks required to fix it. */
4246 /* Select a parser for cons expressions. */
4248 /* Some targets need to parse the expression in various fancy ways.
4249 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
4250 (for example, the HPPA does this). Otherwise, you can define
4251 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
4252 are defined, which is the normal case, then only simple expressions
4257 parse_mri_cons (expressionS
*exp
, unsigned int nbytes
);
4260 /* This function is used by .cfi_* directive handling, and hence must not
4261 invoke parse_repeat_cons(). */
4263 TC_PARSE_CONS_RETURN_TYPE
4264 do_parse_cons_expression (expressionS
*exp
,
4265 int nbytes ATTRIBUTE_UNUSED
)
4267 #ifdef TC_PARSE_CONS_EXPRESSION
4268 return TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
4271 return TC_PARSE_CONS_RETURN_NONE
;
4275 #ifndef TC_PARSE_CONS_EXPRESSION
4276 #ifdef REPEAT_CONS_EXPRESSIONS
4277 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) \
4278 (parse_repeat_cons (EXP, NBYTES), TC_PARSE_CONS_RETURN_NONE)
4280 parse_repeat_cons (expressionS
*exp
, unsigned int nbytes
);
4283 /* If we haven't gotten one yet, just call expression. */
4284 #ifndef TC_PARSE_CONS_EXPRESSION
4285 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) \
4286 (expression (EXP), TC_PARSE_CONS_RETURN_NONE)
4290 /* Worker to do .byte etc statements.
4291 Clobbers input_line_pointer and checks end-of-line. */
4294 cons_worker (int nbytes
, /* 1=.byte, 2=.word, 4=.long. */
4302 #ifdef md_flush_pending_output
4303 md_flush_pending_output ();
4307 stop
= mri_comment_field (&stopc
);
4309 if (is_it_end_of_statement ())
4311 demand_empty_rest_of_line ();
4313 mri_comment_end (stop
, stopc
);
4318 nbytes
= TC_ADDRESS_BYTES ();
4320 #ifdef md_cons_align
4321 md_cons_align (nbytes
);
4327 TC_PARSE_CONS_RETURN_TYPE ret
= TC_PARSE_CONS_RETURN_NONE
;
4328 #ifdef TC_CONS_FIX_CHECK
4329 fixS
**cur_fix
= &frchain_now
->fix_tail
;
4331 if (*cur_fix
!= NULL
)
4332 cur_fix
= &(*cur_fix
)->fx_next
;
4337 parse_mri_cons (&exp
, nbytes
);
4342 if (*input_line_pointer
== '"')
4344 as_bad (_("unexpected `\"' in expression"));
4345 ignore_rest_of_line ();
4349 ret
= TC_PARSE_CONS_EXPRESSION (&exp
, nbytes
);
4354 if (exp
.X_op
== O_symbol
)
4355 exp
.X_op
= O_symbol_rva
;
4357 as_fatal (_("rva without symbol"));
4359 emit_expr_with_reloc (&exp
, nbytes
, ret
);
4360 #ifdef TC_CONS_FIX_CHECK
4361 TC_CONS_FIX_CHECK (&exp
, nbytes
, *cur_fix
);
4365 while (*input_line_pointer
++ == ',');
4367 /* In MRI mode, after an odd number of bytes, we must align to an
4368 even word boundary, unless the next instruction is a dc.b, ds.b
4370 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
4371 mri_pending_align
= 1;
4373 input_line_pointer
--; /* Put terminator back into stream. */
4375 demand_empty_rest_of_line ();
4378 mri_comment_end (stop
, stopc
);
4380 /* Disallow hand-crafting instructions using .byte. FIXME - what about
4381 .word, .long etc ? */
4382 if (flag_synth_cfi
&& frchain_now
&& frchain_now
->frch_ginsn_data
4384 as_bad (_("SCFI: hand-crafting instructions not supported"));
4390 cons_worker (size
, 0);
4396 cons_worker (size
, 1);
4399 /* .reloc offset, reloc_name, symbol+addend. */
4402 s_reloc (int ignore ATTRIBUTE_UNUSED
)
4409 struct reloc_list
*reloc
;
4410 struct _bfd_rel
{ const char * name
; bfd_reloc_code_real_type code
; };
4411 static const struct _bfd_rel bfd_relocs
[] =
4413 { "NONE", BFD_RELOC_NONE
},
4414 { "8", BFD_RELOC_8
},
4415 { "16", BFD_RELOC_16
},
4416 { "32", BFD_RELOC_32
},
4417 { "64", BFD_RELOC_64
}
4420 reloc
= notes_alloc (sizeof (*reloc
));
4423 stop
= mri_comment_field (&stopc
);
4432 as_bad (_("missing or bad offset expression"));
4435 exp
.X_add_symbol
= section_symbol (now_seg
);
4436 /* Mark the section symbol used in relocation so that it will be
4437 included in the symbol table. */
4438 symbol_mark_used_in_reloc (exp
.X_add_symbol
);
4439 exp
.X_op
= O_symbol
;
4442 if (exp
.X_add_number
== 0)
4444 reloc
->u
.a
.offset_sym
= exp
.X_add_symbol
;
4449 reloc
->u
.a
.offset_sym
= make_expr_symbol (&exp
);
4454 if (*input_line_pointer
!= ',')
4456 as_bad (_("missing reloc type"));
4460 ++input_line_pointer
;
4462 c
= get_symbol_name (& r_name
);
4463 if (strncasecmp (r_name
, "BFD_RELOC_", 10) == 0)
4467 for (reloc
->u
.a
.howto
= NULL
, i
= 0; i
< ARRAY_SIZE (bfd_relocs
); i
++)
4468 if (strcasecmp (r_name
+ 10, bfd_relocs
[i
].name
) == 0)
4470 reloc
->u
.a
.howto
= bfd_reloc_type_lookup (stdoutput
,
4471 bfd_relocs
[i
].code
);
4476 reloc
->u
.a
.howto
= bfd_reloc_name_lookup (stdoutput
, r_name
);
4477 restore_line_pointer (c
);
4478 if (reloc
->u
.a
.howto
== NULL
)
4480 as_bad (_("unrecognized reloc type"));
4484 exp
.X_op
= O_absent
;
4486 if (*input_line_pointer
== ',')
4488 ++input_line_pointer
;
4496 as_bad (_("bad reloc expression"));
4498 ignore_rest_of_line ();
4500 mri_comment_end (stop
, stopc
);
4503 reloc
->u
.a
.sym
= NULL
;
4504 reloc
->u
.a
.addend
= 0;
4507 reloc
->u
.a
.sym
= NULL
;
4508 reloc
->u
.a
.addend
= exp
.X_add_number
;
4511 reloc
->u
.a
.sym
= exp
.X_add_symbol
;
4512 reloc
->u
.a
.addend
= exp
.X_add_number
;
4515 reloc
->u
.a
.sym
= make_expr_symbol (&exp
);
4516 reloc
->u
.a
.addend
= 0;
4520 reloc
->file
= as_where (&reloc
->line
);
4521 reloc
->next
= reloc_list
;
4524 demand_empty_rest_of_line ();
4526 mri_comment_end (stop
, stopc
);
4529 /* Put the contents of expression EXP into the object file using
4530 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
4533 emit_expr (expressionS
*exp
, unsigned int nbytes
)
4535 emit_expr_with_reloc (exp
, nbytes
, TC_PARSE_CONS_RETURN_NONE
);
4539 emit_expr_with_reloc (expressionS
*exp
,
4540 unsigned int nbytes
,
4541 TC_PARSE_CONS_RETURN_TYPE reloc
)
4545 valueT extra_digit
= 0;
4547 /* Don't do anything if we are going to make another pass. */
4552 symbol_set_value_now (&dot_symbol
);
4556 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
4557 appear as a four byte positive constant in the .line section,
4558 followed by a 2 byte 0xffff. Look for that case here. */
4559 if (strcmp (segment_name (now_seg
), ".line") != 0)
4561 else if (dwarf_line
>= 0
4563 && exp
->X_op
== O_constant
4564 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
4565 listing_source_line (dwarf_line
);
4566 else if (nbytes
== 4
4567 && exp
->X_op
== O_constant
4568 && exp
->X_add_number
>= 0)
4569 dwarf_line
= exp
->X_add_number
;
4573 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
4574 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
4575 AT_sibling (0x12) followed by a four byte address of the sibling
4576 followed by a 2 byte AT_name (0x38) followed by the name of the
4577 file. We look for that case here. */
4578 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4580 else if (dwarf_file
== 0
4582 && exp
->X_op
== O_constant
4583 && exp
->X_add_number
== 0x11)
4585 else if (dwarf_file
== 1
4587 && exp
->X_op
== O_constant
4588 && exp
->X_add_number
== 0x12)
4590 else if (dwarf_file
== 2
4593 else if (dwarf_file
== 3
4595 && exp
->X_op
== O_constant
4596 && exp
->X_add_number
== 0x38)
4601 /* The variable dwarf_file_string tells stringer that the string
4602 may be the name of the source file. */
4603 if (dwarf_file
== 4)
4604 dwarf_file_string
= 1;
4606 dwarf_file_string
= 0;
4610 if (check_eh_frame (exp
, &nbytes
))
4615 /* Handle a negative bignum. */
4617 && exp
->X_add_number
== 0
4618 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
4619 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
4622 unsigned long carry
;
4624 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
4626 /* Negate the bignum: one's complement each digit and add 1. */
4628 for (i
= 0; i
< exp
->X_add_number
; i
++)
4632 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
4635 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
4636 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
4639 /* We can ignore any carry out, because it will be handled by
4640 extra_digit if it is needed. */
4646 if (op
== O_absent
|| op
== O_illegal
)
4648 as_warn (_("zero assumed for missing expression"));
4649 exp
->X_add_number
= 0;
4652 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4654 as_bad (_("floating point number invalid"));
4655 exp
->X_add_number
= 0;
4658 else if (op
== O_register
)
4660 as_warn (_("register value used as expression"));
4664 /* Allow `.word 0' in the absolute section. */
4665 if (now_seg
== absolute_section
)
4667 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
4668 as_bad (_("attempt to store value in absolute section"));
4669 abs_section_offset
+= nbytes
;
4673 /* Allow `.word 0' in BSS style sections. */
4674 if ((op
!= O_constant
|| exp
->X_add_number
!= 0) && in_bss ())
4675 as_bad (_("attempt to store non-zero value in section `%s'"),
4676 segment_name (now_seg
));
4678 p
= frag_more (nbytes
);
4680 if (reloc
!= TC_PARSE_CONS_RETURN_NONE
)
4682 emit_expr_fix (exp
, nbytes
, frag_now
, p
, reloc
);
4686 #ifndef WORKING_DOT_WORD
4687 /* If we have the difference of two symbols in a word, save it on
4688 the broken_words list. See the code in write.c. */
4689 if (op
== O_subtract
&& nbytes
== 2)
4691 struct broken_word
*x
;
4693 x
= XNEW (struct broken_word
);
4694 x
->next_broken_word
= broken_words
;
4697 x
->subseg
= now_subseg
;
4699 x
->word_goes_here
= p
;
4701 x
->add
= exp
->X_add_symbol
;
4702 x
->sub
= exp
->X_op_symbol
;
4703 x
->addnum
= exp
->X_add_number
;
4711 /* If we have an integer, but the number of bytes is too large to
4712 pass to md_number_to_chars, handle it as a bignum. */
4713 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
4715 extra_digit
= -convert_to_bignum (exp
);
4719 if (op
== O_constant
)
4726 /* JF << of >= number of bits in the object is undefined. In
4727 particular SPARC (Sun 4) has problems. */
4728 if (nbytes
>= sizeof (valueT
))
4730 know (nbytes
== sizeof (valueT
));
4735 /* Don't store these bits. */
4736 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
4739 unmask
= ~mask
; /* Do store these bits. */
4742 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
4743 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
4746 get
= exp
->X_add_number
;
4748 if ((get
& mask
) != 0 && (-get
& mask
) != 0)
4750 /* Leading bits contain both 0s & 1s. */
4751 as_warn (_("value 0x%" PRIx64
" truncated to 0x%" PRIx64
),
4752 (uint64_t) get
, (uint64_t) use
);
4754 /* Put bytes in right order. */
4755 md_number_to_chars (p
, use
, nbytes
);
4757 else if (op
== O_big
)
4760 LITTLENUM_TYPE
*nums
;
4762 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
4765 int i
= nbytes
/ CHARS_PER_LITTLENUM
;
4769 LITTLENUM_TYPE sign
= 0;
4770 if ((generic_bignum
[--i
]
4771 & (1 << (LITTLENUM_NUMBER_OF_BITS
- 1))) != 0)
4772 sign
= ~(LITTLENUM_TYPE
) 0;
4774 while (++i
< exp
->X_add_number
)
4775 if (generic_bignum
[i
] != sign
)
4778 else if (nbytes
== 1)
4780 /* We have nbytes == 1 and CHARS_PER_LITTLENUM == 2 (probably).
4781 Check that bits 8.. of generic_bignum[0] match bit 7
4782 and that they match all of generic_bignum[1..exp->X_add_number]. */
4783 LITTLENUM_TYPE sign
= (generic_bignum
[0] & (1 << 7)) ? -1 : 0;
4784 LITTLENUM_TYPE himask
= LITTLENUM_MASK
& ~ 0xFF;
4786 if ((generic_bignum
[0] & himask
) == (sign
& himask
))
4788 while (++i
< exp
->X_add_number
)
4789 if (generic_bignum
[i
] != sign
)
4794 if (i
< exp
->X_add_number
)
4795 as_warn (ngettext ("bignum truncated to %d byte",
4796 "bignum truncated to %d bytes",
4804 md_number_to_chars (p
, generic_bignum
[0], 1);
4807 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
4809 if (target_big_endian
)
4811 while (nbytes
> size
)
4813 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
4814 nbytes
-= CHARS_PER_LITTLENUM
;
4815 p
+= CHARS_PER_LITTLENUM
;
4818 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
4819 while (size
>= CHARS_PER_LITTLENUM
)
4822 md_number_to_chars (p
, *nums
, CHARS_PER_LITTLENUM
);
4823 size
-= CHARS_PER_LITTLENUM
;
4824 p
+= CHARS_PER_LITTLENUM
;
4829 nums
= generic_bignum
;
4830 while (size
>= CHARS_PER_LITTLENUM
)
4832 md_number_to_chars (p
, *nums
, CHARS_PER_LITTLENUM
);
4834 size
-= CHARS_PER_LITTLENUM
;
4835 p
+= CHARS_PER_LITTLENUM
;
4836 nbytes
-= CHARS_PER_LITTLENUM
;
4839 while (nbytes
>= CHARS_PER_LITTLENUM
)
4841 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
4842 nbytes
-= CHARS_PER_LITTLENUM
;
4843 p
+= CHARS_PER_LITTLENUM
;
4848 emit_expr_fix (exp
, nbytes
, frag_now
, p
, TC_PARSE_CONS_RETURN_NONE
);
4852 emit_expr_fix (expressionS
*exp
, unsigned int nbytes
, fragS
*frag
, char *p
,
4853 TC_PARSE_CONS_RETURN_TYPE r ATTRIBUTE_UNUSED
)
4856 unsigned int size
= nbytes
;
4858 memset (p
, 0, size
);
4860 /* Generate a fixS to record the symbol value. */
4862 #ifdef TC_CONS_FIX_NEW
4863 TC_CONS_FIX_NEW (frag
, p
- frag
->fr_literal
+ offset
, size
, exp
, r
);
4865 if (r
!= TC_PARSE_CONS_RETURN_NONE
)
4867 reloc_howto_type
*reloc_howto
;
4869 reloc_howto
= bfd_reloc_type_lookup (stdoutput
, r
);
4870 size
= bfd_get_reloc_size (reloc_howto
);
4874 as_bad (ngettext ("%s relocations do not fit in %u byte",
4875 "%s relocations do not fit in %u bytes",
4877 reloc_howto
->name
, nbytes
);
4880 else if (target_big_endian
)
4881 offset
= nbytes
- size
;
4902 as_bad (_("unsupported BFD relocation size %u"), size
);
4905 fix_new_exp (frag
, p
- frag
->fr_literal
+ offset
, size
,
4910 /* Handle an MRI style string expression. */
4914 parse_mri_cons (expressionS
*exp
, unsigned int nbytes
)
4916 if (*input_line_pointer
!= '\''
4917 && (input_line_pointer
[1] != '\''
4918 || (*input_line_pointer
!= 'A'
4919 && *input_line_pointer
!= 'E')))
4920 (void) TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
4924 unsigned int result
= 0;
4926 /* An MRI style string. Cut into as many bytes as will fit into
4927 a nbyte chunk, left justify if necessary, and separate with
4928 commas so we can try again later. */
4929 if (*input_line_pointer
== 'A')
4930 ++input_line_pointer
;
4931 else if (*input_line_pointer
== 'E')
4933 as_bad (_("EBCDIC constants are not supported"));
4934 ++input_line_pointer
;
4937 input_line_pointer
++;
4938 for (scan
= 0; scan
< nbytes
; scan
++)
4940 if (*input_line_pointer
== '\'')
4942 if (input_line_pointer
[1] == '\'')
4944 input_line_pointer
++;
4949 result
= (result
<< 8) | (*input_line_pointer
++);
4953 while (scan
< nbytes
)
4959 /* Create correct expression. */
4960 exp
->X_op
= O_constant
;
4961 exp
->X_add_number
= result
;
4963 /* Fake it so that we can read the next char too. */
4964 if (input_line_pointer
[0] != '\'' ||
4965 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
4967 input_line_pointer
-= 2;
4968 input_line_pointer
[0] = ',';
4969 input_line_pointer
[1] = '\'';
4972 input_line_pointer
++;
4975 #endif /* TC_M68K */
4977 #ifdef REPEAT_CONS_EXPRESSIONS
4979 /* Parse a repeat expression for cons. This is used by the MIPS
4980 assembler. The format is NUMBER:COUNT; NUMBER appears in the
4981 object file COUNT times.
4983 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
4986 parse_repeat_cons (expressionS
*exp
, unsigned int nbytes
)
4993 if (*input_line_pointer
!= ':')
4995 /* No repeat count. */
4999 ++input_line_pointer
;
5000 expression (&count
);
5001 if (count
.X_op
!= O_constant
5002 || count
.X_add_number
<= 0)
5004 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
5008 /* The cons function is going to output this expression once. So we
5009 output it count - 1 times. */
5010 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
5011 emit_expr (exp
, nbytes
);
5014 #endif /* REPEAT_CONS_EXPRESSIONS */
5016 /* Parse a floating point number represented as a hex constant. This
5017 permits users to specify the exact bits they want in the floating
5021 hex_float (int float_type
, char *bytes
)
5023 int pad
, length
= float_length (float_type
, &pad
);
5029 /* It would be nice if we could go through expression to parse the
5030 hex constant, but if we get a bignum it's a pain to sort it into
5031 the buffer correctly. */
5033 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
5037 /* The MRI assembler accepts arbitrary underscores strewn about
5038 through the hex constant, so we ignore them as well. */
5039 if (*input_line_pointer
== '_')
5041 ++input_line_pointer
;
5047 as_warn (_("floating point constant too large"));
5050 d
= hex_value (*input_line_pointer
) << 4;
5051 ++input_line_pointer
;
5052 while (*input_line_pointer
== '_')
5053 ++input_line_pointer
;
5054 if (hex_p (*input_line_pointer
))
5056 d
+= hex_value (*input_line_pointer
);
5057 ++input_line_pointer
;
5059 if (target_big_endian
)
5062 bytes
[length
- i
- 1] = d
;
5068 if (target_big_endian
)
5069 memset (bytes
+ i
, 0, length
- i
);
5071 memset (bytes
, 0, length
- i
);
5074 memset (bytes
+ length
, 0, pad
);
5076 return length
+ pad
;
5081 CONStruct some more frag chars of .floats .ffloats etc.
5082 Makes 0 or more new frags.
5083 If need_pass_2 == 1, no frags are emitted.
5084 This understands only floating literals, not expressions. Sorry.
5086 A floating constant is defined by atof_generic(), except it is preceded
5087 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
5088 reading, I decided to be incompatible. This always tries to give you
5089 rounded bits to the precision of the pseudo-op. Former AS did premature
5090 truncation, restored noisy bits instead of trailing 0s AND gave you
5091 a choice of 2 flavours of noise according to which of 2 floating-point
5092 scanners you directed AS to use.
5094 In: input_line_pointer->whitespace before, or '0' of flonum. */
5097 float_cons (/* Clobbers input_line-pointer, checks end-of-line. */
5098 int float_type
/* 'f':.ffloat ... 'F':.float ... */)
5101 int length
; /* Number of chars in an object. */
5102 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
5104 if (is_it_end_of_statement ())
5106 demand_empty_rest_of_line ();
5110 if (now_seg
== absolute_section
)
5112 as_bad (_("attempt to store float in absolute section"));
5113 ignore_rest_of_line ();
5119 as_bad (_("attempt to store float in section `%s'"),
5120 segment_name (now_seg
));
5121 ignore_rest_of_line ();
5125 #ifdef md_flush_pending_output
5126 md_flush_pending_output ();
5129 #ifdef md_cons_align
5135 length
= parse_one_float (float_type
, temp
);
5145 #ifdef REPEAT_CONS_EXPRESSIONS
5146 if (*input_line_pointer
== ':')
5148 expressionS count_exp
;
5150 ++input_line_pointer
;
5151 expression (&count_exp
);
5153 if (count_exp
.X_op
!= O_constant
5154 || count_exp
.X_add_number
<= 0)
5155 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
5157 count
= count_exp
.X_add_number
;
5161 while (--count
>= 0)
5163 p
= frag_more (length
);
5164 memcpy (p
, temp
, length
);
5169 while (*input_line_pointer
++ == ',');
5171 /* Put terminator back into stream. */
5172 --input_line_pointer
;
5173 demand_empty_rest_of_line ();
5178 Note - we are using the DWARF standard's definition of LEB128 encoding
5179 where each 7-bit value is a stored in a byte, *not* an octet. This
5180 means that on targets where a byte contains multiple octets there is
5181 a *huge waste of space*. (This also means that we do not have to
5182 have special versions of these functions for when OCTETS_PER_BYTE_POWER
5185 If the 7-bit values were to be packed into N-bit bytes (where N > 8)
5186 we would then have to consider whether multiple, successive LEB128
5187 values should be packed into the bytes without padding (bad idea) or
5188 whether each LEB128 number is padded out to a whole number of bytes.
5189 Plus you have to decide on the endianness of packing octets into a
5192 /* Return the size of a LEB128 value in bytes. */
5194 static inline unsigned int
5195 sizeof_sleb128 (offsetT value
)
5202 byte
= (value
& 0x7f);
5203 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
5204 Fortunately, we can structure things so that the extra work reduces
5205 to a noop on systems that do things "properly". */
5206 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
5209 while (!(((value
== 0) && ((byte
& 0x40) == 0))
5210 || ((value
== -1) && ((byte
& 0x40) != 0))));
5215 static inline unsigned int
5216 sizeof_uleb128 (valueT value
)
5231 sizeof_leb128 (valueT value
, int sign
)
5234 return sizeof_sleb128 (value
);
5236 return sizeof_uleb128 (value
);
5239 /* Output a LEB128 value. Returns the number of bytes used. */
5241 static inline unsigned int
5242 output_sleb128 (char *p
, offsetT value
)
5249 unsigned byte
= (value
& 0x7f);
5251 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
5252 Fortunately, we can structure things so that the extra work reduces
5253 to a noop on systems that do things "properly". */
5254 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
5256 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
5257 || ((value
== -1) && ((byte
& 0x40) != 0))));
5268 static inline unsigned int
5269 output_uleb128 (char *p
, valueT value
)
5275 unsigned byte
= (value
& 0x7f);
5279 /* More bytes to follow. */
5290 output_leb128 (char *p
, valueT value
, int sign
)
5293 return output_sleb128 (p
, value
);
5295 return output_uleb128 (p
, value
);
5298 /* Do the same for bignums. We combine sizeof with output here in that
5299 we don't output for NULL values of P. It isn't really as critical as
5300 for "normal" values that this be streamlined. Returns the number of
5303 static inline unsigned int
5304 output_big_sleb128 (char *p
, LITTLENUM_TYPE
*bignum
, unsigned int size
)
5311 /* Strip leading sign extensions off the bignum. */
5313 && bignum
[size
- 1] == LITTLENUM_MASK
5314 && bignum
[size
- 2] > LITTLENUM_MASK
/ 2)
5319 /* OR in the next part of the littlenum. */
5320 val
|= (*bignum
<< loaded
);
5321 loaded
+= LITTLENUM_NUMBER_OF_BITS
;
5325 /* Add bytes until there are less than 7 bits left in VAL
5326 or until every non-sign bit has been written. */
5333 || val
!= ((byte
& 0x40) == 0 ? 0 : ((valueT
) 1 << loaded
) - 1))
5340 while ((byte
& 0x80) != 0 && loaded
>= 7);
5344 /* Mop up any left-over bits (of which there will be less than 7). */
5345 if ((byte
& 0x80) != 0)
5347 /* Sign-extend VAL. */
5348 if (val
& (1 << (loaded
- 1)))
5349 val
|= ~0U << loaded
;
5358 static inline unsigned int
5359 output_big_uleb128 (char *p
, LITTLENUM_TYPE
*bignum
, unsigned int size
)
5366 /* Strip leading zeros off the bignum. */
5367 /* XXX: Is this needed? */
5368 while (size
> 0 && bignum
[size
- 1] == 0)
5373 if (loaded
< 7 && size
> 0)
5375 val
|= (*bignum
<< loaded
);
5376 loaded
+= 8 * CHARS_PER_LITTLENUM
;
5385 if (size
> 0 || val
)
5392 while (byte
& 0x80);
5398 output_big_leb128 (char *p
, LITTLENUM_TYPE
*bignum
, unsigned int size
, int sign
)
5401 return output_big_sleb128 (p
, bignum
, size
);
5403 return output_big_uleb128 (p
, bignum
, size
);
5406 /* Generate the appropriate fragments for a given expression to emit a
5407 leb128 value. SIGN is 1 for sleb, 0 for uleb. */
5410 emit_leb128_expr (expressionS
*exp
, int sign
)
5412 operatorT op
= exp
->X_op
;
5413 unsigned int nbytes
;
5415 if (op
== O_absent
|| op
== O_illegal
)
5417 as_warn (_("zero assumed for missing expression"));
5418 exp
->X_add_number
= 0;
5421 else if (op
== O_big
&& exp
->X_add_number
<= 0)
5423 as_bad (_("floating point number invalid"));
5424 exp
->X_add_number
= 0;
5427 else if (op
== O_register
)
5429 as_warn (_("register value used as expression"));
5432 else if (op
== O_constant
5435 ? exp
->X_add_number
< 0
5436 : (exp
->X_add_number
< 0) != exp
->X_extrabit
))
5438 /* We're outputting a signed leb128 and the sign of X_add_number
5439 doesn't reflect the sign of the original value. Convert EXP
5440 to a correctly-extended bignum instead. */
5441 convert_to_bignum (exp
);
5445 if (now_seg
== absolute_section
)
5447 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
5448 as_bad (_("attempt to store value in absolute section"));
5449 abs_section_offset
++;
5453 if ((op
!= O_constant
|| exp
->X_add_number
!= 0) && in_bss ())
5454 as_bad (_("attempt to store non-zero value in section `%s'"),
5455 segment_name (now_seg
));
5457 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
5458 a signal that this is leb128 data. It shouldn't optimize this away. */
5460 if (check_eh_frame (exp
, &nbytes
))
5463 /* Let the backend know that subsequent data may be byte aligned. */
5464 #ifdef md_cons_align
5468 if (op
== O_constant
)
5470 /* If we've got a constant, emit the thing directly right now. */
5472 valueT value
= exp
->X_add_number
;
5476 size
= sizeof_leb128 (value
, sign
);
5477 p
= frag_more (size
);
5478 if (output_leb128 (p
, value
, sign
) > size
)
5481 else if (op
== O_big
)
5483 /* O_big is a different sort of constant. */
5484 int nbr_digits
= exp
->X_add_number
;
5488 /* If the leading littenum is 0xffff, prepend a 0 to avoid confusion with
5489 a signed number. Unary operators like - or ~ always extend the
5490 bignum to its largest size. */
5492 && nbr_digits
< SIZE_OF_LARGE_NUMBER
5493 && generic_bignum
[nbr_digits
- 1] == LITTLENUM_MASK
)
5494 generic_bignum
[nbr_digits
++] = 0;
5496 size
= output_big_leb128 (NULL
, generic_bignum
, nbr_digits
, sign
);
5497 p
= frag_more (size
);
5498 if (output_big_leb128 (p
, generic_bignum
, nbr_digits
, sign
) > size
)
5503 /* Otherwise, we have to create a variable sized fragment and
5504 resolve things later. */
5506 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
5507 make_expr_symbol (exp
), 0, NULL
);
5511 /* Parse the .sleb128 and .uleb128 pseudos. */
5518 #ifdef md_flush_pending_output
5519 md_flush_pending_output ();
5525 emit_leb128_expr (&exp
, sign
);
5527 while (*input_line_pointer
++ == ',');
5529 input_line_pointer
--;
5530 demand_empty_rest_of_line ();
5533 #if defined (TE_PE) && defined (O_secrel)
5535 /* Generate the appropriate fragments for a given expression to emit a
5536 cv_comp value. SIGN is 1 for cv_scomp, 0 for cv_ucomp. */
5539 emit_cv_comp_expr (expressionS
*exp
, int sign
)
5541 operatorT op
= exp
->X_op
;
5543 if (op
== O_absent
|| op
== O_illegal
)
5545 as_warn (_("zero assumed for missing expression"));
5546 exp
->X_add_number
= 0;
5549 else if (op
== O_big
)
5551 as_bad (_("number invalid"));
5552 exp
->X_add_number
= 0;
5555 else if (op
== O_register
)
5557 as_warn (_("register value used as expression"));
5561 if (now_seg
== absolute_section
)
5563 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
5564 as_bad (_("attempt to store value in absolute section"));
5565 abs_section_offset
++;
5569 if ((op
!= O_constant
|| exp
->X_add_number
!= 0) && in_bss ())
5570 as_bad (_("attempt to store non-zero value in section `%s'"),
5571 segment_name (now_seg
));
5573 /* Let the backend know that subsequent data may be byte aligned. */
5574 #ifdef md_cons_align
5578 if (op
== O_constant
)
5580 offsetT value
= exp
->X_add_number
;
5584 /* If we've got a constant, emit the thing directly right now. */
5586 size
= sizeof_cv_comp (value
, sign
);
5587 p
= frag_more (size
);
5588 if (output_cv_comp (p
, value
, sign
) > size
)
5593 /* Otherwise, we have to create a variable sized fragment and
5594 resolve things later. */
5596 frag_var (rs_cv_comp
, 4, 0, sign
, make_expr_symbol (exp
), 0, NULL
);
5600 /* Parse the .cv_ucomp and .cv_scomp pseudos. */
5603 s_cv_comp (int sign
)
5607 #ifdef md_flush_pending_output
5608 md_flush_pending_output ();
5614 emit_cv_comp_expr (&exp
, sign
);
5616 while (*input_line_pointer
++ == ',');
5618 input_line_pointer
--;
5619 demand_empty_rest_of_line ();
5622 #endif /* TE_PE && O_secrel */
5624 /* Code for handling base64 encoded strings.
5625 Based upon code in sharutils' lib/base64.c source file, written by
5626 Simon Josefsson. Which was partially adapted from GNU MailUtils
5627 (mailbox/filter_trans.c, as of 2004-11-28) and improved by review
5628 from Paul Eggert, Bruno Haible, and Stepan Kasal. */
5697 static const signed char b64
[0x100] =
5699 B64 (0), B64 (1), B64 (2), B64 (3),
5700 B64 (4), B64 (5), B64 (6), B64 (7),
5701 B64 (8), B64 (9), B64 (10), B64 (11),
5702 B64 (12), B64 (13), B64 (14), B64 (15),
5703 B64 (16), B64 (17), B64 (18), B64 (19),
5704 B64 (20), B64 (21), B64 (22), B64 (23),
5705 B64 (24), B64 (25), B64 (26), B64 (27),
5706 B64 (28), B64 (29), B64 (30), B64 (31),
5707 B64 (32), B64 (33), B64 (34), B64 (35),
5708 B64 (36), B64 (37), B64 (38), B64 (39),
5709 B64 (40), B64 (41), B64 (42), B64 (43),
5710 B64 (44), B64 (45), B64 (46), B64 (47),
5711 B64 (48), B64 (49), B64 (50), B64 (51),
5712 B64 (52), B64 (53), B64 (54), B64 (55),
5713 B64 (56), B64 (57), B64 (58), B64 (59),
5714 B64 (60), B64 (61), B64 (62), B64 (63),
5715 B64 (64), B64 (65), B64 (66), B64 (67),
5716 B64 (68), B64 (69), B64 (70), B64 (71),
5717 B64 (72), B64 (73), B64 (74), B64 (75),
5718 B64 (76), B64 (77), B64 (78), B64 (79),
5719 B64 (80), B64 (81), B64 (82), B64 (83),
5720 B64 (84), B64 (85), B64 (86), B64 (87),
5721 B64 (88), B64 (89), B64 (90), B64 (91),
5722 B64 (92), B64 (93), B64 (94), B64 (95),
5723 B64 (96), B64 (97), B64 (98), B64 (99),
5724 B64 (100), B64 (101), B64 (102), B64 (103),
5725 B64 (104), B64 (105), B64 (106), B64 (107),
5726 B64 (108), B64 (109), B64 (110), B64 (111),
5727 B64 (112), B64 (113), B64 (114), B64 (115),
5728 B64 (116), B64 (117), B64 (118), B64 (119),
5729 B64 (120), B64 (121), B64 (122), B64 (123),
5730 B64 (124), B64 (125), B64 (126), B64 (127),
5731 B64 (128), B64 (129), B64 (130), B64 (131),
5732 B64 (132), B64 (133), B64 (134), B64 (135),
5733 B64 (136), B64 (137), B64 (138), B64 (139),
5734 B64 (140), B64 (141), B64 (142), B64 (143),
5735 B64 (144), B64 (145), B64 (146), B64 (147),
5736 B64 (148), B64 (149), B64 (150), B64 (151),
5737 B64 (152), B64 (153), B64 (154), B64 (155),
5738 B64 (156), B64 (157), B64 (158), B64 (159),
5739 B64 (160), B64 (161), B64 (162), B64 (163),
5740 B64 (164), B64 (165), B64 (166), B64 (167),
5741 B64 (168), B64 (169), B64 (170), B64 (171),
5742 B64 (172), B64 (173), B64 (174), B64 (175),
5743 B64 (176), B64 (177), B64 (178), B64 (179),
5744 B64 (180), B64 (181), B64 (182), B64 (183),
5745 B64 (184), B64 (185), B64 (186), B64 (187),
5746 B64 (188), B64 (189), B64 (190), B64 (191),
5747 B64 (192), B64 (193), B64 (194), B64 (195),
5748 B64 (196), B64 (197), B64 (198), B64 (199),
5749 B64 (200), B64 (201), B64 (202), B64 (203),
5750 B64 (204), B64 (205), B64 (206), B64 (207),
5751 B64 (208), B64 (209), B64 (210), B64 (211),
5752 B64 (212), B64 (213), B64 (214), B64 (215),
5753 B64 (216), B64 (217), B64 (218), B64 (219),
5754 B64 (220), B64 (221), B64 (222), B64 (223),
5755 B64 (224), B64 (225), B64 (226), B64 (227),
5756 B64 (228), B64 (229), B64 (230), B64 (231),
5757 B64 (232), B64 (233), B64 (234), B64 (235),
5758 B64 (236), B64 (237), B64 (238), B64 (239),
5759 B64 (240), B64 (241), B64 (242), B64 (243),
5760 B64 (244), B64 (245), B64 (246), B64 (247),
5761 B64 (248), B64 (249), B64 (250), B64 (251),
5762 B64 (252), B64 (253), B64 (254), B64 (255)
5766 is_base64_char (unsigned int c
)
5768 return (c
< 0x100) && (b64
[c
] != -1);
5772 decode_base64_and_append (unsigned int b
[4], int len
)
5774 gas_assert (len
> 1);
5776 FRAG_APPEND_1_CHAR ((b64
[b
[0]] << 2) | (b64
[b
[1]] >> 4));
5779 return; /* FIXME: Check for unused bits in b[1] ? */
5781 FRAG_APPEND_1_CHAR (((b64
[b
[1]] << 4) & 0xf0) | (b64
[b
[2]] >> 2));
5784 return; /* FIXME: Check for unused bits in b[2] ? */
5786 FRAG_APPEND_1_CHAR (((b64
[b
[2]] << 6) & 0xc0) | b64
[b
[3]]);
5789 /* Accept one or more comma separated, base64 encoded strings. Decode them
5790 and store them at the current point in the current section. The strings
5791 must be enclosed in double quotes. Line breaks, quoted characters and
5792 escaped characters are not allowed. Only the characters "A-Za-z0-9+/" are
5793 accepted inside the string. The string must be a multiple of four
5794 characters in length. If the encoded string does not fit this requirement
5795 it may use one or more '=' characters at the end as padding. */
5798 s_base64 (int dummy ATTRIBUTE_UNUSED
)
5801 unsigned long num_octets
= 0;
5803 /* If we have been switched into the abs_section then we
5804 will not have an obstack onto which we can hang strings. */
5805 if (now_seg
== absolute_section
)
5807 as_bad (_("base64 strings must be placed into a section"));
5808 ignore_rest_of_line ();
5812 if (is_it_end_of_statement ())
5814 as_bad (_("a string must follow the .base64 pseudo-op"));
5818 #ifdef md_flush_pending_output
5819 md_flush_pending_output ();
5822 #ifdef md_cons_align
5828 SKIP_ALL_WHITESPACE ();
5830 c
= * input_line_pointer
++;
5834 as_bad (_("expected double quote enclosed string as argument to .base64 pseudo-op"));
5835 ignore_rest_of_line ();
5839 /* Read a block of four base64 encoded characters. */
5842 bool seen_equals
= false;
5845 for (i
= 0; i
< 4; i
++)
5847 c
= * input_line_pointer
++;
5849 if (c
>= 256 || is_end_of_stmt (c
))
5851 as_bad (_("end of line encountered inside .base64 string"));
5852 ignore_rest_of_line ();
5858 /* We allow this. But only if there were enough
5859 characters to form a valid base64 encoding. */
5862 as_warn (_(".base64 string terminated early"));
5863 -- input_line_pointer
;
5867 as_bad (_(".base64 string terminated unexpectedly"));
5868 ignore_rest_of_line ();
5872 if (seen_equals
&& c
!= '=')
5874 as_bad (_("equals character only allowed at end of .base64 string"));
5875 ignore_rest_of_line ();
5883 as_bad (_("the equals character cannot start a block of four base64 encoded bytes"));
5884 ignore_rest_of_line ();
5889 as_bad (_("the equals character cannot be the second character in a block of four base64 encoded bytes"));
5890 ignore_rest_of_line ();
5896 else if (! is_base64_char (c
))
5899 as_bad (_("invalid character '%c' found inside .base64 string"), c
);
5901 as_bad (_("invalid character %#x found inside .base64 string"), c
);
5902 ignore_rest_of_line ();
5909 if (seen_equals
&& i
== 4)
5916 /* We have a block of up to four valid base64 encoded bytes. */
5917 decode_base64_and_append (b
, i
);
5918 num_octets
+= (i
- 1);
5920 /* Check the next character. */
5921 c
= * input_line_pointer
++;
5923 if (is_base64_char (c
))
5927 as_bad (_("no base64 characters expected after '=' padding characters"));
5928 ignore_rest_of_line ();
5932 -- input_line_pointer
;
5937 as_bad (_(".base64 string must have a terminating double quote character"));
5938 ignore_rest_of_line ();
5942 SKIP_ALL_WHITESPACE ();
5944 c
= * input_line_pointer
++;
5948 /* Make sure that we have not skipped the EOL marker. */
5949 -- input_line_pointer
;
5951 while (num_octets
% OCTETS_PER_BYTE
)
5953 /* We have finished emiting the octets for this .base64 pseudo-op, but
5954 we have not filled up enough bytes for the target architecture. So
5955 we emit padding octets here. This is done after all of the arguments
5956 to the pseudo-op have been processed, rather than at the end of each
5957 argument, as it is likely that the user wants the arguments to be
5959 FRAG_APPEND_1_CHAR (0);
5963 demand_empty_rest_of_line ();
5967 stringer_append_char (int c
, int bitsize
)
5970 as_bad (_("attempt to store non-empty string in section `%s'"),
5971 segment_name (now_seg
));
5973 if (!target_big_endian
)
5974 FRAG_APPEND_1_CHAR (c
);
5979 FRAG_APPEND_1_CHAR (0);
5980 FRAG_APPEND_1_CHAR (0);
5981 FRAG_APPEND_1_CHAR (0);
5982 FRAG_APPEND_1_CHAR (0);
5985 FRAG_APPEND_1_CHAR (0);
5986 FRAG_APPEND_1_CHAR (0);
5989 FRAG_APPEND_1_CHAR (0);
5994 /* Called with invalid bitsize argument. */
5998 if (target_big_endian
)
5999 FRAG_APPEND_1_CHAR (c
);
6002 /* Worker to do .ascii etc statements.
6003 Reads 0 or more ',' separated, double-quoted strings.
6004 Caller should have checked need_pass_2 is FALSE because we don't
6006 Checks for end-of-line.
6007 BITS_APPENDZERO says how many bits are in a target char.
6008 The bottom bit is set if a NUL char should be appended to the strings. */
6011 stringer (int bits_appendzero
)
6013 const int bitsize
= bits_appendzero
& ~7;
6014 const int append_zero
= bits_appendzero
& 1;
6016 #if !defined(NO_LISTING) && defined (OBJ_ELF)
6020 #ifdef md_flush_pending_output
6021 md_flush_pending_output ();
6024 #ifdef md_cons_align
6028 /* If we have been switched into the abs_section then we
6029 will not have an obstack onto which we can hang strings. */
6030 if (now_seg
== absolute_section
)
6032 as_bad (_("strings must be placed into a section"));
6033 ignore_rest_of_line ();
6037 /* The following awkward logic is to parse ZERO or more strings,
6038 comma separated. Recall a string expression includes spaces
6039 before the opening '\"' and spaces after the closing '\"'.
6040 We fake a leading ',' if there is (supposed to be)
6041 a 1st, expression. We keep demanding expressions for each ','. */
6042 if (is_it_end_of_statement ())
6044 c
= 0; /* Skip loop. */
6045 ++input_line_pointer
; /* Compensate for end of loop. */
6049 c
= ','; /* Do loop. */
6052 while (c
== ',' || c
== '<' || c
== '"')
6055 switch (*input_line_pointer
)
6058 ++input_line_pointer
; /*->1st char of string. */
6059 #if !defined(NO_LISTING) && defined (OBJ_ELF)
6060 start
= input_line_pointer
;
6063 while (is_a_char (c
= next_char_of_string ()))
6064 stringer_append_char (c
, bitsize
);
6066 /* Treat "a" "b" as "ab". Even if we are appending zeros. */
6067 SKIP_ALL_WHITESPACE ();
6068 if (*input_line_pointer
== '"')
6072 stringer_append_char (0, bitsize
);
6074 #if !defined(NO_LISTING) && defined (OBJ_ELF)
6075 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
6076 will emit .string with a filename in the .debug section
6077 after a sequence of constants. See the comment in
6078 emit_expr for the sequence. emit_expr will set
6079 dwarf_file_string to non-zero if this string might be a
6080 source file name. */
6081 if (strcmp (segment_name (now_seg
), ".debug") != 0)
6082 dwarf_file_string
= 0;
6083 else if (dwarf_file_string
)
6085 c
= input_line_pointer
[-1];
6086 input_line_pointer
[-1] = '\0';
6087 listing_source_file (start
);
6088 input_line_pointer
[-1] = c
;
6094 input_line_pointer
++;
6095 c
= get_single_number ();
6096 stringer_append_char (c
, bitsize
);
6097 if (*input_line_pointer
!= '>')
6099 as_bad (_("expected <nn>"));
6100 ignore_rest_of_line ();
6103 input_line_pointer
++;
6106 input_line_pointer
++;
6110 c
= *input_line_pointer
;
6113 demand_empty_rest_of_line ();
6116 /* FIXME-SOMEDAY: I had trouble here on characters with the
6117 high bits set. We'll probably also have trouble with
6118 multibyte chars, wide chars, etc. Also be careful about
6119 returning values bigger than 1 byte. xoxorich. */
6122 next_char_of_string (void)
6126 c
= *input_line_pointer
++ & CHAR_MASK
;
6130 /* PR 20902: Do not advance past the end of the buffer. */
6131 -- input_line_pointer
;
6140 as_warn (_("unterminated string; newline inserted"));
6141 bump_line_counters ();
6145 if (!TC_STRING_ESCAPES
)
6147 switch (c
= *input_line_pointer
++ & CHAR_MASK
)
6175 break; /* As itself. */
6191 for (i
= 0, number
= 0;
6192 ISDIGIT (c
) && i
< 3;
6193 c
= *input_line_pointer
++, i
++)
6195 number
= number
* 8 + c
- '0';
6198 c
= number
& CHAR_MASK
;
6200 --input_line_pointer
;
6209 c
= *input_line_pointer
++;
6210 while (ISXDIGIT (c
))
6213 number
= number
* 16 + c
- '0';
6214 else if (ISUPPER (c
))
6215 number
= number
* 16 + c
- 'A' + 10;
6217 number
= number
* 16 + c
- 'a' + 10;
6218 c
= *input_line_pointer
++;
6220 c
= number
& CHAR_MASK
;
6221 --input_line_pointer
;
6226 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
6227 as_warn (_("unterminated string; newline inserted"));
6229 bump_line_counters ();
6233 /* Do not advance past the end of the buffer. */
6234 -- input_line_pointer
;
6240 #ifdef ONLY_STANDARD_ESCAPES
6241 as_bad (_("bad escaped character in string"));
6243 #endif /* ONLY_STANDARD_ESCAPES */
6256 get_segmented_expression (expressionS
*expP
)
6260 retval
= expression (expP
);
6261 if (expP
->X_op
== O_illegal
6262 || expP
->X_op
== O_absent
6263 || expP
->X_op
== O_big
)
6265 as_bad (_("expected address expression"));
6266 expP
->X_op
= O_constant
;
6267 expP
->X_add_number
= 0;
6268 retval
= absolute_section
;
6274 get_known_segmented_expression (expressionS
*expP
)
6276 segT retval
= get_segmented_expression (expP
);
6278 if (retval
== undefined_section
)
6280 /* There is no easy way to extract the undefined symbol from the
6282 if (expP
->X_add_symbol
!= NULL
6283 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
6284 as_warn (_("symbol \"%s\" undefined; zero assumed"),
6285 S_GET_NAME (expP
->X_add_symbol
));
6287 as_warn (_("some symbol undefined; zero assumed"));
6288 retval
= absolute_section
;
6289 expP
->X_op
= O_constant
;
6290 expP
->X_add_number
= 0;
6295 char /* Return terminator. */
6296 get_absolute_expression_and_terminator (long *val_pointer
/* Return value of expression. */)
6298 /* FIXME: val_pointer should probably be offsetT *. */
6299 *val_pointer
= get_absolute_expression ();
6300 return (*input_line_pointer
++);
6303 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
6304 Give a warning if that happens. */
6307 demand_copy_C_string (int *len_pointer
)
6311 if ((s
= demand_copy_string (len_pointer
)) != 0)
6315 for (len
= *len_pointer
; len
> 0; len
--)
6317 if (s
[len
- 1] == 0)
6321 as_bad (_("this string may not contain \'\\0\'"));
6330 /* Demand string, but return a safe (=private) copy of the string.
6331 Return NULL if we can't read a string here. */
6334 demand_copy_string (int *lenP
)
6342 if (*input_line_pointer
== '\"')
6344 input_line_pointer
++; /* Skip opening quote. */
6346 while (is_a_char (c
= next_char_of_string ()))
6348 obstack_1grow (¬es
, c
);
6351 /* JF this next line is so demand_copy_C_string will return a
6352 null terminated string. */
6353 obstack_1grow (¬es
, '\0');
6354 retval
= obstack_finish (¬es
);
6358 as_bad (_("missing string"));
6360 ignore_rest_of_line ();
6366 /* In: Input_line_pointer->next character.
6368 Do: Skip input_line_pointer over all whitespace.
6370 Out: 1 if input_line_pointer->end-of-line. */
6373 is_it_end_of_statement (void)
6376 return is_end_of_stmt (*input_line_pointer
);
6380 equals (char *sym_name
, int reassign
)
6385 input_line_pointer
++;
6386 if (*input_line_pointer
== '=')
6387 input_line_pointer
++;
6388 if (reassign
< 0 && *input_line_pointer
== '=')
6389 input_line_pointer
++;
6391 while (is_whitespace (*input_line_pointer
))
6392 input_line_pointer
++;
6395 stop
= mri_comment_field (&stopc
);
6397 assign_symbol (sym_name
, reassign
>= 0 ? !reassign
: reassign
);
6401 demand_empty_rest_of_line ();
6402 mri_comment_end (stop
, stopc
);
6406 /* Open FILENAME, first trying the unadorned file name, then if that
6407 fails and the file name is not an absolute path, attempt to open
6408 the file in current -I include paths. PATH is a preallocated
6409 buffer which will be set to the file opened, or FILENAME if no file
6413 search_and_open (const char *filename
, char *path
)
6415 FILE *f
= fopen (filename
, FOPEN_RB
);
6416 if (f
== NULL
&& !IS_ABSOLUTE_PATH (filename
))
6418 for (size_t i
= 0; i
< include_dir_count
; i
++)
6420 sprintf (path
, "%s/%s", include_dirs
[i
], filename
);
6421 f
= fopen (path
, FOPEN_RB
);
6426 strcpy (path
, filename
);
6430 /* .incbin -- include a file verbatim at the current location. */
6433 s_incbin (int x ATTRIBUTE_UNUSED
)
6444 #ifdef md_flush_pending_output
6445 md_flush_pending_output ();
6448 #ifdef md_cons_align
6453 filename
= demand_copy_string (& len
);
6454 if (filename
== NULL
)
6459 /* Look for optional skip and count. */
6460 if (* input_line_pointer
== ',')
6462 ++ input_line_pointer
;
6463 skip
= get_absolute_expression ();
6467 if (* input_line_pointer
== ',')
6469 ++ input_line_pointer
;
6471 count
= get_absolute_expression ();
6473 as_warn (_(".incbin count zero, ignoring `%s'"), filename
);
6479 demand_empty_rest_of_line ();
6481 path
= XNEWVEC (char, len
+ include_dir_maxlen
+ 2);
6482 binfile
= search_and_open (filename
, path
);
6484 if (binfile
== NULL
)
6485 as_bad (_("file not found: %s"), filename
);
6489 struct stat filestat
;
6491 if (fstat (fileno (binfile
), &filestat
) != 0
6492 || ! S_ISREG (filestat
.st_mode
)
6493 || S_ISDIR (filestat
.st_mode
))
6495 as_bad (_("unable to include `%s'"), path
);
6499 register_dependency (path
);
6501 /* Compute the length of the file. */
6502 if (fseek (binfile
, 0, SEEK_END
) != 0)
6504 as_bad (_("seek to end of .incbin file failed `%s'"), path
);
6507 file_len
= ftell (binfile
);
6509 /* If a count was not specified use the remainder of the file. */
6511 count
= file_len
- skip
;
6513 if (skip
< 0 || count
< 0 || file_len
< 0 || skip
+ count
> file_len
)
6515 as_bad (_("skip (%ld) or count (%ld) invalid for file size (%ld)"),
6516 skip
, count
, file_len
);
6520 if (fseek (binfile
, skip
, SEEK_SET
) != 0)
6522 as_bad (_("could not skip to %ld in file `%s'"), skip
, path
);
6526 /* Allocate frag space and store file contents in it. */
6527 binfrag
= frag_more (count
);
6529 bytes
= fread (binfrag
, 1, count
, binfile
);
6531 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
6532 path
, bytes
, count
);
6535 if (binfile
!= NULL
)
6540 /* .include -- include a file at this point. */
6543 s_include (int arg ATTRIBUTE_UNUSED
)
6552 filename
= demand_copy_string (&i
);
6553 if (filename
== NULL
)
6555 /* demand_copy_string has already printed an error and
6556 called ignore_rest_of_line. */
6564 while (!is_end_of_stmt (*input_line_pointer
)
6565 && !is_whitespace (*input_line_pointer
))
6567 obstack_1grow (¬es
, *input_line_pointer
);
6568 ++input_line_pointer
;
6572 obstack_1grow (¬es
, '\0');
6573 filename
= obstack_finish (¬es
);
6574 while (!is_end_of_stmt (*input_line_pointer
))
6575 ++input_line_pointer
;
6578 demand_empty_rest_of_line ();
6580 path
= notes_alloc (i
+ include_dir_maxlen
+ 2);
6581 try_file
= search_and_open (filename
, path
);
6585 register_dependency (path
);
6586 input_scrub_insert_file (path
);
6590 init_include_dir (void)
6592 include_dirs
= XNEWVEC (const char *, 1);
6593 include_dirs
[0] = "."; /* Current dir. */
6594 include_dir_count
= 1;
6595 include_dir_maxlen
= 1;
6599 add_include_dir (char *path
)
6601 include_dir_count
++;
6602 include_dirs
= XRESIZEVEC (const char *, include_dirs
, include_dir_count
);
6603 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
6605 size_t i
= strlen (path
);
6606 if (i
> include_dir_maxlen
)
6607 include_dir_maxlen
= i
;
6610 /* Output debugging information to denote the source file. */
6613 generate_file_debug (void)
6615 if (debug_type
== DEBUG_STABS
)
6616 stabs_generate_asm_file ();
6619 /* Output line number debugging information for the current source line. */
6622 generate_lineno_debug (void)
6626 case DEBUG_UNSPECIFIED
:
6631 stabs_generate_asm_lineno ();
6634 ecoff_generate_asm_lineno ();
6637 /* ??? We could here indicate to dwarf2dbg.c that something
6638 has changed. However, since there is additional backend
6639 support that is required (calling dwarf2_emit_insn), we
6640 let dwarf2dbg.c call as_where on its own. */
6642 case DEBUG_CODEVIEW
:
6643 codeview_generate_asm_lineno ();
6648 /* Output debugging information to mark a function entry point or end point.
6649 END_P is zero for .func, and non-zero for .endfunc. */
6654 do_s_func (end_p
, NULL
);
6657 /* Subroutine of s_func so targets can choose a different default prefix.
6658 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
6661 do_s_func (int end_p
, const char *default_prefix
)
6665 if (current_name
== NULL
)
6667 as_bad (_("missing .func"));
6668 ignore_rest_of_line ();
6672 if (debug_type
== DEBUG_STABS
)
6673 stabs_generate_asm_endfunc (current_name
, current_label
);
6675 free (current_name
);
6676 free (current_label
);
6677 current_name
= current_label
= NULL
;
6682 char delim1
, delim2
;
6684 if (current_name
!= NULL
)
6686 as_bad (_(".endfunc missing for previous .func"));
6687 ignore_rest_of_line ();
6691 delim1
= get_symbol_name (& name
);
6692 name
= xstrdup (name
);
6693 restore_line_pointer (delim1
);
6695 if (*input_line_pointer
!= ',')
6698 label
= xasprintf ("%s%s", default_prefix
, name
);
6701 char leading_char
= bfd_get_symbol_leading_char (stdoutput
);
6702 /* Missing entry point, use function's name with the leading
6705 label
= xasprintf ("%c%s", leading_char
, name
);
6707 label
= xstrdup (name
);
6712 ++input_line_pointer
;
6714 delim2
= get_symbol_name (& label
);
6715 label
= xstrdup (label
);
6716 restore_line_pointer (delim2
);
6719 if (debug_type
== DEBUG_STABS
)
6720 stabs_generate_asm_func (name
, label
);
6722 current_name
= name
;
6723 current_label
= label
;
6726 demand_empty_rest_of_line ();
6729 #ifdef HANDLE_BUNDLE
6732 s_bundle_align_mode (int arg ATTRIBUTE_UNUSED
)
6734 unsigned int align
= get_absolute_expression ();
6736 demand_empty_rest_of_line ();
6738 if (align
> (unsigned int) TC_ALIGN_LIMIT
)
6739 as_fatal (_(".bundle_align_mode alignment too large (maximum %u)"),
6740 (unsigned int) TC_ALIGN_LIMIT
);
6742 if (bundle_lock_frag
!= NULL
)
6744 as_bad (_("cannot change .bundle_align_mode inside .bundle_lock"));
6748 bundle_align_p2
= align
;
6752 s_bundle_lock (int arg ATTRIBUTE_UNUSED
)
6754 demand_empty_rest_of_line ();
6756 if (bundle_align_p2
== 0)
6758 as_bad (_(".bundle_lock is meaningless without .bundle_align_mode"));
6762 if (bundle_lock_depth
== 0)
6764 bundle_lock_frchain
= frchain_now
;
6765 bundle_lock_frag
= start_bundle ();
6767 ++bundle_lock_depth
;
6771 s_bundle_unlock (int arg ATTRIBUTE_UNUSED
)
6775 demand_empty_rest_of_line ();
6777 if (bundle_lock_frag
== NULL
)
6779 as_bad (_(".bundle_unlock without preceding .bundle_lock"));
6783 gas_assert (bundle_align_p2
> 0);
6785 gas_assert (bundle_lock_depth
> 0);
6786 if (--bundle_lock_depth
> 0)
6789 size
= pending_bundle_size (bundle_lock_frag
);
6791 if (size
> (valueT
) 1 << bundle_align_p2
)
6792 as_bad (_(".bundle_lock sequence is %" PRIu64
" bytes, "
6793 "but bundle size is only %" PRIu64
" bytes"),
6794 (uint64_t) size
, (uint64_t) 1 << bundle_align_p2
);
6796 finish_bundle (bundle_lock_frag
, size
);
6798 bundle_lock_frag
= NULL
;
6799 bundle_lock_frchain
= NULL
;
6802 #endif /* HANDLE_BUNDLE */
6805 s_ignore (int arg ATTRIBUTE_UNUSED
)
6807 ignore_rest_of_line ();
6811 read_print_statistics (FILE *file
)
6813 htab_print_statistics (file
, "pseudo-op table", po_hash
);
6816 /* Inserts the given line into the input stream.
6818 This call avoids macro/conditionals nesting checking, since the contents of
6819 the line are assumed to replace the contents of a line already scanned.
6821 An appropriate use of this function would be substitution of input lines when
6822 called by md_start_line_hook(). The given line is assumed to already be
6823 properly scrubbed. */
6826 input_scrub_insert_line (const char *line
)
6829 size_t len
= strlen (line
);
6830 sb_build (&newline
, len
);
6831 sb_add_buffer (&newline
, line
, len
);
6832 input_scrub_include_sb (&newline
, input_line_pointer
, expanding_none
);
6834 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
6837 /* Insert a file into the input stream; the path must resolve to an actual
6838 file; no include path searching or dependency registering is performed. */
6841 input_scrub_insert_file (char *path
)
6843 input_scrub_include_file (path
, input_line_pointer
);
6844 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
6847 /* Find the end of a line, considering quotation and escaping of quotes. */
6849 #if !defined(TC_SINGLE_QUOTE_STRINGS) && defined(SINGLE_QUOTE_STRINGS)
6850 # define TC_SINGLE_QUOTE_STRINGS 1
6854 _find_end_of_line (char *s
, int mri_string
, int insn ATTRIBUTE_UNUSED
,
6857 char inquote
= '\0';
6860 while (!is_end_of_stmt (*s
)
6861 || (inquote
&& !ISCNTRL (*s
))
6862 || (inquote
== '\'' && flag_mri
)
6863 #ifdef TC_EOL_IN_INSN
6864 || (insn
&& TC_EOL_IN_INSN (s
))
6866 /* PR 6926: When we are parsing the body of a macro the sequence
6867 \@ is special - it refers to the invocation count. If the @
6868 character happens to be registered as a line-separator character
6869 by the target, then the is_end_of_stmt() test above will have
6870 returned true, but we need to ignore the line separating
6871 semantics in this particular case. */
6872 || (in_macro
&& inescape
&& *s
== '@')
6875 if (mri_string
&& *s
== '\'')
6879 else if (*s
== '\\')
6883 #ifdef TC_SINGLE_QUOTE_STRINGS
6884 || (TC_SINGLE_QUOTE_STRINGS
&& *s
== '\'')
6891 as_warn (_("missing closing `%c'"), inquote
);
6892 if (inescape
&& !ignore_input ())
6893 as_warn (_("stray `\\'"));
6898 find_end_of_line (char *s
, int mri_string
)
6900 return _find_end_of_line (s
, mri_string
, 0, 0);
6903 static char *saved_ilp
;
6904 static char *saved_limit
;
6906 /* Use BUF as a temporary input pointer for calling other functions in this
6907 file. BUF must be a C string, so that its end can be found by strlen.
6908 Also sets the buffer_limit variable (local to this file) so that buffer
6909 overruns should not occur. Saves the current input line pointer so that
6910 it can be restored by calling restore_ilp().
6912 Does not support recursion. */
6915 temp_ilp (char *buf
)
6917 gas_assert (saved_ilp
== NULL
);
6918 gas_assert (buf
!= NULL
);
6920 saved_ilp
= input_line_pointer
;
6921 saved_limit
= buffer_limit
;
6922 /* Prevent the assert in restore_ilp from triggering if
6923 the input_line_pointer has not yet been initialised. */
6924 if (saved_ilp
== NULL
)
6925 saved_limit
= saved_ilp
= (char *) "";
6927 input_line_pointer
= buf
;
6928 buffer_limit
= buf
+ strlen (buf
);
6929 input_from_string
= true;
6932 /* Restore a saved input line pointer. */
6937 gas_assert (saved_ilp
!= NULL
);
6939 input_line_pointer
= saved_ilp
;
6940 buffer_limit
= saved_limit
;
6941 input_from_string
= false;