1 /* read.c - read a source file -
2 Copyright 1986, 1987, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
3 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
4 2010, 2011, 2012 Free Software Foundation, Inc.
6 This file is part of GAS, the GNU Assembler.
8 GAS is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GAS is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GAS; see the file COPYING. If not, write to the Free
20 Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
23 /* If your chars aren't 8 bits, you will change this a bit (eg. to 0xFF).
24 But then, GNU isn't spozed to run on your machine anyway.
25 (RMS is so shortsighted sometimes.) */
26 #define MASK_CHAR ((int)(unsigned char) -1)
28 /* This is the largest known floating point format (for now). It will
29 grow when we do 4361 style flonums. */
30 #define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
32 /* Routines that read assembler source text to build spaghetti in memory.
33 Another group of these functions is in the expr.c module. */
36 #include "safe-ctype.h"
42 #include "dw2gencfi.h"
45 #ifndef TC_START_LABEL
46 #define TC_START_LABEL(x,y,z) (x == ':')
49 /* Set by the object-format or the target. */
50 #ifndef TC_IMPLICIT_LCOMM_ALIGNMENT
51 #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR) \
56 else if ((SIZE) >= 4) \
58 else if ((SIZE) >= 2) \
66 char *input_line_pointer
; /*->next char of source file to parse. */
68 #if BITS_PER_CHAR != 8
69 /* The following table is indexed by[(char)] and will break if
70 a char does not have exactly 256 states (hopefully 0:255!)! */
79 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
84 /* The Delta 68k assembler permits % inside label names. */
89 /* The PowerPC Windows NT assemblers permits ? inside label names. */
94 /* The IA-64 assembler uses # as a suffix designating a symbol. We include
95 it in the symbol and strip it out in tc_canonicalize_symbol_name. */
104 /* The Delta 68k assembler permits ~ at start of label names. */
108 /* Used by is_... macros. our ctype[]. */
109 char lex_type
[256] = {
110 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
111 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
112 0, 0, 0, LEX_HASH
, LEX_DOLLAR
, LEX_PCT
, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
113 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM
, /* 0123456789:;<=>? */
114 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
115 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 3, /* PQRSTUVWXYZ[\]^_ */
116 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
117 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, LEX_TILDE
, 0, /* pqrstuvwxyz{|}~. */
118 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
119 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
120 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
121 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
122 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
123 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
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
129 Out: 1 if this character ends a line.
130 2 if this character is a line separator. */
131 char is_end_of_line
[256] = {
133 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, /* @abcdefghijklmno */
135 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* @abcdefghijklmno */
137 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
138 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* _!"#$%&'()*+,-./ */
139 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0123456789:;<=>? */
140 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
141 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
142 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
143 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
144 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
145 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
146 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
147 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
148 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
149 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
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 /* */
154 #ifndef TC_CASE_SENSITIVE
155 char original_case_string
[128];
158 /* Functions private to this file. */
160 static char *buffer
; /* 1st char of each buffer of lines is here. */
161 static char *buffer_limit
; /*->1 + last char in buffer. */
163 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1
164 in the tc-<CPU>.h file. See the "Porting GAS" section of the
166 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
168 /* Variables for handling include file directory table. */
170 /* Table of pointers to directories to search for .include's. */
173 /* How many are in the table. */
174 int include_dir_count
;
176 /* Length of longest in table. */
177 int include_dir_maxlen
= 1;
179 #ifndef WORKING_DOT_WORD
180 struct broken_word
*broken_words
;
181 int new_broken_words
;
184 /* The current offset into the absolute section. We don't try to
185 build frags in the absolute section, since no data can be stored
186 there. We just keep track of the current offset. */
187 addressT abs_section_offset
;
189 /* If this line had an MRI style label, it is stored in this variable.
190 This is used by some of the MRI pseudo-ops. */
193 /* This global variable is used to support MRI common sections. We
194 translate such sections into a common symbol. This variable is
195 non-NULL when we are in an MRI common section. */
196 symbolS
*mri_common_symbol
;
198 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
199 need to align to an even byte boundary unless the next pseudo-op is
200 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
202 static int mri_pending_align
;
206 /* This variable is set to be non-zero if the next string we see might
207 be the name of the source file in DWARF debugging information. See
208 the comment in emit_expr for the format we look for. */
209 static int dwarf_file_string
;
213 /* If the target defines the md_frag_max_var hook then we know
214 enough to implement the .bundle_align_mode features. */
215 #ifdef md_frag_max_var
216 # define HANDLE_BUNDLE
220 /* .bundle_align_mode sets this. Normally it's zero. When nonzero,
221 it's the exponent of the bundle size, and aligned instruction bundle
222 mode is in effect. */
223 static unsigned int bundle_align_p2
;
225 /* These are set by .bundle_lock and .bundle_unlock. .bundle_lock sets
226 bundle_lock_frag to frag_now and then starts a new frag with
227 frag_align_code. At the same time, bundle_lock_frain gets frchain_now,
228 so that .bundle_unlock can verify that we didn't change segments.
229 .bundle_unlock resets both to NULL. If we detect a bundling violation,
230 then we reset bundle_lock_frchain to NULL as an indicator that we've
231 already diagnosed the error with as_bad and don't need a cascade of
232 redundant errors, but bundle_lock_frag remains set to indicate that
233 we are expecting to see .bundle_unlock. */
234 static fragS
*bundle_lock_frag
;
235 static frchainS
*bundle_lock_frchain
;
238 static void do_s_func (int end_p
, const char *default_prefix
);
239 static void do_align (int, char *, int, int);
240 static void s_align (int, int);
241 static void s_altmacro (int);
242 static void s_bad_end (int);
244 static void s_gnu_attribute (int);
246 static void s_reloc (int);
247 static int hex_float (int, char *);
248 static segT
get_known_segmented_expression (expressionS
* expP
);
249 static void pobegin (void);
250 static int get_non_macro_line_sb (sb
*);
251 static void generate_file_debug (void);
252 static char *_find_end_of_line (char *, int, int, int);
260 obj_read_begin_hook ();
262 /* Something close -- but not too close -- to a multiple of 1024.
263 The debugging malloc I'm using has 24 bytes of overhead. */
264 obstack_begin (¬es
, chunksize
);
265 obstack_begin (&cond_obstack
, chunksize
);
267 /* Use machine dependent syntax. */
268 for (p
= line_separator_chars
; *p
; p
++)
269 is_end_of_line
[(unsigned char) *p
] = 2;
270 /* Use more. FIXME-SOMEDAY. */
276 #ifndef TC_ADDRESS_BYTES
277 #define TC_ADDRESS_BYTES address_bytes
282 /* Choose smallest of 1, 2, 4, 8 bytes that is large enough to
283 contain an address. */
284 int n
= (stdoutput
->arch_info
->bits_per_address
- 1) / 8;
292 /* Set up pseudo-op tables. */
294 static struct hash_control
*po_hash
;
296 static const pseudo_typeS potable
[] = {
297 {"abort", s_abort
, 0},
298 {"align", s_align_ptwo
, 0},
299 {"altmacro", s_altmacro
, 1},
300 {"ascii", stringer
, 8+0},
301 {"asciz", stringer
, 8+1},
302 {"balign", s_align_bytes
, 0},
303 {"balignw", s_align_bytes
, -2},
304 {"balignl", s_align_bytes
, -4},
307 {"bundle_align_mode", s_bundle_align_mode
, 0},
308 {"bundle_lock", s_bundle_lock
, 0},
309 {"bundle_unlock", s_bundle_unlock
, 0},
313 {"common", s_mri_common
, 0},
314 {"common.s", s_mri_common
, 1},
317 #ifdef TC_ADDRESS_BYTES
321 {"dc.d", float_cons
, 'd'},
323 {"dc.s", float_cons
, 'f'},
325 {"dc.x", float_cons
, 'x'},
327 {"dcb.b", s_space
, 1},
328 {"dcb.d", s_float_space
, 'd'},
329 {"dcb.l", s_space
, 4},
330 {"dcb.s", s_float_space
, 'f'},
331 {"dcb.w", s_space
, 2},
332 {"dcb.x", s_float_space
, 'x'},
334 {"ds.b", s_space
, 1},
335 {"ds.d", s_space
, 8},
336 {"ds.l", s_space
, 4},
337 {"ds.p", s_space
, 12},
338 {"ds.s", s_space
, 4},
339 {"ds.w", s_space
, 2},
340 {"ds.x", s_space
, 12},
341 {"debug", s_ignore
, 0},
346 {"double", float_cons
, 'd'},
348 {"eject", listing_eject
, 0}, /* Formfeed listing. */
350 {"elsec", s_else
, 0},
351 {"elseif", s_elseif
, (int) O_ne
},
353 {"endc", s_endif
, 0},
354 {"endfunc", s_func
, 1},
355 {"endif", s_endif
, 0},
356 {"endm", s_bad_end
, 0},
357 {"endr", s_bad_end
, 1},
363 {"error", s_errwarn
, 1},
364 {"exitm", s_mexit
, 0},
366 {"extern", s_ignore
, 0}, /* We treat all undef as ext. */
367 {"appfile", s_app_file
, 1},
368 {"appline", s_app_line
, 1},
370 {"file", s_app_file
, 0},
372 {"float", float_cons
, 'f'},
373 {"format", s_ignore
, 0},
375 {"global", s_globl
, 0},
376 {"globl", s_globl
, 0},
378 {"gnu_attribute", s_gnu_attribute
, 0},
381 {"if", s_if
, (int) O_ne
},
384 {"ifdef", s_ifdef
, 0},
385 {"ifeq", s_if
, (int) O_eq
},
386 {"ifeqs", s_ifeqs
, 0},
387 {"ifge", s_if
, (int) O_ge
},
388 {"ifgt", s_if
, (int) O_gt
},
389 {"ifle", s_if
, (int) O_le
},
390 {"iflt", s_if
, (int) O_lt
},
393 {"ifndef", s_ifdef
, 1},
394 {"ifne", s_if
, (int) O_ne
},
395 {"ifnes", s_ifeqs
, 1},
396 {"ifnotdef", s_ifdef
, 1},
397 {"incbin", s_incbin
, 0},
398 {"include", s_include
, 0},
404 {"lcomm", s_lcomm
, 0},
405 {"lflags", s_ignore
, 0}, /* Listing flags. */
406 {"linefile", s_app_line
, 0},
407 {"linkonce", s_linkonce
, 0},
408 {"list", listing_list
, 1}, /* Turn listing on. */
409 {"llen", listing_psize
, 1},
412 {"macro", s_macro
, 0},
413 {"mexit", s_mexit
, 0},
415 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
416 {"name", s_ignore
, 0},
417 {"noaltmacro", s_altmacro
, 0},
418 {"noformat", s_ignore
, 0},
419 {"nolist", listing_list
, 0}, /* Turn listing off. */
420 {"nopage", listing_nopage
, 0},
422 {"offset", s_struct
, 0},
424 {"p2align", s_align_ptwo
, 0},
425 {"p2alignw", s_align_ptwo
, -2},
426 {"p2alignl", s_align_ptwo
, -4},
427 {"page", listing_eject
, 0},
428 {"plen", listing_psize
, 0},
429 {"print", s_print
, 0},
430 {"psize", listing_psize
, 0}, /* Set paper size. */
431 {"purgem", s_purgem
, 0},
433 {"reloc", s_reloc
, 0},
437 {"sbttl", listing_title
, 1}, /* Subtitle of listing. */
442 {"single", float_cons
, 'f'},
444 {"space", s_space
, 0},
445 {"skip", s_space
, 0},
446 {"sleb128", s_leb128
, 1},
447 {"spc", s_ignore
, 0},
448 {"stabd", s_stab
, 'd'},
449 {"stabn", s_stab
, 'n'},
450 {"stabs", s_stab
, 's'},
451 {"string", stringer
, 8+1},
452 {"string8", stringer
, 8+1},
453 {"string16", stringer
, 16+1},
454 {"string32", stringer
, 32+1},
455 {"string64", stringer
, 64+1},
456 {"struct", s_struct
, 0},
460 /* This is for gcc to use. It's only just been added (2/94), so gcc
461 won't be able to use it for a while -- probably a year or more.
462 But once this has been released, check with gcc maintainers
463 before deleting it or even changing the spelling. */
464 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
465 /* If we're folding case -- done for some targets, not necessarily
466 all -- the above string in an input file will be converted to
467 this one. Match it either way... */
468 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
470 {"title", listing_title
, 0}, /* Listing title. */
471 {"ttl", listing_title
, 0},
473 {"uleb128", s_leb128
, 0},
477 {"xdef", s_globl
, 0},
478 {"xref", s_ignore
, 0},
479 {"xstabs", s_xstab
, 's'},
480 {"warning", s_errwarn
, 0},
481 {"weakref", s_weakref
, 0},
483 {"zero", s_space
, 0},
484 {NULL
, NULL
, 0} /* End sentinel. */
488 get_absolute_expr (expressionS
*exp
)
490 expression_and_evaluate (exp
);
491 if (exp
->X_op
!= O_constant
)
493 if (exp
->X_op
!= O_absent
)
494 as_bad (_("bad or irreducible absolute expression"));
495 exp
->X_add_number
= 0;
497 return exp
->X_add_number
;
501 get_absolute_expression (void)
505 return get_absolute_expr (&exp
);
508 static int pop_override_ok
= 0;
509 static const char *pop_table_name
;
512 pop_insert (const pseudo_typeS
*table
)
515 const pseudo_typeS
*pop
;
516 for (pop
= table
; pop
->poc_name
; pop
++)
518 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
519 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
520 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name
,
525 #ifndef md_pop_insert
526 #define md_pop_insert() pop_insert(md_pseudo_table)
529 #ifndef obj_pop_insert
530 #define obj_pop_insert() pop_insert(obj_pseudo_table)
533 #ifndef cfi_pop_insert
534 #define cfi_pop_insert() pop_insert(cfi_pseudo_table)
540 po_hash
= hash_new ();
542 /* Do the target-specific pseudo ops. */
543 pop_table_name
= "md";
546 /* Now object specific. Skip any that were in the target table. */
547 pop_table_name
= "obj";
551 /* Now portable ones. Skip any that we've seen already. */
552 pop_table_name
= "standard";
553 pop_insert (potable
);
556 pop_table_name
= "cfi";
561 #define HANDLE_CONDITIONAL_ASSEMBLY() \
562 if (ignore_input ()) \
564 char *eol = find_end_of_line (input_line_pointer, flag_m68k_mri); \
565 input_line_pointer = (input_line_pointer <= buffer_limit \
566 && eol >= buffer_limit) \
572 /* This function is used when scrubbing the characters between #APP
575 static char *scrub_string
;
576 static char *scrub_string_end
;
579 scrub_from_string (char *buf
, int buflen
)
583 copy
= scrub_string_end
- scrub_string
;
586 memcpy (buf
, scrub_string
, copy
);
587 scrub_string
+= copy
;
591 /* Helper function of read_a_source_file, which tries to expand a macro. */
593 try_macro (char term
, const char *line
)
599 if (check_macro (line
, &out
, &err
, ¯o
))
603 *input_line_pointer
++ = term
;
604 input_scrub_include_sb (&out
,
605 input_line_pointer
, 1);
608 input_scrub_next_buffer (&input_line_pointer
);
610 md_macro_info (macro
);
618 /* Start a new instruction bundle. Returns the rs_align_code frag that
619 will be used to align the new bundle. */
623 fragS
*frag
= frag_now
;
625 frag_align_code (0, 0);
627 while (frag
->fr_type
!= rs_align_code
)
628 frag
= frag
->fr_next
;
630 gas_assert (frag
!= frag_now
);
635 /* Calculate the maximum size after relaxation of the region starting
636 at the given frag and extending through frag_now (which is unfinished). */
638 pending_bundle_size (fragS
*frag
)
640 unsigned int offset
= frag
->fr_fix
;
641 unsigned int size
= 0;
643 gas_assert (frag
!= frag_now
);
644 gas_assert (frag
->fr_type
== rs_align_code
);
646 while (frag
!= frag_now
)
648 /* This should only happen in what will later become an error case. */
652 size
+= frag
->fr_fix
;
653 if (frag
->fr_type
== rs_machine_dependent
)
654 size
+= md_frag_max_var (frag
);
656 frag
= frag
->fr_next
;
659 gas_assert (frag
== frag_now
);
660 size
+= frag_now_fix ();
661 if (frag
->fr_type
== rs_machine_dependent
)
662 size
+= md_frag_max_var (frag
);
664 gas_assert (size
>= offset
);
666 return size
- offset
;
669 /* Finish off the frag created to ensure bundle alignment. */
671 finish_bundle (fragS
*frag
, unsigned int size
)
673 gas_assert (bundle_align_p2
> 0);
674 gas_assert (frag
->fr_type
== rs_align_code
);
678 /* If there is more than a single byte, then we need to set up the
679 alignment frag. Otherwise we leave it at its initial state from
680 calling frag_align_code (0, 0), so that it does nothing. */
681 frag
->fr_offset
= bundle_align_p2
;
682 frag
->fr_subtype
= size
- 1;
685 /* We do this every time rather than just in s_bundle_align_mode
686 so that we catch any affected section without needing hooks all
687 over for all paths that do section changes. It's cheap enough. */
688 record_alignment (now_seg
, bundle_align_p2
- OCTETS_PER_BYTE_POWER
);
691 /* Assemble one instruction. This takes care of the bundle features
692 around calling md_assemble. */
694 assemble_one (char *line
)
696 fragS
*insn_start_frag
= NULL
;
698 if (bundle_lock_frchain
!= NULL
&& bundle_lock_frchain
!= frchain_now
)
700 as_bad (_("cannot change section or subsection inside .bundle_lock"));
701 /* Clearing this serves as a marker that we have already complained. */
702 bundle_lock_frchain
= NULL
;
705 if (bundle_lock_frchain
== NULL
&& bundle_align_p2
> 0)
706 insn_start_frag
= start_bundle ();
710 if (bundle_lock_frchain
!= NULL
)
712 /* Make sure this hasn't pushed the locked sequence
713 past the bundle size. */
714 unsigned int bundle_size
= pending_bundle_size (bundle_lock_frag
);
715 if (bundle_size
> (1U << bundle_align_p2
))
717 .bundle_lock sequence at %u bytes but .bundle_align_mode limit is %u bytes"),
718 bundle_size
, 1U << bundle_align_p2
);
720 else if (bundle_align_p2
> 0)
722 unsigned int insn_size
= pending_bundle_size (insn_start_frag
);
724 if (insn_size
> (1U << bundle_align_p2
))
726 single instruction is %u bytes long but .bundle_align_mode limit is %u"),
727 (unsigned int) insn_size
, 1U << bundle_align_p2
);
729 finish_bundle (insn_start_frag
, insn_size
);
733 #else /* !HANDLE_BUNDLE */
735 # define assemble_one(line) md_assemble(line)
737 #endif /* HANDLE_BUNDLE */
739 /* We read the file, putting things into a web that represents what we
740 have been reading. */
742 read_a_source_file (char *name
)
745 char *s
; /* String of symbol, '\0' appended. */
753 buffer
= input_scrub_new_file (name
);
756 listing_newline (NULL
);
757 register_dependency (name
);
759 /* Generate debugging information before we've read anything in to denote
760 this file as the "main" source file and not a subordinate one
761 (e.g. N_SO vs N_SOL in stabs). */
762 generate_file_debug ();
764 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
765 { /* We have another line to parse. */
767 /* In order to avoid listing macro expansion lines with labels
768 multiple times, keep track of which line was last issued. */
769 static char *last_eol
;
773 while (input_line_pointer
< buffer_limit
)
775 bfd_boolean was_new_line
;
776 /* We have more of this buffer to parse. */
778 /* We now have input_line_pointer->1st char of next line.
779 If input_line_pointer [-1] == '\n' then we just
780 scanned another line: so bump line counters. */
781 was_new_line
= is_end_of_line
[(unsigned char) input_line_pointer
[-1]];
784 symbol_set_value_now (&dot_symbol
);
785 #ifdef md_start_line_hook
786 md_start_line_hook ();
788 if (input_line_pointer
[-1] == '\n')
789 bump_line_counters ();
793 /* If listing is on, and we are expanding a macro, then give
794 the listing code the contents of the expanded line. */
797 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
799 /* Find the end of the current expanded macro line. */
800 s
= find_end_of_line (input_line_pointer
, flag_m68k_mri
);
808 /* Copy it for safe keeping. Also give an indication of
809 how much macro nesting is involved at this point. */
810 len
= s
- input_line_pointer
;
811 copy
= (char *) xmalloc (len
+ macro_nest
+ 2);
812 memset (copy
, '>', macro_nest
);
813 copy
[macro_nest
] = ' ';
814 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
, len
);
815 copy
[macro_nest
+ 1 + len
] = '\0';
817 /* Install the line with the listing facility. */
818 listing_newline (copy
);
822 listing_newline (NULL
);
829 if (LABELS_WITHOUT_COLONS
|| flag_m68k_mri
)
831 /* Text at the start of a line must be a label, we
832 run down and stick a colon in. */
833 if (is_name_beginner (*input_line_pointer
))
835 char *line_start
= input_line_pointer
;
838 HANDLE_CONDITIONAL_ASSEMBLY ();
840 c
= get_symbol_end ();
842 /* In MRI mode, the EQU and MACRO pseudoops must
843 be handled specially. */
847 char *rest
= input_line_pointer
+ 1;
851 if (*rest
== ' ' || *rest
== '\t')
853 if ((strncasecmp (rest
, "EQU", 3) == 0
854 || strncasecmp (rest
, "SET", 3) == 0)
855 && (rest
[3] == ' ' || rest
[3] == '\t'))
857 input_line_pointer
= rest
+ 3;
859 strncasecmp (rest
, "SET", 3) == 0);
862 if (strncasecmp (rest
, "MACRO", 5) == 0
865 || is_end_of_line
[(unsigned char) rest
[5]]))
869 /* In MRI mode, we need to handle the MACRO
870 pseudo-op specially: we don't want to put the
871 symbol in the symbol table. */
873 #ifdef TC_START_LABEL_WITHOUT_COLON
874 && TC_START_LABEL_WITHOUT_COLON(c
,
878 line_label
= colon (line_start
);
880 line_label
= symbol_create (line_start
,
885 *input_line_pointer
= c
;
887 input_line_pointer
++;
892 /* We are at the beginning of a line, or similar place.
893 We expect a well-formed assembler statement.
894 A "symbol-name:" is a statement.
896 Depending on what compiler is used, the order of these tests
897 may vary to catch most common case 1st.
898 Each test is independent of all other tests at the (top)
901 c
= *input_line_pointer
++;
902 while (c
== '\t' || c
== ' ' || c
== '\f');
904 /* C is the 1st significant character.
905 Input_line_pointer points after that character. */
906 if (is_name_beginner (c
))
908 /* Want user-defined label or pseudo/opcode. */
909 HANDLE_CONDITIONAL_ASSEMBLY ();
911 s
= --input_line_pointer
;
912 c
= get_symbol_end (); /* name's delimiter. */
914 /* C is character after symbol.
915 That character's place in the input line is now '\0'.
916 S points to the beginning of the symbol.
917 [In case of pseudo-op, s->'.'.]
918 Input_line_pointer->'\0' where c was. */
919 if (TC_START_LABEL (c
, s
, input_line_pointer
))
923 char *rest
= input_line_pointer
+ 1;
925 /* In MRI mode, \tsym: set 0 is permitted. */
929 if (*rest
== ' ' || *rest
== '\t')
932 if ((strncasecmp (rest
, "EQU", 3) == 0
933 || strncasecmp (rest
, "SET", 3) == 0)
934 && (rest
[3] == ' ' || rest
[3] == '\t'))
936 input_line_pointer
= rest
+ 3;
942 line_label
= colon (s
); /* User-defined label. */
943 /* Put ':' back for error messages' sake. */
944 *input_line_pointer
++ = ':';
945 #ifdef tc_check_label
946 tc_check_label (line_label
);
948 /* Input_line_pointer->after ':'. */
951 else if ((c
== '=' && input_line_pointer
[1] == '=')
952 || ((c
== ' ' || c
== '\t')
953 && input_line_pointer
[1] == '='
954 && input_line_pointer
[2] == '='))
957 demand_empty_rest_of_line ();
960 || ((c
== ' ' || c
== '\t')
961 && input_line_pointer
[1] == '='))
962 #ifdef TC_EQUAL_IN_INSN
963 && !TC_EQUAL_IN_INSN (c
, s
)
968 demand_empty_rest_of_line ();
972 /* Expect pseudo-op or machine instruction. */
975 #ifndef TC_CASE_SENSITIVE
979 strncpy (original_case_string
, s2
, sizeof (original_case_string
));
980 original_case_string
[sizeof (original_case_string
) - 1] = 0;
989 if (NO_PSEUDO_DOT
|| flag_m68k_mri
)
991 /* The MRI assembler uses pseudo-ops without
993 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
994 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
999 || (!flag_m68k_mri
&& *s
== '.'))
1003 WARNING: c has next char, which may be end-of-line.
1004 We lookup the pseudo-op table with s+1 because we
1005 already know that the pseudo-op begins with a '.'. */
1008 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
1009 if (pop
&& !pop
->poc_handler
)
1012 /* In MRI mode, we may need to insert an
1013 automatic alignment directive. What a hack
1015 if (mri_pending_align
1017 || !((pop
->poc_handler
== cons
1018 && pop
->poc_val
== 1)
1019 || (pop
->poc_handler
== s_space
1020 && pop
->poc_val
== 1)
1021 #ifdef tc_conditional_pseudoop
1022 || tc_conditional_pseudoop (pop
)
1024 || pop
->poc_handler
== s_if
1025 || pop
->poc_handler
== s_ifdef
1026 || pop
->poc_handler
== s_ifc
1027 || pop
->poc_handler
== s_ifeqs
1028 || pop
->poc_handler
== s_else
1029 || pop
->poc_handler
== s_endif
1030 || pop
->poc_handler
== s_globl
1031 || pop
->poc_handler
== s_ignore
)))
1033 do_align (1, (char *) NULL
, 0, 0);
1034 mri_pending_align
= 0;
1036 if (line_label
!= NULL
)
1038 symbol_set_frag (line_label
, frag_now
);
1039 S_SET_VALUE (line_label
, frag_now_fix ());
1043 /* Print the error msg now, while we still can. */
1046 char *end
= input_line_pointer
;
1048 *input_line_pointer
= c
;
1050 c
= *--input_line_pointer
;
1051 *input_line_pointer
= '\0';
1052 if (! macro_defined
|| ! try_macro (c
, s
))
1055 as_bad (_("unknown pseudo-op: `%s'"), s
);
1056 *input_line_pointer
++ = c
;
1061 /* Put it back for error messages etc. */
1062 *input_line_pointer
= c
;
1063 /* The following skip of whitespace is compulsory.
1064 A well shaped space is sometimes all that separates
1065 keyword from operands. */
1066 if (c
== ' ' || c
== '\t')
1067 input_line_pointer
++;
1069 /* Input_line is restored.
1070 Input_line_pointer->1st non-blank char
1071 after pseudo-operation. */
1072 (*pop
->poc_handler
) (pop
->poc_val
);
1074 /* If that was .end, just get out now. */
1075 if (pop
->poc_handler
== s_end
)
1080 /* WARNING: c has char, which may be end-of-line. */
1081 /* Also: input_line_pointer->`\0` where c was. */
1082 *input_line_pointer
= c
;
1083 input_line_pointer
= _find_end_of_line (input_line_pointer
, flag_m68k_mri
, 1, 0);
1084 c
= *input_line_pointer
;
1085 *input_line_pointer
= '\0';
1087 generate_lineno_debug ();
1089 if (macro_defined
&& try_macro (c
, s
))
1092 if (mri_pending_align
)
1094 do_align (1, (char *) NULL
, 0, 0);
1095 mri_pending_align
= 0;
1096 if (line_label
!= NULL
)
1098 symbol_set_frag (line_label
, frag_now
);
1099 S_SET_VALUE (line_label
, frag_now_fix ());
1103 assemble_one (s
); /* Assemble 1 instruction. */
1105 *input_line_pointer
++ = c
;
1107 /* We resume loop AFTER the end-of-line from
1108 this instruction. */
1114 /* Empty statement? */
1115 if (is_end_of_line
[(unsigned char) c
])
1118 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
) && ISDIGIT (c
))
1120 /* local label ("4:") */
1121 char *backup
= input_line_pointer
;
1123 HANDLE_CONDITIONAL_ASSEMBLY ();
1127 /* Read the whole number. */
1128 while (ISDIGIT (*input_line_pointer
))
1130 temp
= (temp
* 10) + *input_line_pointer
- '0';
1131 ++input_line_pointer
;
1134 if (LOCAL_LABELS_DOLLAR
1135 && *input_line_pointer
== '$'
1136 && *(input_line_pointer
+ 1) == ':')
1138 input_line_pointer
+= 2;
1140 if (dollar_label_defined (temp
))
1142 as_fatal (_("label \"%d$\" redefined"), temp
);
1145 define_dollar_label (temp
);
1146 colon (dollar_label_name (temp
, 0));
1151 && *input_line_pointer
++ == ':')
1153 fb_label_instance_inc (temp
);
1154 colon (fb_label_name (temp
, 0));
1158 input_line_pointer
= backup
;
1159 } /* local label ("4:") */
1161 if (c
&& strchr (line_comment_chars
, c
))
1162 { /* Its a comment. Better say APP or NO_APP. */
1167 unsigned int new_length
;
1170 s
= input_line_pointer
;
1171 if (strncmp (s
, "APP\n", 4))
1174 ignore_rest_of_line ();
1177 bump_line_counters ();
1181 ends
= strstr (s
, "#NO_APP\n");
1185 unsigned int tmp_len
;
1188 /* The end of the #APP wasn't in this buffer. We
1189 keep reading in buffers until we find the #NO_APP
1190 that goes with this #APP There is one. The specs
1192 tmp_len
= buffer_limit
- s
;
1193 tmp_buf
= (char *) xmalloc (tmp_len
+ 1);
1194 memcpy (tmp_buf
, s
, tmp_len
);
1197 new_tmp
= input_scrub_next_buffer (&buffer
);
1201 buffer_limit
= new_tmp
;
1202 input_line_pointer
= buffer
;
1203 ends
= strstr (buffer
, "#NO_APP\n");
1205 num
= ends
- buffer
;
1207 num
= buffer_limit
- buffer
;
1209 tmp_buf
= (char *) xrealloc (tmp_buf
, tmp_len
+ num
);
1210 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
1215 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1223 input_line_pointer
= ends
+ 8;
1227 scrub_string_end
= ends
;
1229 new_length
= ends
- s
;
1230 new_buf
= (char *) xmalloc (new_length
);
1237 space
= (new_buf
+ new_length
) - new_tmp
;
1238 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
1246 new_buf
= (char *) xrealloc (new_buf
, new_length
+ 100);
1247 new_tmp
= new_buf
+ new_length
;
1254 /* We've "scrubbed" input to the preferred format. In the
1255 process we may have consumed the whole of the remaining
1256 file (and included files). We handle this formatted
1257 input similar to that of macro expansion, letting
1258 actual macro expansion (possibly nested) and other
1259 input expansion work. Beware that in messages, line
1260 numbers and possibly file names will be incorrect. */
1261 sb_add_string (&sbuf
, new_buf
);
1262 input_scrub_include_sb (&sbuf
, input_line_pointer
, 0);
1264 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1269 HANDLE_CONDITIONAL_ASSEMBLY ();
1271 #ifdef tc_unrecognized_line
1272 if (tc_unrecognized_line (c
))
1275 input_line_pointer
--;
1276 /* Report unknown char as error. */
1277 demand_empty_rest_of_line ();
1282 symbol_set_value_now (&dot_symbol
);
1284 #ifdef HANDLE_BUNDLE
1285 if (bundle_lock_frag
!= NULL
)
1287 as_bad_where (bundle_lock_frag
->fr_file
, bundle_lock_frag
->fr_line
,
1288 _(".bundle_lock with no matching .bundle_unlock"));
1289 bundle_lock_frag
= NULL
;
1290 bundle_lock_frchain
= NULL
;
1297 /* Close the input file. */
1298 input_scrub_close ();
1299 #ifdef WARN_COMMENTS
1301 if (warn_comment
&& found_comment
)
1302 as_warn_where (found_comment_file
, found_comment
,
1303 "first comment found here");
1308 /* Convert O_constant expression EXP into the equivalent O_big representation.
1309 Take the sign of the number from X_unsigned rather than X_add_number. */
1312 convert_to_bignum (expressionS
*exp
)
1317 value
= exp
->X_add_number
;
1318 for (i
= 0; i
< sizeof (exp
->X_add_number
) / CHARS_PER_LITTLENUM
; i
++)
1320 generic_bignum
[i
] = value
& LITTLENUM_MASK
;
1321 value
>>= LITTLENUM_NUMBER_OF_BITS
;
1323 /* Add a sequence of sign bits if the top bit of X_add_number is not
1324 the sign of the original value. */
1325 if ((exp
->X_add_number
< 0) != !exp
->X_unsigned
)
1326 generic_bignum
[i
++] = exp
->X_unsigned
? 0 : LITTLENUM_MASK
;
1328 exp
->X_add_number
= i
;
1331 /* For most MRI pseudo-ops, the line actually ends at the first
1332 nonquoted space. This function looks for that point, stuffs a null
1333 in, and sets *STOPCP to the character that used to be there, and
1334 returns the location.
1336 Until I hear otherwise, I am going to assume that this is only true
1337 for the m68k MRI assembler. */
1340 mri_comment_field (char *stopcp
)
1346 know (flag_m68k_mri
);
1348 for (s
= input_line_pointer
;
1349 ((!is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1357 for (s
= input_line_pointer
;
1358 !is_end_of_line
[(unsigned char) *s
];
1368 /* Skip to the end of an MRI comment field. */
1371 mri_comment_end (char *stop
, int stopc
)
1375 input_line_pointer
= stop
;
1377 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
1378 ++input_line_pointer
;
1382 s_abort (int ignore ATTRIBUTE_UNUSED
)
1384 as_fatal (_(".abort detected. Abandoning ship."));
1387 /* Guts of .align directive. N is the power of two to which to align.
1388 FILL may be NULL, or it may point to the bytes of the fill pattern.
1389 LEN is the length of whatever FILL points to, if anything. MAX is
1390 the maximum number of characters to skip when doing the alignment,
1391 or 0 if there is no maximum. */
1394 do_align (int n
, char *fill
, int len
, int max
)
1396 if (now_seg
== absolute_section
)
1400 if (*fill
++ != '\0')
1402 as_warn (_("ignoring fill value in absolute section"));
1409 #ifdef md_flush_pending_output
1410 md_flush_pending_output ();
1413 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1416 /* Only make a frag if we HAVE to... */
1417 if (n
!= 0 && !need_pass_2
)
1421 if (subseg_text_p (now_seg
))
1422 frag_align_code (n
, max
);
1424 frag_align (n
, 0, max
);
1427 frag_align (n
, *fill
, max
);
1429 frag_align_pattern (n
, fill
, len
, max
);
1433 just_record_alignment
: ATTRIBUTE_UNUSED_LABEL
1436 record_alignment (now_seg
, n
- OCTETS_PER_BYTE_POWER
);
1439 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1440 (in bytes). A negative ARG is the negative of the length of the
1441 fill pattern. BYTES_P is non-zero if the alignment value should be
1442 interpreted as the byte boundary, rather than the power of 2. */
1443 #ifndef TC_ALIGN_LIMIT
1444 #define TC_ALIGN_LIMIT (stdoutput->arch_info->bits_per_address - 1)
1448 s_align (int arg
, int bytes_p
)
1450 unsigned int align_limit
= TC_ALIGN_LIMIT
;
1459 stop
= mri_comment_field (&stopc
);
1461 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1466 align
= arg
; /* Default value from pseudo-op table. */
1470 align
= get_absolute_expression ();
1476 /* Convert to a power of 2. */
1481 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1484 as_bad (_("alignment not a power of 2"));
1490 if (align
> align_limit
)
1492 align
= align_limit
;
1493 as_warn (_("alignment too large: %u assumed"), align
);
1496 if (*input_line_pointer
!= ',')
1503 ++input_line_pointer
;
1504 if (*input_line_pointer
== ',')
1508 fill
= get_absolute_expression ();
1513 if (*input_line_pointer
!= ',')
1517 ++input_line_pointer
;
1518 max
= get_absolute_expression ();
1525 as_warn (_("expected fill pattern missing"));
1526 do_align (align
, (char *) NULL
, 0, max
);
1541 do_align (align
, &fill_char
, fill_len
, max
);
1547 if ((size_t) fill_len
> sizeof ab
)
1549 md_number_to_chars (ab
, fill
, fill_len
);
1550 do_align (align
, ab
, fill_len
, max
);
1554 demand_empty_rest_of_line ();
1557 mri_comment_end (stop
, stopc
);
1560 /* Handle the .align pseudo-op on machines where ".align 4" means
1561 align to a 4 byte boundary. */
1564 s_align_bytes (int arg
)
1569 /* Handle the .align pseudo-op on machines where ".align 4" means align
1570 to a 2**4 boundary. */
1573 s_align_ptwo (int arg
)
1578 /* Switch in and out of alternate macro mode. */
1583 demand_empty_rest_of_line ();
1584 macro_set_alternate (on
);
1587 /* Read a symbol name from input_line_pointer.
1589 Stores the symbol name in a buffer and returns a pointer to this buffer.
1590 The buffer is xalloc'ed. It is the caller's responsibility to free
1593 The name is not left in the i_l_p buffer as it may need processing
1594 to handle escape characters.
1596 Advances i_l_p to the next non-whitespace character.
1598 If a symbol name could not be read, the routine issues an error
1599 messages, skips to the end of the line and returns NULL. */
1602 read_symbol_name (void)
1608 c
= *input_line_pointer
++;
1612 #define SYM_NAME_CHUNK_LEN 128
1613 ptrdiff_t len
= SYM_NAME_CHUNK_LEN
;
1617 start
= name
= xmalloc (len
+ 1);
1619 name_end
= name
+ SYM_NAME_CHUNK_LEN
;
1621 while (is_a_char (C
= next_char_of_string ()))
1623 if (name
>= name_end
)
1627 sofar
= name
- start
;
1628 len
+= SYM_NAME_CHUNK_LEN
;
1629 start
= xrealloc (start
, len
+ 1);
1630 name_end
= start
+ len
;
1631 name
= start
+ sofar
;
1638 /* Since quoted symbol names can contain non-ASCII characters,
1639 check the string and warn if it cannot be recognised by the
1640 current character set. */
1641 if (mbstowcs (NULL
, name
, len
) == (size_t) -1)
1642 as_warn (_("symbol name not recognised in the current locale"));
1644 else if (is_name_beginner (c
) || c
== '\001')
1648 name
= input_line_pointer
- 1;
1650 /* We accept \001 in a name in case this is
1651 being called with a constructed string. */
1652 while (is_part_of_name (c
= *input_line_pointer
++)
1656 len
= (input_line_pointer
- name
) - 1;
1657 start
= xmalloc (len
+ 1);
1659 memcpy (start
, name
, len
);
1662 /* Skip a name ender char if one is present. */
1663 if (! is_name_ender (c
))
1664 --input_line_pointer
;
1667 name
= start
= NULL
;
1671 as_bad (_("expected symbol name"));
1672 ignore_rest_of_line ();
1683 s_comm_internal (int param
,
1684 symbolS
*(*comm_parse_extra
) (int, symbolS
*, addressT
))
1688 symbolS
*symbolP
= NULL
;
1694 stop
= mri_comment_field (&stopc
);
1696 if ((name
= read_symbol_name ()) == NULL
)
1699 /* Accept an optional comma after the name. The comma used to be
1700 required, but Irix 5 cc does not generate it for .lcomm. */
1701 if (*input_line_pointer
== ',')
1702 input_line_pointer
++;
1704 temp
= get_absolute_expr (&exp
);
1706 size
&= ((offsetT
) 2 << (stdoutput
->arch_info
->bits_per_address
- 1)) - 1;
1707 if (exp
.X_op
== O_absent
)
1709 as_bad (_("missing size expression"));
1710 ignore_rest_of_line ();
1713 else if (temp
!= size
|| !exp
.X_unsigned
)
1715 as_warn (_("size (%ld) out of range, ignored"), (long) temp
);
1716 ignore_rest_of_line ();
1720 symbolP
= symbol_find_or_make (name
);
1721 if ((S_IS_DEFINED (symbolP
) || symbol_equated_p (symbolP
))
1722 && !S_IS_COMMON (symbolP
))
1724 if (!S_IS_VOLATILE (symbolP
))
1727 as_bad (_("symbol `%s' is already defined"), name
);
1728 ignore_rest_of_line ();
1731 symbolP
= symbol_clone (symbolP
, 1);
1732 S_SET_SEGMENT (symbolP
, undefined_section
);
1733 S_SET_VALUE (symbolP
, 0);
1734 symbol_set_frag (symbolP
, &zero_address_frag
);
1735 S_CLEAR_VOLATILE (symbolP
);
1738 size
= S_GET_VALUE (symbolP
);
1741 else if (size
!= temp
)
1742 as_warn (_("size of \"%s\" is already %ld; not changing to %ld"),
1743 name
, (long) size
, (long) temp
);
1745 if (comm_parse_extra
!= NULL
)
1746 symbolP
= (*comm_parse_extra
) (param
, symbolP
, size
);
1749 S_SET_VALUE (symbolP
, (valueT
) size
);
1750 S_SET_EXTERNAL (symbolP
);
1751 S_SET_SEGMENT (symbolP
, bfd_com_section_ptr
);
1754 demand_empty_rest_of_line ();
1757 mri_comment_end (stop
, stopc
);
1766 s_comm_internal (ignore
, NULL
);
1769 /* The MRI COMMON pseudo-op. We handle this by creating a common
1770 symbol with the appropriate name. We make s_space do the right
1771 thing by increasing the size. */
1774 s_mri_common (int small ATTRIBUTE_UNUSED
)
1790 stop
= mri_comment_field (&stopc
);
1794 name
= input_line_pointer
;
1795 if (!ISDIGIT (*name
))
1796 c
= get_symbol_end ();
1801 ++input_line_pointer
;
1803 while (ISDIGIT (*input_line_pointer
));
1805 c
= *input_line_pointer
;
1806 *input_line_pointer
= '\0';
1808 if (line_label
!= NULL
)
1810 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1811 + (input_line_pointer
- name
)
1813 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1818 sym
= symbol_find_or_make (name
);
1819 *input_line_pointer
= c
;
1823 if (*input_line_pointer
!= ',')
1827 ++input_line_pointer
;
1828 align
= get_absolute_expression ();
1831 if (S_IS_DEFINED (sym
) && !S_IS_COMMON (sym
))
1833 as_bad (_("symbol `%s' is already defined"), S_GET_NAME (sym
));
1834 ignore_rest_of_line ();
1835 mri_comment_end (stop
, stopc
);
1839 S_SET_EXTERNAL (sym
);
1840 S_SET_SEGMENT (sym
, bfd_com_section_ptr
);
1841 mri_common_symbol
= sym
;
1845 S_SET_ALIGN (sym
, align
);
1850 if (line_label
!= NULL
)
1853 exp
.X_op
= O_symbol
;
1854 exp
.X_add_symbol
= sym
;
1855 exp
.X_add_number
= 0;
1856 symbol_set_value_expression (line_label
, &exp
);
1857 symbol_set_frag (line_label
, &zero_address_frag
);
1858 S_SET_SEGMENT (line_label
, expr_section
);
1861 /* FIXME: We just ignore the small argument, which distinguishes
1862 COMMON and COMMON.S. I don't know what we can do about it. */
1864 /* Ignore the type and hptype. */
1865 if (*input_line_pointer
== ',')
1866 input_line_pointer
+= 2;
1867 if (*input_line_pointer
== ',')
1868 input_line_pointer
+= 2;
1870 demand_empty_rest_of_line ();
1872 mri_comment_end (stop
, stopc
);
1876 s_data (int ignore ATTRIBUTE_UNUSED
)
1881 temp
= get_absolute_expression ();
1882 if (flag_readonly_data_in_text
)
1884 section
= text_section
;
1888 section
= data_section
;
1890 subseg_set (section
, (subsegT
) temp
);
1892 demand_empty_rest_of_line ();
1895 /* Handle the .appfile pseudo-op. This is automatically generated by
1896 do_scrub_chars when a preprocessor # line comment is seen with a
1897 file name. This default definition may be overridden by the object
1898 or CPU specific pseudo-ops. This function is also the default
1899 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1903 s_app_file_string (char *file
, int appfile ATTRIBUTE_UNUSED
)
1907 listing_source_file (file
);
1909 register_dependency (file
);
1911 obj_app_file (file
, appfile
);
1916 s_app_file (int appfile
)
1921 /* Some assemblers tolerate immediately following '"'. */
1922 if ((s
= demand_copy_string (&length
)) != 0)
1925 = (!new_logical_line_flags (s
, -1, 1) && appfile
);
1927 /* In MRI mode, the preprocessor may have inserted an extraneous
1930 && *input_line_pointer
== '\''
1931 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1932 ++input_line_pointer
;
1934 demand_empty_rest_of_line ();
1936 s_app_file_string (s
, appfile
);
1941 get_linefile_number (int *flag
)
1945 if (*input_line_pointer
< '0' || *input_line_pointer
> '9')
1948 *flag
= get_absolute_expression ();
1953 /* Handle the .appline pseudo-op. This is automatically generated by
1954 do_scrub_chars when a preprocessor # line comment is seen. This
1955 default definition may be overridden by the object or CPU specific
1959 s_app_line (int appline
)
1964 /* The given number is that of the next line. */
1966 l
= get_absolute_expression ();
1967 else if (!get_linefile_number (&l
))
1969 ignore_rest_of_line ();
1976 /* Some of the back ends can't deal with non-positive line numbers.
1977 Besides, it's silly. GCC however will generate a line number of
1978 zero when it is pre-processing builtins for assembler-with-cpp files:
1982 We do not want to barf on this, especially since such files are used
1983 in the GCC and GDB testsuites. So we check for negative line numbers
1984 rather than non-positive line numbers. */
1985 as_warn (_("line numbers must be positive; line number %d rejected"),
1996 if (*input_line_pointer
== '"')
1997 file
= demand_copy_string (&length
);
2003 while (get_linefile_number (&this_flag
))
2006 /* From GCC's cpp documentation:
2007 1: start of a new file.
2008 2: returning to a file after having included
2010 3: following text comes from a system header file.
2011 4: following text should be treated as extern "C".
2013 4 is nonsensical for the assembler; 3, we don't
2014 care about, so we ignore it just in case a
2015 system header file is included while
2016 preprocessing assembly. So 1 and 2 are all we
2017 care about, and they are mutually incompatible.
2018 new_logical_line_flags() demands this. */
2021 if (flags
&& flags
!= (1 << this_flag
))
2022 as_warn (_("incompatible flag %i in line directive"),
2025 flags
|= 1 << this_flag
;
2030 /* We ignore these. */
2034 as_warn (_("unsupported flag %i in line directive"),
2039 if (!is_end_of_line
[(unsigned char)*input_line_pointer
])
2044 if (appline
|| file
)
2046 new_logical_line_flags (file
, l
, flags
);
2049 listing_source_line (l
);
2053 if (appline
|| file
)
2054 demand_empty_rest_of_line ();
2056 ignore_rest_of_line ();
2059 /* Handle the .end pseudo-op. Actually, the real work is done in
2060 read_a_source_file. */
2063 s_end (int ignore ATTRIBUTE_UNUSED
)
2067 /* The MRI assembler permits the start symbol to follow .end,
2068 but we don't support that. */
2070 if (!is_end_of_line
[(unsigned char) *input_line_pointer
]
2071 && *input_line_pointer
!= '*'
2072 && *input_line_pointer
!= '!')
2073 as_warn (_("start address not supported"));
2077 /* Handle the .err pseudo-op. */
2080 s_err (int ignore ATTRIBUTE_UNUSED
)
2082 as_bad (_(".err encountered"));
2083 demand_empty_rest_of_line ();
2086 /* Handle the .error and .warning pseudo-ops. */
2092 /* The purpose for the conditional assignment is not to
2093 internationalize the directive itself, but that we need a
2094 self-contained message, one that can be passed like the
2095 demand_copy_C_string return value, and with no assumption on the
2096 location of the name of the directive within the message. */
2098 = (err
? _(".error directive invoked in source file")
2099 : _(".warning directive invoked in source file"));
2101 if (!is_it_end_of_statement ())
2103 if (*input_line_pointer
!= '\"')
2105 as_bad (_("%s argument must be a string"),
2106 err
? ".error" : ".warning");
2107 ignore_rest_of_line ();
2111 msg
= demand_copy_C_string (&len
);
2119 as_warn ("%s", msg
);
2120 demand_empty_rest_of_line ();
2123 /* Handle the MRI fail pseudo-op. */
2126 s_fail (int ignore ATTRIBUTE_UNUSED
)
2133 stop
= mri_comment_field (&stopc
);
2135 temp
= get_absolute_expression ();
2137 as_warn (_(".fail %ld encountered"), (long) temp
);
2139 as_bad (_(".fail %ld encountered"), (long) temp
);
2141 demand_empty_rest_of_line ();
2144 mri_comment_end (stop
, stopc
);
2148 s_fill (int ignore ATTRIBUTE_UNUSED
)
2150 expressionS rep_exp
;
2155 #ifdef md_flush_pending_output
2156 md_flush_pending_output ();
2159 #ifdef md_cons_align
2163 get_known_segmented_expression (&rep_exp
);
2164 if (*input_line_pointer
== ',')
2166 input_line_pointer
++;
2167 size
= get_absolute_expression ();
2168 if (*input_line_pointer
== ',')
2170 input_line_pointer
++;
2171 fill
= get_absolute_expression ();
2175 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
2176 #define BSD_FILL_SIZE_CROCK_8 (8)
2177 if (size
> BSD_FILL_SIZE_CROCK_8
)
2179 as_warn (_(".fill size clamped to %d"), BSD_FILL_SIZE_CROCK_8
);
2180 size
= BSD_FILL_SIZE_CROCK_8
;
2184 as_warn (_("size negative; .fill ignored"));
2187 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
2189 if (rep_exp
.X_add_number
< 0)
2190 as_warn (_("repeat < 0; .fill ignored"));
2194 if (size
&& !need_pass_2
)
2196 if (rep_exp
.X_op
== O_constant
)
2198 p
= frag_var (rs_fill
, (int) size
, (int) size
,
2199 (relax_substateT
) 0, (symbolS
*) 0,
2200 (offsetT
) rep_exp
.X_add_number
,
2205 /* We don't have a constant repeat count, so we can't use
2206 rs_fill. We can get the same results out of rs_space,
2207 but its argument is in bytes, so we must multiply the
2208 repeat count by size. */
2211 rep_sym
= make_expr_symbol (&rep_exp
);
2214 expressionS size_exp
;
2215 size_exp
.X_op
= O_constant
;
2216 size_exp
.X_add_number
= size
;
2218 rep_exp
.X_op
= O_multiply
;
2219 rep_exp
.X_add_symbol
= rep_sym
;
2220 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
2221 rep_exp
.X_add_number
= 0;
2222 rep_sym
= make_expr_symbol (&rep_exp
);
2225 p
= frag_var (rs_space
, (int) size
, (int) size
,
2226 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
2229 memset (p
, 0, (unsigned int) size
);
2231 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
2232 flavoured AS. The following bizarre behaviour is to be
2233 compatible with above. I guess they tried to take up to 8
2234 bytes from a 4-byte expression and they forgot to sign
2236 #define BSD_FILL_SIZE_CROCK_4 (4)
2237 md_number_to_chars (p
, (valueT
) fill
,
2238 (size
> BSD_FILL_SIZE_CROCK_4
2239 ? BSD_FILL_SIZE_CROCK_4
2241 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
2242 but emits no error message because it seems a legal thing to do.
2243 It is a degenerate case of .fill but could be emitted by a
2246 demand_empty_rest_of_line ();
2250 s_globl (int ignore ATTRIBUTE_UNUSED
)
2259 stop
= mri_comment_field (&stopc
);
2263 if ((name
= read_symbol_name ()) == NULL
)
2266 symbolP
= symbol_find_or_make (name
);
2267 S_SET_EXTERNAL (symbolP
);
2270 c
= *input_line_pointer
;
2273 input_line_pointer
++;
2275 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
2283 demand_empty_rest_of_line ();
2286 mri_comment_end (stop
, stopc
);
2290 #define skip_whitespace(str) do { if (*(str) == ' ') ++(str); } while (0)
2293 skip_past_char (char ** str
, char c
)
2303 #define skip_past_comma(str) skip_past_char (str, ',')
2305 /* Parse an attribute directive for VENDOR.
2306 Returns the attribute number read, or zero on error. */
2308 s_vendor_attribute (int vendor
)
2316 /* Read the first number or name. */
2317 skip_whitespace (input_line_pointer
);
2318 s
= input_line_pointer
;
2319 if (ISDIGIT (*input_line_pointer
))
2322 if (exp
.X_op
!= O_constant
)
2324 tag
= exp
.X_add_number
;
2330 /* A name may contain '_', but no other punctuation. */
2331 for (; ISALNUM (*input_line_pointer
) || *input_line_pointer
== '_';
2332 ++input_line_pointer
)
2337 name
= (char *) alloca (i
+ 1);
2338 memcpy (name
, s
, i
);
2341 #ifndef CONVERT_SYMBOLIC_ATTRIBUTE
2342 #define CONVERT_SYMBOLIC_ATTRIBUTE(a) -1
2345 tag
= CONVERT_SYMBOLIC_ATTRIBUTE (name
);
2348 as_bad (_("Attribute name not recognised: %s"), name
);
2349 ignore_rest_of_line ();
2354 type
= _bfd_elf_obj_attrs_arg_type (stdoutput
, vendor
, tag
);
2356 if (skip_past_comma (&input_line_pointer
) == -1)
2361 if (exp
.X_op
!= O_constant
)
2363 as_bad (_("expected numeric constant"));
2364 ignore_rest_of_line ();
2367 i
= exp
.X_add_number
;
2370 && skip_past_comma (&input_line_pointer
) == -1)
2372 as_bad (_("expected comma"));
2373 ignore_rest_of_line ();
2380 skip_whitespace (input_line_pointer
);
2381 if (*input_line_pointer
!= '"')
2383 s
= demand_copy_C_string (&len
);
2389 bfd_elf_add_obj_attr_int_string (stdoutput
, vendor
, tag
, i
, s
);
2392 bfd_elf_add_obj_attr_string (stdoutput
, vendor
, tag
, s
);
2395 bfd_elf_add_obj_attr_int (stdoutput
, vendor
, tag
, i
);
2401 demand_empty_rest_of_line ();
2404 as_bad (_("bad string constant"));
2405 ignore_rest_of_line ();
2408 as_bad (_("expected <tag> , <value>"));
2409 ignore_rest_of_line ();
2413 /* Parse a .gnu_attribute directive. */
2416 s_gnu_attribute (int ignored ATTRIBUTE_UNUSED
)
2418 s_vendor_attribute (OBJ_ATTR_GNU
);
2420 #endif /* OBJ_ELF */
2422 /* Handle the MRI IRP and IRPC pseudo-ops. */
2433 as_where (&file
, &line
);
2436 eol
= find_end_of_line (input_line_pointer
, 0);
2437 sb_add_buffer (&s
, input_line_pointer
, eol
- input_line_pointer
);
2438 input_line_pointer
= eol
;
2442 err
= expand_irp (irpc
, 0, &s
, &out
, get_non_macro_line_sb
);
2444 as_bad_where (file
, line
, "%s", err
);
2448 input_scrub_include_sb (&out
, input_line_pointer
, 1);
2450 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2453 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
2454 the section to only be linked once. However, this is not supported
2455 by most object file formats. This takes an optional argument,
2456 which is what to do about duplicates. */
2459 s_linkonce (int ignore ATTRIBUTE_UNUSED
)
2461 enum linkonce_type type
;
2465 type
= LINKONCE_DISCARD
;
2467 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
2472 s
= input_line_pointer
;
2473 c
= get_symbol_end ();
2474 if (strcasecmp (s
, "discard") == 0)
2475 type
= LINKONCE_DISCARD
;
2476 else if (strcasecmp (s
, "one_only") == 0)
2477 type
= LINKONCE_ONE_ONLY
;
2478 else if (strcasecmp (s
, "same_size") == 0)
2479 type
= LINKONCE_SAME_SIZE
;
2480 else if (strcasecmp (s
, "same_contents") == 0)
2481 type
= LINKONCE_SAME_CONTENTS
;
2483 as_warn (_("unrecognized .linkonce type `%s'"), s
);
2485 *input_line_pointer
= c
;
2488 #ifdef obj_handle_link_once
2489 obj_handle_link_once (type
);
2490 #else /* ! defined (obj_handle_link_once) */
2494 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
2495 as_warn (_(".linkonce is not supported for this object file format"));
2497 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
2498 flags
|= SEC_LINK_ONCE
;
2503 case LINKONCE_DISCARD
:
2504 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
2506 case LINKONCE_ONE_ONLY
:
2507 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
2509 case LINKONCE_SAME_SIZE
:
2510 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
2512 case LINKONCE_SAME_CONTENTS
:
2513 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
2516 if (!bfd_set_section_flags (stdoutput
, now_seg
, flags
))
2517 as_bad (_("bfd_set_section_flags: %s"),
2518 bfd_errmsg (bfd_get_error ()));
2520 #endif /* ! defined (obj_handle_link_once) */
2522 demand_empty_rest_of_line ();
2526 bss_alloc (symbolS
*symbolP
, addressT size
, int align
)
2529 segT current_seg
= now_seg
;
2530 subsegT current_subseg
= now_subseg
;
2531 segT bss_seg
= bss_section
;
2533 #if defined (TC_MIPS) || defined (TC_ALPHA)
2534 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
2535 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
2537 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
2538 if (size
<= bfd_get_gp_size (stdoutput
))
2540 bss_seg
= subseg_new (".sbss", 1);
2541 seg_info (bss_seg
)->bss
= 1;
2542 if (!bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
2543 as_warn (_("error setting flags for \".sbss\": %s"),
2544 bfd_errmsg (bfd_get_error ()));
2548 subseg_set (bss_seg
, 1);
2552 record_alignment (bss_seg
, align
);
2553 frag_align (align
, 0, 0);
2556 /* Detach from old frag. */
2557 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2558 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2560 symbol_set_frag (symbolP
, frag_now
);
2561 pfrag
= frag_var (rs_org
, 1, 1, 0, symbolP
, size
, NULL
);
2565 S_SET_SIZE (symbolP
, size
);
2567 S_SET_SEGMENT (symbolP
, bss_seg
);
2570 /* The symbol may already have been created with a preceding
2571 ".globl" directive -- be careful not to step on storage class
2572 in that case. Otherwise, set it to static. */
2573 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2574 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2575 #endif /* OBJ_COFF */
2577 subseg_set (current_seg
, current_subseg
);
2581 parse_align (int align_bytes
)
2587 if (*input_line_pointer
!= ',')
2590 as_bad (_("expected alignment after size"));
2591 ignore_rest_of_line ();
2595 input_line_pointer
++;
2598 align
= get_absolute_expr (&exp
);
2599 if (exp
.X_op
== O_absent
)
2602 if (!exp
.X_unsigned
)
2604 as_warn (_("alignment negative; 0 assumed"));
2608 if (align_bytes
&& align
!= 0)
2610 /* convert to a power of 2 alignment */
2611 unsigned int alignp2
= 0;
2612 while ((align
& 1) == 0)
2613 align
>>= 1, ++alignp2
;
2616 as_bad (_("alignment not a power of 2"));
2617 ignore_rest_of_line ();
2625 /* Called from s_comm_internal after symbol name and size have been
2626 parsed. NEEDS_ALIGN is 0 if it was an ".lcomm" (2 args only),
2627 1 if this was a ".bss" directive which has a 3rd argument
2628 (alignment as a power of 2), or 2 if this was a ".bss" directive
2629 with alignment in bytes. */
2632 s_lcomm_internal (int needs_align
, symbolS
*symbolP
, addressT size
)
2638 align
= parse_align (needs_align
- 1);
2639 if (align
== (addressT
) -1)
2643 /* Assume some objects may require alignment on some systems. */
2644 TC_IMPLICIT_LCOMM_ALIGNMENT (size
, align
);
2646 bss_alloc (symbolP
, size
, align
);
2651 s_lcomm (int needs_align
)
2653 s_comm_internal (needs_align
, s_lcomm_internal
);
2657 s_lcomm_bytes (int needs_align
)
2659 s_comm_internal (needs_align
* 2, s_lcomm_internal
);
2663 s_lsym (int ignore ATTRIBUTE_UNUSED
)
2669 /* We permit ANY defined expression: BSD4.2 demands constants. */
2670 if ((name
= read_symbol_name ()) == NULL
)
2673 if (*input_line_pointer
!= ',')
2675 as_bad (_("expected comma after \"%s\""), name
);
2679 input_line_pointer
++;
2680 expression_and_evaluate (&exp
);
2682 if (exp
.X_op
!= O_constant
2683 && exp
.X_op
!= O_register
)
2685 as_bad (_("bad expression"));
2689 symbolP
= symbol_find_or_make (name
);
2691 if (S_GET_SEGMENT (symbolP
) == undefined_section
)
2693 /* The name might be an undefined .global symbol; be sure to
2694 keep the "external" bit. */
2695 S_SET_SEGMENT (symbolP
,
2696 (exp
.X_op
== O_constant
2699 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2703 as_bad (_("symbol `%s' is already defined"), name
);
2706 demand_empty_rest_of_line ();
2711 ignore_rest_of_line ();
2716 /* Read a line into an sb. Returns the character that ended the line
2717 or zero if there are no more lines. */
2720 get_line_sb (sb
*line
, int in_macro
)
2724 if (input_line_pointer
[-1] == '\n')
2725 bump_line_counters ();
2727 if (input_line_pointer
>= buffer_limit
)
2729 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2730 if (buffer_limit
== 0)
2734 eol
= _find_end_of_line (input_line_pointer
, flag_m68k_mri
, 0, in_macro
);
2735 sb_add_buffer (line
, input_line_pointer
, eol
- input_line_pointer
);
2736 input_line_pointer
= eol
;
2738 /* Don't skip multiple end-of-line characters, because that breaks support
2739 for the IA-64 stop bit (;;) which looks like two consecutive end-of-line
2740 characters but isn't. Instead just skip one end of line character and
2741 return the character skipped so that the caller can re-insert it if
2743 return *input_line_pointer
++;
2747 get_non_macro_line_sb (sb
*line
)
2749 return get_line_sb (line
, 0);
2753 get_macro_line_sb (sb
*line
)
2755 return get_line_sb (line
, 1);
2758 /* Define a macro. This is an interface to macro.c. */
2761 s_macro (int ignore ATTRIBUTE_UNUSED
)
2769 as_where (&file
, &line
);
2772 eol
= find_end_of_line (input_line_pointer
, 0);
2773 sb_add_buffer (&s
, input_line_pointer
, eol
- input_line_pointer
);
2774 input_line_pointer
= eol
;
2776 if (line_label
!= NULL
)
2781 sb_add_string (&label
, S_GET_NAME (line_label
));
2782 err
= define_macro (0, &s
, &label
, get_macro_line_sb
, file
, line
, &name
);
2786 err
= define_macro (0, &s
, NULL
, get_macro_line_sb
, file
, line
, &name
);
2788 as_bad_where (file
, line
, err
, name
);
2791 if (line_label
!= NULL
)
2793 S_SET_SEGMENT (line_label
, absolute_section
);
2794 S_SET_VALUE (line_label
, 0);
2795 symbol_set_frag (line_label
, &zero_address_frag
);
2798 if (((NO_PSEUDO_DOT
|| flag_m68k_mri
)
2799 && hash_find (po_hash
, name
) != NULL
)
2802 && hash_find (po_hash
, name
+ 1) != NULL
))
2803 as_warn_where (file
,
2805 _("attempt to redefine pseudo-op `%s' ignored"),
2812 /* Handle the .mexit pseudo-op, which immediately exits a macro
2816 s_mexit (int ignore ATTRIBUTE_UNUSED
)
2820 cond_exit_macro (macro_nest
);
2821 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2824 as_warn (_("ignoring macro exit outside a macro definition."));
2827 /* Switch in and out of MRI mode. */
2830 s_mri (int ignore ATTRIBUTE_UNUSED
)
2833 #ifdef MRI_MODE_CHANGE
2837 on
= get_absolute_expression ();
2838 #ifdef MRI_MODE_CHANGE
2839 old_flag
= flag_mri
;
2858 /* Operator precedence changes in m68k MRI mode, so we need to
2859 update the operator rankings. */
2860 expr_set_precedence ();
2862 #ifdef MRI_MODE_CHANGE
2864 MRI_MODE_CHANGE (on
);
2867 demand_empty_rest_of_line ();
2870 /* Handle changing the location counter. */
2873 do_org (segT segment
, expressionS
*exp
, int fill
)
2875 if (segment
!= now_seg
2876 && segment
!= absolute_section
2877 && segment
!= expr_section
)
2878 as_bad (_("invalid segment \"%s\""), segment_name (segment
));
2880 if (now_seg
== absolute_section
)
2883 as_warn (_("ignoring fill value in absolute section"));
2884 if (exp
->X_op
!= O_constant
)
2886 as_bad (_("only constant offsets supported in absolute section"));
2887 exp
->X_add_number
= 0;
2889 abs_section_offset
= exp
->X_add_number
;
2894 symbolS
*sym
= exp
->X_add_symbol
;
2895 offsetT off
= exp
->X_add_number
* OCTETS_PER_BYTE
;
2897 if (exp
->X_op
!= O_constant
&& exp
->X_op
!= O_symbol
)
2899 /* Handle complex expressions. */
2900 sym
= make_expr_symbol (exp
);
2904 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, sym
, off
, (char *) 0);
2910 s_org (int ignore ATTRIBUTE_UNUSED
)
2916 #ifdef md_flush_pending_output
2917 md_flush_pending_output ();
2920 /* The m68k MRI assembler has a different meaning for .org. It
2921 means to create an absolute section at a given address. We can't
2922 support that--use a linker script instead. */
2925 as_bad (_("MRI style ORG pseudo-op not supported"));
2926 ignore_rest_of_line ();
2930 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2931 thing as a sub-segment-relative origin. Any absolute origin is
2932 given a warning, then assumed to be segment-relative. Any
2933 segmented origin expression ("foo+42") had better be in the right
2934 segment or the .org is ignored.
2936 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2937 we never know sub-segment sizes when we are reading code. BSD
2938 will crash trying to emit negative numbers of filler bytes in
2939 certain .orgs. We don't crash, but see as-write for that code.
2941 Don't make frag if need_pass_2==1. */
2942 segment
= get_known_segmented_expression (&exp
);
2943 if (*input_line_pointer
== ',')
2945 input_line_pointer
++;
2946 temp_fill
= get_absolute_expression ();
2952 do_org (segment
, &exp
, temp_fill
);
2954 demand_empty_rest_of_line ();
2957 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2958 called by the obj-format routine which handles section changing
2959 when in MRI mode. It will create a new section, and return it. It
2960 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2961 'M' (mixed), or 'R' (romable). The flags will be set in the section. */
2964 s_mri_sect (char *type ATTRIBUTE_UNUSED
)
2974 name
= input_line_pointer
;
2975 if (!ISDIGIT (*name
))
2976 c
= get_symbol_end ();
2981 ++input_line_pointer
;
2983 while (ISDIGIT (*input_line_pointer
));
2985 c
= *input_line_pointer
;
2986 *input_line_pointer
= '\0';
2989 name
= xstrdup (name
);
2991 *input_line_pointer
= c
;
2993 seg
= subseg_new (name
, 0);
2995 if (*input_line_pointer
== ',')
2999 ++input_line_pointer
;
3000 align
= get_absolute_expression ();
3001 record_alignment (seg
, align
);
3005 if (*input_line_pointer
== ',')
3007 c
= *++input_line_pointer
;
3009 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
3012 as_bad (_("unrecognized section type"));
3013 ++input_line_pointer
;
3018 flags
= SEC_NO_FLAGS
;
3020 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
3021 else if (*type
== 'D' || *type
== 'M')
3022 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
3023 else if (*type
== 'R')
3024 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
3025 if (flags
!= SEC_NO_FLAGS
)
3027 if (!bfd_set_section_flags (stdoutput
, seg
, flags
))
3028 as_warn (_("error setting flags for \"%s\": %s"),
3029 bfd_section_name (stdoutput
, seg
),
3030 bfd_errmsg (bfd_get_error ()));
3035 /* Ignore the HP type. */
3036 if (*input_line_pointer
== ',')
3037 input_line_pointer
+= 2;
3039 demand_empty_rest_of_line ();
3041 #else /* ! TC_M68K */
3050 name
= input_line_pointer
;
3051 c
= get_symbol_end ();
3053 name
= xstrdup (name
);
3055 *input_line_pointer
= c
;
3057 seg
= subseg_new (name
, 0);
3059 if (*input_line_pointer
!= ',')
3065 ++input_line_pointer
;
3067 sectype
= input_line_pointer
;
3068 c
= get_symbol_end ();
3069 if (*sectype
== '\0')
3071 else if (strcasecmp (sectype
, "text") == 0)
3073 else if (strcasecmp (sectype
, "data") == 0)
3075 else if (strcasecmp (sectype
, "romdata") == 0)
3078 as_warn (_("unrecognized section type `%s'"), sectype
);
3079 *input_line_pointer
= c
;
3082 if (*input_line_pointer
== ',')
3086 ++input_line_pointer
;
3088 seccmd
= input_line_pointer
;
3089 c
= get_symbol_end ();
3090 if (strcasecmp (seccmd
, "absolute") == 0)
3092 as_bad (_("absolute sections are not supported"));
3093 *input_line_pointer
= c
;
3094 ignore_rest_of_line ();
3097 else if (strcasecmp (seccmd
, "align") == 0)
3101 *input_line_pointer
= c
;
3102 align
= get_absolute_expression ();
3103 record_alignment (seg
, align
);
3107 as_warn (_("unrecognized section command `%s'"), seccmd
);
3108 *input_line_pointer
= c
;
3112 demand_empty_rest_of_line ();
3114 #else /* ! TC_I960 */
3115 /* The MRI assembler seems to use different forms of .sect for
3116 different targets. */
3117 as_bad ("MRI mode not supported for this target");
3118 ignore_rest_of_line ();
3119 #endif /* ! TC_I960 */
3120 #endif /* ! TC_M68K */
3123 /* Handle the .print pseudo-op. */
3126 s_print (int ignore ATTRIBUTE_UNUSED
)
3131 s
= demand_copy_C_string (&len
);
3134 demand_empty_rest_of_line ();
3137 /* Handle the .purgem pseudo-op. */
3140 s_purgem (int ignore ATTRIBUTE_UNUSED
)
3142 if (is_it_end_of_statement ())
3144 demand_empty_rest_of_line ();
3154 name
= input_line_pointer
;
3155 c
= get_symbol_end ();
3156 delete_macro (name
);
3157 *input_line_pointer
= c
;
3160 while (*input_line_pointer
++ == ',');
3162 --input_line_pointer
;
3163 demand_empty_rest_of_line ();
3166 /* Handle the .endm/.endr pseudo-ops. */
3169 s_bad_end (int endr
)
3171 as_warn (_(".end%c encountered without preceding %s"),
3173 endr
? ".rept, .irp, or .irpc" : ".macro");
3174 demand_empty_rest_of_line ();
3177 /* Handle the .rept pseudo-op. */
3180 s_rept (int ignore ATTRIBUTE_UNUSED
)
3184 count
= get_absolute_expression ();
3186 do_repeat (count
, "REPT", "ENDR");
3189 /* This function provides a generic repeat block implementation. It allows
3190 different directives to be used as the start/end keys. */
3193 do_repeat (int count
, const char *start
, const char *end
)
3199 if (!buffer_and_nest (start
, end
, &one
, get_non_macro_line_sb
))
3201 as_bad (_("%s without %s"), start
, end
);
3207 sb_add_sb (&many
, &one
);
3211 input_scrub_include_sb (&many
, input_line_pointer
, 1);
3213 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
3216 /* Like do_repeat except that any text matching EXPANDER in the
3217 block is replaced by the itteration count. */
3220 do_repeat_with_expander (int count
,
3223 const char * expander
)
3229 if (!buffer_and_nest (start
, end
, &one
, get_non_macro_line_sb
))
3231 as_bad (_("%s without %s"), start
, end
);
3237 if (expander
!= NULL
&& strstr (one
.ptr
, expander
) != NULL
)
3239 while (count
-- > 0)
3245 sb_new (& processed
);
3246 sb_add_sb (& processed
, & one
);
3247 sub
= strstr (processed
.ptr
, expander
);
3248 len
= sprintf (sub
, "%d", count
);
3249 gas_assert (len
< 8);
3250 strcpy (sub
+ len
, sub
+ 8);
3251 processed
.len
-= (8 - len
);
3252 sb_add_sb (& many
, & processed
);
3253 sb_kill (& processed
);
3258 sb_add_sb (&many
, &one
);
3262 input_scrub_include_sb (&many
, input_line_pointer
, 1);
3264 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
3267 /* Skip to end of current repeat loop; EXTRA indicates how many additional
3268 input buffers to skip. Assumes that conditionals preceding the loop end
3269 are properly nested.
3271 This function makes it easier to implement a premature "break" out of the
3272 loop. The EXTRA arg accounts for other buffers we might have inserted,
3273 such as line substitutions. */
3276 end_repeat (int extra
)
3278 cond_exit_macro (macro_nest
);
3279 while (extra
-- >= 0)
3280 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
3284 assign_symbol (char *name
, int mode
)
3288 if (name
[0] == '.' && name
[1] == '\0')
3290 /* Turn '. = mumble' into a .org mumble. */
3294 segment
= get_known_segmented_expression (&exp
);
3297 do_org (segment
, &exp
, 0);
3302 if ((symbolP
= symbol_find (name
)) == NULL
3303 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
3305 symbolP
= symbol_find_or_make (name
);
3307 /* When doing symbol listings, play games with dummy fragments living
3308 outside the normal fragment chain to record the file and line info
3310 if (listing
& LISTING_SYMBOLS
)
3312 extern struct list_info_struct
*listing_tail
;
3313 fragS
*dummy_frag
= (fragS
*) xcalloc (1, sizeof (fragS
));
3314 dummy_frag
->line
= listing_tail
;
3315 dummy_frag
->fr_symbol
= symbolP
;
3316 symbol_set_frag (symbolP
, dummy_frag
);
3320 /* "set" symbols are local unless otherwise specified. */
3321 SF_SET_LOCAL (symbolP
);
3325 if (S_IS_DEFINED (symbolP
) || symbol_equated_p (symbolP
))
3327 if ((mode
!= 0 || !S_IS_VOLATILE (symbolP
))
3328 && !S_CAN_BE_REDEFINED (symbolP
))
3330 as_bad (_("symbol `%s' is already defined"), name
);
3331 symbolP
= symbol_clone (symbolP
, 0);
3333 /* If the symbol is volatile, copy the symbol and replace the
3334 original with the copy, so that previous uses of the symbol will
3335 retain the value of the symbol at the point of use. */
3336 else if (S_IS_VOLATILE (symbolP
))
3337 symbolP
= symbol_clone (symbolP
, 1);
3341 S_SET_VOLATILE (symbolP
);
3343 S_SET_FORWARD_REF (symbolP
);
3345 pseudo_set (symbolP
);
3348 /* Handle the .equ, .equiv, .eqv, and .set directives. If EQUIV is 1,
3349 then this is .equiv, and it is an error if the symbol is already
3350 defined. If EQUIV is -1, the symbol additionally is a forward
3358 /* Especial apologies for the random logic:
3359 this just grew, and could be parsed much more simply!
3361 if ((name
= read_symbol_name ()) == NULL
)
3364 if (*input_line_pointer
!= ',')
3366 as_bad (_("expected comma after \"%s\""), name
);
3367 ignore_rest_of_line ();
3372 input_line_pointer
++;
3373 assign_symbol (name
, equiv
);
3374 demand_empty_rest_of_line ();
3388 #ifdef md_flush_pending_output
3389 md_flush_pending_output ();
3392 #ifdef md_cons_align
3397 stop
= mri_comment_field (&stopc
);
3399 /* In m68k MRI mode, we need to align to a word boundary, unless
3401 if (flag_m68k_mri
&& mult
> 1)
3403 if (now_seg
== absolute_section
)
3405 abs_section_offset
+= abs_section_offset
& 1;
3406 if (line_label
!= NULL
)
3407 S_SET_VALUE (line_label
, abs_section_offset
);
3409 else if (mri_common_symbol
!= NULL
)
3413 mri_val
= S_GET_VALUE (mri_common_symbol
);
3414 if ((mri_val
& 1) != 0)
3416 S_SET_VALUE (mri_common_symbol
, mri_val
+ 1);
3417 if (line_label
!= NULL
)
3419 expressionS
*symexp
;
3421 symexp
= symbol_get_value_expression (line_label
);
3422 know (symexp
->X_op
== O_symbol
);
3423 know (symexp
->X_add_symbol
== mri_common_symbol
);
3424 symexp
->X_add_number
+= 1;
3430 do_align (1, (char *) NULL
, 0, 0);
3431 if (line_label
!= NULL
)
3433 symbol_set_frag (line_label
, frag_now
);
3434 S_SET_VALUE (line_label
, frag_now_fix ());
3444 if (*input_line_pointer
== ',')
3446 ++input_line_pointer
;
3451 val
.X_op
= O_constant
;
3452 val
.X_add_number
= 0;
3455 if (val
.X_op
!= O_constant
3456 || val
.X_add_number
< - 0x80
3457 || val
.X_add_number
> 0xff
3458 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
3460 resolve_expression (&exp
);
3461 if (exp
.X_op
!= O_constant
)
3462 as_bad (_("unsupported variable size or fill value"));
3469 bytes
= mult
* exp
.X_add_number
;
3470 for (i
= 0; i
< exp
.X_add_number
; i
++)
3471 emit_expr (&val
, mult
);
3476 if (now_seg
== absolute_section
|| mri_common_symbol
!= NULL
)
3477 resolve_expression (&exp
);
3479 if (exp
.X_op
== O_constant
)
3483 repeat
= exp
.X_add_number
;
3490 as_warn (_(".space repeat count is zero, ignored"));
3491 else if (repeat
< 0)
3492 as_warn (_(".space repeat count is negative, ignored"));
3496 /* If we are in the absolute section, just bump the offset. */
3497 if (now_seg
== absolute_section
)
3499 abs_section_offset
+= repeat
;
3503 /* If we are secretly in an MRI common section, then
3504 creating space just increases the size of the common
3506 if (mri_common_symbol
!= NULL
)
3508 S_SET_VALUE (mri_common_symbol
,
3509 S_GET_VALUE (mri_common_symbol
) + repeat
);
3514 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
3515 (offsetT
) repeat
, (char *) 0);
3519 if (now_seg
== absolute_section
)
3521 as_bad (_("space allocation too complex in absolute section"));
3522 subseg_set (text_section
, 0);
3525 if (mri_common_symbol
!= NULL
)
3527 as_bad (_("space allocation too complex in common section"));
3528 mri_common_symbol
= NULL
;
3532 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
3533 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
3537 *p
= val
.X_add_number
;
3542 /* In MRI mode, after an odd number of bytes, we must align to an
3543 even word boundary, unless the next instruction is a dc.b, ds.b
3545 if (flag_mri
&& (bytes
& 1) != 0)
3546 mri_pending_align
= 1;
3548 demand_empty_rest_of_line ();
3551 mri_comment_end (stop
, stopc
);
3554 /* This is like s_space, but the value is a floating point number with
3555 the given precision. This is for the MRI dcb.s pseudo-op and
3559 s_float_space (int float_type
)
3563 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3567 #ifdef md_cons_align
3572 stop
= mri_comment_field (&stopc
);
3574 count
= get_absolute_expression ();
3577 if (*input_line_pointer
!= ',')
3579 as_bad (_("missing value"));
3580 ignore_rest_of_line ();
3582 mri_comment_end (stop
, stopc
);
3586 ++input_line_pointer
;
3590 /* Skip any 0{letter} that may be present. Don't even check if the
3591 * letter is legal. */
3592 if (input_line_pointer
[0] == '0'
3593 && ISALPHA (input_line_pointer
[1]))
3594 input_line_pointer
+= 2;
3596 /* Accept :xxxx, where the x's are hex digits, for a floating point
3597 with the exact digits specified. */
3598 if (input_line_pointer
[0] == ':')
3600 flen
= hex_float (float_type
, temp
);
3603 ignore_rest_of_line ();
3605 mri_comment_end (stop
, stopc
);
3613 err
= md_atof (float_type
, temp
, &flen
);
3614 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
3615 know (err
!= NULL
|| flen
> 0);
3618 as_bad (_("bad floating literal: %s"), err
);
3619 ignore_rest_of_line ();
3621 mri_comment_end (stop
, stopc
);
3626 while (--count
>= 0)
3630 p
= frag_more (flen
);
3631 memcpy (p
, temp
, (unsigned int) flen
);
3634 demand_empty_rest_of_line ();
3637 mri_comment_end (stop
, stopc
);
3640 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3643 s_struct (int ignore ATTRIBUTE_UNUSED
)
3649 stop
= mri_comment_field (&stopc
);
3650 abs_section_offset
= get_absolute_expression ();
3651 #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
3652 /* The ELF backend needs to know that we are changing sections, so
3653 that .previous works correctly. */
3655 obj_elf_section_change_hook ();
3657 subseg_set (absolute_section
, 0);
3658 demand_empty_rest_of_line ();
3660 mri_comment_end (stop
, stopc
);
3664 s_text (int ignore ATTRIBUTE_UNUSED
)
3668 temp
= get_absolute_expression ();
3669 subseg_set (text_section
, (subsegT
) temp
);
3670 demand_empty_rest_of_line ();
3673 /* .weakref x, y sets x as an alias to y that, as long as y is not
3674 referenced directly, will cause y to become a weak symbol. */
3676 s_weakref (int ignore ATTRIBUTE_UNUSED
)
3683 if ((name
= read_symbol_name ()) == NULL
)
3686 symbolP
= symbol_find_or_make (name
);
3688 if (S_IS_DEFINED (symbolP
) || symbol_equated_p (symbolP
))
3690 if (!S_IS_VOLATILE (symbolP
))
3692 as_bad (_("symbol `%s' is already defined"), name
);
3695 symbolP
= symbol_clone (symbolP
, 1);
3696 S_CLEAR_VOLATILE (symbolP
);
3701 if (*input_line_pointer
!= ',')
3703 as_bad (_("expected comma after \"%s\""), name
);
3707 input_line_pointer
++;
3712 if ((name
= read_symbol_name ()) == NULL
)
3715 if ((symbolP2
= symbol_find_noref (name
, 1)) == NULL
3716 && (symbolP2
= md_undefined_symbol (name
)) == NULL
)
3718 symbolP2
= symbol_find_or_make (name
);
3719 S_SET_WEAKREFD (symbolP2
);
3723 symbolS
*symp
= symbolP2
;
3725 while (S_IS_WEAKREFR (symp
) && symp
!= symbolP
)
3727 expressionS
*expP
= symbol_get_value_expression (symp
);
3729 gas_assert (expP
->X_op
== O_symbol
3730 && expP
->X_add_number
== 0);
3731 symp
= expP
->X_add_symbol
;
3733 if (symp
== symbolP
)
3737 loop
= concat (S_GET_NAME (symbolP
),
3738 " => ", S_GET_NAME (symbolP2
), (const char *) NULL
);
3741 while (symp
!= symbolP
)
3743 char *old_loop
= loop
;
3745 symp
= symbol_get_value_expression (symp
)->X_add_symbol
;
3746 loop
= concat (loop
, " => ", S_GET_NAME (symp
),
3747 (const char *) NULL
);
3751 as_bad (_("%s: would close weakref loop: %s"),
3752 S_GET_NAME (symbolP
), loop
);
3756 ignore_rest_of_line ();
3760 /* Short-circuiting instead of just checking here might speed
3761 things up a tiny little bit, but loop error messages would
3762 miss intermediate links. */
3763 /* symbolP2 = symp; */
3766 memset (&exp
, 0, sizeof (exp
));
3767 exp
.X_op
= O_symbol
;
3768 exp
.X_add_symbol
= symbolP2
;
3770 S_SET_SEGMENT (symbolP
, undefined_section
);
3771 symbol_set_value_expression (symbolP
, &exp
);
3772 symbol_set_frag (symbolP
, &zero_address_frag
);
3773 S_SET_WEAKREFR (symbolP
);
3775 demand_empty_rest_of_line ();
3780 ignore_rest_of_line ();
3786 /* Verify that we are at the end of a line. If not, issue an error and
3790 demand_empty_rest_of_line (void)
3793 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3794 input_line_pointer
++;
3797 if (ISPRINT (*input_line_pointer
))
3798 as_bad (_("junk at end of line, first unrecognized character is `%c'"),
3799 *input_line_pointer
);
3801 as_bad (_("junk at end of line, first unrecognized character valued 0x%x"),
3802 *input_line_pointer
);
3803 ignore_rest_of_line ();
3806 /* Return pointing just after end-of-line. */
3807 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3810 /* Silently advance to the end of line. Use this after already having
3811 issued an error about something bad. */
3814 ignore_rest_of_line (void)
3816 while (input_line_pointer
< buffer_limit
3817 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3818 input_line_pointer
++;
3820 input_line_pointer
++;
3822 /* Return pointing just after end-of-line. */
3823 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3826 /* Sets frag for given symbol to zero_address_frag, except when the
3827 symbol frag is already set to a dummy listing frag. */
3830 set_zero_frag (symbolS
*symbolP
)
3832 if (symbol_get_frag (symbolP
)->fr_type
!= rs_dummy
)
3833 symbol_set_frag (symbolP
, &zero_address_frag
);
3836 /* In: Pointer to a symbol.
3837 Input_line_pointer->expression.
3839 Out: Input_line_pointer->just after any whitespace after expression.
3840 Tried to set symbol to value of expression.
3841 Will change symbols type, value, and frag; */
3844 pseudo_set (symbolS
*symbolP
)
3849 know (symbolP
); /* NULL pointer is logic error. */
3851 if (!S_IS_FORWARD_REF (symbolP
))
3852 (void) expression (&exp
);
3854 (void) deferred_expression (&exp
);
3856 if (exp
.X_op
== O_illegal
)
3857 as_bad (_("illegal expression"));
3858 else if (exp
.X_op
== O_absent
)
3859 as_bad (_("missing expression"));
3860 else if (exp
.X_op
== O_big
)
3862 if (exp
.X_add_number
> 0)
3863 as_bad (_("bignum invalid"));
3865 as_bad (_("floating point number invalid"));
3867 else if (exp
.X_op
== O_subtract
3868 && !S_IS_FORWARD_REF (symbolP
)
3869 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3870 && (symbol_get_frag (exp
.X_add_symbol
)
3871 == symbol_get_frag (exp
.X_op_symbol
)))
3873 exp
.X_op
= O_constant
;
3874 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3875 - S_GET_VALUE (exp
.X_op_symbol
));
3878 if (symbol_section_p (symbolP
))
3880 as_bad ("attempt to set value of section symbol");
3889 exp
.X_add_number
= 0;
3892 S_SET_SEGMENT (symbolP
, absolute_section
);
3893 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3894 set_zero_frag (symbolP
);
3898 #ifndef TC_GLOBAL_REGISTER_SYMBOL_OK
3899 if (S_IS_EXTERNAL (symbolP
))
3901 as_bad ("can't equate global symbol `%s' with register name",
3902 S_GET_NAME (symbolP
));
3906 S_SET_SEGMENT (symbolP
, reg_section
);
3907 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3908 set_zero_frag (symbolP
);
3909 symbol_get_value_expression (symbolP
)->X_op
= O_register
;
3913 seg
= S_GET_SEGMENT (exp
.X_add_symbol
);
3914 /* For x=undef+const, create an expression symbol.
3915 For x=x+const, just update x except when x is an undefined symbol
3916 For x=defined+const, evaluate x. */
3917 if (symbolP
== exp
.X_add_symbol
3918 && (seg
!= undefined_section
3919 || !symbol_constant_p (symbolP
)))
3921 *symbol_X_add_number (symbolP
) += exp
.X_add_number
;
3924 else if (!S_IS_FORWARD_REF (symbolP
) && seg
!= undefined_section
)
3926 symbolS
*s
= exp
.X_add_symbol
;
3928 if (S_IS_COMMON (s
))
3929 as_bad (_("`%s' can't be equated to common symbol '%s'"),
3930 S_GET_NAME (symbolP
), S_GET_NAME (s
));
3932 S_SET_SEGMENT (symbolP
, seg
);
3933 S_SET_VALUE (symbolP
, exp
.X_add_number
+ S_GET_VALUE (s
));
3934 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3935 copy_symbol_attributes (symbolP
, s
);
3938 S_SET_SEGMENT (symbolP
, undefined_section
);
3939 symbol_set_value_expression (symbolP
, &exp
);
3940 copy_symbol_attributes (symbolP
, exp
.X_add_symbol
);
3941 set_zero_frag (symbolP
);
3945 /* The value is some complex expression. */
3946 S_SET_SEGMENT (symbolP
, expr_section
);
3947 symbol_set_value_expression (symbolP
, &exp
);
3948 set_zero_frag (symbolP
);
3955 CONStruct more frag of .bytes, or .words etc.
3956 Should need_pass_2 be 1 then emit no frag(s).
3957 This understands EXPRESSIONS.
3961 This has a split personality. We use expression() to read the
3962 value. We can detect if the value won't fit in a byte or word.
3963 But we can't detect if expression() discarded significant digits
3964 in the case of a long. Not worth the crocks required to fix it. */
3966 /* Select a parser for cons expressions. */
3968 /* Some targets need to parse the expression in various fancy ways.
3969 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3970 (for example, the HPPA does this). Otherwise, you can define
3971 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3972 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3973 are defined, which is the normal case, then only simple expressions
3978 parse_mri_cons (expressionS
*exp
, unsigned int nbytes
);
3981 #ifndef TC_PARSE_CONS_EXPRESSION
3982 #ifdef BITFIELD_CONS_EXPRESSIONS
3983 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3985 parse_bitfield_cons (expressionS
*exp
, unsigned int nbytes
);
3987 #ifdef REPEAT_CONS_EXPRESSIONS
3988 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3990 parse_repeat_cons (expressionS
*exp
, unsigned int nbytes
);
3993 /* If we haven't gotten one yet, just call expression. */
3994 #ifndef TC_PARSE_CONS_EXPRESSION
3995 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
4000 do_parse_cons_expression (expressionS
*exp
,
4001 int nbytes ATTRIBUTE_UNUSED
)
4003 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
4007 /* Worker to do .byte etc statements.
4008 Clobbers input_line_pointer and checks end-of-line. */
4011 cons_worker (int nbytes
, /* 1=.byte, 2=.word, 4=.long. */
4019 #ifdef md_flush_pending_output
4020 md_flush_pending_output ();
4024 stop
= mri_comment_field (&stopc
);
4026 if (is_it_end_of_statement ())
4028 demand_empty_rest_of_line ();
4030 mri_comment_end (stop
, stopc
);
4034 #ifdef TC_ADDRESS_BYTES
4036 nbytes
= TC_ADDRESS_BYTES ();
4039 #ifdef md_cons_align
4040 md_cons_align (nbytes
);
4048 parse_mri_cons (&exp
, (unsigned int) nbytes
);
4052 if (*input_line_pointer
== '"')
4054 as_bad (_("unexpected `\"' in expression"));
4055 ignore_rest_of_line ();
4058 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
4063 if (exp
.X_op
== O_symbol
)
4064 exp
.X_op
= O_symbol_rva
;
4066 as_fatal (_("rva without symbol"));
4068 emit_expr (&exp
, (unsigned int) nbytes
);
4071 while (*input_line_pointer
++ == ',');
4073 /* In MRI mode, after an odd number of bytes, we must align to an
4074 even word boundary, unless the next instruction is a dc.b, ds.b
4076 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
4077 mri_pending_align
= 1;
4079 input_line_pointer
--; /* Put terminator back into stream. */
4081 demand_empty_rest_of_line ();
4084 mri_comment_end (stop
, stopc
);
4090 cons_worker (size
, 0);
4096 cons_worker (size
, 1);
4099 /* .reloc offset, reloc_name, symbol+addend. */
4102 s_reloc (int ignore ATTRIBUTE_UNUSED
)
4109 struct reloc_list
*reloc
;
4111 reloc
= (struct reloc_list
*) xmalloc (sizeof (*reloc
));
4114 stop
= mri_comment_field (&stopc
);
4123 as_bad (_("missing or bad offset expression"));
4126 exp
.X_add_symbol
= section_symbol (now_seg
);
4127 exp
.X_op
= O_symbol
;
4130 if (exp
.X_add_number
== 0)
4132 reloc
->u
.a
.offset_sym
= exp
.X_add_symbol
;
4137 reloc
->u
.a
.offset_sym
= make_expr_symbol (&exp
);
4142 if (*input_line_pointer
!= ',')
4144 as_bad (_("missing reloc type"));
4148 ++input_line_pointer
;
4150 r_name
= input_line_pointer
;
4151 c
= get_symbol_end ();
4152 reloc
->u
.a
.howto
= bfd_reloc_name_lookup (stdoutput
, r_name
);
4153 *input_line_pointer
= c
;
4154 if (reloc
->u
.a
.howto
== NULL
)
4156 as_bad (_("unrecognized reloc type"));
4160 exp
.X_op
= O_absent
;
4162 if (*input_line_pointer
== ',')
4164 ++input_line_pointer
;
4172 as_bad (_("bad reloc expression"));
4174 ignore_rest_of_line ();
4177 mri_comment_end (stop
, stopc
);
4180 reloc
->u
.a
.sym
= NULL
;
4181 reloc
->u
.a
.addend
= 0;
4184 reloc
->u
.a
.sym
= NULL
;
4185 reloc
->u
.a
.addend
= exp
.X_add_number
;
4188 reloc
->u
.a
.sym
= exp
.X_add_symbol
;
4189 reloc
->u
.a
.addend
= exp
.X_add_number
;
4192 reloc
->u
.a
.sym
= make_expr_symbol (&exp
);
4193 reloc
->u
.a
.addend
= 0;
4197 as_where (&reloc
->file
, &reloc
->line
);
4198 reloc
->next
= reloc_list
;
4201 demand_empty_rest_of_line ();
4203 mri_comment_end (stop
, stopc
);
4206 /* Put the contents of expression EXP into the object file using
4207 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
4210 emit_expr (expressionS
*exp
, unsigned int nbytes
)
4214 valueT extra_digit
= 0;
4216 /* Don't do anything if we are going to make another pass. */
4220 /* Grow the current frag now so that dot_value does not get invalidated
4221 if the frag were to fill up in the frag_more() call below. */
4223 dot_value
= frag_now_fix ();
4227 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
4228 appear as a four byte positive constant in the .line section,
4229 followed by a 2 byte 0xffff. Look for that case here. */
4231 static int dwarf_line
= -1;
4233 if (strcmp (segment_name (now_seg
), ".line") != 0)
4235 else if (dwarf_line
>= 0
4237 && exp
->X_op
== O_constant
4238 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
4239 listing_source_line ((unsigned int) dwarf_line
);
4240 else if (nbytes
== 4
4241 && exp
->X_op
== O_constant
4242 && exp
->X_add_number
>= 0)
4243 dwarf_line
= exp
->X_add_number
;
4248 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
4249 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
4250 AT_sibling (0x12) followed by a four byte address of the sibling
4251 followed by a 2 byte AT_name (0x38) followed by the name of the
4252 file. We look for that case here. */
4254 static int dwarf_file
= 0;
4256 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4258 else if (dwarf_file
== 0
4260 && exp
->X_op
== O_constant
4261 && exp
->X_add_number
== 0x11)
4263 else if (dwarf_file
== 1
4265 && exp
->X_op
== O_constant
4266 && exp
->X_add_number
== 0x12)
4268 else if (dwarf_file
== 2
4271 else if (dwarf_file
== 3
4273 && exp
->X_op
== O_constant
4274 && exp
->X_add_number
== 0x38)
4279 /* The variable dwarf_file_string tells stringer that the string
4280 may be the name of the source file. */
4281 if (dwarf_file
== 4)
4282 dwarf_file_string
= 1;
4284 dwarf_file_string
= 0;
4289 if (check_eh_frame (exp
, &nbytes
))
4294 /* Allow `.word 0' in the absolute section. */
4295 if (now_seg
== absolute_section
)
4297 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
4298 as_bad (_("attempt to store value in absolute section"));
4299 abs_section_offset
+= nbytes
;
4303 /* Handle a negative bignum. */
4305 && exp
->X_add_number
== 0
4306 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
4307 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
4310 unsigned long carry
;
4312 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
4314 /* Negate the bignum: one's complement each digit and add 1. */
4316 for (i
= 0; i
< exp
->X_add_number
; i
++)
4320 next
= (((~(generic_bignum
[i
] & LITTLENUM_MASK
))
4323 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
4324 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
4327 /* We can ignore any carry out, because it will be handled by
4328 extra_digit if it is needed. */
4330 extra_digit
= (valueT
) -1;
4334 if (op
== O_absent
|| op
== O_illegal
)
4336 as_warn (_("zero assumed for missing expression"));
4337 exp
->X_add_number
= 0;
4340 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4342 as_bad (_("floating point number invalid"));
4343 exp
->X_add_number
= 0;
4346 else if (op
== O_register
)
4348 as_warn (_("register value used as expression"));
4352 p
= frag_more ((int) nbytes
);
4354 #ifndef WORKING_DOT_WORD
4355 /* If we have the difference of two symbols in a word, save it on
4356 the broken_words list. See the code in write.c. */
4357 if (op
== O_subtract
&& nbytes
== 2)
4359 struct broken_word
*x
;
4361 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
4362 x
->next_broken_word
= broken_words
;
4365 x
->subseg
= now_subseg
;
4367 x
->word_goes_here
= p
;
4369 x
->add
= exp
->X_add_symbol
;
4370 x
->sub
= exp
->X_op_symbol
;
4371 x
->addnum
= exp
->X_add_number
;
4379 /* If we have an integer, but the number of bytes is too large to
4380 pass to md_number_to_chars, handle it as a bignum. */
4381 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
4383 extra_digit
= exp
->X_unsigned
? 0 : -1;
4384 convert_to_bignum (exp
);
4388 if (op
== O_constant
)
4396 /* JF << of >= number of bits in the object is undefined. In
4397 particular SPARC (Sun 4) has problems. */
4398 if (nbytes
>= sizeof (valueT
))
4401 if (nbytes
> sizeof (valueT
))
4404 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
4408 /* Don't store these bits. */
4409 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
4410 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
4413 unmask
= ~mask
; /* Do store these bits. */
4416 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
4417 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
4420 get
= exp
->X_add_number
;
4422 if ((get
& mask
) != 0
4423 && ((get
& mask
) != mask
4424 || (get
& hibit
) == 0))
4425 { /* Leading bits contain both 0s & 1s. */
4426 #if defined (BFD64) && BFD_HOST_64BIT_LONG_LONG
4428 as_warn (_("value 0x%llx truncated to 0x%llx"),
4429 (unsigned long long) get
, (unsigned long long) use
);
4431 as_warn (_("value 0x%I64x truncated to 0x%I64x"),
4432 (unsigned long long) get
, (unsigned long long) use
);
4435 as_warn (_("value 0x%lx truncated to 0x%lx"),
4436 (unsigned long) get
, (unsigned long) use
);
4439 /* Put bytes in right order. */
4440 md_number_to_chars (p
, use
, (int) nbytes
);
4442 else if (op
== O_big
)
4445 LITTLENUM_TYPE
*nums
;
4447 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
4450 int i
= nbytes
/ CHARS_PER_LITTLENUM
;
4453 LITTLENUM_TYPE sign
= 0;
4454 if ((generic_bignum
[--i
]
4455 & (1 << (LITTLENUM_NUMBER_OF_BITS
- 1))) != 0)
4456 sign
= ~(LITTLENUM_TYPE
) 0;
4457 while (++i
< exp
->X_add_number
)
4458 if (generic_bignum
[i
] != sign
)
4461 if (i
< exp
->X_add_number
)
4462 as_warn (_("bignum truncated to %d bytes"), nbytes
);
4468 md_number_to_chars (p
, (valueT
) generic_bignum
[0], 1);
4471 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
4473 if (target_big_endian
)
4475 while (nbytes
> size
)
4477 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
4478 nbytes
-= CHARS_PER_LITTLENUM
;
4479 p
+= CHARS_PER_LITTLENUM
;
4482 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
4483 while (size
>= CHARS_PER_LITTLENUM
)
4486 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
4487 size
-= CHARS_PER_LITTLENUM
;
4488 p
+= CHARS_PER_LITTLENUM
;
4493 nums
= generic_bignum
;
4494 while (size
>= CHARS_PER_LITTLENUM
)
4496 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
4498 size
-= CHARS_PER_LITTLENUM
;
4499 p
+= CHARS_PER_LITTLENUM
;
4500 nbytes
-= CHARS_PER_LITTLENUM
;
4503 while (nbytes
>= CHARS_PER_LITTLENUM
)
4505 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
4506 nbytes
-= CHARS_PER_LITTLENUM
;
4507 p
+= CHARS_PER_LITTLENUM
;
4512 emit_expr_fix (exp
, nbytes
, frag_now
, p
);
4516 emit_expr_fix (expressionS
*exp
, unsigned int nbytes
, fragS
*frag
, char *p
)
4518 memset (p
, 0, nbytes
);
4520 /* Generate a fixS to record the symbol value. */
4522 #ifdef TC_CONS_FIX_NEW
4523 TC_CONS_FIX_NEW (frag
, p
- frag
->fr_literal
, nbytes
, exp
);
4526 bfd_reloc_code_real_type r
;
4546 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
4550 fix_new_exp (frag
, p
- frag
->fr_literal
, (int) nbytes
, exp
,
4556 #ifdef BITFIELD_CONS_EXPRESSIONS
4558 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
4559 w:x,y:z, where w and y are bitwidths and x and y are values. They
4560 then pack them all together. We do a little better in that we allow
4561 them in words, longs, etc. and we'll pack them in target byte order
4564 The rules are: pack least significant bit first, if a field doesn't
4565 entirely fit, put it in the next unit. Overflowing the bitfield is
4566 explicitly *not* even a warning. The bitwidth should be considered
4569 To use this function the tc-XXX.h file should define
4570 BITFIELD_CONS_EXPRESSIONS. */
4573 parse_bitfield_cons (exp
, nbytes
)
4575 unsigned int nbytes
;
4577 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
4578 char *hold
= input_line_pointer
;
4580 (void) expression (exp
);
4582 if (*input_line_pointer
== ':')
4589 unsigned long width
;
4591 if (*input_line_pointer
!= ':')
4593 input_line_pointer
= hold
;
4595 } /* Next piece is not a bitfield. */
4597 /* In the general case, we can't allow
4598 full expressions with symbol
4599 differences and such. The relocation
4600 entries for symbols not defined in this
4601 assembly would require arbitrary field
4602 widths, positions, and masks which most
4603 of our current object formats don't
4606 In the specific case where a symbol
4607 *is* defined in this assembly, we
4608 *could* build fixups and track it, but
4609 this could lead to confusion for the
4610 backends. I'm lazy. I'll take any
4611 SEG_ABSOLUTE. I think that means that
4612 you can use a previous .set or
4613 .equ type symbol. xoxorich. */
4615 if (exp
->X_op
== O_absent
)
4617 as_warn (_("using a bit field width of zero"));
4618 exp
->X_add_number
= 0;
4619 exp
->X_op
= O_constant
;
4620 } /* Implied zero width bitfield. */
4622 if (exp
->X_op
!= O_constant
)
4624 *input_line_pointer
= '\0';
4625 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
4626 *input_line_pointer
= ':';
4627 demand_empty_rest_of_line ();
4629 } /* Too complex. */
4631 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
4633 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
4634 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
4635 width
= BITS_PER_CHAR
* nbytes
;
4638 if (width
> bits_available
)
4640 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
4641 input_line_pointer
= hold
;
4642 exp
->X_add_number
= value
;
4647 hold
= ++input_line_pointer
;
4649 (void) expression (exp
);
4650 if (exp
->X_op
!= O_constant
)
4652 char cache
= *input_line_pointer
;
4654 *input_line_pointer
= '\0';
4655 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
4656 *input_line_pointer
= cache
;
4657 demand_empty_rest_of_line ();
4659 } /* Too complex. */
4661 value
|= ((~(-1 << width
) & exp
->X_add_number
)
4662 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
4664 if ((bits_available
-= width
) == 0
4665 || is_it_end_of_statement ()
4666 || *input_line_pointer
!= ',')
4669 } /* All the bitfields we're gonna get. */
4671 hold
= ++input_line_pointer
;
4672 (void) expression (exp
);
4675 exp
->X_add_number
= value
;
4676 exp
->X_op
= O_constant
;
4677 exp
->X_unsigned
= 1;
4681 #endif /* BITFIELD_CONS_EXPRESSIONS */
4683 /* Handle an MRI style string expression. */
4687 parse_mri_cons (exp
, nbytes
)
4689 unsigned int nbytes
;
4691 if (*input_line_pointer
!= '\''
4692 && (input_line_pointer
[1] != '\''
4693 || (*input_line_pointer
!= 'A'
4694 && *input_line_pointer
!= 'E')))
4695 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
4699 unsigned int result
= 0;
4701 /* An MRI style string. Cut into as many bytes as will fit into
4702 a nbyte chunk, left justify if necessary, and separate with
4703 commas so we can try again later. */
4704 if (*input_line_pointer
== 'A')
4705 ++input_line_pointer
;
4706 else if (*input_line_pointer
== 'E')
4708 as_bad (_("EBCDIC constants are not supported"));
4709 ++input_line_pointer
;
4712 input_line_pointer
++;
4713 for (scan
= 0; scan
< nbytes
; scan
++)
4715 if (*input_line_pointer
== '\'')
4717 if (input_line_pointer
[1] == '\'')
4719 input_line_pointer
++;
4724 result
= (result
<< 8) | (*input_line_pointer
++);
4728 while (scan
< nbytes
)
4734 /* Create correct expression. */
4735 exp
->X_op
= O_constant
;
4736 exp
->X_add_number
= result
;
4738 /* Fake it so that we can read the next char too. */
4739 if (input_line_pointer
[0] != '\'' ||
4740 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
4742 input_line_pointer
-= 2;
4743 input_line_pointer
[0] = ',';
4744 input_line_pointer
[1] = '\'';
4747 input_line_pointer
++;
4750 #endif /* TC_M68K */
4752 #ifdef REPEAT_CONS_EXPRESSIONS
4754 /* Parse a repeat expression for cons. This is used by the MIPS
4755 assembler. The format is NUMBER:COUNT; NUMBER appears in the
4756 object file COUNT times.
4758 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
4761 parse_repeat_cons (exp
, nbytes
)
4763 unsigned int nbytes
;
4770 if (*input_line_pointer
!= ':')
4772 /* No repeat count. */
4776 ++input_line_pointer
;
4777 expression (&count
);
4778 if (count
.X_op
!= O_constant
4779 || count
.X_add_number
<= 0)
4781 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4785 /* The cons function is going to output this expression once. So we
4786 output it count - 1 times. */
4787 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
4788 emit_expr (exp
, nbytes
);
4791 #endif /* REPEAT_CONS_EXPRESSIONS */
4793 /* Parse a floating point number represented as a hex constant. This
4794 permits users to specify the exact bits they want in the floating
4798 hex_float (int float_type
, char *bytes
)
4830 as_bad (_("unknown floating type type '%c'"), float_type
);
4834 /* It would be nice if we could go through expression to parse the
4835 hex constant, but if we get a bignum it's a pain to sort it into
4836 the buffer correctly. */
4838 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
4842 /* The MRI assembler accepts arbitrary underscores strewn about
4843 through the hex constant, so we ignore them as well. */
4844 if (*input_line_pointer
== '_')
4846 ++input_line_pointer
;
4852 as_warn (_("floating point constant too large"));
4855 d
= hex_value (*input_line_pointer
) << 4;
4856 ++input_line_pointer
;
4857 while (*input_line_pointer
== '_')
4858 ++input_line_pointer
;
4859 if (hex_p (*input_line_pointer
))
4861 d
+= hex_value (*input_line_pointer
);
4862 ++input_line_pointer
;
4864 if (target_big_endian
)
4867 bytes
[length
- i
- 1] = d
;
4873 if (target_big_endian
)
4874 memset (bytes
+ i
, 0, length
- i
);
4876 memset (bytes
, 0, length
- i
);
4884 CONStruct some more frag chars of .floats .ffloats etc.
4885 Makes 0 or more new frags.
4886 If need_pass_2 == 1, no frags are emitted.
4887 This understands only floating literals, not expressions. Sorry.
4889 A floating constant is defined by atof_generic(), except it is preceded
4890 by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4891 reading, I decided to be incompatible. This always tries to give you
4892 rounded bits to the precision of the pseudo-op. Former AS did premature
4893 truncation, restored noisy bits instead of trailing 0s AND gave you
4894 a choice of 2 flavours of noise according to which of 2 floating-point
4895 scanners you directed AS to use.
4897 In: input_line_pointer->whitespace before, or '0' of flonum. */
4900 float_cons (/* Clobbers input_line-pointer, checks end-of-line. */
4901 int float_type
/* 'f':.ffloat ... 'F':.float ... */)
4904 int length
; /* Number of chars in an object. */
4905 char *err
; /* Error from scanning floating literal. */
4906 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4908 if (is_it_end_of_statement ())
4910 demand_empty_rest_of_line ();
4914 #ifdef md_flush_pending_output
4915 md_flush_pending_output ();
4918 #ifdef md_cons_align
4924 /* input_line_pointer->1st char of a flonum (we hope!). */
4927 /* Skip any 0{letter} that may be present. Don't even check if the
4928 letter is legal. Someone may invent a "z" format and this routine
4929 has no use for such information. Lusers beware: you get
4930 diagnostics if your input is ill-conditioned. */
4931 if (input_line_pointer
[0] == '0'
4932 && ISALPHA (input_line_pointer
[1]))
4933 input_line_pointer
+= 2;
4935 /* Accept :xxxx, where the x's are hex digits, for a floating
4936 point with the exact digits specified. */
4937 if (input_line_pointer
[0] == ':')
4939 ++input_line_pointer
;
4940 length
= hex_float (float_type
, temp
);
4943 ignore_rest_of_line ();
4949 err
= md_atof (float_type
, temp
, &length
);
4950 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4951 know (err
!= NULL
|| length
> 0);
4954 as_bad (_("bad floating literal: %s"), err
);
4955 ignore_rest_of_line ();
4966 #ifdef REPEAT_CONS_EXPRESSIONS
4967 if (*input_line_pointer
== ':')
4969 expressionS count_exp
;
4971 ++input_line_pointer
;
4972 expression (&count_exp
);
4974 if (count_exp
.X_op
!= O_constant
4975 || count_exp
.X_add_number
<= 0)
4976 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4978 count
= count_exp
.X_add_number
;
4982 while (--count
>= 0)
4984 p
= frag_more (length
);
4985 memcpy (p
, temp
, (unsigned int) length
);
4990 while (*input_line_pointer
++ == ',');
4992 /* Put terminator back into stream. */
4993 --input_line_pointer
;
4994 demand_empty_rest_of_line ();
4997 /* Return the size of a LEB128 value. */
5000 sizeof_sleb128 (offsetT value
)
5007 byte
= (value
& 0x7f);
5008 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
5009 Fortunately, we can structure things so that the extra work reduces
5010 to a noop on systems that do things "properly". */
5011 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
5014 while (!(((value
== 0) && ((byte
& 0x40) == 0))
5015 || ((value
== -1) && ((byte
& 0x40) != 0))));
5021 sizeof_uleb128 (valueT value
)
5036 sizeof_leb128 (valueT value
, int sign
)
5039 return sizeof_sleb128 ((offsetT
) value
);
5041 return sizeof_uleb128 (value
);
5044 /* Output a LEB128 value. */
5047 output_sleb128 (char *p
, offsetT value
)
5054 unsigned byte
= (value
& 0x7f);
5056 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
5057 Fortunately, we can structure things so that the extra work reduces
5058 to a noop on systems that do things "properly". */
5059 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
5061 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
5062 || ((value
== -1) && ((byte
& 0x40) != 0))));
5074 output_uleb128 (char *p
, valueT value
)
5080 unsigned byte
= (value
& 0x7f);
5083 /* More bytes to follow. */
5094 output_leb128 (char *p
, valueT value
, int sign
)
5097 return output_sleb128 (p
, (offsetT
) value
);
5099 return output_uleb128 (p
, value
);
5102 /* Do the same for bignums. We combine sizeof with output here in that
5103 we don't output for NULL values of P. It isn't really as critical as
5104 for "normal" values that this be streamlined. */
5107 output_big_sleb128 (char *p
, LITTLENUM_TYPE
*bignum
, int size
)
5114 /* Strip leading sign extensions off the bignum. */
5116 && bignum
[size
- 1] == LITTLENUM_MASK
5117 && bignum
[size
- 2] > LITTLENUM_MASK
/ 2)
5122 /* OR in the next part of the littlenum. */
5123 val
|= (*bignum
<< loaded
);
5124 loaded
+= LITTLENUM_NUMBER_OF_BITS
;
5128 /* Add bytes until there are less than 7 bits left in VAL
5129 or until every non-sign bit has been written. */
5136 || val
!= ((byte
& 0x40) == 0 ? 0 : ((valueT
) 1 << loaded
) - 1))
5143 while ((byte
& 0x80) != 0 && loaded
>= 7);
5147 /* Mop up any left-over bits (of which there will be less than 7). */
5148 if ((byte
& 0x80) != 0)
5150 /* Sign-extend VAL. */
5151 if (val
& (1 << (loaded
- 1)))
5152 val
|= ~0 << loaded
;
5162 output_big_uleb128 (char *p
, LITTLENUM_TYPE
*bignum
, int size
)
5169 /* Strip leading zeros off the bignum. */
5170 /* XXX: Is this needed? */
5171 while (size
> 0 && bignum
[size
- 1] == 0)
5176 if (loaded
< 7 && size
> 0)
5178 val
|= (*bignum
<< loaded
);
5179 loaded
+= 8 * CHARS_PER_LITTLENUM
;
5188 if (size
> 0 || val
)
5195 while (byte
& 0x80);
5201 output_big_leb128 (char *p
, LITTLENUM_TYPE
*bignum
, int size
, int sign
)
5204 return output_big_sleb128 (p
, bignum
, size
);
5206 return output_big_uleb128 (p
, bignum
, size
);
5209 /* Generate the appropriate fragments for a given expression to emit a
5213 emit_leb128_expr (expressionS
*exp
, int sign
)
5215 operatorT op
= exp
->X_op
;
5216 unsigned int nbytes
;
5218 if (op
== O_absent
|| op
== O_illegal
)
5220 as_warn (_("zero assumed for missing expression"));
5221 exp
->X_add_number
= 0;
5224 else if (op
== O_big
&& exp
->X_add_number
<= 0)
5226 as_bad (_("floating point number invalid"));
5227 exp
->X_add_number
= 0;
5230 else if (op
== O_register
)
5232 as_warn (_("register value used as expression"));
5235 else if (op
== O_constant
5237 && (exp
->X_add_number
< 0) != !exp
->X_unsigned
)
5239 /* We're outputting a signed leb128 and the sign of X_add_number
5240 doesn't reflect the sign of the original value. Convert EXP
5241 to a correctly-extended bignum instead. */
5242 convert_to_bignum (exp
);
5246 /* Let check_eh_frame know that data is being emitted. nbytes == -1 is
5247 a signal that this is leb128 data. It shouldn't optimize this away. */
5248 nbytes
= (unsigned int) -1;
5249 if (check_eh_frame (exp
, &nbytes
))
5252 /* Let the backend know that subsequent data may be byte aligned. */
5253 #ifdef md_cons_align
5257 if (op
== O_constant
)
5259 /* If we've got a constant, emit the thing directly right now. */
5261 valueT value
= exp
->X_add_number
;
5265 size
= sizeof_leb128 (value
, sign
);
5266 p
= frag_more (size
);
5267 output_leb128 (p
, value
, sign
);
5269 else if (op
== O_big
)
5271 /* O_big is a different sort of constant. */
5276 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
5277 p
= frag_more (size
);
5278 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
5282 /* Otherwise, we have to create a variable sized fragment and
5283 resolve things later. */
5285 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
) 0), 0, sign
,
5286 make_expr_symbol (exp
), 0, (char *) NULL
);
5290 /* Parse the .sleb128 and .uleb128 pseudos. */
5297 #ifdef md_flush_pending_output
5298 md_flush_pending_output ();
5304 emit_leb128_expr (&exp
, sign
);
5306 while (*input_line_pointer
++ == ',');
5308 input_line_pointer
--;
5309 demand_empty_rest_of_line ();
5313 stringer_append_char (int c
, int bitsize
)
5315 if (!target_big_endian
)
5316 FRAG_APPEND_1_CHAR (c
);
5321 FRAG_APPEND_1_CHAR (0);
5322 FRAG_APPEND_1_CHAR (0);
5323 FRAG_APPEND_1_CHAR (0);
5324 FRAG_APPEND_1_CHAR (0);
5327 FRAG_APPEND_1_CHAR (0);
5328 FRAG_APPEND_1_CHAR (0);
5331 FRAG_APPEND_1_CHAR (0);
5336 /* Called with invalid bitsize argument. */
5340 if (target_big_endian
)
5341 FRAG_APPEND_1_CHAR (c
);
5344 /* Worker to do .ascii etc statements.
5345 Reads 0 or more ',' separated, double-quoted strings.
5346 Caller should have checked need_pass_2 is FALSE because we don't
5348 Checks for end-of-line.
5349 BITS_APPENDZERO says how many bits are in a target char.
5350 The bottom bit is set if a NUL char should be appended to the strings. */
5353 stringer (int bits_appendzero
)
5355 const int bitsize
= bits_appendzero
& ~7;
5356 const int append_zero
= bits_appendzero
& 1;
5358 #if !defined(NO_LISTING) && defined (OBJ_ELF)
5362 #ifdef md_flush_pending_output
5363 md_flush_pending_output ();
5366 #ifdef md_cons_align
5370 /* The following awkward logic is to parse ZERO or more strings,
5371 comma separated. Recall a string expression includes spaces
5372 before the opening '\"' and spaces after the closing '\"'.
5373 We fake a leading ',' if there is (supposed to be)
5374 a 1st, expression. We keep demanding expressions for each ','. */
5375 if (is_it_end_of_statement ())
5377 c
= 0; /* Skip loop. */
5378 ++input_line_pointer
; /* Compensate for end of loop. */
5382 c
= ','; /* Do loop. */
5384 /* If we have been switched into the abs_section then we
5385 will not have an obstack onto which we can hang strings. */
5386 if (now_seg
== absolute_section
)
5388 as_bad (_("strings must be placed into a section"));
5390 ignore_rest_of_line ();
5393 while (c
== ',' || c
== '<' || c
== '"')
5396 switch (*input_line_pointer
)
5399 ++input_line_pointer
; /*->1st char of string. */
5400 #if !defined(NO_LISTING) && defined (OBJ_ELF)
5401 start
= input_line_pointer
;
5404 while (is_a_char (c
= next_char_of_string ()))
5405 stringer_append_char (c
, bitsize
);
5408 stringer_append_char (0, bitsize
);
5410 know (input_line_pointer
[-1] == '\"');
5412 #if !defined(NO_LISTING) && defined (OBJ_ELF)
5413 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
5414 will emit .string with a filename in the .debug section
5415 after a sequence of constants. See the comment in
5416 emit_expr for the sequence. emit_expr will set
5417 dwarf_file_string to non-zero if this string might be a
5418 source file name. */
5419 if (strcmp (segment_name (now_seg
), ".debug") != 0)
5420 dwarf_file_string
= 0;
5421 else if (dwarf_file_string
)
5423 c
= input_line_pointer
[-1];
5424 input_line_pointer
[-1] = '\0';
5425 listing_source_file (start
);
5426 input_line_pointer
[-1] = c
;
5432 input_line_pointer
++;
5433 c
= get_single_number ();
5434 stringer_append_char (c
, bitsize
);
5435 if (*input_line_pointer
!= '>')
5436 as_bad (_("expected <nn>"));
5438 input_line_pointer
++;
5441 input_line_pointer
++;
5445 c
= *input_line_pointer
;
5448 demand_empty_rest_of_line ();
5451 /* FIXME-SOMEDAY: I had trouble here on characters with the
5452 high bits set. We'll probably also have trouble with
5453 multibyte chars, wide chars, etc. Also be careful about
5454 returning values bigger than 1 byte. xoxorich. */
5457 next_char_of_string (void)
5461 c
= *input_line_pointer
++ & CHAR_MASK
;
5469 as_warn (_("unterminated string; newline inserted"));
5470 bump_line_counters ();
5473 #ifndef NO_STRING_ESCAPES
5475 switch (c
= *input_line_pointer
++)
5503 break; /* As itself. */
5519 for (i
= 0, number
= 0;
5520 ISDIGIT (c
) && i
< 3;
5521 c
= *input_line_pointer
++, i
++)
5523 number
= number
* 8 + c
- '0';
5528 --input_line_pointer
;
5537 c
= *input_line_pointer
++;
5538 while (ISXDIGIT (c
))
5541 number
= number
* 16 + c
- '0';
5542 else if (ISUPPER (c
))
5543 number
= number
* 16 + c
- 'A' + 10;
5545 number
= number
* 16 + c
- 'a' + 10;
5546 c
= *input_line_pointer
++;
5549 --input_line_pointer
;
5554 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
5555 as_warn (_("unterminated string; newline inserted"));
5557 bump_line_counters ();
5562 #ifdef ONLY_STANDARD_ESCAPES
5563 as_bad (_("bad escaped character in string"));
5565 #endif /* ONLY_STANDARD_ESCAPES */
5570 #endif /* ! defined (NO_STRING_ESCAPES) */
5579 get_segmented_expression (expressionS
*expP
)
5583 retval
= expression (expP
);
5584 if (expP
->X_op
== O_illegal
5585 || expP
->X_op
== O_absent
5586 || expP
->X_op
== O_big
)
5588 as_bad (_("expected address expression"));
5589 expP
->X_op
= O_constant
;
5590 expP
->X_add_number
= 0;
5591 retval
= absolute_section
;
5597 get_known_segmented_expression (expressionS
*expP
)
5599 segT retval
= get_segmented_expression (expP
);
5601 if (retval
== undefined_section
)
5603 /* There is no easy way to extract the undefined symbol from the
5605 if (expP
->X_add_symbol
!= NULL
5606 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
5607 as_warn (_("symbol \"%s\" undefined; zero assumed"),
5608 S_GET_NAME (expP
->X_add_symbol
));
5610 as_warn (_("some symbol undefined; zero assumed"));
5611 retval
= absolute_section
;
5612 expP
->X_op
= O_constant
;
5613 expP
->X_add_number
= 0;
5618 char /* Return terminator. */
5619 get_absolute_expression_and_terminator (long *val_pointer
/* Return value of expression. */)
5621 /* FIXME: val_pointer should probably be offsetT *. */
5622 *val_pointer
= (long) get_absolute_expression ();
5623 return (*input_line_pointer
++);
5626 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
5627 Give a warning if that happens. */
5630 demand_copy_C_string (int *len_pointer
)
5634 if ((s
= demand_copy_string (len_pointer
)) != 0)
5638 for (len
= *len_pointer
; len
> 0; len
--)
5645 as_bad (_("this string may not contain \'\\0\'"));
5653 /* Demand string, but return a safe (=private) copy of the string.
5654 Return NULL if we can't read a string here. */
5657 demand_copy_string (int *lenP
)
5665 if (*input_line_pointer
== '\"')
5667 input_line_pointer
++; /* Skip opening quote. */
5669 while (is_a_char (c
= next_char_of_string ()))
5671 obstack_1grow (¬es
, c
);
5674 /* JF this next line is so demand_copy_C_string will return a
5675 null terminated string. */
5676 obstack_1grow (¬es
, '\0');
5677 retval
= (char *) obstack_finish (¬es
);
5681 as_bad (_("missing string"));
5683 ignore_rest_of_line ();
5689 /* In: Input_line_pointer->next character.
5691 Do: Skip input_line_pointer over all whitespace.
5693 Out: 1 if input_line_pointer->end-of-line. */
5696 is_it_end_of_statement (void)
5699 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
5703 equals (char *sym_name
, int reassign
)
5708 input_line_pointer
++;
5709 if (*input_line_pointer
== '=')
5710 input_line_pointer
++;
5711 if (reassign
< 0 && *input_line_pointer
== '=')
5712 input_line_pointer
++;
5714 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
5715 input_line_pointer
++;
5718 stop
= mri_comment_field (&stopc
);
5720 assign_symbol (sym_name
, reassign
>= 0 ? !reassign
: reassign
);
5724 demand_empty_rest_of_line ();
5725 mri_comment_end (stop
, stopc
);
5729 /* .incbin -- include a file verbatim at the current location. */
5732 s_incbin (int x ATTRIBUTE_UNUSED
)
5743 #ifdef md_flush_pending_output
5744 md_flush_pending_output ();
5747 #ifdef md_cons_align
5752 filename
= demand_copy_string (& len
);
5753 if (filename
== NULL
)
5758 /* Look for optional skip and count. */
5759 if (* input_line_pointer
== ',')
5761 ++ input_line_pointer
;
5762 skip
= get_absolute_expression ();
5766 if (* input_line_pointer
== ',')
5768 ++ input_line_pointer
;
5770 count
= get_absolute_expression ();
5772 as_warn (_(".incbin count zero, ignoring `%s'"), filename
);
5778 demand_empty_rest_of_line ();
5780 /* Try opening absolute path first, then try include dirs. */
5781 binfile
= fopen (filename
, FOPEN_RB
);
5782 if (binfile
== NULL
)
5786 path
= (char *) xmalloc ((unsigned long) len
+ include_dir_maxlen
+ 5);
5788 for (i
= 0; i
< include_dir_count
; i
++)
5790 sprintf (path
, "%s/%s", include_dirs
[i
], filename
);
5792 binfile
= fopen (path
, FOPEN_RB
);
5793 if (binfile
!= NULL
)
5797 if (binfile
== NULL
)
5798 as_bad (_("file not found: %s"), filename
);
5801 path
= xstrdup (filename
);
5807 register_dependency (path
);
5809 /* Compute the length of the file. */
5810 if (fseek (binfile
, 0, SEEK_END
) != 0)
5812 as_bad (_("seek to end of .incbin file failed `%s'"), path
);
5815 file_len
= ftell (binfile
);
5817 /* If a count was not specified use the remainder of the file. */
5819 count
= file_len
- skip
;
5821 if (skip
< 0 || count
< 0 || file_len
< 0 || skip
+ count
> file_len
)
5823 as_bad (_("skip (%ld) or count (%ld) invalid for file size (%ld)"),
5824 skip
, count
, file_len
);
5828 if (fseek (binfile
, skip
, SEEK_SET
) != 0)
5830 as_bad (_("could not skip to %ld in file `%s'"), skip
, path
);
5834 /* Allocate frag space and store file contents in it. */
5835 binfrag
= frag_more (count
);
5837 bytes
= fread (binfrag
, 1, count
, binfile
);
5839 as_warn (_("truncated file `%s', %ld of %ld bytes read"),
5840 path
, bytes
, count
);
5843 if (binfile
!= NULL
)
5849 /* .include -- include a file at this point. */
5852 s_include (int arg ATTRIBUTE_UNUSED
)
5861 filename
= demand_copy_string (&i
);
5862 if (filename
== NULL
)
5864 /* demand_copy_string has already printed an error and
5865 called ignore_rest_of_line. */
5873 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
5874 && *input_line_pointer
!= ' '
5875 && *input_line_pointer
!= '\t')
5877 obstack_1grow (¬es
, *input_line_pointer
);
5878 ++input_line_pointer
;
5882 obstack_1grow (¬es
, '\0');
5883 filename
= (char *) obstack_finish (¬es
);
5884 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5885 ++input_line_pointer
;
5888 demand_empty_rest_of_line ();
5889 path
= (char *) xmalloc ((unsigned long) i
5890 + include_dir_maxlen
+ 5 /* slop */ );
5892 for (i
= 0; i
< include_dir_count
; i
++)
5894 strcpy (path
, include_dirs
[i
]);
5896 strcat (path
, filename
);
5897 if (0 != (try_file
= fopen (path
, FOPEN_RT
)))
5907 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
5908 register_dependency (path
);
5909 input_scrub_insert_file (path
);
5913 add_include_dir (char *path
)
5917 if (include_dir_count
== 0)
5919 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
5920 include_dirs
[0] = "."; /* Current dir. */
5921 include_dir_count
= 2;
5925 include_dir_count
++;
5927 (char **) realloc (include_dirs
,
5928 include_dir_count
* sizeof (*include_dirs
));
5931 include_dirs
[include_dir_count
- 1] = path
; /* New one. */
5934 if (i
> include_dir_maxlen
)
5935 include_dir_maxlen
= i
;
5938 /* Output debugging information to denote the source file. */
5941 generate_file_debug (void)
5943 if (debug_type
== DEBUG_STABS
)
5944 stabs_generate_asm_file ();
5947 /* Output line number debugging information for the current source line. */
5950 generate_lineno_debug (void)
5954 case DEBUG_UNSPECIFIED
:
5959 stabs_generate_asm_lineno ();
5962 ecoff_generate_asm_lineno ();
5965 /* ??? We could here indicate to dwarf2dbg.c that something
5966 has changed. However, since there is additional backend
5967 support that is required (calling dwarf2_emit_insn), we
5968 let dwarf2dbg.c call as_where on its own. */
5973 /* Output debugging information to mark a function entry point or end point.
5974 END_P is zero for .func, and non-zero for .endfunc. */
5979 do_s_func (end_p
, NULL
);
5982 /* Subroutine of s_func so targets can choose a different default prefix.
5983 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
5986 do_s_func (int end_p
, const char *default_prefix
)
5988 /* Record the current function so that we can issue an error message for
5989 misplaced .func,.endfunc, and also so that .endfunc needs no
5991 static char *current_name
;
5992 static char *current_label
;
5996 if (current_name
== NULL
)
5998 as_bad (_("missing .func"));
5999 ignore_rest_of_line ();
6003 if (debug_type
== DEBUG_STABS
)
6004 stabs_generate_asm_endfunc (current_name
, current_label
);
6006 current_name
= current_label
= NULL
;
6011 char delim1
, delim2
;
6013 if (current_name
!= NULL
)
6015 as_bad (_(".endfunc missing for previous .func"));
6016 ignore_rest_of_line ();
6020 name
= input_line_pointer
;
6021 delim1
= get_symbol_end ();
6022 name
= xstrdup (name
);
6023 *input_line_pointer
= delim1
;
6025 if (*input_line_pointer
!= ',')
6029 if (asprintf (&label
, "%s%s", default_prefix
, name
) == -1)
6030 as_fatal ("%s", xstrerror (errno
));
6034 char leading_char
= bfd_get_symbol_leading_char (stdoutput
);
6035 /* Missing entry point, use function's name with the leading
6039 if (asprintf (&label
, "%c%s", leading_char
, name
) == -1)
6040 as_fatal ("%s", xstrerror (errno
));
6048 ++input_line_pointer
;
6050 label
= input_line_pointer
;
6051 delim2
= get_symbol_end ();
6052 label
= xstrdup (label
);
6053 *input_line_pointer
= delim2
;
6056 if (debug_type
== DEBUG_STABS
)
6057 stabs_generate_asm_func (name
, label
);
6059 current_name
= name
;
6060 current_label
= label
;
6063 demand_empty_rest_of_line ();
6066 #ifdef HANDLE_BUNDLE
6069 s_bundle_align_mode (int arg ATTRIBUTE_UNUSED
)
6071 unsigned int align
= get_absolute_expression ();
6073 demand_empty_rest_of_line ();
6075 if (align
> (unsigned int) TC_ALIGN_LIMIT
)
6076 as_fatal (_(".bundle_align_mode alignment too large (maximum %u)"),
6077 (unsigned int) TC_ALIGN_LIMIT
);
6079 if (bundle_lock_frag
!= NULL
)
6081 as_bad (_("cannot change .bundle_align_mode inside .bundle_lock"));
6085 bundle_align_p2
= align
;
6089 s_bundle_lock (int arg ATTRIBUTE_UNUSED
)
6091 demand_empty_rest_of_line ();
6093 if (bundle_align_p2
== 0)
6095 as_bad (_(".bundle_lock is meaningless without .bundle_align_mode"));
6099 if (bundle_lock_frag
!= NULL
)
6101 as_bad (_("second .bundle_lock without .bundle_unlock"));
6105 bundle_lock_frchain
= frchain_now
;
6106 bundle_lock_frag
= start_bundle ();
6110 s_bundle_unlock (int arg ATTRIBUTE_UNUSED
)
6114 demand_empty_rest_of_line ();
6116 if (bundle_lock_frag
== NULL
)
6118 as_bad (_(".bundle_unlock without preceding .bundle_lock"));
6122 gas_assert (bundle_align_p2
> 0);
6124 size
= pending_bundle_size (bundle_lock_frag
);
6126 if (size
> (1U << bundle_align_p2
))
6127 as_bad (_(".bundle_lock sequence is %u bytes, but bundle size only %u"),
6128 size
, 1 << bundle_align_p2
);
6130 finish_bundle (bundle_lock_frag
, size
);
6132 bundle_lock_frag
= NULL
;
6133 bundle_lock_frchain
= NULL
;
6136 #endif /* HANDLE_BUNDLE */
6139 s_ignore (int arg ATTRIBUTE_UNUSED
)
6141 ignore_rest_of_line ();
6145 read_print_statistics (FILE *file
)
6147 hash_print_statistics (file
, "pseudo-op table", po_hash
);
6150 /* Inserts the given line into the input stream.
6152 This call avoids macro/conditionals nesting checking, since the contents of
6153 the line are assumed to replace the contents of a line already scanned.
6155 An appropriate use of this function would be substitution of input lines when
6156 called by md_start_line_hook(). The given line is assumed to already be
6157 properly scrubbed. */
6160 input_scrub_insert_line (const char *line
)
6164 sb_add_string (&newline
, line
);
6165 input_scrub_include_sb (&newline
, input_line_pointer
, 0);
6167 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
6170 /* Insert a file into the input stream; the path must resolve to an actual
6171 file; no include path searching or dependency registering is performed. */
6174 input_scrub_insert_file (char *path
)
6176 input_scrub_include_file (path
, input_line_pointer
);
6177 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
6180 /* Find the end of a line, considering quotation and escaping of quotes. */
6182 #if !defined(TC_SINGLE_QUOTE_STRINGS) && defined(SINGLE_QUOTE_STRINGS)
6183 # define TC_SINGLE_QUOTE_STRINGS 1
6187 _find_end_of_line (char *s
, int mri_string
, int insn ATTRIBUTE_UNUSED
,
6190 char inquote
= '\0';
6193 while (!is_end_of_line
[(unsigned char) *s
]
6194 || (inquote
&& !ISCNTRL (*s
))
6195 || (inquote
== '\'' && flag_mri
)
6196 #ifdef TC_EOL_IN_INSN
6197 || (insn
&& TC_EOL_IN_INSN (s
))
6199 /* PR 6926: When we are parsing the body of a macro the sequence
6200 \@ is special - it refers to the invocation count. If the @
6201 character happens to be registered as a line-separator character
6202 by the target, then the is_end_of_line[] test above will have
6203 returned true, but we need to ignore the line separating
6204 semantics in this particular case. */
6205 || (in_macro
&& inescape
&& *s
== '@')
6208 if (mri_string
&& *s
== '\'')
6212 else if (*s
== '\\')
6216 #ifdef TC_SINGLE_QUOTE_STRINGS
6217 || (TC_SINGLE_QUOTE_STRINGS
&& *s
== '\'')
6224 as_warn (_("missing closing `%c'"), inquote
);
6226 as_warn (_("stray `\\'"));
6231 find_end_of_line (char *s
, int mri_string
)
6233 return _find_end_of_line (s
, mri_string
, 0, 0);