1 /* read.c - read a source file -
2 Copyright (C) 1986-2024 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!)! */
84 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
89 /* The Delta 68k assembler permits % inside label names. */
94 /* The PowerPC Windows NT assemblers permits ? inside label names. */
99 /* The IA-64 assembler uses # as a suffix designating a symbol. We include
100 it in the symbol and strip it out in tc_canonicalize_symbol_name. */
109 /* The Delta 68k assembler permits ~ at start of label names. */
113 /* Used by is_... macros. our ctype[]. */
114 char lex_type
[256] = {
115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
117 0, 0, 0, LEX_HASH
, LEX_DOLLAR
, LEX_PCT
, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
118 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM
, /* 0123456789:;<=>? */
119 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
120 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 3, /* PQRSTUVWXYZ[\]^_ */
121 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
122 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, LEX_TILDE
, 0, /* pqrstuvwxyz{|}~. */
123 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
124 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
125 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
126 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
127 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
128 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
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
134 Out: 1 if this character ends a line.
135 2 if this character is a line separator. */
136 char is_end_of_line
[256] = {
138 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, /* @abcdefghijklmno */
140 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* @abcdefghijklmno */
142 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
143 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* _!"#$%&'()*+,-./ */
144 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */
145 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
146 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
147 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
148 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
149 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
150 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
151 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
152 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
153 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
154 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
156 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* */
159 #ifndef TC_CASE_SENSITIVE
160 char original_case_string
[128];
163 /* Functions private to this file. */
165 static char *buffer
; /* 1st char of each buffer of lines is here. */
166 static char *buffer_limit
; /*->1 + last char in buffer. */
168 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1
169 in the tc-<CPU>.h file. See the "Porting GAS" section of the
171 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
173 /* Variables for handling include file directory table. */
175 /* Table of pointers to directories to search for .include's. */
176 const char **include_dirs
;
178 /* How many are in the table. */
179 size_t include_dir_count
;
181 /* Length of longest in table. */
182 size_t include_dir_maxlen
;
184 #ifndef WORKING_DOT_WORD
185 struct broken_word
*broken_words
;
186 int new_broken_words
;
189 /* The current offset into the absolute section. We don't try to
190 build frags in the absolute section, since no data can be stored
191 there. We just keep track of the current offset. */
192 addressT abs_section_offset
;
194 /* If this line had an MRI style label, it is stored in this variable.
195 This is used by some of the MRI pseudo-ops. */
198 /* This global variable is used to support MRI common sections. We
199 translate such sections into a common symbol. This variable is
200 non-NULL when we are in an MRI common section. */
201 symbolS
*mri_common_symbol
;
203 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
204 need to align to an even byte boundary unless the next pseudo-op is
205 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
207 static int mri_pending_align
;
209 /* Record the current function so that we can issue an error message for
210 misplaced .func,.endfunc, and also so that .endfunc needs no
212 static char *current_name
;
213 static char *current_label
;
217 static int dwarf_file
;
218 static int dwarf_line
;
220 /* This variable is set to be non-zero if the next string we see might
221 be the name of the source file in DWARF debugging information. See
222 the comment in emit_expr for the format we look for. */
223 static int dwarf_file_string
;
227 /* If the target defines the md_frag_max_var hook then we know
228 enough to implement the .bundle_align_mode features. */
229 #ifdef md_frag_max_var
230 # define HANDLE_BUNDLE
234 /* .bundle_align_mode sets this. Normally it's zero. When nonzero,
235 it's the exponent of the bundle size, and aligned instruction bundle
236 mode is in effect. */
237 static unsigned int bundle_align_p2
;
239 /* These are set by .bundle_lock and .bundle_unlock. .bundle_lock sets
240 bundle_lock_frag to frag_now and then starts a new frag with
241 frag_align_code. At the same time, bundle_lock_frain gets frchain_now,
242 so that .bundle_unlock can verify that we didn't change segments.
243 .bundle_unlock resets both to NULL. If we detect a bundling violation,
244 then we reset bundle_lock_frchain to NULL as an indicator that we've
245 already diagnosed the error with as_bad and don't need a cascade of
246 redundant errors, but bundle_lock_frag remains set to indicate that
247 we are expecting to see .bundle_unlock. */
248 static fragS
*bundle_lock_frag
;
249 static frchainS
*bundle_lock_frchain
;
251 /* This is incremented by .bundle_lock and decremented by .bundle_unlock,
253 static unsigned int bundle_lock_depth
;
256 static void do_s_func (int end_p
, const char *default_prefix
);
257 static void s_align (int, int);
258 static void s_altmacro (int);
259 static void s_bad_end (int);
260 static void s_reloc (int);
261 static int hex_float (int, char *);
262 static segT
get_known_segmented_expression (expressionS
* expP
);
263 static void pobegin (void);
264 static void poend (void);
265 static size_t get_macro_line_sb (sb
*);
266 static void generate_file_debug (void);
267 static char *_find_end_of_line (char *, int, int, int);
268 #if defined (TE_PE) && defined (O_secrel)
269 static void s_cv_comp (int sign
);
278 obj_read_begin_hook ();
280 obstack_begin (&cond_obstack
, chunksize
);
282 #ifndef tc_line_separator_chars
283 #define tc_line_separator_chars line_separator_chars
285 /* Use machine dependent syntax. */
286 for (p
= tc_line_separator_chars
; *p
; p
++)
287 is_end_of_line
[(unsigned char) *p
] = 2;
288 /* Use more. FIXME-SOMEDAY. */
291 lex_type
['?'] = LEX_BEGIN_NAME
| LEX_NAME
;
295 #ifndef WORKING_DOT_WORD
297 new_broken_words
= 0;
300 abs_section_offset
= 0;
303 mri_common_symbol
= NULL
;
304 mri_pending_align
= 0;
307 current_label
= NULL
;
313 dwarf_file_string
= 0;
319 bundle_lock_frag
= NULL
;
320 bundle_lock_frchain
= NULL
;
321 bundle_lock_depth
= 0;
330 _obstack_free (&cond_obstack
, NULL
);
332 free (current_label
);
335 #ifndef TC_ADDRESS_BYTES
336 #define TC_ADDRESS_BYTES address_bytes
341 /* Choose smallest of 1, 2, 4, 8 bytes that is large enough to
342 contain an address. */
343 int n
= (stdoutput
->arch_info
->bits_per_address
- 1) / 8;
351 /* Set up pseudo-op tables. */
353 static htab_t po_hash
;
355 static const pseudo_typeS potable
[] = {
356 {"abort", s_abort
, 0},
357 {"align", s_align_ptwo
, 0},
358 {"altmacro", s_altmacro
, 1},
359 {"ascii", stringer
, 8+0},
360 {"asciz", stringer
, 8+1},
361 {"balign", s_align_bytes
, 0},
362 {"balignw", s_align_bytes
, -2},
363 {"balignl", s_align_bytes
, -4},
364 {"base64", s_base64
, 0},
367 {"bundle_align_mode", s_bundle_align_mode
, 0},
368 {"bundle_lock", s_bundle_lock
, 0},
369 {"bundle_unlock", s_bundle_unlock
, 0},
373 {"common", s_mri_common
, 0},
374 {"common.s", s_mri_common
, 1},
375 #if defined (TE_PE) && defined (O_secrel)
376 {"cv_scomp", s_cv_comp
, 1},
377 {"cv_ucomp", s_cv_comp
, 0},
383 {"dc.d", float_cons
, 'd'},
385 {"dc.s", float_cons
, 'f'},
387 {"dc.x", float_cons
, 'x'},
389 {"dcb.b", s_space
, 1},
390 {"dcb.d", s_float_space
, 'd'},
391 {"dcb.l", s_space
, 4},
392 {"dcb.s", s_float_space
, 'f'},
393 {"dcb.w", s_space
, 2},
394 {"dcb.x", s_float_space
, 'x'},
396 {"ds.b", s_space
, 1},
397 {"ds.d", s_space
, 8},
398 {"ds.l", s_space
, 4},
399 {"ds.p", s_space
, 'p'},
400 {"ds.s", s_space
, 4},
401 {"ds.w", s_space
, 2},
402 {"ds.x", s_space
, 'x'},
403 {"debug", s_ignore
, 0},
408 {"double", float_cons
, 'd'},
410 {"eject", listing_eject
, 0}, /* Formfeed listing. */
412 {"elsec", s_else
, 0},
413 {"elseif", s_elseif
, (int) O_ne
},
415 {"endc", s_endif
, 0},
416 {"endfunc", s_func
, 1},
417 {"endif", s_endif
, 0},
418 {"endm", s_bad_end
, 0},
419 {"endr", s_bad_end
, 1},
425 {"error", s_errwarn
, 1},
426 {"exitm", s_mexit
, 0},
428 {"extern", s_ignore
, 0}, /* We treat all undef as ext. */
432 {"float", float_cons
, 'f'},
433 {"format", s_ignore
, 0},
435 {"global", s_globl
, 0},
436 {"globl", s_globl
, 0},
438 {"if", s_if
, (int) O_ne
},
441 {"ifdef", s_ifdef
, 0},
442 {"ifeq", s_if
, (int) O_eq
},
443 {"ifeqs", s_ifeqs
, 0},
444 {"ifge", s_if
, (int) O_ge
},
445 {"ifgt", s_if
, (int) O_gt
},
446 {"ifle", s_if
, (int) O_le
},
447 {"iflt", s_if
, (int) O_lt
},
450 {"ifndef", s_ifdef
, 1},
451 {"ifne", s_if
, (int) O_ne
},
452 {"ifnes", s_ifeqs
, 1},
453 {"ifnotdef", s_ifdef
, 1},
454 {"incbin", s_incbin
, 0},
455 {"include", s_include
, 0},
461 {"lcomm", s_lcomm
, 0},
462 {"lflags", s_ignore
, 0}, /* Listing flags. */
463 {"linefile", s_linefile
, 0},
464 {"linkonce", s_linkonce
, 0},
465 {"list", listing_list
, 1}, /* Turn listing on. */
466 {"llen", listing_psize
, 1},
469 {"macro", s_macro
, 0},
470 {"mexit", s_mexit
, 0},
472 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
473 {"name", s_ignore
, 0},
474 {"noaltmacro", s_altmacro
, 0},
475 {"noformat", s_ignore
, 0},
476 {"nolist", listing_list
, 0}, /* Turn listing off. */
477 {"nopage", listing_nopage
, 0},
481 {"offset", s_struct
, 0},
483 {"p2align", s_align_ptwo
, 0},
484 {"p2alignw", s_align_ptwo
, -2},
485 {"p2alignl", s_align_ptwo
, -4},
486 {"page", listing_eject
, 0},
487 {"plen", listing_psize
, 0},
488 {"print", s_print
, 0},
489 {"psize", listing_psize
, 0}, /* Set paper size. */
490 {"purgem", s_purgem
, 0},
492 {"reloc", s_reloc
, 0},
496 {"sbttl", listing_title
, 1}, /* Subtitle of listing. */
501 {"single", float_cons
, 'f'},
503 {"space", s_space
, 0},
504 {"skip", s_space
, 0},
505 {"sleb128", s_leb128
, 1},
506 {"spc", s_ignore
, 0},
507 {"stabd", s_stab
, 'd'},
508 {"stabn", s_stab
, 'n'},
509 {"stabs", s_stab
, 's'},
510 {"string", stringer
, 8+1},
511 {"string8", stringer
, 8+1},
512 {"string16", stringer
, 16+1},
513 {"string32", stringer
, 32+1},
514 {"string64", stringer
, 64+1},
515 {"struct", s_struct
, 0},
519 /* This is for gcc to use. It's only just been added (2/94), so gcc
520 won't be able to use it for a while -- probably a year or more.
521 But once this has been released, check with gcc maintainers
522 before deleting it or even changing the spelling. */
523 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
524 /* If we're folding case -- done for some targets, not necessarily
525 all -- the above string in an input file will be converted to
526 this one. Match it either way... */
527 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
529 {"title", listing_title
, 0}, /* Listing title. */
530 {"ttl", listing_title
, 0},
532 {"uleb128", s_leb128
, 0},
536 {"xdef", s_globl
, 0},
537 {"xref", s_ignore
, 0},
538 {"xstabs", s_xstab
, 's'},
539 {"warning", s_errwarn
, 0},
540 {"weakref", s_weakref
, 0},
542 {"zero", s_space
, 0},
546 {NULL
, NULL
, 0} /* End sentinel. */
550 get_absolute_expr (expressionS
*exp
)
552 expression_and_evaluate (exp
);
554 if (exp
->X_op
!= O_constant
)
556 if (exp
->X_op
!= O_absent
)
557 as_bad (_("bad or irreducible absolute expression"));
558 exp
->X_add_number
= 0;
560 return exp
->X_add_number
;
564 get_absolute_expression (void)
568 return get_absolute_expr (&exp
);
571 static int pop_override_ok
;
572 static const char *pop_table_name
;
575 pop_insert (const pseudo_typeS
*table
)
577 const pseudo_typeS
*pop
;
578 for (pop
= table
; pop
->poc_name
; pop
++)
580 if (str_hash_insert (po_hash
, pop
->poc_name
, pop
, 0) != NULL
)
582 if (!pop_override_ok
)
583 as_fatal (_("error constructing %s pseudo-op table"),
589 #ifndef md_pop_insert
590 #define md_pop_insert() pop_insert(md_pseudo_table)
593 #ifndef obj_pop_insert
594 #define obj_pop_insert() pop_insert(obj_pseudo_table)
597 #ifndef cfi_pop_insert
598 #define cfi_pop_insert() pop_insert(cfi_pseudo_table)
601 #ifndef scfi_pop_insert
602 #define scfi_pop_insert() pop_insert(scfi_pseudo_table)
608 po_hash
= str_htab_create ();
610 /* Do the target-specific pseudo ops. */
611 pop_table_name
= "md";
615 /* Now object specific. Skip any that were in the target table. */
616 pop_table_name
= "obj";
620 /* Now portable ones. Skip any that we've seen already. */
621 pop_table_name
= "standard";
622 pop_insert (potable
);
625 #if defined (TARGET_USE_SCFI) && defined (TARGET_USE_GINSN)
628 pop_table_name
= "scfi";
634 pop_table_name
= "cfi";
642 htab_delete (po_hash
);
645 #define HANDLE_CONDITIONAL_ASSEMBLY(num_read) \
646 if (ignore_input ()) \
648 char *eol = find_end_of_line (input_line_pointer - (num_read), \
650 input_line_pointer = (input_line_pointer <= buffer_limit \
651 && eol >= buffer_limit) \
657 /* Helper function of read_a_source_file, which tries to expand a macro. */
659 try_macro (char term
, const char *line
)
665 if (check_macro (line
, &out
, &err
, ¯o
))
669 *input_line_pointer
++ = term
;
670 input_scrub_include_sb (&out
,
671 input_line_pointer
, expanding_macro
);
674 input_scrub_next_buffer (&input_line_pointer
);
676 md_macro_info (macro
);
684 /* Start a new instruction bundle. Returns the rs_align_code frag that
685 will be used to align the new bundle. */
689 fragS
*frag
= frag_now
;
691 frag_align_code (0, 0);
693 while (frag
->fr_type
!= rs_align_code
)
694 frag
= frag
->fr_next
;
696 gas_assert (frag
!= frag_now
);
701 /* Calculate the maximum size after relaxation of the region starting
702 at the given frag and extending through frag_now (which is unfinished). */
704 pending_bundle_size (fragS
*frag
)
706 unsigned int offset
= frag
->fr_fix
;
707 unsigned int size
= 0;
709 gas_assert (frag
!= frag_now
);
710 gas_assert (frag
->fr_type
== rs_align_code
);
712 while (frag
!= frag_now
)
714 /* This should only happen in what will later become an error case. */
718 size
+= frag
->fr_fix
;
719 if (frag
->fr_type
== rs_machine_dependent
)
720 size
+= md_frag_max_var (frag
);
722 frag
= frag
->fr_next
;
725 gas_assert (frag
== frag_now
);
726 size
+= frag_now_fix ();
727 if (frag
->fr_type
== rs_machine_dependent
)
728 size
+= md_frag_max_var (frag
);
730 gas_assert (size
>= offset
);
732 return size
- offset
;
735 /* Finish off the frag created to ensure bundle alignment. */
737 finish_bundle (fragS
*frag
, unsigned int size
)
739 gas_assert (bundle_align_p2
> 0);
740 gas_assert (frag
->fr_type
== rs_align_code
);
744 /* If there is more than a single byte, then we need to set up the
745 alignment frag. Otherwise we leave it at its initial state from
746 calling frag_align_code (0, 0), so that it does nothing. */
747 frag
->fr_offset
= bundle_align_p2
;
748 frag
->fr_subtype
= size
- 1;
751 /* We do this every time rather than just in s_bundle_align_mode
752 so that we catch any affected section without needing hooks all
753 over for all paths that do section changes. It's cheap enough. */
754 if (bundle_align_p2
> OCTETS_PER_BYTE_POWER
)
755 record_alignment (now_seg
, bundle_align_p2
- OCTETS_PER_BYTE_POWER
);
758 /* Assemble one instruction. This takes care of the bundle features
759 around calling md_assemble. */
761 assemble_one (char *line
)
763 fragS
*insn_start_frag
= NULL
;
765 if (bundle_lock_frchain
!= NULL
&& bundle_lock_frchain
!= frchain_now
)
767 as_bad (_("cannot change section or subsection inside .bundle_lock"));
768 /* Clearing this serves as a marker that we have already complained. */
769 bundle_lock_frchain
= NULL
;
772 if (bundle_lock_frchain
== NULL
&& bundle_align_p2
> 0)
773 insn_start_frag
= start_bundle ();
777 if (bundle_lock_frchain
!= NULL
)
779 /* Make sure this hasn't pushed the locked sequence
780 past the bundle size. */
781 unsigned int bundle_size
= pending_bundle_size (bundle_lock_frag
);
782 if (bundle_size
> 1U << bundle_align_p2
)
783 as_bad (_ (".bundle_lock sequence at %u bytes, "
784 "but .bundle_align_mode limit is %u bytes"),
785 bundle_size
, 1U << bundle_align_p2
);
787 else if (bundle_align_p2
> 0)
789 unsigned int insn_size
= pending_bundle_size (insn_start_frag
);
791 if (insn_size
> 1U << bundle_align_p2
)
792 as_bad (_("single instruction is %u bytes long, "
793 "but .bundle_align_mode limit is %u bytes"),
794 insn_size
, 1U << bundle_align_p2
);
796 finish_bundle (insn_start_frag
, insn_size
);
800 #else /* !HANDLE_BUNDLE */
802 # define assemble_one(line) md_assemble(line)
804 #endif /* HANDLE_BUNDLE */
809 flagword flags
= bfd_section_flags (now_seg
);
811 return (flags
& SEC_ALLOC
) && !(flags
& (SEC_LOAD
| SEC_HAS_CONTENTS
));
814 /* Guts of .align directive:
815 N is the power of two to which to align. A value of zero is accepted but
816 ignored: the default alignment of the section will be at least this.
817 FILL may be NULL, or it may point to the bytes of the fill pattern.
818 LEN is the length of whatever FILL points to, if anything. If LEN is zero
819 but FILL is not NULL then LEN is treated as if it were one.
820 MAX is the maximum number of characters to skip when doing the alignment,
821 or 0 if there is no maximum. */
824 do_align (unsigned int n
, char *fill
, unsigned int len
, unsigned int max
)
826 if (now_seg
== absolute_section
|| in_bss ())
832 if (now_seg
== absolute_section
)
833 as_warn (_("ignoring fill value in absolute section"));
835 as_warn (_("ignoring fill value in section `%s'"),
836 segment_name (now_seg
));
843 #ifdef md_flush_pending_output
844 md_flush_pending_output ();
848 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
851 /* Only make a frag if we HAVE to... */
852 if ((n
> OCTETS_PER_BYTE_POWER
) && !need_pass_2
)
856 if (subseg_text_p (now_seg
))
857 frag_align_code (n
, max
);
859 frag_align (n
, 0, max
);
862 frag_align (n
, *fill
, max
);
864 frag_align_pattern (n
, fill
, len
, max
);
868 just_record_alignment
: ATTRIBUTE_UNUSED_LABEL
871 if (n
> OCTETS_PER_BYTE_POWER
)
872 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
875 /* Find first <eol><next_char>NO_APP<eol>, if any, in the supplied buffer.
876 Return NULL if there's none, or else the position of <next_char>. */
878 find_no_app (const char *s
, char next_char
)
880 const char *start
= s
;
881 const char srch
[] = { next_char
, 'N', 'O', '_', 'A', 'P', 'P', '\0' };
885 char *ends
= strstr (s
, srch
);
889 if (is_end_of_line (ends
[sizeof (srch
) - 1])
890 && (ends
== start
|| is_end_of_line (ends
[-1])))
892 s
= ends
+ sizeof (srch
) - 1;
898 /* We read the file, putting things into a web that represents what we
899 have been reading. */
901 read_a_source_file (const char *name
)
905 char *s
; /* String of symbol, '\0' appended. */
907 const pseudo_typeS
*pop
;
913 buffer
= input_scrub_new_file (name
);
916 listing_newline (NULL
);
917 register_dependency (name
);
919 /* Generate debugging information before we've read anything in to denote
920 this file as the "main" source file and not a subordinate one
921 (e.g. N_SO vs N_SOL in stabs). */
922 generate_file_debug ();
924 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
925 { /* We have another line to parse. */
927 /* In order to avoid listing macro expansion lines with labels
928 multiple times, keep track of which line was last issued. */
929 char *last_eol
= NULL
;
932 while (input_line_pointer
< buffer_limit
)
935 /* We have more of this buffer to parse. */
937 /* We now have input_line_pointer->1st char of next line.
938 If input_line_pointer [-1] == '\n' then we just
939 scanned another line: so bump line counters. */
940 was_new_line
= is_end_of_line
[(unsigned char) input_line_pointer
[-1]];
943 symbol_set_value_now (&dot_symbol
);
944 #ifdef md_start_line_hook
945 md_start_line_hook ();
947 if (input_line_pointer
[-1] == '\n')
948 bump_line_counters ();
952 /* If listing is on, and we are expanding a macro, then give
953 the listing code the contents of the expanded line. */
956 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
958 /* Find the end of the current expanded macro line. */
959 s
= find_end_of_line (input_line_pointer
, flag_m68k_mri
);
962 && !startswith (input_line_pointer
,
963 !flag_m68k_mri
? " .linefile "
970 /* Copy it for safe keeping. Also give an indication of
971 how much macro nesting is involved at this point. */
972 len
= s
- input_line_pointer
;
973 copy
= XNEWVEC (char, len
+ macro_nest
+ 2);
974 memset (copy
, '>', macro_nest
);
975 copy
[macro_nest
] = ' ';
976 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
, len
);
977 copy
[macro_nest
+ 1 + len
] = '\0';
979 /* Install the line with the listing facility. */
980 listing_newline (copy
);
984 listing_newline (NULL
);
988 next_char
= *input_line_pointer
;
989 if (was_new_line
== 1
990 && (strchr (line_comment_chars
, '#')
992 : next_char
&& strchr (line_comment_chars
, next_char
)))
994 /* Its a comment. Check for APP followed by NO_APP. */
999 s
= input_line_pointer
+ 1;
1000 if (!startswith (s
, "APP") || !is_end_of_line (s
[3]))
1002 /* We ignore it. Note: Not ignore_rest_of_line ()! */
1003 while (s
<= buffer_limit
)
1004 if (is_end_of_line (*s
++))
1006 input_line_pointer
= s
;
1011 ends
= find_no_app (s
, next_char
);
1012 len
= ends
? ends
- s
: buffer_limit
- s
;
1014 sb_build (&sbuf
, len
+ 100);
1015 sb_add_buffer (&sbuf
, s
, len
);
1018 /* The end of the #APP wasn't in this buffer. We
1019 keep reading in buffers until we find the #NO_APP
1020 that goes with this #APP There is one. The specs
1024 buffer_limit
= input_scrub_next_buffer (&buffer
);
1027 ends
= find_no_app (buffer
, next_char
);
1028 len
= ends
? ends
- buffer
: buffer_limit
- buffer
;
1029 sb_add_buffer (&sbuf
, buffer
, len
);
1033 sb_add_char (&sbuf
, '\n');
1035 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1036 input_scrub_include_sb (&sbuf
, input_line_pointer
, expanding_app
);
1038 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1046 if (LABELS_WITHOUT_COLONS
|| flag_m68k_mri
)
1048 next_char
= * input_line_pointer
;
1049 /* Text at the start of a line must be a label, we
1050 run down and stick a colon in. */
1051 if (is_name_beginner (next_char
) || next_char
== '"')
1056 HANDLE_CONDITIONAL_ASSEMBLY (0);
1058 nul_char
= get_symbol_name (& line_start
);
1059 next_char
= (nul_char
== '"' ? input_line_pointer
[1] : nul_char
);
1061 /* In MRI mode, the EQU and MACRO pseudoops must
1062 be handled specially. */
1066 char *rest
= input_line_pointer
+ 1;
1070 if (*rest
== ' ' || *rest
== '\t')
1072 if ((strncasecmp (rest
, "EQU", 3) == 0
1073 || strncasecmp (rest
, "SET", 3) == 0)
1074 && (rest
[3] == ' ' || rest
[3] == '\t'))
1076 input_line_pointer
= rest
+ 3;
1078 strncasecmp (rest
, "SET", 3) == 0);
1081 if (strncasecmp (rest
, "MACRO", 5) == 0
1084 || is_end_of_line
[(unsigned char) rest
[5]]))
1088 /* In MRI mode, we need to handle the MACRO
1089 pseudo-op specially: we don't want to put the
1090 symbol in the symbol table. */
1092 #ifdef TC_START_LABEL_WITHOUT_COLON
1093 && TC_START_LABEL_WITHOUT_COLON (nul_char
, next_char
)
1096 line_label
= colon (line_start
);
1098 line_label
= symbol_create (line_start
,
1100 &zero_address_frag
, 0);
1102 next_char
= restore_line_pointer (nul_char
);
1103 if (next_char
== ':')
1104 input_line_pointer
++;
1109 /* We are at the beginning of a line, or similar place.
1110 We expect a well-formed assembler statement.
1111 A "symbol-name:" is a statement.
1113 Depending on what compiler is used, the order of these tests
1114 may vary to catch most common case 1st.
1115 Each test is independent of all other tests at the (top)
1118 nul_char
= next_char
= *input_line_pointer
++;
1119 while (next_char
== '\t' || next_char
== ' ' || next_char
== '\f');
1121 /* C is the 1st significant character.
1122 Input_line_pointer points after that character. */
1123 if (is_name_beginner (next_char
) || next_char
== '"')
1127 /* Want user-defined label or pseudo/opcode. */
1128 HANDLE_CONDITIONAL_ASSEMBLY (1);
1130 --input_line_pointer
;
1131 nul_char
= get_symbol_name (& s
); /* name's delimiter. */
1132 next_char
= (nul_char
== '"' ? input_line_pointer
[1] : nul_char
);
1133 rest
= input_line_pointer
+ (nul_char
== '"' ? 2 : 1);
1135 /* NEXT_CHAR is character after symbol.
1136 The end of symbol in the input line is now '\0'.
1137 S points to the beginning of the symbol.
1138 [In case of pseudo-op, s->'.'.]
1139 Input_line_pointer->'\0' where NUL_CHAR was. */
1140 if (TC_START_LABEL (s
, nul_char
, next_char
))
1144 /* In MRI mode, \tsym: set 0 is permitted. */
1148 if (*rest
== ' ' || *rest
== '\t')
1151 if ((strncasecmp (rest
, "EQU", 3) == 0
1152 || strncasecmp (rest
, "SET", 3) == 0)
1153 && (rest
[3] == ' ' || rest
[3] == '\t'))
1155 input_line_pointer
= rest
+ 3;
1161 line_label
= colon (s
); /* User-defined label. */
1162 restore_line_pointer (nul_char
);
1163 ++ input_line_pointer
;
1164 #ifdef tc_check_label
1165 tc_check_label (line_label
);
1167 /* Input_line_pointer->after ':'. */
1170 else if ((next_char
== '=' && *rest
== '=')
1171 || ((next_char
== ' ' || next_char
== '\t')
1176 demand_empty_rest_of_line ();
1178 else if ((next_char
== '='
1179 || ((next_char
== ' ' || next_char
== '\t')
1181 #ifdef TC_EQUAL_IN_INSN
1182 && !TC_EQUAL_IN_INSN (next_char
, s
)
1187 demand_empty_rest_of_line ();
1191 /* Expect pseudo-op or machine instruction. */
1194 #ifndef TC_CASE_SENSITIVE
1198 strncpy (original_case_string
, s2
,
1199 sizeof (original_case_string
) - 1);
1200 original_case_string
[sizeof (original_case_string
) - 1] = 0;
1204 *s2
= TOLOWER (*s2
);
1209 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
1211 /* The MRI assembler uses pseudo-ops without
1213 pop
= str_hash_find (po_hash
, s
);
1214 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
1219 || (!flag_m68k_mri
&& *s
== '.'))
1223 WARNING: next_char may be end-of-line.
1224 We lookup the pseudo-op table with s+1 because we
1225 already know that the pseudo-op begins with a '.'. */
1228 pop
= str_hash_find (po_hash
, s
+ 1);
1229 if (pop
&& !pop
->poc_handler
)
1232 /* In MRI mode, we may need to insert an
1233 automatic alignment directive. What a hack
1235 if (mri_pending_align
1237 || !((pop
->poc_handler
== cons
1238 && pop
->poc_val
== 1)
1239 || (pop
->poc_handler
== s_space
1240 && pop
->poc_val
== 1)
1241 #ifdef tc_conditional_pseudoop
1242 || tc_conditional_pseudoop (pop
)
1244 || pop
->poc_handler
== s_if
1245 || pop
->poc_handler
== s_ifdef
1246 || pop
->poc_handler
== s_ifc
1247 || pop
->poc_handler
== s_ifeqs
1248 || pop
->poc_handler
== s_else
1249 || pop
->poc_handler
== s_endif
1250 || pop
->poc_handler
== s_globl
1251 || pop
->poc_handler
== s_ignore
)))
1253 do_align (1, (char *) NULL
, 0, 0);
1254 mri_pending_align
= 0;
1256 if (line_label
!= NULL
)
1258 symbol_set_frag (line_label
, frag_now
);
1259 S_SET_VALUE (line_label
, frag_now_fix ());
1263 /* Print the error msg now, while we still can. */
1266 char *end
= input_line_pointer
;
1268 (void) restore_line_pointer (nul_char
);
1270 nul_char
= next_char
= *--input_line_pointer
;
1271 *input_line_pointer
= '\0';
1272 if (! macro_defined
|| ! try_macro (next_char
, s
))
1275 as_bad (_("unknown pseudo-op: `%s'"), s
);
1276 *input_line_pointer
++ = nul_char
;
1281 /* Put it back for error messages etc. */
1282 next_char
= restore_line_pointer (nul_char
);
1283 /* The following skip of whitespace is compulsory.
1284 A well shaped space is sometimes all that separates
1285 keyword from operands. */
1286 if (next_char
== ' ' || next_char
== '\t')
1287 input_line_pointer
++;
1289 /* Input_line is restored.
1290 Input_line_pointer->1st non-blank char
1291 after pseudo-operation. */
1292 (*pop
->poc_handler
) (pop
->poc_val
);
1294 /* If that was .end, just get out now. */
1295 if (pop
->poc_handler
== s_end
)
1300 /* WARNING: next_char may be end-of-line. */
1301 /* Also: input_line_pointer->`\0` where nul_char was. */
1302 (void) restore_line_pointer (nul_char
);
1303 input_line_pointer
= _find_end_of_line (input_line_pointer
, flag_m68k_mri
, 1, 0);
1304 next_char
= nul_char
= *input_line_pointer
;
1305 *input_line_pointer
= '\0';
1307 generate_lineno_debug ();
1309 if (macro_defined
&& try_macro (next_char
, s
))
1312 if (mri_pending_align
)
1314 do_align (1, (char *) NULL
, 0, 0);
1315 mri_pending_align
= 0;
1316 if (line_label
!= NULL
)
1318 symbol_set_frag (line_label
, frag_now
);
1319 S_SET_VALUE (line_label
, frag_now_fix ());
1323 assemble_one (s
); /* Assemble 1 instruction. */
1325 /* PR 19630: The backend may have set ilp to NULL
1326 if it encountered a catastrophic failure. */
1327 if (input_line_pointer
== NULL
)
1328 as_fatal (_("unable to continue with assembly."));
1330 *input_line_pointer
++ = nul_char
;
1332 /* We resume loop AFTER the end-of-line from
1333 this instruction. */
1339 /* Empty statement? */
1340 if (is_end_of_line
[(unsigned char) next_char
])
1343 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
) && ISDIGIT (next_char
))
1345 /* local label ("4:") */
1346 char *backup
= input_line_pointer
;
1348 HANDLE_CONDITIONAL_ASSEMBLY (1);
1350 temp
= next_char
- '0';
1352 /* Read the whole number. */
1353 while (ISDIGIT (*input_line_pointer
))
1355 const long digit
= *input_line_pointer
- '0';
1357 /* Don't accept labels which look like octal numbers. */
1360 if (temp
> (INT_MAX
- digit
) / 10)
1362 as_bad (_("local label too large near %s"), backup
);
1366 temp
= temp
* 10 + digit
;
1367 ++input_line_pointer
;
1370 /* Overflow: stop processing the label. */
1373 ignore_rest_of_line ();
1377 if (LOCAL_LABELS_DOLLAR
1378 && *input_line_pointer
== '$'
1379 && *(input_line_pointer
+ 1) == ':')
1381 input_line_pointer
+= 2;
1383 if (dollar_label_defined (temp
))
1385 as_fatal (_("label \"%ld$\" redefined"), temp
);
1388 define_dollar_label (temp
);
1389 colon (dollar_label_name (temp
, 0));
1394 && *input_line_pointer
++ == ':')
1396 fb_label_instance_inc (temp
);
1397 colon (fb_label_name (temp
, 0));
1401 input_line_pointer
= backup
;
1404 if (next_char
&& strchr (line_comment_chars
, next_char
))
1406 /* Its a comment, ignore it. Note: Not ignore_rest_of_line ()! */
1407 s
= input_line_pointer
;
1408 while (s
<= buffer_limit
)
1409 if (is_end_of_line (*s
++))
1411 input_line_pointer
= s
;
1415 HANDLE_CONDITIONAL_ASSEMBLY (1);
1417 #ifdef tc_unrecognized_line
1418 if (tc_unrecognized_line (next_char
))
1421 input_line_pointer
--;
1422 /* Report unknown char as error. */
1423 demand_empty_rest_of_line ();
1428 symbol_set_value_now (&dot_symbol
);
1430 #ifdef HANDLE_BUNDLE
1431 if (bundle_lock_frag
!= NULL
)
1433 as_bad_where (bundle_lock_frag
->fr_file
, bundle_lock_frag
->fr_line
,
1434 _(".bundle_lock with no matching .bundle_unlock"));
1435 bundle_lock_frag
= NULL
;
1436 bundle_lock_frchain
= NULL
;
1437 bundle_lock_depth
= 0;
1442 ginsn_data_end (symbol_temp_new_now ());
1447 /* Close the input file. */
1448 input_scrub_close ();
1449 #ifdef WARN_COMMENTS
1451 if (warn_comment
&& found_comment
)
1452 as_warn_where (found_comment_file
, found_comment
,
1453 "first comment found here");
1458 /* Convert O_constant expression EXP into the equivalent O_big representation.
1459 Take the sign of the number from SIGN rather than X_add_number. */
1462 convert_to_bignum (expressionS
*exp
, int sign
)
1467 value
= exp
->X_add_number
;
1468 for (i
= 0; i
< sizeof (exp
->X_add_number
) / CHARS_PER_LITTLENUM
; i
++)
1470 generic_bignum
[i
] = value
& LITTLENUM_MASK
;
1471 value
>>= LITTLENUM_NUMBER_OF_BITS
;
1473 /* Add a sequence of sign bits if the top bit of X_add_number is not
1474 the sign of the original value. */
1475 if ((exp
->X_add_number
< 0) == !sign
)
1476 generic_bignum
[i
++] = sign
? LITTLENUM_MASK
: 0;
1478 exp
->X_add_number
= i
;
1481 /* For most MRI pseudo-ops, the line actually ends at the first
1482 nonquoted space. This function looks for that point, stuffs a null
1483 in, and sets *STOPCP to the character that used to be there, and
1484 returns the location.
1486 Until I hear otherwise, I am going to assume that this is only true
1487 for the m68k MRI assembler. */
1490 mri_comment_field (char *stopcp
)
1496 know (flag_m68k_mri
);
1498 for (s
= input_line_pointer
;
1499 ((!is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1507 for (s
= input_line_pointer
;
1508 !is_end_of_line
[(unsigned char) *s
];
1518 /* Skip to the end of an MRI comment field. */
1521 mri_comment_end (char *stop
, int stopc
)
1525 input_line_pointer
= stop
;
1527 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1528 ++input_line_pointer
;
1532 s_abort (int ignore ATTRIBUTE_UNUSED
)
1534 as_fatal (_(".abort detected. Abandoning ship."));
1537 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1538 (in bytes). A negative ARG is the negative of the length of the
1539 fill pattern. BYTES_P is non-zero if the alignment value should be
1540 interpreted as the byte boundary, rather than the power of 2. */
1541 #ifndef TC_ALIGN_LIMIT
1542 #define TC_ALIGN_LIMIT (stdoutput->arch_info->bits_per_address - 1)
1546 s_align (signed int arg
, int bytes_p
)
1548 unsigned int align_limit
= TC_ALIGN_LIMIT
;
1557 stop
= mri_comment_field (&stopc
);
1559 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1564 align
= arg
; /* Default value from pseudo-op table. */
1568 align
= get_absolute_expression ();
1571 #ifdef TC_ALIGN_ZERO_IS_DEFAULT
1572 if (arg
> 0 && align
== 0)
1579 /* Convert to a power of 2. */
1584 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1587 as_bad (_("alignment not a power of 2"));
1593 if (align
> align_limit
)
1595 align
= align_limit
;
1596 as_warn (_("alignment too large: %u assumed"), align_limit
);
1599 if (*input_line_pointer
!= ',')
1606 ++input_line_pointer
;
1607 if (*input_line_pointer
== ',')
1611 fill
= get_absolute_expression ();
1616 if (*input_line_pointer
!= ',')
1620 ++input_line_pointer
;
1621 max
= get_absolute_expression ();
1628 as_warn (_("expected fill pattern missing"));
1629 do_align (align
, (char *) NULL
, 0, max
);
1633 unsigned int fill_len
;
1645 do_align (align
, &fill_char
, fill_len
, max
);
1651 if ((size_t) fill_len
> sizeof ab
)
1653 as_warn (_("fill pattern too long, truncating to %u"),
1654 (unsigned) sizeof ab
);
1655 fill_len
= sizeof ab
;
1658 md_number_to_chars (ab
, fill
, fill_len
);
1659 do_align (align
, ab
, fill_len
, max
);
1663 demand_empty_rest_of_line ();
1666 mri_comment_end (stop
, stopc
);
1669 /* Handle the .align pseudo-op on machines where ".align 4" means
1670 align to a 4 byte boundary. */
1673 s_align_bytes (int arg
)
1678 /* Handle the .align pseudo-op on machines where ".align 4" means align
1679 to a 2**4 boundary. */
1682 s_align_ptwo (int arg
)
1687 /* Switch in and out of alternate macro mode. */
1692 demand_empty_rest_of_line ();
1693 flag_macro_alternate
= on
;
1696 /* Read a symbol name from input_line_pointer.
1698 Stores the symbol name in a buffer and returns a pointer to this buffer.
1699 The buffer is xalloc'ed. It is the caller's responsibility to free
1702 The name is not left in the i_l_p buffer as it may need processing
1703 to handle escape characters.
1705 Advances i_l_p to the next non-whitespace character.
1707 If a symbol name could not be read, the routine issues an error
1708 messages, skips to the end of the line and returns NULL. */
1711 read_symbol_name (void)
1717 c
= *input_line_pointer
++;
1721 #define SYM_NAME_CHUNK_LEN 128
1722 ptrdiff_t len
= SYM_NAME_CHUNK_LEN
;
1726 start
= name
= XNEWVEC (char, len
+ 1);
1728 name_end
= name
+ SYM_NAME_CHUNK_LEN
;
1730 while (is_a_char (C
= next_char_of_string ()))
1732 if (name
>= name_end
)
1736 sofar
= name
- start
;
1737 len
+= SYM_NAME_CHUNK_LEN
;
1738 start
= XRESIZEVEC (char, start
, len
+ 1);
1739 name_end
= start
+ len
;
1740 name
= start
+ sofar
;
1747 /* Since quoted symbol names can contain non-ASCII characters,
1748 check the string and warn if it cannot be recognised by the
1749 current character set. */
1750 /* PR 29447: mbstowcs ignores the third (length) parameter when
1751 the first (destination) parameter is NULL. For clarity sake
1752 therefore we pass 0 rather than 'len' as the third parameter. */
1753 if (mbstowcs (NULL
, name
, 0) == (size_t) -1)
1754 as_warn (_("symbol name not recognised in the current locale"));
1756 else if (is_name_beginner (c
) || (input_from_string
&& c
== FAKE_LABEL_CHAR
))
1760 name
= input_line_pointer
- 1;
1762 /* We accept FAKE_LABEL_CHAR in a name in case this is
1763 being called with a constructed string. */
1764 while (is_part_of_name (c
= *input_line_pointer
++)
1765 || (input_from_string
&& c
== FAKE_LABEL_CHAR
))
1768 len
= (input_line_pointer
- name
) - 1;
1769 start
= XNEWVEC (char, len
+ 1);
1771 memcpy (start
, name
, len
);
1774 /* Skip a name ender char if one is present. */
1775 if (! is_name_ender (c
))
1776 --input_line_pointer
;
1779 name
= start
= NULL
;
1783 as_bad (_("expected symbol name"));
1784 ignore_rest_of_line ();
1796 s_comm_internal (int param
,
1797 symbolS
*(*comm_parse_extra
) (int, symbolS
*, addressT
))
1801 symbolS
*symbolP
= NULL
;
1807 stop
= mri_comment_field (&stopc
);
1809 if ((name
= read_symbol_name ()) == NULL
)
1812 /* Accept an optional comma after the name. The comma used to be
1813 required, but Irix 5 cc does not generate it for .lcomm. */
1814 if (*input_line_pointer
== ',')
1815 input_line_pointer
++;
1817 temp
= get_absolute_expr (&exp
);
1819 size
&= ((addressT
) 2 << (stdoutput
->arch_info
->bits_per_address
- 1)) - 1;
1820 if (exp
.X_op
== O_absent
)
1822 as_bad (_("missing size expression"));
1823 ignore_rest_of_line ();
1826 else if (temp
!= size
|| (!exp
.X_unsigned
&& exp
.X_add_number
< 0))
1828 as_warn (_("size (%ld) out of range, ignored"), (long) temp
);
1829 ignore_rest_of_line ();
1833 symbolP
= symbol_find_or_make (name
);
1834 if ((S_IS_DEFINED (symbolP
) || symbol_equated_p (symbolP
))
1835 && !S_IS_COMMON (symbolP
))
1837 if (!S_IS_VOLATILE (symbolP
))
1840 as_bad (_("symbol `%s' is already defined"), name
);
1841 ignore_rest_of_line ();
1844 symbolP
= symbol_clone (symbolP
, 1);
1845 S_SET_SEGMENT (symbolP
, undefined_section
);
1846 S_SET_VALUE (symbolP
, 0);
1847 symbol_set_frag (symbolP
, &zero_address_frag
);
1848 S_CLEAR_VOLATILE (symbolP
);
1851 size
= S_GET_VALUE (symbolP
);
1854 else if (size
!= temp
)
1855 as_warn (_("size of \"%s\" is already %ld; not changing to %ld"),
1856 name
, (long) size
, (long) temp
);
1858 if (comm_parse_extra
!= NULL
)
1859 symbolP
= (*comm_parse_extra
) (param
, symbolP
, size
);
1862 S_SET_VALUE (symbolP
, (valueT
) size
);
1863 S_SET_EXTERNAL (symbolP
);
1864 S_SET_SEGMENT (symbolP
, bfd_com_section_ptr
);
1867 demand_empty_rest_of_line ();
1870 mri_comment_end (stop
, stopc
);
1878 s_comm_internal (ignore
, NULL
);
1881 /* The MRI COMMON pseudo-op. We handle this by creating a common
1882 symbol with the appropriate name. We make s_space do the right
1883 thing by increasing the size. */
1886 s_mri_common (int small ATTRIBUTE_UNUSED
)
1902 stop
= mri_comment_field (&stopc
);
1906 name
= input_line_pointer
;
1907 if (!ISDIGIT (*name
))
1908 c
= get_symbol_name (& name
);
1913 ++input_line_pointer
;
1915 while (ISDIGIT (*input_line_pointer
));
1917 c
= *input_line_pointer
;
1918 *input_line_pointer
= '\0';
1920 if (line_label
!= NULL
)
1922 alc
= XNEWVEC (char, strlen (S_GET_NAME (line_label
))
1923 + (input_line_pointer
- name
) + 1);
1924 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1929 sym
= symbol_find_or_make (name
);
1930 c
= restore_line_pointer (c
);
1933 if (*input_line_pointer
!= ',')
1937 ++input_line_pointer
;
1938 align
= get_absolute_expression ();
1941 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1943 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (sym
));
1944 mri_comment_end (stop
, stopc
);
1948 S_SET_EXTERNAL (sym
);
1949 S_SET_SEGMENT (sym
, bfd_com_section_ptr
);
1950 mri_common_symbol
= sym
;
1954 S_SET_ALIGN (sym
, align
);
1959 if (line_label
!= NULL
)
1962 exp
.X_op
= O_symbol
;
1963 exp
.X_add_symbol
= sym
;
1964 exp
.X_add_number
= 0;
1965 symbol_set_value_expression (line_label
, &exp
);
1966 symbol_set_frag (line_label
, &zero_address_frag
);
1967 S_SET_SEGMENT (line_label
, expr_section
);
1970 /* FIXME: We just ignore the small argument, which distinguishes
1971 COMMON and COMMON.S. I don't know what we can do about it. */
1973 /* Ignore the type and hptype. */
1974 if (*input_line_pointer
== ',')
1975 input_line_pointer
+= 2;
1976 if (*input_line_pointer
== ',')
1977 input_line_pointer
+= 2;
1979 demand_empty_rest_of_line ();
1981 mri_comment_end (stop
, stopc
);
1985 s_data (int ignore ATTRIBUTE_UNUSED
)
1990 temp
= get_absolute_expression ();
1991 if (flag_readonly_data_in_text
)
1993 section
= text_section
;
1997 section
= data_section
;
1999 subseg_set (section
, (subsegT
) temp
);
2001 demand_empty_rest_of_line ();
2004 /* Handle the .file pseudo-op. This default definition may be overridden by
2005 the object or CPU specific pseudo-ops. */
2008 s_file_string (char *file
)
2012 listing_source_file (file
);
2014 register_dependency (file
);
2016 obj_app_file (file
);
2021 s_file (int ignore ATTRIBUTE_UNUSED
)
2026 /* Some assemblers tolerate immediately following '"'. */
2027 if ((s
= demand_copy_string (&length
)) != 0)
2029 new_logical_line_flags (s
, -1, 1);
2031 /* In MRI mode, the preprocessor may have inserted an extraneous
2034 && *input_line_pointer
== '\''
2035 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
2036 ++input_line_pointer
;
2038 demand_empty_rest_of_line ();
2044 get_linefile_number (int *flag
)
2050 if (*input_line_pointer
< '0' || *input_line_pointer
> '9')
2053 /* Don't mistakenly interpret octal numbers as line numbers. */
2054 if (*input_line_pointer
== '0')
2057 ++input_line_pointer
;
2061 expression_and_evaluate (&exp
);
2062 if (exp
.X_op
!= O_constant
)
2065 #if defined (BFD64) || LONG_MAX > INT_MAX
2066 if (exp
.X_add_number
< INT_MIN
|| exp
.X_add_number
> INT_MAX
)
2070 *flag
= exp
.X_add_number
;
2075 /* Handle the .linefile pseudo-op. This is automatically generated by
2076 do_scrub_chars when a preprocessor # line comment is seen. This
2077 default definition may be overridden by the object or CPU specific
2081 s_linefile (int ignore ATTRIBUTE_UNUSED
)
2084 int linenum
, flags
= 0;
2086 /* The given number is that of the next line. */
2087 if (!get_linefile_number (&linenum
))
2089 ignore_rest_of_line ();
2094 /* Some of the back ends can't deal with non-positive line numbers.
2095 Besides, it's silly. GCC however will generate a line number of
2096 zero when it is pre-processing builtins for assembler-with-cpp files:
2100 We do not want to barf on this, especially since such files are used
2101 in the GCC and GDB testsuites. So we check for negative line numbers
2102 rather than non-positive line numbers. */
2103 as_warn (_("line numbers must be positive; line number %d rejected"),
2111 if (*input_line_pointer
== '"')
2112 file
= demand_copy_string (&length
);
2113 else if (*input_line_pointer
== '.')
2115 /* buffer_and_nest() may insert this form. */
2116 ++input_line_pointer
;
2124 while (get_linefile_number (&this_flag
))
2127 /* From GCC's cpp documentation:
2128 1: start of a new file.
2129 2: returning to a file after having included another file.
2130 3: following text comes from a system header file.
2131 4: following text should be treated as extern "C".
2133 4 is nonsensical for the assembler; 3, we don't care about,
2134 so we ignore it just in case a system header file is
2135 included while preprocessing assembly. So 1 and 2 are all
2136 we care about, and they are mutually incompatible.
2137 new_logical_line_flags() demands this. */
2140 if (flags
&& flags
!= (1 << this_flag
))
2141 as_warn (_("incompatible flag %i in line directive"),
2144 flags
|= 1 << this_flag
;
2149 /* We ignore these. */
2153 as_warn (_("unsupported flag %i in line directive"),
2158 if (!is_end_of_line
[(unsigned char)*input_line_pointer
])
2164 demand_empty_rest_of_line ();
2166 /* read_a_source_file() will bump the line number only if the line
2167 is terminated by '\n'. */
2168 if (input_line_pointer
[-1] == '\n')
2171 new_logical_line_flags (file
, linenum
, flags
);
2174 listing_source_line (linenum
);
2179 ignore_rest_of_line ();
2182 /* Handle the .end pseudo-op. Actually, the real work is done in
2183 read_a_source_file. */
2186 s_end (int ignore ATTRIBUTE_UNUSED
)
2190 /* The MRI assembler permits the start symbol to follow .end,
2191 but we don't support that. */
2193 if (!is_end_of_line
[(unsigned char) *input_line_pointer
]
2194 && *input_line_pointer
!= '*'
2195 && *input_line_pointer
!= '!')
2196 as_warn (_("start address not supported"));
2200 /* Handle the .err pseudo-op. */
2203 s_err (int ignore ATTRIBUTE_UNUSED
)
2205 as_bad (_(".err encountered"));
2206 demand_empty_rest_of_line ();
2209 /* Handle the .error and .warning pseudo-ops. */
2215 /* The purpose for the conditional assignment is not to
2216 internationalize the directive itself, but that we need a
2217 self-contained message, one that can be passed like the
2218 demand_copy_C_string return value, and with no assumption on the
2219 location of the name of the directive within the message. */
2221 = (err
? _(".error directive invoked in source file")
2222 : _(".warning directive invoked in source file"));
2224 if (!is_it_end_of_statement ())
2226 if (*input_line_pointer
!= '\"')
2228 as_bad (_("%s argument must be a string"),
2229 err
? ".error" : ".warning");
2230 ignore_rest_of_line ();
2234 msg
= demand_copy_C_string (&len
);
2242 as_warn ("%s", msg
);
2243 demand_empty_rest_of_line ();
2246 /* Handle the MRI fail pseudo-op. */
2249 s_fail (int ignore ATTRIBUTE_UNUSED
)
2256 stop
= mri_comment_field (&stopc
);
2258 temp
= get_absolute_expression ();
2260 as_warn (_(".fail %ld encountered"), (long) temp
);
2262 as_bad (_(".fail %ld encountered"), (long) temp
);
2264 demand_empty_rest_of_line ();
2267 mri_comment_end (stop
, stopc
);
2271 s_fill (int ignore ATTRIBUTE_UNUSED
)
2273 expressionS rep_exp
;
2278 #ifdef md_flush_pending_output
2279 md_flush_pending_output ();
2282 #ifdef md_cons_align
2286 expression (&rep_exp
);
2287 if (*input_line_pointer
== ',')
2289 input_line_pointer
++;
2290 size
= get_absolute_expression ();
2291 if (*input_line_pointer
== ',')
2293 input_line_pointer
++;
2294 fill
= get_absolute_expression ();
2298 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
2299 #define BSD_FILL_SIZE_CROCK_8 (8)
2300 if (size
> BSD_FILL_SIZE_CROCK_8
)
2302 as_warn (_(".fill size clamped to %d"), BSD_FILL_SIZE_CROCK_8
);
2303 size
= BSD_FILL_SIZE_CROCK_8
;
2307 as_warn (_("size negative; .fill ignored"));
2310 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
2312 if (rep_exp
.X_add_number
< 0)
2313 as_warn (_("repeat < 0; .fill ignored"));
2316 else if (size
&& !need_pass_2
)
2318 if (now_seg
== absolute_section
&& rep_exp
.X_op
!= O_constant
)
2320 as_bad (_("non-constant fill count for absolute section"));
2323 else if (now_seg
== absolute_section
&& fill
&& rep_exp
.X_add_number
!= 0)
2325 as_bad (_("attempt to fill absolute section with non-zero value"));
2329 && (rep_exp
.X_op
!= O_constant
|| rep_exp
.X_add_number
!= 0)
2332 as_bad (_("attempt to fill section `%s' with non-zero value"),
2333 segment_name (now_seg
));
2338 if (size
&& !need_pass_2
)
2340 if (now_seg
== absolute_section
)
2341 abs_section_offset
+= rep_exp
.X_add_number
* size
;
2343 if (rep_exp
.X_op
== O_constant
)
2345 p
= frag_var (rs_fill
, (int) size
, (int) size
,
2346 (relax_substateT
) 0, (symbolS
*) 0,
2347 (offsetT
) rep_exp
.X_add_number
,
2352 /* We don't have a constant repeat count, so we can't use
2353 rs_fill. We can get the same results out of rs_space,
2354 but its argument is in bytes, so we must multiply the
2355 repeat count by size. */
2358 rep_sym
= make_expr_symbol (&rep_exp
);
2361 expressionS size_exp
;
2362 size_exp
.X_op
= O_constant
;
2363 size_exp
.X_add_number
= size
;
2365 rep_exp
.X_op
= O_multiply
;
2366 rep_exp
.X_add_symbol
= rep_sym
;
2367 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
2368 rep_exp
.X_add_number
= 0;
2369 rep_sym
= make_expr_symbol (&rep_exp
);
2372 p
= frag_var (rs_space
, (int) size
, (int) size
,
2373 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
2376 memset (p
, 0, (unsigned int) size
);
2378 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
2379 flavoured AS. The following bizarre behaviour is to be
2380 compatible with above. I guess they tried to take up to 8
2381 bytes from a 4-byte expression and they forgot to sign
2383 #define BSD_FILL_SIZE_CROCK_4 (4)
2384 md_number_to_chars (p
, (valueT
) fill
,
2385 (size
> BSD_FILL_SIZE_CROCK_4
2386 ? BSD_FILL_SIZE_CROCK_4
2388 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
2389 but emits no error message because it seems a legal thing to do.
2390 It is a degenerate case of .fill but could be emitted by a
2393 demand_empty_rest_of_line ();
2397 s_globl (int ignore ATTRIBUTE_UNUSED
)
2406 stop
= mri_comment_field (&stopc
);
2410 if ((name
= read_symbol_name ()) == NULL
)
2413 symbolP
= symbol_find_or_make (name
);
2414 S_SET_EXTERNAL (symbolP
);
2417 c
= *input_line_pointer
;
2420 input_line_pointer
++;
2422 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
2430 demand_empty_rest_of_line ();
2433 mri_comment_end (stop
, stopc
);
2436 /* Handle the MRI IRP and IRPC pseudo-ops. */
2448 file
= as_where (&line
);
2450 eol
= find_end_of_line (input_line_pointer
, 0);
2451 sb_build (&s
, eol
- input_line_pointer
);
2452 sb_add_buffer (&s
, input_line_pointer
, eol
- input_line_pointer
);
2453 input_line_pointer
= eol
;
2457 err
= expand_irp (irpc
, 0, &s
, &out
, get_macro_line_sb
);
2459 as_bad_where (file
, line
, "%s", err
);
2463 input_scrub_include_sb (&out
, input_line_pointer
, expanding_repeat
);
2465 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2468 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
2469 the section to only be linked once. However, this is not supported
2470 by most object file formats. This takes an optional argument,
2471 which is what to do about duplicates. */
2474 s_linkonce (int ignore ATTRIBUTE_UNUSED
)
2476 enum linkonce_type type
;
2480 type
= LINKONCE_DISCARD
;
2482 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2487 c
= get_symbol_name (& s
);
2488 if (strcasecmp (s
, "discard") == 0)
2489 type
= LINKONCE_DISCARD
;
2490 else if (strcasecmp (s
, "one_only") == 0)
2491 type
= LINKONCE_ONE_ONLY
;
2492 else if (strcasecmp (s
, "same_size") == 0)
2493 type
= LINKONCE_SAME_SIZE
;
2494 else if (strcasecmp (s
, "same_contents") == 0)
2495 type
= LINKONCE_SAME_CONTENTS
;
2497 as_warn (_("unrecognized .linkonce type `%s'"), s
);
2499 (void) restore_line_pointer (c
);
2502 #ifdef obj_handle_link_once
2503 obj_handle_link_once (type
);
2504 #else /* ! defined (obj_handle_link_once) */
2508 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
2509 as_warn (_(".linkonce is not supported for this object file format"));
2511 flags
= bfd_section_flags (now_seg
);
2512 flags
|= SEC_LINK_ONCE
;
2517 case LINKONCE_DISCARD
:
2518 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
2520 case LINKONCE_ONE_ONLY
:
2521 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
2523 case LINKONCE_SAME_SIZE
:
2524 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
2526 case LINKONCE_SAME_CONTENTS
:
2527 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
2530 if (!bfd_set_section_flags (now_seg
, flags
))
2531 as_bad (_("bfd_set_section_flags: %s"),
2532 bfd_errmsg (bfd_get_error ()));
2534 #endif /* ! defined (obj_handle_link_once) */
2536 demand_empty_rest_of_line ();
2540 bss_alloc (symbolS
*symbolP
, addressT size
, unsigned int align
)
2543 segT current_seg
= now_seg
;
2544 subsegT current_subseg
= now_subseg
;
2545 segT bss_seg
= bss_section
;
2547 #if defined (TC_MIPS) || defined (TC_ALPHA)
2548 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
2549 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
2551 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
2552 if (size
<= bfd_get_gp_size (stdoutput
))
2554 bss_seg
= subseg_new (".sbss", 1);
2555 seg_info (bss_seg
)->bss
= 1;
2556 if (!bfd_set_section_flags (bss_seg
, SEC_ALLOC
| SEC_SMALL_DATA
))
2557 as_warn (_("error setting flags for \".sbss\": %s"),
2558 bfd_errmsg (bfd_get_error ()));
2562 subseg_set (bss_seg
, 1);
2564 if (align
> OCTETS_PER_BYTE_POWER
)
2566 record_alignment (bss_seg
, align
);
2567 frag_align (align
, 0, 0);
2570 /* Detach from old frag. */
2571 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2572 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2574 symbol_set_frag (symbolP
, frag_now
);
2575 pfrag
= frag_var (rs_org
, 1, 1, 0, symbolP
, size
* OCTETS_PER_BYTE
, NULL
);
2579 S_SET_SIZE (symbolP
, size
);
2581 S_SET_SEGMENT (symbolP
, bss_seg
);
2584 /* The symbol may already have been created with a preceding
2585 ".globl" directive -- be careful not to step on storage class
2586 in that case. Otherwise, set it to static. */
2587 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2588 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2589 #endif /* OBJ_COFF */
2591 subseg_set (current_seg
, current_subseg
);
2595 parse_align (int align_bytes
)
2601 if (*input_line_pointer
!= ',')
2604 as_bad (_("expected alignment after size"));
2605 ignore_rest_of_line ();
2609 input_line_pointer
++;
2612 align
= get_absolute_expr (&exp
);
2613 if (exp
.X_op
== O_absent
)
2616 if (!exp
.X_unsigned
&& exp
.X_add_number
< 0)
2618 as_warn (_("alignment negative; 0 assumed"));
2622 if (align_bytes
&& align
!= 0)
2624 /* convert to a power of 2 alignment */
2625 unsigned int alignp2
= 0;
2626 while ((align
& 1) == 0)
2627 align
>>= 1, ++alignp2
;
2630 as_bad (_("alignment not a power of 2"));
2631 ignore_rest_of_line ();
2639 /* Called from s_comm_internal after symbol name and size have been
2640 parsed. NEEDS_ALIGN is 0 if it was an ".lcomm" (2 args only),
2641 1 if this was a ".bss" directive which has a 3rd argument
2642 (alignment as a power of 2), or 2 if this was a ".bss" directive
2643 with alignment in bytes. */
2646 s_lcomm_internal (int needs_align
, symbolS
*symbolP
, addressT size
)
2652 align
= parse_align (needs_align
- 1);
2653 if (align
== (addressT
) -1)
2657 /* Assume some objects may require alignment on some systems. */
2658 TC_IMPLICIT_LCOMM_ALIGNMENT (size
, align
);
2660 bss_alloc (symbolP
, size
, align
);
2665 s_lcomm (int needs_align
)
2667 s_comm_internal (needs_align
, s_lcomm_internal
);
2671 s_lcomm_bytes (int needs_align
)
2673 s_comm_internal (needs_align
* 2, s_lcomm_internal
);
2677 s_lsym (int ignore ATTRIBUTE_UNUSED
)
2683 /* We permit ANY defined expression: BSD4.2 demands constants. */
2684 if ((name
= read_symbol_name ()) == NULL
)
2687 if (*input_line_pointer
!= ',')
2689 as_bad (_("expected comma after \"%s\""), name
);
2693 input_line_pointer
++;
2694 expression_and_evaluate (&exp
);
2696 if (exp
.X_op
!= O_constant
2697 && exp
.X_op
!= O_register
)
2699 as_bad (_("bad expression"));
2703 symbolP
= symbol_find_or_make (name
);
2705 if (S_GET_SEGMENT (symbolP
) == undefined_section
)
2707 /* The name might be an undefined .global symbol; be sure to
2708 keep the "external" bit. */
2709 S_SET_SEGMENT (symbolP
,
2710 (exp
.X_op
== O_constant
2713 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2717 as_bad (_("symbol `%s' is already defined"), name
);
2720 demand_empty_rest_of_line ();
2725 ignore_rest_of_line ();
2730 /* Read a line into an sb. Returns the character that ended the line
2731 or zero if there are no more lines. */
2734 get_line_sb (sb
*line
, int in_macro
)
2738 if (input_line_pointer
[-1] == '\n')
2739 bump_line_counters ();
2741 if (input_line_pointer
>= buffer_limit
)
2743 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2744 if (buffer_limit
== 0)
2748 eol
= _find_end_of_line (input_line_pointer
, flag_m68k_mri
, 0, in_macro
);
2749 sb_add_buffer (line
, input_line_pointer
, eol
- input_line_pointer
);
2750 input_line_pointer
= eol
;
2752 /* Don't skip multiple end-of-line characters, because that breaks support
2753 for the IA-64 stop bit (;;) which looks like two consecutive end-of-line
2754 characters but isn't. Instead just skip one end of line character and
2755 return the character skipped so that the caller can re-insert it if
2757 return *input_line_pointer
++;
2761 get_non_macro_line_sb (sb
*line
)
2763 return get_line_sb (line
, 0);
2767 get_macro_line_sb (sb
*line
)
2769 return get_line_sb (line
, 1);
2772 /* Define a macro. This is an interface to macro.c. */
2775 s_macro (int ignore ATTRIBUTE_UNUSED
)
2781 eol
= find_end_of_line (input_line_pointer
, 0);
2782 sb_build (&s
, eol
- input_line_pointer
);
2783 sb_add_buffer (&s
, input_line_pointer
, eol
- input_line_pointer
);
2784 input_line_pointer
= eol
;
2786 if (line_label
!= NULL
)
2792 name
= S_GET_NAME (line_label
);
2793 len
= strlen (name
);
2794 sb_build (&label
, len
);
2795 sb_add_buffer (&label
, name
, len
);
2796 macro
= define_macro (&s
, &label
, get_macro_line_sb
);
2800 macro
= define_macro (&s
, NULL
, get_macro_line_sb
);
2803 if (line_label
!= NULL
)
2805 S_SET_SEGMENT (line_label
, absolute_section
);
2806 S_SET_VALUE (line_label
, 0);
2807 symbol_set_frag (line_label
, &zero_address_frag
);
2810 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2811 && str_hash_find (po_hash
, macro
->name
) != NULL
)
2813 && macro
->name
[0] == '.'
2814 && str_hash_find (po_hash
, macro
->name
+ 1) != NULL
))
2816 as_warn_where (macro
->file
, macro
->line
,
2817 _("attempt to redefine pseudo-op `%s' ignored"),
2819 str_hash_delete (macro_hash
, macro
->name
);
2826 /* Handle the .mexit pseudo-op, which immediately exits a macro
2830 s_mexit (int ignore ATTRIBUTE_UNUSED
)
2834 cond_exit_macro (macro_nest
);
2835 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2838 as_warn (_("ignoring macro exit outside a macro definition."));
2841 /* Switch in and out of MRI mode. */
2844 s_mri (int ignore ATTRIBUTE_UNUSED
)
2847 #ifdef MRI_MODE_CHANGE
2851 on
= get_absolute_expression ();
2852 #ifdef MRI_MODE_CHANGE
2853 old_flag
= flag_mri
;
2861 lex_type
['?'] = LEX_BEGIN_NAME
| LEX_NAME
;
2869 lex_type
['?'] = LEX_QM
;
2872 /* Operator precedence changes in m68k MRI mode, so we need to
2873 update the operator rankings. */
2874 expr_set_precedence ();
2876 #ifdef MRI_MODE_CHANGE
2878 MRI_MODE_CHANGE (on
);
2881 demand_empty_rest_of_line ();
2884 /* Handle changing the location counter. */
2887 do_org (segT segment
, expressionS
*exp
, int fill
)
2889 if (segment
!= now_seg
2890 && segment
!= absolute_section
2891 && segment
!= expr_section
)
2892 as_bad (_("invalid segment \"%s\""), segment_name (segment
));
2894 if (now_seg
== absolute_section
)
2897 as_warn (_("ignoring fill value in absolute section"));
2898 if (exp
->X_op
!= O_constant
)
2900 as_bad (_("only constant offsets supported in absolute section"));
2901 exp
->X_add_number
= 0;
2903 abs_section_offset
= exp
->X_add_number
;
2908 symbolS
*sym
= exp
->X_add_symbol
;
2909 offsetT off
= exp
->X_add_number
* OCTETS_PER_BYTE
;
2911 if (fill
&& in_bss ())
2912 as_warn (_("ignoring fill value in section `%s'"),
2913 segment_name (now_seg
));
2915 if (exp
->X_op
!= O_constant
&& exp
->X_op
!= O_symbol
)
2917 /* Handle complex expressions. */
2918 sym
= make_expr_symbol (exp
);
2922 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, sym
, off
, (char *) 0);
2928 s_org (int ignore ATTRIBUTE_UNUSED
)
2934 #ifdef md_flush_pending_output
2935 md_flush_pending_output ();
2938 /* The m68k MRI assembler has a different meaning for .org. It
2939 means to create an absolute section at a given address. We can't
2940 support that--use a linker script instead. */
2943 as_bad (_("MRI style ORG pseudo-op not supported"));
2944 ignore_rest_of_line ();
2948 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2949 thing as a sub-segment-relative origin. Any absolute origin is
2950 given a warning, then assumed to be segment-relative. Any
2951 segmented origin expression ("foo+42") had better be in the right
2952 segment or the .org is ignored.
2954 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2955 we never know sub-segment sizes when we are reading code. BSD
2956 will crash trying to emit negative numbers of filler bytes in
2957 certain .orgs. We don't crash, but see as-write for that code.
2959 Don't make frag if need_pass_2==1. */
2960 segment
= get_known_segmented_expression (&exp
);
2961 if (*input_line_pointer
== ',')
2963 input_line_pointer
++;
2964 temp_fill
= get_absolute_expression ();
2970 do_org (segment
, &exp
, temp_fill
);
2972 demand_empty_rest_of_line ();
2975 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2976 called by the obj-format routine which handles section changing
2977 when in MRI mode. It will create a new section, and return it. It
2978 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2979 'M' (mixed), or 'R' (romable). The flags will be set in the section. */
2982 s_mri_sect (char *type ATTRIBUTE_UNUSED
)
2992 name
= input_line_pointer
;
2993 if (!ISDIGIT (*name
))
2994 c
= get_symbol_name (& name
);
2999 ++input_line_pointer
;
3001 while (ISDIGIT (*input_line_pointer
));
3003 c
= *input_line_pointer
;
3004 *input_line_pointer
= '\0';
3007 name
= xstrdup (name
);
3009 c
= restore_line_pointer (c
);
3011 seg
= subseg_new (name
, 0);
3017 ++input_line_pointer
;
3018 align
= get_absolute_expression ();
3019 record_alignment (seg
, align
);
3023 if (*input_line_pointer
== ',')
3025 c
= *++input_line_pointer
;
3027 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
3030 as_bad (_("unrecognized section type"));
3031 ++input_line_pointer
;
3036 flags
= SEC_NO_FLAGS
;
3038 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
3039 else if (*type
== 'D' || *type
== 'M')
3040 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
3041 else if (*type
== 'R')
3042 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
3043 if (flags
!= SEC_NO_FLAGS
)
3045 if (!bfd_set_section_flags (seg
, flags
))
3046 as_warn (_("error setting flags for \"%s\": %s"),
3047 bfd_section_name (seg
),
3048 bfd_errmsg (bfd_get_error ()));
3053 /* Ignore the HP type. */
3054 if (*input_line_pointer
== ',')
3055 input_line_pointer
+= 2;
3057 demand_empty_rest_of_line ();
3059 #else /* ! TC_M68K */
3060 /* The MRI assembler seems to use different forms of .sect for
3061 different targets. */
3062 as_bad ("MRI mode not supported for this target");
3063 ignore_rest_of_line ();
3064 #endif /* ! TC_M68K */
3067 /* Handle the .print pseudo-op. */
3070 s_print (int ignore ATTRIBUTE_UNUSED
)
3075 s
= demand_copy_C_string (&len
);
3078 demand_empty_rest_of_line ();
3081 /* Handle the .purgem pseudo-op. */
3084 s_purgem (int ignore ATTRIBUTE_UNUSED
)
3086 if (is_it_end_of_statement ())
3088 demand_empty_rest_of_line ();
3098 c
= get_symbol_name (& name
);
3099 delete_macro (name
);
3100 restore_line_pointer (c
);
3103 while (*input_line_pointer
++ == ',');
3105 --input_line_pointer
;
3106 demand_empty_rest_of_line ();
3109 /* Handle the .endm/.endr pseudo-ops. */
3112 s_bad_end (int endr
)
3114 as_warn (_(".end%c encountered without preceding %s"),
3116 endr
? ".rept, .irp, or .irpc" : ".macro");
3117 demand_empty_rest_of_line ();
3120 /* Handle the .rept pseudo-op. */
3123 s_rept (int expand_count
)
3127 count
= (size_t) get_absolute_expression ();
3129 do_repeat (count
, "REPT", "ENDR", expand_count
? "" : NULL
);
3132 /* This function provides a generic repeat block implementation. It allows
3133 different directives to be used as the start/end keys. Any text matching
3134 the optional EXPANDER in the block is replaced by the remaining iteration
3135 count. Except when EXPANDER is the empty string, in which case \+ will
3136 be looked for (as also recognized in macros as well as .irp and .irpc),
3137 where the replacement will be the number of iterations done so far. */
3140 do_repeat (size_t count
, const char *start
, const char *end
,
3141 const char *expander
)
3146 if (((ssize_t
) count
) < 0)
3148 as_bad (_("negative count for %s - ignored"), start
);
3153 if (!buffer_and_nest (start
, end
, &one
, get_non_macro_line_sb
))
3155 as_bad (_("%s without %s"), start
, end
);
3160 sb_terminate (&one
);
3162 if (expander
!= NULL
&& !*expander
&& strstr (one
.ptr
, "\\+") != NULL
)
3164 /* The 3 here and below are arbitrary, added in an attempt to limit
3165 re-allocation needs in sb_add_...() for moderate repeat counts. */
3166 sb_build (&many
, count
* (one
.len
+ 3));
3168 for (size_t done
= 0; count
-- > 0; ++done
)
3170 const char *ptr
, *bs
;
3173 sb_build (&processed
, one
.len
+ 3);
3175 for (ptr
= one
.ptr
; (bs
= strchr (ptr
, '\\')) != NULL
; )
3177 sb_add_buffer (&processed
, ptr
, bs
- ptr
);
3183 sb_add_char (&processed
, '\\');
3184 sb_add_char (&processed
, bs
[1]);
3189 as_warn (_("`\\' at end of line/statement; ignored"));
3194 sb_add_char (&processed
, '\\');
3199 snprintf (scratch
, ARRAY_SIZE (scratch
), "%zu", done
);
3200 sb_add_string (&processed
, scratch
);
3206 sb_add_string (&processed
, ptr
);
3208 sb_add_sb (&many
, &processed
);
3209 sb_kill (&processed
);
3212 else if (expander
== NULL
|| !*expander
|| strstr (one
.ptr
, expander
) == NULL
)
3214 sb_build (&many
, count
* one
.len
);
3216 sb_add_sb (&many
, &one
);
3222 while (count
-- > 0)
3228 sb_build (& processed
, one
.len
);
3229 sb_add_sb (& processed
, & one
);
3230 sub
= strstr (processed
.ptr
, expander
);
3231 len
= sprintf (sub
, "%lu", (unsigned long) count
);
3232 gas_assert (len
< 8);
3233 memmove (sub
+ len
, sub
+ 8,
3234 processed
.ptr
+ processed
.len
- (sub
+ 8));
3235 processed
.len
-= (8 - len
);
3236 sb_add_sb (& many
, & processed
);
3237 sb_kill (& processed
);
3243 input_scrub_include_sb (&many
, input_line_pointer
, expanding_repeat
);
3245 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
3248 /* Skip to end of current repeat loop; EXTRA indicates how many additional
3249 input buffers to skip. Assumes that conditionals preceding the loop end
3250 are properly nested.
3252 This function makes it easier to implement a premature "break" out of the
3253 loop. The EXTRA arg accounts for other buffers we might have inserted,
3254 such as line substitutions. */
3257 end_repeat (int extra
)
3259 cond_exit_macro (macro_nest
);
3260 while (extra
-- >= 0)
3261 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
3265 assign_symbol (char *name
, int mode
)
3269 if (name
[0] == '.' && name
[1] == '\0')
3271 /* Turn '. = mumble' into a .org mumble. */
3275 segment
= get_known_segmented_expression (&exp
);
3278 do_org (segment
, &exp
, 0);
3283 if ((symbolP
= symbol_find (name
)) == NULL
3284 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
3286 symbolP
= symbol_find_or_make (name
);
3288 /* When doing symbol listings, play games with dummy fragments living
3289 outside the normal fragment chain to record the file and line info
3291 if (listing
& LISTING_SYMBOLS
)
3293 extern struct list_info_struct
*listing_tail
;
3294 fragS
*dummy_frag
= notes_calloc (1, sizeof (*dummy_frag
));
3295 dummy_frag
->line
= listing_tail
;
3296 dummy_frag
->fr_symbol
= symbolP
;
3297 symbol_set_frag (symbolP
, dummy_frag
);
3300 #ifdef obj_assign_symbol
3301 obj_assign_symbol (symbolP
);
3305 if (S_IS_DEFINED (symbolP
) || symbol_equated_p (symbolP
))
3307 if ((mode
!= 0 || !S_IS_VOLATILE (symbolP
))
3308 && !S_CAN_BE_REDEFINED (symbolP
))
3310 as_bad (_("symbol `%s' is already defined"), name
);
3311 ignore_rest_of_line ();
3312 input_line_pointer
--;
3315 /* If the symbol is volatile, copy the symbol and replace the
3316 original with the copy, so that previous uses of the symbol will
3317 retain the value of the symbol at the point of use. */
3318 else if (S_IS_VOLATILE (symbolP
))
3319 symbolP
= symbol_clone (symbolP
, 1);
3323 S_SET_VOLATILE (symbolP
);
3325 S_SET_FORWARD_REF (symbolP
);
3327 pseudo_set (symbolP
);
3330 /* Handle the .equ, .equiv, .eqv, and .set directives. If EQUIV is 1,
3331 then this is .equiv, and it is an error if the symbol is already
3332 defined. If EQUIV is -1, the symbol additionally is a forward
3340 /* Especial apologies for the random logic:
3341 this just grew, and could be parsed much more simply!
3343 if ((name
= read_symbol_name ()) == NULL
)
3346 if (*input_line_pointer
!= ',')
3348 as_bad (_("expected comma after \"%s\""), name
);
3349 ignore_rest_of_line ();
3354 input_line_pointer
++;
3355 assign_symbol (name
, equiv
);
3356 demand_empty_rest_of_line ();
3370 #ifdef md_flush_pending_output
3371 md_flush_pending_output ();
3378 # ifndef P_PRECISION
3379 # define P_PRECISION X_PRECISION
3380 # define P_PRECISION_PAD X_PRECISION_PAD
3382 mult
= (X_PRECISION
+ X_PRECISION_PAD
) * sizeof (LITTLENUM_TYPE
);
3390 mult
= (P_PRECISION
+ P_PRECISION_PAD
) * sizeof (LITTLENUM_TYPE
);
3397 #ifdef md_cons_align
3402 stop
= mri_comment_field (&stopc
);
3404 /* In m68k MRI mode, we need to align to a word boundary, unless
3406 if (flag_m68k_mri
&& mult
> 1)
3408 if (now_seg
== absolute_section
)
3410 abs_section_offset
+= abs_section_offset
& 1;
3411 if (line_label
!= NULL
)
3412 S_SET_VALUE (line_label
, abs_section_offset
);
3414 else if (mri_common_symbol
!= NULL
)
3418 mri_val
= S_GET_VALUE (mri_common_symbol
);
3419 if ((mri_val
& 1) != 0)
3421 S_SET_VALUE (mri_common_symbol
, mri_val
+ 1);
3422 if (line_label
!= NULL
)
3424 expressionS
*symexp
;
3426 symexp
= symbol_get_value_expression (line_label
);
3427 know (symexp
->X_op
== O_symbol
);
3428 know (symexp
->X_add_symbol
== mri_common_symbol
);
3429 symexp
->X_add_number
+= 1;
3435 do_align (1, (char *) NULL
, 0, 0);
3436 if (line_label
!= NULL
)
3438 symbol_set_frag (line_label
, frag_now
);
3439 S_SET_VALUE (line_label
, frag_now_fix ());
3449 if (*input_line_pointer
== ',')
3451 ++input_line_pointer
;
3456 val
.X_op
= O_constant
;
3457 val
.X_add_number
= 0;
3460 if ((val
.X_op
!= O_constant
3461 || val
.X_add_number
< - 0x80
3462 || val
.X_add_number
> 0xff
3463 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
3464 && (now_seg
!= absolute_section
&& !in_bss ()))
3466 resolve_expression (&exp
);
3467 if (exp
.X_op
!= O_constant
)
3468 as_bad (_("unsupported variable size or fill value"));
3473 /* PR 20901: Check for excessive values.
3474 FIXME: 1<<10 is an arbitrary limit. Maybe use maxpagesize instead ? */
3475 if (exp
.X_add_number
< 0 || exp
.X_add_number
> (1 << 10))
3476 as_bad (_("size value for space directive too large: %lx"),
3477 (long) exp
.X_add_number
);
3482 bytes
= mult
* exp
.X_add_number
;
3484 for (i
= 0; i
< exp
.X_add_number
; i
++)
3485 emit_expr (&val
, mult
);
3491 if (now_seg
== absolute_section
|| mri_common_symbol
!= NULL
)
3492 resolve_expression (&exp
);
3494 if (exp
.X_op
== O_constant
)
3496 addressT repeat
= exp
.X_add_number
;
3500 if ((offsetT
) repeat
< 0)
3502 as_warn (_(".space repeat count is negative, ignored"));
3508 as_warn (_(".space repeat count is zero, ignored"));
3511 if ((unsigned int) mult
<= 1)
3513 else if (gas_mul_overflow (repeat
, mult
, &total
)
3514 || (offsetT
) total
< 0)
3516 as_warn (_(".space repeat count overflow, ignored"));
3521 /* If we are in the absolute section, just bump the offset. */
3522 if (now_seg
== absolute_section
)
3524 if (val
.X_op
!= O_constant
|| val
.X_add_number
!= 0)
3525 as_warn (_("ignoring fill value in absolute section"));
3526 abs_section_offset
+= total
;
3530 /* If we are secretly in an MRI common section, then
3531 creating space just increases the size of the common
3533 if (mri_common_symbol
!= NULL
)
3535 S_SET_VALUE (mri_common_symbol
,
3536 S_GET_VALUE (mri_common_symbol
) + total
);
3541 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
3542 (offsetT
) total
, (char *) 0);
3546 if (now_seg
== absolute_section
)
3548 as_bad (_("space allocation too complex in absolute section"));
3549 subseg_set (text_section
, 0);
3552 if (mri_common_symbol
!= NULL
)
3554 as_bad (_("space allocation too complex in common section"));
3555 mri_common_symbol
= NULL
;
3559 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
3560 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
3563 if ((val
.X_op
!= O_constant
|| val
.X_add_number
!= 0) && in_bss ())
3564 as_warn (_("ignoring fill value in section `%s'"),
3565 segment_name (now_seg
));
3567 *p
= val
.X_add_number
;
3572 /* In MRI mode, after an odd number of bytes, we must align to an
3573 even word boundary, unless the next instruction is a dc.b, ds.b
3575 if (flag_mri
&& (bytes
& 1) != 0)
3576 mri_pending_align
= 1;
3578 demand_empty_rest_of_line ();
3581 mri_comment_end (stop
, stopc
);
3585 s_nop (int ignore ATTRIBUTE_UNUSED
)
3592 #ifdef md_flush_pending_output
3593 md_flush_pending_output ();
3598 demand_empty_rest_of_line ();
3601 start_off
= frag_now_fix ();
3604 #ifdef md_emit_single_noop
3605 md_emit_single_noop
;
3609 #ifndef md_single_noop_insn
3610 #define md_single_noop_insn "nop"
3612 /* md_assemble might modify its argument, so
3613 we must pass it a string that is writable. */
3614 nop
= xasprintf ("%s", md_single_noop_insn
);
3616 /* Some targets assume that they can update input_line_pointer
3617 inside md_assemble, and, worse, that they can leave it
3618 assigned to the string pointer that was provided as an
3619 argument. So preserve ilp here. */
3620 char *saved_ilp
= input_line_pointer
;
3622 input_line_pointer
= saved_ilp
;
3625 #ifdef md_flush_pending_output
3626 md_flush_pending_output ();
3628 } while (exp
.X_op
== O_constant
3629 && exp
.X_add_number
> 0
3630 && frag_offset_ignore_align_p (start
, frag_now
, &frag_off
)
3631 && frag_off
+ frag_now_fix () < start_off
+ exp
.X_add_number
);
3635 s_nops (int ignore ATTRIBUTE_UNUSED
)
3640 #ifdef md_flush_pending_output
3641 md_flush_pending_output ();
3646 /* Note - this expression is tested for an absolute value in
3647 write.c:relax_segment(). */
3650 if (*input_line_pointer
== ',')
3652 ++input_line_pointer
;
3657 val
.X_op
= O_constant
;
3658 val
.X_add_number
= 0;
3661 if (val
.X_op
!= O_constant
)
3663 as_bad (_("unsupported variable nop control in .nops directive"));
3664 val
.X_op
= O_constant
;
3665 val
.X_add_number
= 0;
3667 else if (val
.X_add_number
< 0)
3669 as_warn (_("negative nop control byte, ignored"));
3670 val
.X_add_number
= 0;
3673 demand_empty_rest_of_line ();
3676 /* Ignore this directive if we are going to perform a second pass. */
3679 /* Store the no-op instruction control byte in the first byte of frag. */
3681 symbolS
*sym
= make_expr_symbol (&exp
);
3682 p
= frag_var (rs_space_nop
, 1, 1, (relax_substateT
) 0,
3683 sym
, (offsetT
) 0, (char *) 0);
3684 *p
= val
.X_add_number
;
3687 /* Obtain the size of a floating point number, given a type. */
3690 float_length (int float_type
, int *pad_p
)
3692 int length
, pad
= 0;
3720 length
= X_PRECISION
* sizeof (LITTLENUM_TYPE
);
3721 pad
= X_PRECISION_PAD
* sizeof (LITTLENUM_TYPE
);
3730 length
= P_PRECISION
* sizeof (LITTLENUM_TYPE
);
3731 pad
= P_PRECISION_PAD
* sizeof (LITTLENUM_TYPE
);
3738 as_bad (_("unknown floating type '%c'"), float_type
);
3750 parse_one_float (int float_type
, char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
])
3756 /* Skip any 0{letter} that may be present. Don't even check if the
3757 letter is legal. Someone may invent a "z" format and this routine
3758 has no use for such information. Lusers beware: you get
3759 diagnostics if your input is ill-conditioned. */
3760 if (input_line_pointer
[0] == '0'
3761 && ISALPHA (input_line_pointer
[1]))
3762 input_line_pointer
+= 2;
3764 /* Accept :xxxx, where the x's are hex digits, for a floating point
3765 with the exact digits specified. */
3766 if (input_line_pointer
[0] == ':')
3768 ++input_line_pointer
;
3769 length
= hex_float (float_type
, temp
);
3772 ignore_rest_of_line ();
3780 err
= md_atof (float_type
, temp
, &length
);
3781 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3782 know (err
!= NULL
|| length
> 0);
3785 as_bad (_("bad floating literal: %s"), err
);
3786 ignore_rest_of_line ();
3794 /* This is like s_space, but the value is a floating point number with
3795 the given precision. This is for the MRI dcb.s pseudo-op and
3799 s_float_space (int float_type
)
3803 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3807 #ifdef md_cons_align
3812 stop
= mri_comment_field (&stopc
);
3814 count
= get_absolute_expression ();
3817 if (*input_line_pointer
!= ',')
3821 flen
= float_length (float_type
, &pad
);
3823 memset (temp
, 0, flen
+= pad
);
3827 ++input_line_pointer
;
3829 flen
= parse_one_float (float_type
, temp
);
3835 mri_comment_end (stop
, stopc
);
3839 while (--count
>= 0)
3843 p
= frag_more (flen
);
3844 memcpy (p
, temp
, (unsigned int) flen
);
3847 demand_empty_rest_of_line ();
3850 mri_comment_end (stop
, stopc
);
3853 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3856 s_struct (int ignore ATTRIBUTE_UNUSED
)
3862 stop
= mri_comment_field (&stopc
);
3863 abs_section_offset
= get_absolute_expression ();
3864 #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
3865 /* The ELF backend needs to know that we are changing sections, so
3866 that .previous works correctly. */
3868 obj_elf_section_change_hook ();
3870 subseg_set (absolute_section
, 0);
3871 demand_empty_rest_of_line ();
3873 mri_comment_end (stop
, stopc
);
3877 s_text (int ignore ATTRIBUTE_UNUSED
)
3881 temp
= get_absolute_expression ();
3882 subseg_set (text_section
, (subsegT
) temp
);
3883 demand_empty_rest_of_line ();
3886 /* .weakref x, y sets x as an alias to y that, as long as y is not
3887 referenced directly, will cause y to become a weak symbol. */
3889 s_weakref (int ignore ATTRIBUTE_UNUSED
)
3896 if ((name
= read_symbol_name ()) == NULL
)
3899 symbolP
= symbol_find_or_make (name
);
3901 if (S_IS_DEFINED (symbolP
) || symbol_equated_p (symbolP
))
3903 if (!S_IS_VOLATILE (symbolP
))
3905 as_bad (_("symbol `%s' is already defined"), name
);
3908 symbolP
= symbol_clone (symbolP
, 1);
3909 S_CLEAR_VOLATILE (symbolP
);
3914 if (*input_line_pointer
!= ',')
3916 as_bad (_("expected comma after \"%s\""), name
);
3920 input_line_pointer
++;
3925 if ((name
= read_symbol_name ()) == NULL
)
3928 if ((symbolP2
= symbol_find_noref (name
, 1)) == NULL
3929 && (symbolP2
= md_undefined_symbol (name
)) == NULL
)
3931 symbolP2
= symbol_find_or_make (name
);
3932 S_SET_WEAKREFD (symbolP2
);
3936 symbolS
*symp
= symbolP2
;
3938 while (S_IS_WEAKREFR (symp
) && symp
!= symbolP
)
3940 expressionS
*expP
= symbol_get_value_expression (symp
);
3942 gas_assert (expP
->X_op
== O_symbol
3943 && expP
->X_add_number
== 0);
3944 symp
= expP
->X_add_symbol
;
3946 if (symp
== symbolP
)
3950 loop
= concat (S_GET_NAME (symbolP
),
3951 " => ", S_GET_NAME (symbolP2
), (const char *) NULL
);
3954 while (symp
!= symbolP
)
3956 char *old_loop
= loop
;
3958 symp
= symbol_get_value_expression (symp
)->X_add_symbol
;
3959 loop
= concat (loop
, " => ", S_GET_NAME (symp
),
3960 (const char *) NULL
);
3964 as_bad (_("%s: would close weakref loop: %s"),
3965 S_GET_NAME (symbolP
), loop
);
3969 ignore_rest_of_line ();
3973 /* Short-circuiting instead of just checking here might speed
3974 things up a tiny little bit, but loop error messages would
3975 miss intermediate links. */
3976 /* symbolP2 = symp; */
3979 memset (&exp
, 0, sizeof (exp
));
3980 exp
.X_op
= O_symbol
;
3981 exp
.X_add_symbol
= symbolP2
;
3983 S_SET_SEGMENT (symbolP
, undefined_section
);
3984 symbol_set_value_expression (symbolP
, &exp
);
3985 symbol_set_frag (symbolP
, &zero_address_frag
);
3986 S_SET_WEAKREFR (symbolP
);
3988 demand_empty_rest_of_line ();
3993 ignore_rest_of_line ();
3999 /* Verify that we are at the end of a line. If not, issue an error and
4000 skip to EOL. This function may leave input_line_pointer one past
4001 buffer_limit, so should not be called from places that may
4002 dereference input_line_pointer unconditionally. Note that when the
4003 gas parser is switched to handling a string (where buffer_limit
4004 should be the size of the string excluding the NUL terminator) this
4005 will be one past the NUL; is_end_of_line(0) returns true. */
4008 demand_empty_rest_of_line (void)
4011 if (input_line_pointer
> buffer_limit
)
4013 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
4014 input_line_pointer
++;
4017 if (ISPRINT (*input_line_pointer
))
4018 as_bad (_("junk at end of line, first unrecognized character is `%c'"),
4019 *input_line_pointer
);
4021 as_bad (_("junk at end of line, first unrecognized character valued 0x%x"),
4022 *input_line_pointer
);
4023 ignore_rest_of_line ();
4025 /* Return pointing just after end-of-line. */
4028 /* Silently advance to the end of a statement. Use this after already having
4029 issued an error about something bad. Like demand_empty_rest_of_line,
4030 this function may leave input_line_pointer one after buffer_limit;
4031 Don't call it from within expression parsing code in an attempt to
4032 silence further errors. */
4035 ignore_rest_of_line (void)
4037 while (input_line_pointer
<= buffer_limit
)
4038 if (is_end_of_stmt (*input_line_pointer
++))
4040 /* Return pointing just after end-of-statement. */
4043 /* Sets frag for given symbol to zero_address_frag, except when the
4044 symbol frag is already set to a dummy listing frag. */
4047 set_zero_frag (symbolS
*symbolP
)
4049 if (symbol_get_frag (symbolP
)->fr_type
!= rs_dummy
)
4050 symbol_set_frag (symbolP
, &zero_address_frag
);
4053 /* In: Pointer to a symbol.
4054 Input_line_pointer->expression.
4056 Out: Input_line_pointer->just after any whitespace after expression.
4057 Tried to set symbol to value of expression.
4058 Will change symbols type, value, and frag; */
4061 pseudo_set (symbolS
*symbolP
)
4066 know (symbolP
); /* NULL pointer is logic error. */
4068 if (!S_IS_FORWARD_REF (symbolP
))
4069 (void) expression (&exp
);
4071 (void) deferred_expression (&exp
);
4073 if (exp
.X_op
== O_illegal
)
4074 as_bad (_("illegal expression"));
4075 else if (exp
.X_op
== O_absent
)
4076 as_bad (_("missing expression"));
4077 else if (exp
.X_op
== O_big
)
4079 if (exp
.X_add_number
> 0)
4080 as_bad (_("bignum invalid"));
4082 as_bad (_("floating point number invalid"));
4084 else if (exp
.X_op
== O_subtract
4085 && !S_IS_FORWARD_REF (symbolP
)
4086 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
4087 && (symbol_get_frag (exp
.X_add_symbol
)
4088 == symbol_get_frag (exp
.X_op_symbol
)))
4090 exp
.X_op
= O_constant
;
4091 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
4092 - S_GET_VALUE (exp
.X_op_symbol
));
4095 if (symbol_section_p (symbolP
))
4097 as_bad ("attempt to set value of section symbol");
4106 exp
.X_add_number
= 0;
4109 S_SET_SEGMENT (symbolP
, absolute_section
);
4110 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
4111 set_zero_frag (symbolP
);
4115 #ifndef TC_GLOBAL_REGISTER_SYMBOL_OK
4116 if (S_IS_EXTERNAL (symbolP
))
4118 as_bad ("can't equate global symbol `%s' with register name",
4119 S_GET_NAME (symbolP
));
4123 /* Make sure symbol_equated_p() recognizes the symbol as an equate. */
4124 exp
.X_add_symbol
= make_expr_symbol (&exp
);
4125 exp
.X_add_number
= 0;
4126 exp
.X_op
= O_symbol
;
4127 symbol_set_value_expression (symbolP
, &exp
);
4128 S_SET_SEGMENT (symbolP
, reg_section
);
4129 set_zero_frag (symbolP
);
4133 seg
= S_GET_SEGMENT (exp
.X_add_symbol
);
4134 /* For x=undef+const, create an expression symbol.
4135 For x=x+const, just update x except when x is an undefined symbol
4136 For x=defined+const, evaluate x. */
4137 if (symbolP
== exp
.X_add_symbol
4138 && (seg
!= undefined_section
4139 || !symbol_constant_p (symbolP
)))
4141 *symbol_X_add_number (symbolP
) += exp
.X_add_number
;
4144 else if (!S_IS_FORWARD_REF (symbolP
) && seg
!= undefined_section
)
4146 symbolS
*s
= exp
.X_add_symbol
;
4148 if (S_IS_COMMON (s
))
4149 as_bad (_("`%s' can't be equated to common symbol `%s'"),
4150 S_GET_NAME (symbolP
), S_GET_NAME (s
));
4152 S_SET_SEGMENT (symbolP
, seg
);
4153 S_SET_VALUE (symbolP
, exp
.X_add_number
+ S_GET_VALUE (s
));
4154 symbol_set_frag (symbolP
, symbol_get_frag (s
));
4155 copy_symbol_attributes (symbolP
, s
);
4158 S_SET_SEGMENT (symbolP
, undefined_section
);
4159 symbol_set_value_expression (symbolP
, &exp
);
4160 copy_symbol_attributes (symbolP
, exp
.X_add_symbol
);
4161 set_zero_frag (symbolP
);
4165 /* The value is some complex expression. */
4166 S_SET_SEGMENT (symbolP
, expr_section
);
4167 symbol_set_value_expression (symbolP
, &exp
);
4168 set_zero_frag (symbolP
);
4175 CONStruct more frag of .bytes, or .words etc.
4176 Should need_pass_2 be 1 then emit no frag(s).
4177 This understands EXPRESSIONS.
4181 This has a split personality. We use expression() to read the
4182 value. We can detect if the value won't fit in a byte or word.
4183 But we can't detect if expression() discarded significant digits
4184 in the case of a long. Not worth the crocks required to fix it. */
4186 /* Select a parser for cons expressions. */
4188 /* Some targets need to parse the expression in various fancy ways.
4189 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
4190 (for example, the HPPA does this). Otherwise, you can define
4191 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
4192 are defined, which is the normal case, then only simple expressions
4197 parse_mri_cons (expressionS
*exp
, unsigned int nbytes
);
4200 #ifndef TC_PARSE_CONS_EXPRESSION
4201 #ifdef REPEAT_CONS_EXPRESSIONS
4202 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) \
4203 (parse_repeat_cons (EXP, NBYTES), TC_PARSE_CONS_RETURN_NONE)
4205 parse_repeat_cons (expressionS
*exp
, unsigned int nbytes
);
4208 /* If we haven't gotten one yet, just call expression. */
4209 #ifndef TC_PARSE_CONS_EXPRESSION
4210 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) \
4211 (expression (EXP), TC_PARSE_CONS_RETURN_NONE)
4216 do_parse_cons_expression (expressionS
*exp
,
4217 int nbytes ATTRIBUTE_UNUSED
)
4219 (void) TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
4223 /* Worker to do .byte etc statements.
4224 Clobbers input_line_pointer and checks end-of-line. */
4227 cons_worker (int nbytes
, /* 1=.byte, 2=.word, 4=.long. */
4235 #ifdef md_flush_pending_output
4236 md_flush_pending_output ();
4240 stop
= mri_comment_field (&stopc
);
4242 if (is_it_end_of_statement ())
4244 demand_empty_rest_of_line ();
4246 mri_comment_end (stop
, stopc
);
4251 nbytes
= TC_ADDRESS_BYTES ();
4253 #ifdef md_cons_align
4254 md_cons_align (nbytes
);
4260 TC_PARSE_CONS_RETURN_TYPE ret
= TC_PARSE_CONS_RETURN_NONE
;
4261 #ifdef TC_CONS_FIX_CHECK
4262 fixS
**cur_fix
= &frchain_now
->fix_tail
;
4264 if (*cur_fix
!= NULL
)
4265 cur_fix
= &(*cur_fix
)->fx_next
;
4270 parse_mri_cons (&exp
, (unsigned int) nbytes
);
4275 if (*input_line_pointer
== '"')
4277 as_bad (_("unexpected `\"' in expression"));
4278 ignore_rest_of_line ();
4282 ret
= TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
4287 if (exp
.X_op
== O_symbol
)
4288 exp
.X_op
= O_symbol_rva
;
4290 as_fatal (_("rva without symbol"));
4292 emit_expr_with_reloc (&exp
, (unsigned int) nbytes
, ret
);
4293 #ifdef TC_CONS_FIX_CHECK
4294 TC_CONS_FIX_CHECK (&exp
, nbytes
, *cur_fix
);
4298 while (*input_line_pointer
++ == ',');
4300 /* In MRI mode, after an odd number of bytes, we must align to an
4301 even word boundary, unless the next instruction is a dc.b, ds.b
4303 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
4304 mri_pending_align
= 1;
4306 input_line_pointer
--; /* Put terminator back into stream. */
4308 demand_empty_rest_of_line ();
4311 mri_comment_end (stop
, stopc
);
4313 /* Disallow hand-crafting instructions using .byte. FIXME - what about
4314 .word, .long etc ? */
4315 if (flag_synth_cfi
&& frchain_now
&& frchain_now
->frch_ginsn_data
4317 as_bad (_("SCFI: hand-crafting instructions not supported"));
4323 cons_worker (size
, 0);
4329 cons_worker (size
, 1);
4332 /* .reloc offset, reloc_name, symbol+addend. */
4335 s_reloc (int ignore ATTRIBUTE_UNUSED
)
4342 struct reloc_list
*reloc
;
4343 struct _bfd_rel
{ const char * name
; bfd_reloc_code_real_type code
; };
4344 static const struct _bfd_rel bfd_relocs
[] =
4346 { "NONE", BFD_RELOC_NONE
},
4347 { "8", BFD_RELOC_8
},
4348 { "16", BFD_RELOC_16
},
4349 { "32", BFD_RELOC_32
},
4350 { "64", BFD_RELOC_64
}
4353 reloc
= XNEW (struct reloc_list
);
4356 stop
= mri_comment_field (&stopc
);
4365 as_bad (_("missing or bad offset expression"));
4368 exp
.X_add_symbol
= section_symbol (now_seg
);
4369 /* Mark the section symbol used in relocation so that it will be
4370 included in the symbol table. */
4371 symbol_mark_used_in_reloc (exp
.X_add_symbol
);
4372 exp
.X_op
= O_symbol
;
4375 if (exp
.X_add_number
== 0)
4377 reloc
->u
.a
.offset_sym
= exp
.X_add_symbol
;
4382 reloc
->u
.a
.offset_sym
= make_expr_symbol (&exp
);
4387 if (*input_line_pointer
!= ',')
4389 as_bad (_("missing reloc type"));
4393 ++input_line_pointer
;
4395 c
= get_symbol_name (& r_name
);
4396 if (strncasecmp (r_name
, "BFD_RELOC_", 10) == 0)
4400 for (reloc
->u
.a
.howto
= NULL
, i
= 0; i
< ARRAY_SIZE (bfd_relocs
); i
++)
4401 if (strcasecmp (r_name
+ 10, bfd_relocs
[i
].name
) == 0)
4403 reloc
->u
.a
.howto
= bfd_reloc_type_lookup (stdoutput
,
4404 bfd_relocs
[i
].code
);
4409 reloc
->u
.a
.howto
= bfd_reloc_name_lookup (stdoutput
, r_name
);
4410 restore_line_pointer (c
);
4411 if (reloc
->u
.a
.howto
== NULL
)
4413 as_bad (_("unrecognized reloc type"));
4417 exp
.X_op
= O_absent
;
4419 if (*input_line_pointer
== ',')
4421 ++input_line_pointer
;
4429 as_bad (_("bad reloc expression"));
4431 ignore_rest_of_line ();
4434 mri_comment_end (stop
, stopc
);
4437 reloc
->u
.a
.sym
= NULL
;
4438 reloc
->u
.a
.addend
= 0;
4441 reloc
->u
.a
.sym
= NULL
;
4442 reloc
->u
.a
.addend
= exp
.X_add_number
;
4445 reloc
->u
.a
.sym
= exp
.X_add_symbol
;
4446 reloc
->u
.a
.addend
= exp
.X_add_number
;
4449 reloc
->u
.a
.sym
= make_expr_symbol (&exp
);
4450 reloc
->u
.a
.addend
= 0;
4454 reloc
->file
= as_where (&reloc
->line
);
4455 reloc
->next
= reloc_list
;
4458 demand_empty_rest_of_line ();
4460 mri_comment_end (stop
, stopc
);
4463 /* Put the contents of expression EXP into the object file using
4464 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
4467 emit_expr (expressionS
*exp
, unsigned int nbytes
)
4469 emit_expr_with_reloc (exp
, nbytes
, TC_PARSE_CONS_RETURN_NONE
);
4473 emit_expr_with_reloc (expressionS
*exp
,
4474 unsigned int nbytes
,
4475 TC_PARSE_CONS_RETURN_TYPE reloc
)
4479 valueT extra_digit
= 0;
4481 /* Don't do anything if we are going to make another pass. */
4486 dot_value
= frag_now_fix ();
4487 dot_frag
= frag_now
;
4491 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
4492 appear as a four byte positive constant in the .line section,
4493 followed by a 2 byte 0xffff. Look for that case here. */
4494 if (strcmp (segment_name (now_seg
), ".line") != 0)
4496 else if (dwarf_line
>= 0
4498 && exp
->X_op
== O_constant
4499 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
4500 listing_source_line ((unsigned int) dwarf_line
);
4501 else if (nbytes
== 4
4502 && exp
->X_op
== O_constant
4503 && exp
->X_add_number
>= 0)
4504 dwarf_line
= exp
->X_add_number
;
4508 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
4509 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
4510 AT_sibling (0x12) followed by a four byte address of the sibling
4511 followed by a 2 byte AT_name (0x38) followed by the name of the
4512 file. We look for that case here. */
4513 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4515 else if (dwarf_file
== 0
4517 && exp
->X_op
== O_constant
4518 && exp
->X_add_number
== 0x11)
4520 else if (dwarf_file
== 1
4522 && exp
->X_op
== O_constant
4523 && exp
->X_add_number
== 0x12)
4525 else if (dwarf_file
== 2
4528 else if (dwarf_file
== 3
4530 && exp
->X_op
== O_constant
4531 && exp
->X_add_number
== 0x38)
4536 /* The variable dwarf_file_string tells stringer that the string
4537 may be the name of the source file. */
4538 if (dwarf_file
== 4)
4539 dwarf_file_string
= 1;
4541 dwarf_file_string
= 0;
4545 if (check_eh_frame (exp
, &nbytes
))
4550 /* Handle a negative bignum. */
4552 && exp
->X_add_number
== 0
4553 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
4554 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
4557 unsigned long carry
;
4559 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
4561 /* Negate the bignum: one's complement each digit and add 1. */
4563 for (i
= 0; i
< exp
->X_add_number
; i
++)
4567 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
4570 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
4571 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
4574 /* We can ignore any carry out, because it will be handled by
4575 extra_digit if it is needed. */
4577 extra_digit
= (valueT
) -1;
4581 if (op
== O_absent
|| op
== O_illegal
)
4583 as_warn (_("zero assumed for missing expression"));
4584 exp
->X_add_number
= 0;
4587 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4589 as_bad (_("floating point number invalid"));
4590 exp
->X_add_number
= 0;
4593 else if (op
== O_register
)
4595 as_warn (_("register value used as expression"));
4599 /* Allow `.word 0' in the absolute section. */
4600 if (now_seg
== absolute_section
)
4602 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
4603 as_bad (_("attempt to store value in absolute section"));
4604 abs_section_offset
+= nbytes
;
4608 /* Allow `.word 0' in BSS style sections. */
4609 if ((op
!= O_constant
|| exp
->X_add_number
!= 0) && in_bss ())
4610 as_bad (_("attempt to store non-zero value in section `%s'"),
4611 segment_name (now_seg
));
4613 p
= frag_more ((int) nbytes
);
4615 if (reloc
!= TC_PARSE_CONS_RETURN_NONE
)
4617 emit_expr_fix (exp
, nbytes
, frag_now
, p
, reloc
);
4621 #ifndef WORKING_DOT_WORD
4622 /* If we have the difference of two symbols in a word, save it on
4623 the broken_words list. See the code in write.c. */
4624 if (op
== O_subtract
&& nbytes
== 2)
4626 struct broken_word
*x
;
4628 x
= XNEW (struct broken_word
);
4629 x
->next_broken_word
= broken_words
;
4632 x
->subseg
= now_subseg
;
4634 x
->word_goes_here
= p
;
4636 x
->add
= exp
->X_add_symbol
;
4637 x
->sub
= exp
->X_op_symbol
;
4638 x
->addnum
= exp
->X_add_number
;
4646 /* If we have an integer, but the number of bytes is too large to
4647 pass to md_number_to_chars, handle it as a bignum. */
4648 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
4650 extra_digit
= exp
->X_unsigned
? 0 : -1;
4651 convert_to_bignum (exp
, !exp
->X_unsigned
);
4655 if (op
== O_constant
)
4662 /* JF << of >= number of bits in the object is undefined. In
4663 particular SPARC (Sun 4) has problems. */
4664 if (nbytes
>= sizeof (valueT
))
4666 know (nbytes
== sizeof (valueT
));
4671 /* Don't store these bits. */
4672 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
4675 unmask
= ~mask
; /* Do store these bits. */
4678 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
4679 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
4682 get
= exp
->X_add_number
;
4684 if ((get
& mask
) != 0 && (-get
& mask
) != 0)
4686 /* Leading bits contain both 0s & 1s. */
4687 as_warn (_("value 0x%" PRIx64
" truncated to 0x%" PRIx64
),
4688 (uint64_t) get
, (uint64_t) use
);
4690 /* Put bytes in right order. */
4691 md_number_to_chars (p
, use
, (int) nbytes
);
4693 else if (op
== O_big
)
4696 LITTLENUM_TYPE
*nums
;
4698 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
4701 int i
= nbytes
/ CHARS_PER_LITTLENUM
;
4705 LITTLENUM_TYPE sign
= 0;
4706 if ((generic_bignum
[--i
]
4707 & (1 << (LITTLENUM_NUMBER_OF_BITS
- 1))) != 0)
4708 sign
= ~(LITTLENUM_TYPE
) 0;
4710 while (++i
< exp
->X_add_number
)
4711 if (generic_bignum
[i
] != sign
)
4714 else if (nbytes
== 1)
4716 /* We have nbytes == 1 and CHARS_PER_LITTLENUM == 2 (probably).
4717 Check that bits 8.. of generic_bignum[0] match bit 7
4718 and that they match all of generic_bignum[1..exp->X_add_number]. */
4719 LITTLENUM_TYPE sign
= (generic_bignum
[0] & (1 << 7)) ? -1 : 0;
4720 LITTLENUM_TYPE himask
= LITTLENUM_MASK
& ~ 0xFF;
4722 if ((generic_bignum
[0] & himask
) == (sign
& himask
))
4724 while (++i
< exp
->X_add_number
)
4725 if (generic_bignum
[i
] != sign
)
4730 if (i
< exp
->X_add_number
)
4731 as_warn (ngettext ("bignum truncated to %d byte",
4732 "bignum truncated to %d bytes",
4740 md_number_to_chars (p
, (valueT
) generic_bignum
[0], 1);
4743 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
4745 if (target_big_endian
)
4747 while (nbytes
> size
)
4749 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
4750 nbytes
-= CHARS_PER_LITTLENUM
;
4751 p
+= CHARS_PER_LITTLENUM
;
4754 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
4755 while (size
>= CHARS_PER_LITTLENUM
)
4758 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
4759 size
-= CHARS_PER_LITTLENUM
;
4760 p
+= CHARS_PER_LITTLENUM
;
4765 nums
= generic_bignum
;
4766 while (size
>= CHARS_PER_LITTLENUM
)
4768 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
4770 size
-= CHARS_PER_LITTLENUM
;
4771 p
+= CHARS_PER_LITTLENUM
;
4772 nbytes
-= CHARS_PER_LITTLENUM
;
4775 while (nbytes
>= CHARS_PER_LITTLENUM
)
4777 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
4778 nbytes
-= CHARS_PER_LITTLENUM
;
4779 p
+= CHARS_PER_LITTLENUM
;
4784 emit_expr_fix (exp
, nbytes
, frag_now
, p
, TC_PARSE_CONS_RETURN_NONE
);
4788 emit_expr_fix (expressionS
*exp
, unsigned int nbytes
, fragS
*frag
, char *p
,
4789 TC_PARSE_CONS_RETURN_TYPE r ATTRIBUTE_UNUSED
)
4792 unsigned int size
= nbytes
;
4794 memset (p
, 0, size
);
4796 /* Generate a fixS to record the symbol value. */
4798 #ifdef TC_CONS_FIX_NEW
4799 TC_CONS_FIX_NEW (frag
, p
- frag
->fr_literal
+ offset
, size
, exp
, r
);
4801 if (r
!= TC_PARSE_CONS_RETURN_NONE
)
4803 reloc_howto_type
*reloc_howto
;
4805 reloc_howto
= bfd_reloc_type_lookup (stdoutput
, r
);
4806 size
= bfd_get_reloc_size (reloc_howto
);
4810 as_bad (ngettext ("%s relocations do not fit in %u byte",
4811 "%s relocations do not fit in %u bytes",
4813 reloc_howto
->name
, nbytes
);
4816 else if (target_big_endian
)
4817 offset
= nbytes
- size
;
4838 as_bad (_("unsupported BFD relocation size %u"), size
);
4841 fix_new_exp (frag
, p
- frag
->fr_literal
+ offset
, size
,
4846 /* Handle an MRI style string expression. */
4850 parse_mri_cons (expressionS
*exp
, unsigned int nbytes
)
4852 if (*input_line_pointer
!= '\''
4853 && (input_line_pointer
[1] != '\''
4854 || (*input_line_pointer
!= 'A'
4855 && *input_line_pointer
!= 'E')))
4856 (void) TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
4860 unsigned int result
= 0;
4862 /* An MRI style string. Cut into as many bytes as will fit into
4863 a nbyte chunk, left justify if necessary, and separate with
4864 commas so we can try again later. */
4865 if (*input_line_pointer
== 'A')
4866 ++input_line_pointer
;
4867 else if (*input_line_pointer
== 'E')
4869 as_bad (_("EBCDIC constants are not supported"));
4870 ++input_line_pointer
;
4873 input_line_pointer
++;
4874 for (scan
= 0; scan
< nbytes
; scan
++)
4876 if (*input_line_pointer
== '\'')
4878 if (input_line_pointer
[1] == '\'')
4880 input_line_pointer
++;
4885 result
= (result
<< 8) | (*input_line_pointer
++);
4889 while (scan
< nbytes
)
4895 /* Create correct expression. */
4896 exp
->X_op
= O_constant
;
4897 exp
->X_add_number
= result
;
4899 /* Fake it so that we can read the next char too. */
4900 if (input_line_pointer
[0] != '\'' ||
4901 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
4903 input_line_pointer
-= 2;
4904 input_line_pointer
[0] = ',';
4905 input_line_pointer
[1] = '\'';
4908 input_line_pointer
++;
4911 #endif /* TC_M68K */
4913 #ifdef REPEAT_CONS_EXPRESSIONS
4915 /* Parse a repeat expression for cons. This is used by the MIPS
4916 assembler. The format is NUMBER:COUNT; NUMBER appears in the
4917 object file COUNT times.
4919 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
4922 parse_repeat_cons (expressionS
*exp
, unsigned int nbytes
)
4929 if (*input_line_pointer
!= ':')
4931 /* No repeat count. */
4935 ++input_line_pointer
;
4936 expression (&count
);
4937 if (count
.X_op
!= O_constant
4938 || count
.X_add_number
<= 0)
4940 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4944 /* The cons function is going to output this expression once. So we
4945 output it count - 1 times. */
4946 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
4947 emit_expr (exp
, nbytes
);
4950 #endif /* REPEAT_CONS_EXPRESSIONS */
4952 /* Parse a floating point number represented as a hex constant. This
4953 permits users to specify the exact bits they want in the floating
4957 hex_float (int float_type
, char *bytes
)
4959 int pad
, length
= float_length (float_type
, &pad
);
4965 /* It would be nice if we could go through expression to parse the
4966 hex constant, but if we get a bignum it's a pain to sort it into
4967 the buffer correctly. */
4969 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
4973 /* The MRI assembler accepts arbitrary underscores strewn about
4974 through the hex constant, so we ignore them as well. */
4975 if (*input_line_pointer
== '_')
4977 ++input_line_pointer
;
4983 as_warn (_("floating point constant too large"));
4986 d
= hex_value (*input_line_pointer
) << 4;
4987 ++input_line_pointer
;
4988 while (*input_line_pointer
== '_')
4989 ++input_line_pointer
;
4990 if (hex_p (*input_line_pointer
))
4992 d
+= hex_value (*input_line_pointer
);
4993 ++input_line_pointer
;
4995 if (target_big_endian
)
4998 bytes
[length
- i
- 1] = d
;
5004 if (target_big_endian
)
5005 memset (bytes
+ i
, 0, length
- i
);
5007 memset (bytes
, 0, length
- i
);
5010 memset (bytes
+ length
, 0, pad
);
5012 return length
+ pad
;
5017 CONStruct some more frag chars of .floats .ffloats etc.
5018 Makes 0 or more new frags.
5019 If need_pass_2 == 1, no frags are emitted.
5020 This understands only floating literals, not expressions. Sorry.
5022 A floating constant is defined by atof_generic(), except it is preceded
5023 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
5024 reading, I decided to be incompatible. This always tries to give you
5025 rounded bits to the precision of the pseudo-op. Former AS did premature
5026 truncation, restored noisy bits instead of trailing 0s AND gave you
5027 a choice of 2 flavours of noise according to which of 2 floating-point
5028 scanners you directed AS to use.
5030 In: input_line_pointer->whitespace before, or '0' of flonum. */
5033 float_cons (/* Clobbers input_line-pointer, checks end-of-line. */
5034 int float_type
/* 'f':.ffloat ... 'F':.float ... */)
5037 int length
; /* Number of chars in an object. */
5038 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
5040 if (is_it_end_of_statement ())
5042 demand_empty_rest_of_line ();
5046 if (now_seg
== absolute_section
)
5048 as_bad (_("attempt to store float in absolute section"));
5049 ignore_rest_of_line ();
5055 as_bad (_("attempt to store float in section `%s'"),
5056 segment_name (now_seg
));
5057 ignore_rest_of_line ();
5061 #ifdef md_flush_pending_output
5062 md_flush_pending_output ();
5065 #ifdef md_cons_align
5071 length
= parse_one_float (float_type
, temp
);
5081 #ifdef REPEAT_CONS_EXPRESSIONS
5082 if (*input_line_pointer
== ':')
5084 expressionS count_exp
;
5086 ++input_line_pointer
;
5087 expression (&count_exp
);
5089 if (count_exp
.X_op
!= O_constant
5090 || count_exp
.X_add_number
<= 0)
5091 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
5093 count
= count_exp
.X_add_number
;
5097 while (--count
>= 0)
5099 p
= frag_more (length
);
5100 memcpy (p
, temp
, (unsigned int) length
);
5105 while (*input_line_pointer
++ == ',');
5107 /* Put terminator back into stream. */
5108 --input_line_pointer
;
5109 demand_empty_rest_of_line ();
5114 Note - we are using the DWARF standard's definition of LEB128 encoding
5115 where each 7-bit value is a stored in a byte, *not* an octet. This
5116 means that on targets where a byte contains multiple octets there is
5117 a *huge waste of space*. (This also means that we do not have to
5118 have special versions of these functions for when OCTETS_PER_BYTE_POWER
5121 If the 7-bit values were to be packed into N-bit bytes (where N > 8)
5122 we would then have to consider whether multiple, successive LEB128
5123 values should be packed into the bytes without padding (bad idea) or
5124 whether each LEB128 number is padded out to a whole number of bytes.
5125 Plus you have to decide on the endianness of packing octets into a
5128 /* Return the size of a LEB128 value in bytes. */
5130 static inline unsigned int
5131 sizeof_sleb128 (offsetT value
)
5138 byte
= (value
& 0x7f);
5139 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
5140 Fortunately, we can structure things so that the extra work reduces
5141 to a noop on systems that do things "properly". */
5142 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
5145 while (!(((value
== 0) && ((byte
& 0x40) == 0))
5146 || ((value
== -1) && ((byte
& 0x40) != 0))));
5151 static inline unsigned int
5152 sizeof_uleb128 (valueT value
)
5167 sizeof_leb128 (valueT value
, int sign
)
5170 return sizeof_sleb128 ((offsetT
) value
);
5172 return sizeof_uleb128 (value
);
5175 /* Output a LEB128 value. Returns the number of bytes used. */
5177 static inline unsigned int
5178 output_sleb128 (char *p
, offsetT value
)
5185 unsigned byte
= (value
& 0x7f);
5187 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
5188 Fortunately, we can structure things so that the extra work reduces
5189 to a noop on systems that do things "properly". */
5190 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
5192 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
5193 || ((value
== -1) && ((byte
& 0x40) != 0))));
5204 static inline unsigned int
5205 output_uleb128 (char *p
, valueT value
)
5211 unsigned byte
= (value
& 0x7f);
5215 /* More bytes to follow. */
5226 output_leb128 (char *p
, valueT value
, int sign
)
5229 return output_sleb128 (p
, (offsetT
) value
);
5231 return output_uleb128 (p
, value
);
5234 /* Do the same for bignums. We combine sizeof with output here in that
5235 we don't output for NULL values of P. It isn't really as critical as
5236 for "normal" values that this be streamlined. Returns the number of
5239 static inline unsigned int
5240 output_big_sleb128 (char *p
, LITTLENUM_TYPE
*bignum
, unsigned int size
)
5247 /* Strip leading sign extensions off the bignum. */
5249 && bignum
[size
- 1] == LITTLENUM_MASK
5250 && bignum
[size
- 2] > LITTLENUM_MASK
/ 2)
5255 /* OR in the next part of the littlenum. */
5256 val
|= (*bignum
<< loaded
);
5257 loaded
+= LITTLENUM_NUMBER_OF_BITS
;
5261 /* Add bytes until there are less than 7 bits left in VAL
5262 or until every non-sign bit has been written. */
5269 || val
!= ((byte
& 0x40) == 0 ? 0 : ((valueT
) 1 << loaded
) - 1))
5276 while ((byte
& 0x80) != 0 && loaded
>= 7);
5280 /* Mop up any left-over bits (of which there will be less than 7). */
5281 if ((byte
& 0x80) != 0)
5283 /* Sign-extend VAL. */
5284 if (val
& (1 << (loaded
- 1)))
5285 val
|= ~0U << loaded
;
5294 static inline unsigned int
5295 output_big_uleb128 (char *p
, LITTLENUM_TYPE
*bignum
, unsigned int size
)
5302 /* Strip leading zeros off the bignum. */
5303 /* XXX: Is this needed? */
5304 while (size
> 0 && bignum
[size
- 1] == 0)
5309 if (loaded
< 7 && size
> 0)
5311 val
|= (*bignum
<< loaded
);
5312 loaded
+= 8 * CHARS_PER_LITTLENUM
;
5321 if (size
> 0 || val
)
5328 while (byte
& 0x80);
5334 output_big_leb128 (char *p
, LITTLENUM_TYPE
*bignum
, unsigned int size
, int sign
)
5337 return output_big_sleb128 (p
, bignum
, size
);
5339 return output_big_uleb128 (p
, bignum
, size
);
5342 /* Generate the appropriate fragments for a given expression to emit a
5343 leb128 value. SIGN is 1 for sleb, 0 for uleb. */
5346 emit_leb128_expr (expressionS
*exp
, int sign
)
5348 operatorT op
= exp
->X_op
;
5349 unsigned int nbytes
;
5351 if (op
== O_absent
|| op
== O_illegal
)
5353 as_warn (_("zero assumed for missing expression"));
5354 exp
->X_add_number
= 0;
5357 else if (op
== O_big
&& exp
->X_add_number
<= 0)
5359 as_bad (_("floating point number invalid"));
5360 exp
->X_add_number
= 0;
5363 else if (op
== O_register
)
5365 as_warn (_("register value used as expression"));
5368 else if (op
== O_constant
5370 && (exp
->X_add_number
< 0) == !exp
->X_extrabit
)
5372 /* We're outputting a signed leb128 and the sign of X_add_number
5373 doesn't reflect the sign of the original value. Convert EXP
5374 to a correctly-extended bignum instead. */
5375 convert_to_bignum (exp
, exp
->X_extrabit
);
5379 if (now_seg
== absolute_section
)
5381 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
5382 as_bad (_("attempt to store value in absolute section"));
5383 abs_section_offset
++;
5387 if ((op
!= O_constant
|| exp
->X_add_number
!= 0) && in_bss ())
5388 as_bad (_("attempt to store non-zero value in section `%s'"),
5389 segment_name (now_seg
));
5391 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
5392 a signal that this is leb128 data. It shouldn't optimize this away. */
5393 nbytes
= (unsigned int) -1;
5394 if (check_eh_frame (exp
, &nbytes
))
5397 /* Let the backend know that subsequent data may be byte aligned. */
5398 #ifdef md_cons_align
5402 if (op
== O_constant
)
5404 /* If we've got a constant, emit the thing directly right now. */
5406 valueT value
= exp
->X_add_number
;
5410 size
= sizeof_leb128 (value
, sign
);
5411 p
= frag_more (size
);
5412 if (output_leb128 (p
, value
, sign
) > size
)
5415 else if (op
== O_big
)
5417 /* O_big is a different sort of constant. */
5418 int nbr_digits
= exp
->X_add_number
;
5422 /* If the leading littenum is 0xffff, prepend a 0 to avoid confusion with
5423 a signed number. Unary operators like - or ~ always extend the
5424 bignum to its largest size. */
5426 && nbr_digits
< SIZE_OF_LARGE_NUMBER
5427 && generic_bignum
[nbr_digits
- 1] == LITTLENUM_MASK
)
5428 generic_bignum
[nbr_digits
++] = 0;
5430 size
= output_big_leb128 (NULL
, generic_bignum
, nbr_digits
, sign
);
5431 p
= frag_more (size
);
5432 if (output_big_leb128 (p
, generic_bignum
, nbr_digits
, sign
) > size
)
5437 /* Otherwise, we have to create a variable sized fragment and
5438 resolve things later. */
5440 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
5441 make_expr_symbol (exp
), 0, (char *) NULL
);
5445 /* Parse the .sleb128 and .uleb128 pseudos. */
5452 #ifdef md_flush_pending_output
5453 md_flush_pending_output ();
5459 emit_leb128_expr (&exp
, sign
);
5461 while (*input_line_pointer
++ == ',');
5463 input_line_pointer
--;
5464 demand_empty_rest_of_line ();
5467 #if defined (TE_PE) && defined (O_secrel)
5469 /* Generate the appropriate fragments for a given expression to emit a
5470 cv_comp value. SIGN is 1 for cv_scomp, 0 for cv_ucomp. */
5473 emit_cv_comp_expr (expressionS
*exp
, int sign
)
5475 operatorT op
= exp
->X_op
;
5477 if (op
== O_absent
|| op
== O_illegal
)
5479 as_warn (_("zero assumed for missing expression"));
5480 exp
->X_add_number
= 0;
5483 else if (op
== O_big
)
5485 as_bad (_("number invalid"));
5486 exp
->X_add_number
= 0;
5489 else if (op
== O_register
)
5491 as_warn (_("register value used as expression"));
5495 if (now_seg
== absolute_section
)
5497 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
5498 as_bad (_("attempt to store value in absolute section"));
5499 abs_section_offset
++;
5503 if ((op
!= O_constant
|| exp
->X_add_number
!= 0) && in_bss ())
5504 as_bad (_("attempt to store non-zero value in section `%s'"),
5505 segment_name (now_seg
));
5507 /* Let the backend know that subsequent data may be byte aligned. */
5508 #ifdef md_cons_align
5512 if (op
== O_constant
)
5514 offsetT value
= exp
->X_add_number
;
5518 /* If we've got a constant, emit the thing directly right now. */
5520 size
= sizeof_cv_comp (value
, sign
);
5521 p
= frag_more (size
);
5522 if (output_cv_comp (p
, value
, sign
) > size
)
5527 /* Otherwise, we have to create a variable sized fragment and
5528 resolve things later. */
5530 frag_var (rs_cv_comp
, 4, 0, sign
, make_expr_symbol (exp
), 0, NULL
);
5534 /* Parse the .cv_ucomp and .cv_scomp pseudos. */
5537 s_cv_comp (int sign
)
5541 #ifdef md_flush_pending_output
5542 md_flush_pending_output ();
5548 emit_cv_comp_expr (&exp
, sign
);
5550 while (*input_line_pointer
++ == ',');
5552 input_line_pointer
--;
5553 demand_empty_rest_of_line ();
5556 #endif /* TE_PE && O_secrel */
5558 /* Code for handling base64 encoded strings.
5559 Based upon code in sharutils' lib/base64.c source file, written by
5560 Simon Josefsson. Which was partially adapted from GNU MailUtils
5561 (mailbox/filter_trans.c, as of 2004-11-28) and improved by review
5562 from Paul Eggert, Bruno Haible, and Stepan Kasal. */
5631 static const signed char b64
[0x100] =
5633 B64 (0), B64 (1), B64 (2), B64 (3),
5634 B64 (4), B64 (5), B64 (6), B64 (7),
5635 B64 (8), B64 (9), B64 (10), B64 (11),
5636 B64 (12), B64 (13), B64 (14), B64 (15),
5637 B64 (16), B64 (17), B64 (18), B64 (19),
5638 B64 (20), B64 (21), B64 (22), B64 (23),
5639 B64 (24), B64 (25), B64 (26), B64 (27),
5640 B64 (28), B64 (29), B64 (30), B64 (31),
5641 B64 (32), B64 (33), B64 (34), B64 (35),
5642 B64 (36), B64 (37), B64 (38), B64 (39),
5643 B64 (40), B64 (41), B64 (42), B64 (43),
5644 B64 (44), B64 (45), B64 (46), B64 (47),
5645 B64 (48), B64 (49), B64 (50), B64 (51),
5646 B64 (52), B64 (53), B64 (54), B64 (55),
5647 B64 (56), B64 (57), B64 (58), B64 (59),
5648 B64 (60), B64 (61), B64 (62), B64 (63),
5649 B64 (64), B64 (65), B64 (66), B64 (67),
5650 B64 (68), B64 (69), B64 (70), B64 (71),
5651 B64 (72), B64 (73), B64 (74), B64 (75),
5652 B64 (76), B64 (77), B64 (78), B64 (79),
5653 B64 (80), B64 (81), B64 (82), B64 (83),
5654 B64 (84), B64 (85), B64 (86), B64 (87),
5655 B64 (88), B64 (89), B64 (90), B64 (91),
5656 B64 (92), B64 (93), B64 (94), B64 (95),
5657 B64 (96), B64 (97), B64 (98), B64 (99),
5658 B64 (100), B64 (101), B64 (102), B64 (103),
5659 B64 (104), B64 (105), B64 (106), B64 (107),
5660 B64 (108), B64 (109), B64 (110), B64 (111),
5661 B64 (112), B64 (113), B64 (114), B64 (115),
5662 B64 (116), B64 (117), B64 (118), B64 (119),
5663 B64 (120), B64 (121), B64 (122), B64 (123),
5664 B64 (124), B64 (125), B64 (126), B64 (127),
5665 B64 (128), B64 (129), B64 (130), B64 (131),
5666 B64 (132), B64 (133), B64 (134), B64 (135),
5667 B64 (136), B64 (137), B64 (138), B64 (139),
5668 B64 (140), B64 (141), B64 (142), B64 (143),
5669 B64 (144), B64 (145), B64 (146), B64 (147),
5670 B64 (148), B64 (149), B64 (150), B64 (151),
5671 B64 (152), B64 (153), B64 (154), B64 (155),
5672 B64 (156), B64 (157), B64 (158), B64 (159),
5673 B64 (160), B64 (161), B64 (162), B64 (163),
5674 B64 (164), B64 (165), B64 (166), B64 (167),
5675 B64 (168), B64 (169), B64 (170), B64 (171),
5676 B64 (172), B64 (173), B64 (174), B64 (175),
5677 B64 (176), B64 (177), B64 (178), B64 (179),
5678 B64 (180), B64 (181), B64 (182), B64 (183),
5679 B64 (184), B64 (185), B64 (186), B64 (187),
5680 B64 (188), B64 (189), B64 (190), B64 (191),
5681 B64 (192), B64 (193), B64 (194), B64 (195),
5682 B64 (196), B64 (197), B64 (198), B64 (199),
5683 B64 (200), B64 (201), B64 (202), B64 (203),
5684 B64 (204), B64 (205), B64 (206), B64 (207),
5685 B64 (208), B64 (209), B64 (210), B64 (211),
5686 B64 (212), B64 (213), B64 (214), B64 (215),
5687 B64 (216), B64 (217), B64 (218), B64 (219),
5688 B64 (220), B64 (221), B64 (222), B64 (223),
5689 B64 (224), B64 (225), B64 (226), B64 (227),
5690 B64 (228), B64 (229), B64 (230), B64 (231),
5691 B64 (232), B64 (233), B64 (234), B64 (235),
5692 B64 (236), B64 (237), B64 (238), B64 (239),
5693 B64 (240), B64 (241), B64 (242), B64 (243),
5694 B64 (244), B64 (245), B64 (246), B64 (247),
5695 B64 (248), B64 (249), B64 (250), B64 (251),
5696 B64 (252), B64 (253), B64 (254), B64 (255)
5700 is_base64_char (unsigned int c
)
5702 return (c
< 0x100) && (b64
[c
] != -1);
5706 decode_base64_and_append (unsigned int b
[4], int len
)
5708 gas_assert (len
> 1);
5710 FRAG_APPEND_1_CHAR ((b64
[b
[0]] << 2) | (b64
[b
[1]] >> 4));
5713 return; /* FIXME: Check for unused bits in b[1] ? */
5715 FRAG_APPEND_1_CHAR (((b64
[b
[1]] << 4) & 0xf0) | (b64
[b
[2]] >> 2));
5718 return; /* FIXME: Check for unused bits in b[2] ? */
5720 FRAG_APPEND_1_CHAR (((b64
[b
[2]] << 6) & 0xc0) | b64
[b
[3]]);
5723 /* Accept one or more comma separated, base64 encoded strings. Decode them
5724 and store them at the current point in the current section. The strings
5725 must be enclosed in double quotes. Line breaks, quoted characters and
5726 escaped characters are not allowed. Only the characters "A-Za-z0-9+/" are
5727 accepted inside the string. The string must be a multiple of four
5728 characters in length. If the encoded string does not fit this requirement
5729 it may use one or more '=' characters at the end as padding. */
5732 s_base64 (int dummy ATTRIBUTE_UNUSED
)
5735 unsigned long num_octets
= 0;
5737 /* If we have been switched into the abs_section then we
5738 will not have an obstack onto which we can hang strings. */
5739 if (now_seg
== absolute_section
)
5741 as_bad (_("base64 strings must be placed into a section"));
5742 ignore_rest_of_line ();
5746 if (is_it_end_of_statement ())
5748 as_bad (_("a string must follow the .base64 pseudo-op"));
5752 #ifdef md_flush_pending_output
5753 md_flush_pending_output ();
5756 #ifdef md_cons_align
5762 SKIP_ALL_WHITESPACE ();
5764 c
= * input_line_pointer
++;
5768 as_bad (_("expected double quote enclosed string as argument to .base64 pseudo-op"));
5769 ignore_rest_of_line ();
5773 /* Read a block of four base64 encoded characters. */
5776 bool seen_equals
= false;
5779 for (i
= 0; i
< 4; i
++)
5781 c
= * input_line_pointer
++;
5783 if (c
>= 256 || is_end_of_line
[c
])
5785 as_bad (_("end of line encountered inside .base64 string"));
5786 ignore_rest_of_line ();
5792 /* We allow this. But only if there were enough
5793 characters to form a valid base64 encoding. */
5796 as_warn (_(".base64 string terminated early"));
5797 -- input_line_pointer
;
5801 as_bad (_(".base64 string terminated unexpectedly"));
5802 ignore_rest_of_line ();
5806 if (seen_equals
&& c
!= '=')
5808 as_bad (_("equals character only allowed at end of .base64 string"));
5809 ignore_rest_of_line ();
5817 as_bad (_("the equals character cannot start a block of four base64 encoded bytes"));
5818 ignore_rest_of_line ();
5823 as_bad (_("the equals character cannot be the second character in a block of four base64 encoded bytes"));
5824 ignore_rest_of_line ();
5830 else if (! is_base64_char (c
))
5833 as_bad (_("invalid character '%c' found inside .base64 string"), c
);
5835 as_bad (_("invalid character %#x found inside .base64 string"), c
);
5836 ignore_rest_of_line ();
5843 if (seen_equals
&& i
== 4)
5850 /* We have a block of up to four valid base64 encoded bytes. */
5851 decode_base64_and_append (b
, i
);
5852 num_octets
+= (i
- 1);
5854 /* Check the next character. */
5855 c
= * input_line_pointer
++;
5857 if (is_base64_char (c
))
5861 as_bad (_("no base64 characters expected after '=' padding characters"));
5862 ignore_rest_of_line ();
5866 -- input_line_pointer
;
5871 as_bad (_(".base64 string must have a terminating double quote character"));
5872 ignore_rest_of_line ();
5876 SKIP_ALL_WHITESPACE ();
5878 c
= * input_line_pointer
++;
5882 /* Make sure that we have not skipped the EOL marker. */
5883 -- input_line_pointer
;
5885 while (num_octets
% OCTETS_PER_BYTE
)
5887 /* We have finished emiting the octets for this .base64 pseudo-op, but
5888 we have not filled up enough bytes for the target architecture. So
5889 we emit padding octets here. This is done after all of the arguments
5890 to the pseudo-op have been processed, rather than at the end of each
5891 argument, as it is likely that the user wants the arguments to be
5893 FRAG_APPEND_1_CHAR (0);
5897 demand_empty_rest_of_line ();
5901 stringer_append_char (int c
, int bitsize
)
5904 as_bad (_("attempt to store non-empty string in section `%s'"),
5905 segment_name (now_seg
));
5907 if (!target_big_endian
)
5908 FRAG_APPEND_1_CHAR (c
);
5913 FRAG_APPEND_1_CHAR (0);
5914 FRAG_APPEND_1_CHAR (0);
5915 FRAG_APPEND_1_CHAR (0);
5916 FRAG_APPEND_1_CHAR (0);
5919 FRAG_APPEND_1_CHAR (0);
5920 FRAG_APPEND_1_CHAR (0);
5923 FRAG_APPEND_1_CHAR (0);
5928 /* Called with invalid bitsize argument. */
5932 if (target_big_endian
)
5933 FRAG_APPEND_1_CHAR (c
);
5936 /* Worker to do .ascii etc statements.
5937 Reads 0 or more ',' separated, double-quoted strings.
5938 Caller should have checked need_pass_2 is FALSE because we don't
5940 Checks for end-of-line.
5941 BITS_APPENDZERO says how many bits are in a target char.
5942 The bottom bit is set if a NUL char should be appended to the strings. */
5945 stringer (int bits_appendzero
)
5947 const int bitsize
= bits_appendzero
& ~7;
5948 const int append_zero
= bits_appendzero
& 1;
5950 #if !defined(NO_LISTING) && defined (OBJ_ELF)
5954 #ifdef md_flush_pending_output
5955 md_flush_pending_output ();
5958 #ifdef md_cons_align
5962 /* If we have been switched into the abs_section then we
5963 will not have an obstack onto which we can hang strings. */
5964 if (now_seg
== absolute_section
)
5966 as_bad (_("strings must be placed into a section"));
5967 ignore_rest_of_line ();
5971 /* The following awkward logic is to parse ZERO or more strings,
5972 comma separated. Recall a string expression includes spaces
5973 before the opening '\"' and spaces after the closing '\"'.
5974 We fake a leading ',' if there is (supposed to be)
5975 a 1st, expression. We keep demanding expressions for each ','. */
5976 if (is_it_end_of_statement ())
5978 c
= 0; /* Skip loop. */
5979 ++input_line_pointer
; /* Compensate for end of loop. */
5983 c
= ','; /* Do loop. */
5986 while (c
== ',' || c
== '<' || c
== '"')
5989 switch (*input_line_pointer
)
5992 ++input_line_pointer
; /*->1st char of string. */
5993 #if !defined(NO_LISTING) && defined (OBJ_ELF)
5994 start
= input_line_pointer
;
5997 while (is_a_char (c
= next_char_of_string ()))
5998 stringer_append_char (c
, bitsize
);
6000 /* Treat "a" "b" as "ab". Even if we are appending zeros. */
6001 SKIP_ALL_WHITESPACE ();
6002 if (*input_line_pointer
== '"')
6006 stringer_append_char (0, bitsize
);
6008 #if !defined(NO_LISTING) && defined (OBJ_ELF)
6009 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
6010 will emit .string with a filename in the .debug section
6011 after a sequence of constants. See the comment in
6012 emit_expr for the sequence. emit_expr will set
6013 dwarf_file_string to non-zero if this string might be a
6014 source file name. */
6015 if (strcmp (segment_name (now_seg
), ".debug") != 0)
6016 dwarf_file_string
= 0;
6017 else if (dwarf_file_string
)
6019 c
= input_line_pointer
[-1];
6020 input_line_pointer
[-1] = '\0';
6021 listing_source_file (start
);
6022 input_line_pointer
[-1] = c
;
6028 input_line_pointer
++;
6029 c
= get_single_number ();
6030 stringer_append_char (c
, bitsize
);
6031 if (*input_line_pointer
!= '>')
6033 as_bad (_("expected <nn>"));
6034 ignore_rest_of_line ();
6037 input_line_pointer
++;
6040 input_line_pointer
++;
6044 c
= *input_line_pointer
;
6047 demand_empty_rest_of_line ();
6050 /* FIXME-SOMEDAY: I had trouble here on characters with the
6051 high bits set. We'll probably also have trouble with
6052 multibyte chars, wide chars, etc. Also be careful about
6053 returning values bigger than 1 byte. xoxorich. */
6056 next_char_of_string (void)
6060 c
= *input_line_pointer
++ & CHAR_MASK
;
6064 /* PR 20902: Do not advance past the end of the buffer. */
6065 -- input_line_pointer
;
6074 as_warn (_("unterminated string; newline inserted"));
6075 bump_line_counters ();
6079 if (!TC_STRING_ESCAPES
)
6081 switch (c
= *input_line_pointer
++ & CHAR_MASK
)
6109 break; /* As itself. */
6125 for (i
= 0, number
= 0;
6126 ISDIGIT (c
) && i
< 3;
6127 c
= *input_line_pointer
++, i
++)
6129 number
= number
* 8 + c
- '0';
6132 c
= number
& CHAR_MASK
;
6134 --input_line_pointer
;
6143 c
= *input_line_pointer
++;
6144 while (ISXDIGIT (c
))
6147 number
= number
* 16 + c
- '0';
6148 else if (ISUPPER (c
))
6149 number
= number
* 16 + c
- 'A' + 10;
6151 number
= number
* 16 + c
- 'a' + 10;
6152 c
= *input_line_pointer
++;
6154 c
= number
& CHAR_MASK
;
6155 --input_line_pointer
;
6160 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
6161 as_warn (_("unterminated string; newline inserted"));
6163 bump_line_counters ();
6167 /* Do not advance past the end of the buffer. */
6168 -- input_line_pointer
;
6174 #ifdef ONLY_STANDARD_ESCAPES
6175 as_bad (_("bad escaped character in string"));
6177 #endif /* ONLY_STANDARD_ESCAPES */
6190 get_segmented_expression (expressionS
*expP
)
6194 retval
= expression (expP
);
6195 if (expP
->X_op
== O_illegal
6196 || expP
->X_op
== O_absent
6197 || expP
->X_op
== O_big
)
6199 as_bad (_("expected address expression"));
6200 expP
->X_op
= O_constant
;
6201 expP
->X_add_number
= 0;
6202 retval
= absolute_section
;
6208 get_known_segmented_expression (expressionS
*expP
)
6210 segT retval
= get_segmented_expression (expP
);
6212 if (retval
== undefined_section
)
6214 /* There is no easy way to extract the undefined symbol from the
6216 if (expP
->X_add_symbol
!= NULL
6217 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
6218 as_warn (_("symbol \"%s\" undefined; zero assumed"),
6219 S_GET_NAME (expP
->X_add_symbol
));
6221 as_warn (_("some symbol undefined; zero assumed"));
6222 retval
= absolute_section
;
6223 expP
->X_op
= O_constant
;
6224 expP
->X_add_number
= 0;
6229 char /* Return terminator. */
6230 get_absolute_expression_and_terminator (long *val_pointer
/* Return value of expression. */)
6232 /* FIXME: val_pointer should probably be offsetT *. */
6233 *val_pointer
= (long) get_absolute_expression ();
6234 return (*input_line_pointer
++);
6237 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
6238 Give a warning if that happens. */
6241 demand_copy_C_string (int *len_pointer
)
6245 if ((s
= demand_copy_string (len_pointer
)) != 0)
6249 for (len
= *len_pointer
; len
> 0; len
--)
6251 if (s
[len
- 1] == 0)
6255 as_bad (_("this string may not contain \'\\0\'"));
6264 /* Demand string, but return a safe (=private) copy of the string.
6265 Return NULL if we can't read a string here. */
6268 demand_copy_string (int *lenP
)
6276 if (*input_line_pointer
== '\"')
6278 input_line_pointer
++; /* Skip opening quote. */
6280 while (is_a_char (c
= next_char_of_string ()))
6282 obstack_1grow (¬es
, c
);
6285 /* JF this next line is so demand_copy_C_string will return a
6286 null terminated string. */
6287 obstack_1grow (¬es
, '\0');
6288 retval
= (char *) obstack_finish (¬es
);
6292 as_bad (_("missing string"));
6294 ignore_rest_of_line ();
6300 /* In: Input_line_pointer->next character.
6302 Do: Skip input_line_pointer over all whitespace.
6304 Out: 1 if input_line_pointer->end-of-line. */
6307 is_it_end_of_statement (void)
6310 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
6314 equals (char *sym_name
, int reassign
)
6319 input_line_pointer
++;
6320 if (*input_line_pointer
== '=')
6321 input_line_pointer
++;
6322 if (reassign
< 0 && *input_line_pointer
== '=')
6323 input_line_pointer
++;
6325 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
6326 input_line_pointer
++;
6329 stop
= mri_comment_field (&stopc
);
6331 assign_symbol (sym_name
, reassign
>= 0 ? !reassign
: reassign
);
6335 demand_empty_rest_of_line ();
6336 mri_comment_end (stop
, stopc
);
6340 /* Open FILENAME, first trying the unadorned file name, then if that
6341 fails and the file name is not an absolute path, attempt to open
6342 the file in current -I include paths. PATH is a preallocated
6343 buffer which will be set to the file opened, or FILENAME if no file
6347 search_and_open (const char *filename
, char *path
)
6349 FILE *f
= fopen (filename
, FOPEN_RB
);
6350 if (f
== NULL
&& !IS_ABSOLUTE_PATH (filename
))
6352 for (size_t i
= 0; i
< include_dir_count
; i
++)
6354 sprintf (path
, "%s/%s", include_dirs
[i
], filename
);
6355 f
= fopen (path
, FOPEN_RB
);
6360 strcpy (path
, filename
);
6364 /* .incbin -- include a file verbatim at the current location. */
6367 s_incbin (int x ATTRIBUTE_UNUSED
)
6378 #ifdef md_flush_pending_output
6379 md_flush_pending_output ();
6382 #ifdef md_cons_align
6387 filename
= demand_copy_string (& len
);
6388 if (filename
== NULL
)
6393 /* Look for optional skip and count. */
6394 if (* input_line_pointer
== ',')
6396 ++ input_line_pointer
;
6397 skip
= get_absolute_expression ();
6401 if (* input_line_pointer
== ',')
6403 ++ input_line_pointer
;
6405 count
= get_absolute_expression ();
6407 as_warn (_(".incbin count zero, ignoring `%s'"), filename
);
6413 demand_empty_rest_of_line ();
6415 path
= XNEWVEC (char, len
+ include_dir_maxlen
+ 2);
6416 binfile
= search_and_open (filename
, path
);
6418 if (binfile
== NULL
)
6419 as_bad (_("file not found: %s"), filename
);
6423 struct stat filestat
;
6425 if (fstat (fileno (binfile
), &filestat
) != 0
6426 || ! S_ISREG (filestat
.st_mode
)
6427 || S_ISDIR (filestat
.st_mode
))
6429 as_bad (_("unable to include `%s'"), path
);
6433 register_dependency (path
);
6435 /* Compute the length of the file. */
6436 if (fseek (binfile
, 0, SEEK_END
) != 0)
6438 as_bad (_("seek to end of .incbin file failed `%s'"), path
);
6441 file_len
= ftell (binfile
);
6443 /* If a count was not specified use the remainder of the file. */
6445 count
= file_len
- skip
;
6447 if (skip
< 0 || count
< 0 || file_len
< 0 || skip
+ count
> file_len
)
6449 as_bad (_("skip (%ld) or count (%ld) invalid for file size (%ld)"),
6450 skip
, count
, file_len
);
6454 if (fseek (binfile
, skip
, SEEK_SET
) != 0)
6456 as_bad (_("could not skip to %ld in file `%s'"), skip
, path
);
6460 /* Allocate frag space and store file contents in it. */
6461 binfrag
= frag_more (count
);
6463 bytes
= fread (binfrag
, 1, count
, binfile
);
6465 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
6466 path
, bytes
, count
);
6469 if (binfile
!= NULL
)
6474 /* .include -- include a file at this point. */
6477 s_include (int arg ATTRIBUTE_UNUSED
)
6486 filename
= demand_copy_string (&i
);
6487 if (filename
== NULL
)
6489 /* demand_copy_string has already printed an error and
6490 called ignore_rest_of_line. */
6498 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
6499 && *input_line_pointer
!= ' '
6500 && *input_line_pointer
!= '\t')
6502 obstack_1grow (¬es
, *input_line_pointer
);
6503 ++input_line_pointer
;
6507 obstack_1grow (¬es
, '\0');
6508 filename
= (char *) obstack_finish (¬es
);
6509 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
6510 ++input_line_pointer
;
6513 demand_empty_rest_of_line ();
6515 path
= notes_alloc (i
+ include_dir_maxlen
+ 2);
6516 try_file
= search_and_open (filename
, path
);
6520 register_dependency (path
);
6521 input_scrub_insert_file (path
);
6525 init_include_dir (void)
6527 include_dirs
= XNEWVEC (const char *, 1);
6528 include_dirs
[0] = "."; /* Current dir. */
6529 include_dir_count
= 1;
6530 include_dir_maxlen
= 1;
6534 add_include_dir (char *path
)
6536 include_dir_count
++;
6537 include_dirs
= XRESIZEVEC (const char *, include_dirs
, include_dir_count
);
6538 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
6540 size_t i
= strlen (path
);
6541 if (i
> include_dir_maxlen
)
6542 include_dir_maxlen
= i
;
6545 /* Output debugging information to denote the source file. */
6548 generate_file_debug (void)
6550 if (debug_type
== DEBUG_STABS
)
6551 stabs_generate_asm_file ();
6554 /* Output line number debugging information for the current source line. */
6557 generate_lineno_debug (void)
6561 case DEBUG_UNSPECIFIED
:
6566 stabs_generate_asm_lineno ();
6569 ecoff_generate_asm_lineno ();
6572 /* ??? We could here indicate to dwarf2dbg.c that something
6573 has changed. However, since there is additional backend
6574 support that is required (calling dwarf2_emit_insn), we
6575 let dwarf2dbg.c call as_where on its own. */
6577 case DEBUG_CODEVIEW
:
6578 codeview_generate_asm_lineno ();
6583 /* Output debugging information to mark a function entry point or end point.
6584 END_P is zero for .func, and non-zero for .endfunc. */
6589 do_s_func (end_p
, NULL
);
6592 /* Subroutine of s_func so targets can choose a different default prefix.
6593 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
6596 do_s_func (int end_p
, const char *default_prefix
)
6600 if (current_name
== NULL
)
6602 as_bad (_("missing .func"));
6603 ignore_rest_of_line ();
6607 if (debug_type
== DEBUG_STABS
)
6608 stabs_generate_asm_endfunc (current_name
, current_label
);
6610 free (current_name
);
6611 free (current_label
);
6612 current_name
= current_label
= NULL
;
6617 char delim1
, delim2
;
6619 if (current_name
!= NULL
)
6621 as_bad (_(".endfunc missing for previous .func"));
6622 ignore_rest_of_line ();
6626 delim1
= get_symbol_name (& name
);
6627 name
= xstrdup (name
);
6628 restore_line_pointer (delim1
);
6630 if (*input_line_pointer
!= ',')
6633 label
= xasprintf ("%s%s", default_prefix
, name
);
6636 char leading_char
= bfd_get_symbol_leading_char (stdoutput
);
6637 /* Missing entry point, use function's name with the leading
6640 label
= xasprintf ("%c%s", leading_char
, name
);
6642 label
= xstrdup (name
);
6647 ++input_line_pointer
;
6649 delim2
= get_symbol_name (& label
);
6650 label
= xstrdup (label
);
6651 restore_line_pointer (delim2
);
6654 if (debug_type
== DEBUG_STABS
)
6655 stabs_generate_asm_func (name
, label
);
6657 current_name
= name
;
6658 current_label
= label
;
6661 demand_empty_rest_of_line ();
6664 #ifdef HANDLE_BUNDLE
6667 s_bundle_align_mode (int arg ATTRIBUTE_UNUSED
)
6669 unsigned int align
= get_absolute_expression ();
6671 demand_empty_rest_of_line ();
6673 if (align
> (unsigned int) TC_ALIGN_LIMIT
)
6674 as_fatal (_(".bundle_align_mode alignment too large (maximum %u)"),
6675 (unsigned int) TC_ALIGN_LIMIT
);
6677 if (bundle_lock_frag
!= NULL
)
6679 as_bad (_("cannot change .bundle_align_mode inside .bundle_lock"));
6683 bundle_align_p2
= align
;
6687 s_bundle_lock (int arg ATTRIBUTE_UNUSED
)
6689 demand_empty_rest_of_line ();
6691 if (bundle_align_p2
== 0)
6693 as_bad (_(".bundle_lock is meaningless without .bundle_align_mode"));
6697 if (bundle_lock_depth
== 0)
6699 bundle_lock_frchain
= frchain_now
;
6700 bundle_lock_frag
= start_bundle ();
6702 ++bundle_lock_depth
;
6706 s_bundle_unlock (int arg ATTRIBUTE_UNUSED
)
6710 demand_empty_rest_of_line ();
6712 if (bundle_lock_frag
== NULL
)
6714 as_bad (_(".bundle_unlock without preceding .bundle_lock"));
6718 gas_assert (bundle_align_p2
> 0);
6720 gas_assert (bundle_lock_depth
> 0);
6721 if (--bundle_lock_depth
> 0)
6724 size
= pending_bundle_size (bundle_lock_frag
);
6726 if (size
> 1U << bundle_align_p2
)
6727 as_bad (_(".bundle_lock sequence is %u bytes, "
6728 "but bundle size is only %u bytes"),
6729 size
, 1u << bundle_align_p2
);
6731 finish_bundle (bundle_lock_frag
, size
);
6733 bundle_lock_frag
= NULL
;
6734 bundle_lock_frchain
= NULL
;
6737 #endif /* HANDLE_BUNDLE */
6740 s_ignore (int arg ATTRIBUTE_UNUSED
)
6742 ignore_rest_of_line ();
6746 read_print_statistics (FILE *file
)
6748 htab_print_statistics (file
, "pseudo-op table", po_hash
);
6751 /* Inserts the given line into the input stream.
6753 This call avoids macro/conditionals nesting checking, since the contents of
6754 the line are assumed to replace the contents of a line already scanned.
6756 An appropriate use of this function would be substitution of input lines when
6757 called by md_start_line_hook(). The given line is assumed to already be
6758 properly scrubbed. */
6761 input_scrub_insert_line (const char *line
)
6764 size_t len
= strlen (line
);
6765 sb_build (&newline
, len
);
6766 sb_add_buffer (&newline
, line
, len
);
6767 input_scrub_include_sb (&newline
, input_line_pointer
, expanding_none
);
6769 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
6772 /* Insert a file into the input stream; the path must resolve to an actual
6773 file; no include path searching or dependency registering is performed. */
6776 input_scrub_insert_file (char *path
)
6778 input_scrub_include_file (path
, input_line_pointer
);
6779 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
6782 /* Find the end of a line, considering quotation and escaping of quotes. */
6784 #if !defined(TC_SINGLE_QUOTE_STRINGS) && defined(SINGLE_QUOTE_STRINGS)
6785 # define TC_SINGLE_QUOTE_STRINGS 1
6789 _find_end_of_line (char *s
, int mri_string
, int insn ATTRIBUTE_UNUSED
,
6792 char inquote
= '\0';
6795 while (!is_end_of_line
[(unsigned char) *s
]
6796 || (inquote
&& !ISCNTRL (*s
))
6797 || (inquote
== '\'' && flag_mri
)
6798 #ifdef TC_EOL_IN_INSN
6799 || (insn
&& TC_EOL_IN_INSN (s
))
6801 /* PR 6926: When we are parsing the body of a macro the sequence
6802 \@ is special - it refers to the invocation count. If the @
6803 character happens to be registered as a line-separator character
6804 by the target, then the is_end_of_line[] test above will have
6805 returned true, but we need to ignore the line separating
6806 semantics in this particular case. */
6807 || (in_macro
&& inescape
&& *s
== '@')
6810 if (mri_string
&& *s
== '\'')
6814 else if (*s
== '\\')
6818 #ifdef TC_SINGLE_QUOTE_STRINGS
6819 || (TC_SINGLE_QUOTE_STRINGS
&& *s
== '\'')
6826 as_warn (_("missing closing `%c'"), inquote
);
6827 if (inescape
&& !ignore_input ())
6828 as_warn (_("stray `\\'"));
6833 find_end_of_line (char *s
, int mri_string
)
6835 return _find_end_of_line (s
, mri_string
, 0, 0);
6838 static char *saved_ilp
;
6839 static char *saved_limit
;
6841 /* Use BUF as a temporary input pointer for calling other functions in this
6842 file. BUF must be a C string, so that its end can be found by strlen.
6843 Also sets the buffer_limit variable (local to this file) so that buffer
6844 overruns should not occur. Saves the current input line pointer so that
6845 it can be restored by calling restore_ilp().
6847 Does not support recursion. */
6850 temp_ilp (char *buf
)
6852 gas_assert (saved_ilp
== NULL
);
6853 gas_assert (buf
!= NULL
);
6855 saved_ilp
= input_line_pointer
;
6856 saved_limit
= buffer_limit
;
6857 /* Prevent the assert in restore_ilp from triggering if
6858 the input_line_pointer has not yet been initialised. */
6859 if (saved_ilp
== NULL
)
6860 saved_limit
= saved_ilp
= (char *) "";
6862 input_line_pointer
= buf
;
6863 buffer_limit
= buf
+ strlen (buf
);
6864 input_from_string
= true;
6867 /* Restore a saved input line pointer. */
6872 gas_assert (saved_ilp
!= NULL
);
6874 input_line_pointer
= saved_ilp
;
6875 buffer_limit
= saved_limit
;
6876 input_from_string
= false;