gas/
[external/binutils.git] / gas / read.c
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
4    Free Software Foundation, Inc.
5
6 This file is part of GAS, the GNU Assembler.
7
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 2, or (at your option)
11 any later version.
12
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.
17
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
21 02110-1301, USA.  */
22
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)
27
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)
31
32 /* Routines that read assembler source text to build spaghetti in memory.
33    Another group of these functions is in the expr.c module.  */
34
35 #include "as.h"
36 #include "safe-ctype.h"
37 #include "subsegs.h"
38 #include "sb.h"
39 #include "macro.h"
40 #include "obstack.h"
41 #include "listing.h"
42 #include "ecoff.h"
43 #include "dw2gencfi.h"
44
45 #ifndef TC_START_LABEL
46 #define TC_START_LABEL(x,y) (x == ':')
47 #endif
48
49 /* Set by the object-format or the target.  */
50 #ifndef TC_IMPLICIT_LCOMM_ALIGNMENT
51 #define TC_IMPLICIT_LCOMM_ALIGNMENT(SIZE, P2VAR)                \
52   do                                                            \
53     {                                                           \
54       if ((SIZE) >= 8)                                          \
55         (P2VAR) = 3;                                            \
56       else if ((SIZE) >= 4)                                     \
57         (P2VAR) = 2;                                            \
58       else if ((SIZE) >= 2)                                     \
59         (P2VAR) = 1;                                            \
60       else                                                      \
61         (P2VAR) = 0;                                            \
62     }                                                           \
63   while (0)
64 #endif
65
66 char *input_line_pointer;       /*->next char of source file to parse.  */
67
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!)!  */
71 die horribly;
72 #endif
73
74 #ifndef LEX_AT
75 /* The m88k unfortunately uses @ as a label beginner.  */
76 #define LEX_AT 0
77 #endif
78
79 #ifndef LEX_BR
80 /* The RS/6000 assembler uses {,},[,] as parts of symbol names.  */
81 #define LEX_BR 0
82 #endif
83
84 #ifndef LEX_PCT
85 /* The Delta 68k assembler permits % inside label names.  */
86 #define LEX_PCT 0
87 #endif
88
89 #ifndef LEX_QM
90 /* The PowerPC Windows NT assemblers permits ? inside label names.  */
91 #define LEX_QM 0
92 #endif
93
94 #ifndef LEX_HASH
95 /* The IA-64 assembler uses # as a suffix designating a symbol.  We include
96    it in the symbol and strip it out in tc_canonicalize_symbol_name.  */
97 #define LEX_HASH 0
98 #endif
99
100 #ifndef LEX_DOLLAR
101 /* The a29k assembler does not permits labels to start with $.  */
102 #define LEX_DOLLAR 3
103 #endif
104
105 #ifndef LEX_TILDE
106 /* The Delta 68k assembler permits ~ at start of label names.  */
107 #define LEX_TILDE 0
108 #endif
109
110 /* Used by is_... macros. our ctype[].  */
111 char lex_type[256] = {
112   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,       /* @ABCDEFGHIJKLMNO */
113   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,       /* PQRSTUVWXYZ[\]^_ */
114   0, 0, 0, LEX_HASH, LEX_DOLLAR, LEX_PCT, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
115   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM,  /* 0123456789:;<=>? */
116   LEX_AT, 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, 0, 3, /* PQRSTUVWXYZ[\]^_ */
118   0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,       /* `abcdefghijklmno */
119   3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR, 0, LEX_BR, LEX_TILDE, 0, /* pqrstuvwxyz{|}~.  */
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,
126   3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
127   3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
128 };
129
130 /* In: a character.
131    Out: 1 if this character ends a line.  */
132 char is_end_of_line[256] = {
133 #ifdef CR_EOL
134   1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,       /* @abcdefghijklmno */
135 #else
136   1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,       /* @abcdefghijklmno */
137 #endif
138   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,       /* */
139   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,       /* _!"#$%&'()*+,-./ */
140   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,       /* 0123456789:;<=>? */
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,       /* */
152   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0        /* */
153 };
154
155 #ifndef TC_CASE_SENSITIVE
156 char original_case_string[128];
157 #endif
158
159 /* Functions private to this file.  */
160
161 static char *buffer;    /* 1st char of each buffer of lines is here.  */
162 static char *buffer_limit;      /*->1 + last char in buffer.  */
163
164 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1
165    in the tc-<CPU>.h file.  See the "Porting GAS" section of the
166    internals manual.  */
167 int target_big_endian = TARGET_BYTES_BIG_ENDIAN;
168
169 /* Variables for handling include file directory table.  */
170
171 /* Table of pointers to directories to search for .include's.  */
172 char **include_dirs;
173
174 /* How many are in the table.  */
175 int include_dir_count;
176
177 /* Length of longest in table.  */
178 int include_dir_maxlen = 1;
179
180 #ifndef WORKING_DOT_WORD
181 struct broken_word *broken_words;
182 int new_broken_words;
183 #endif
184
185 /* The current offset into the absolute section.  We don't try to
186    build frags in the absolute section, since no data can be stored
187    there.  We just keep track of the current offset.  */
188 addressT abs_section_offset;
189
190 /* If this line had an MRI style label, it is stored in this variable.
191    This is used by some of the MRI pseudo-ops.  */
192 symbolS *line_label;
193
194 /* This global variable is used to support MRI common sections.  We
195    translate such sections into a common symbol.  This variable is
196    non-NULL when we are in an MRI common section.  */
197 symbolS *mri_common_symbol;
198
199 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
200    need to align to an even byte boundary unless the next pseudo-op is
201    dc.b, ds.b, or dcb.b.  This variable is set to 1 if an alignment
202    may be needed.  */
203 static int mri_pending_align;
204
205 #ifndef NO_LISTING
206 #ifdef OBJ_ELF
207 /* This variable is set to be non-zero if the next string we see might
208    be the name of the source file in DWARF debugging information.  See
209    the comment in emit_expr for the format we look for.  */
210 static int dwarf_file_string;
211 #endif
212 #endif
213
214 static void do_s_func (int end_p, const char *default_prefix);
215 static void do_align (int, char *, int, int);
216 static void s_align (int, int);
217 static void s_altmacro (int);
218 static void s_bad_end (int);
219 static int hex_float (int, char *);
220 static segT get_known_segmented_expression (expressionS * expP);
221 static void pobegin (void);
222 static int get_line_sb (sb *);
223 static void generate_file_debug (void);
224 \f
225 void
226 read_begin (void)
227 {
228   const char *p;
229
230   pobegin ();
231   obj_read_begin_hook ();
232
233   /* Something close -- but not too close -- to a multiple of 1024.
234      The debugging malloc I'm using has 24 bytes of overhead.  */
235   obstack_begin (&notes, chunksize);
236   obstack_begin (&cond_obstack, chunksize);
237
238   /* Use machine dependent syntax.  */
239   for (p = line_separator_chars; *p; p++)
240     is_end_of_line[(unsigned char) *p] = 1;
241   /* Use more.  FIXME-SOMEDAY.  */
242
243   if (flag_mri)
244     lex_type['?'] = 3;
245 }
246 \f
247 #ifndef TC_ADDRESS_BYTES
248 #ifdef BFD_ASSEMBLER
249 #define TC_ADDRESS_BYTES address_bytes
250
251 static inline int
252 address_bytes (void)
253 {
254   /* Choose smallest of 1, 2, 4, 8 bytes that is large enough to
255      contain an address.  */
256   int n = (stdoutput->arch_info->bits_per_address - 1) / 8;
257   n |= n >> 1;
258   n |= n >> 2;
259   n += 1;
260   return n;
261 }
262 #endif
263 #endif
264
265 /* Set up pseudo-op tables.  */
266
267 static struct hash_control *po_hash;
268
269 static const pseudo_typeS potable[] = {
270   {"abort", s_abort, 0},
271   {"align", s_align_ptwo, 0},
272   {"altmacro", s_altmacro, 1},
273   {"ascii", stringer, 0},
274   {"asciz", stringer, 1},
275   {"balign", s_align_bytes, 0},
276   {"balignw", s_align_bytes, -2},
277   {"balignl", s_align_bytes, -4},
278 /* block  */
279   {"byte", cons, 1},
280   {"comm", s_comm, 0},
281   {"common", s_mri_common, 0},
282   {"common.s", s_mri_common, 1},
283   {"data", s_data, 0},
284   {"dc", cons, 2},
285 #ifdef TC_ADDRESS_BYTES
286   {"dc.a", cons, 0},
287 #endif
288   {"dc.b", cons, 1},
289   {"dc.d", float_cons, 'd'},
290   {"dc.l", cons, 4},
291   {"dc.s", float_cons, 'f'},
292   {"dc.w", cons, 2},
293   {"dc.x", float_cons, 'x'},
294   {"dcb", s_space, 2},
295   {"dcb.b", s_space, 1},
296   {"dcb.d", s_float_space, 'd'},
297   {"dcb.l", s_space, 4},
298   {"dcb.s", s_float_space, 'f'},
299   {"dcb.w", s_space, 2},
300   {"dcb.x", s_float_space, 'x'},
301   {"ds", s_space, 2},
302   {"ds.b", s_space, 1},
303   {"ds.d", s_space, 8},
304   {"ds.l", s_space, 4},
305   {"ds.p", s_space, 12},
306   {"ds.s", s_space, 4},
307   {"ds.w", s_space, 2},
308   {"ds.x", s_space, 12},
309   {"debug", s_ignore, 0},
310 #ifdef S_SET_DESC
311   {"desc", s_desc, 0},
312 #endif
313 /* dim  */
314   {"double", float_cons, 'd'},
315 /* dsect  */
316   {"eject", listing_eject, 0},  /* Formfeed listing.  */
317   {"else", s_else, 0},
318   {"elsec", s_else, 0},
319   {"elseif", s_elseif, (int) O_ne},
320   {"end", s_end, 0},
321   {"endc", s_endif, 0},
322   {"endfunc", s_func, 1},
323   {"endif", s_endif, 0},
324   {"endm", s_bad_end, 0},
325   {"endr", s_bad_end, 1},
326 /* endef  */
327   {"equ", s_set, 0},
328   {"equiv", s_set, 1},
329   {"err", s_err, 0},
330   {"error", s_errwarn, 1},
331   {"exitm", s_mexit, 0},
332 /* extend  */
333   {"extern", s_ignore, 0},      /* We treat all undef as ext.  */
334   {"appfile", s_app_file, 1},
335   {"appline", s_app_line, 0},
336   {"fail", s_fail, 0},
337   {"file", s_app_file, 0},
338   {"fill", s_fill, 0},
339   {"float", float_cons, 'f'},
340   {"format", s_ignore, 0},
341   {"func", s_func, 0},
342   {"global", s_globl, 0},
343   {"globl", s_globl, 0},
344   {"hword", cons, 2},
345   {"if", s_if, (int) O_ne},
346   {"ifb", s_ifb, 1},
347   {"ifc", s_ifc, 0},
348   {"ifdef", s_ifdef, 0},
349   {"ifeq", s_if, (int) O_eq},
350   {"ifeqs", s_ifeqs, 0},
351   {"ifge", s_if, (int) O_ge},
352   {"ifgt", s_if, (int) O_gt},
353   {"ifle", s_if, (int) O_le},
354   {"iflt", s_if, (int) O_lt},
355   {"ifnb", s_ifb, 0},
356   {"ifnc", s_ifc, 1},
357   {"ifndef", s_ifdef, 1},
358   {"ifne", s_if, (int) O_ne},
359   {"ifnes", s_ifeqs, 1},
360   {"ifnotdef", s_ifdef, 1},
361   {"incbin", s_incbin, 0},
362   {"include", s_include, 0},
363   {"int", cons, 4},
364   {"irp", s_irp, 0},
365   {"irep", s_irp, 0},
366   {"irpc", s_irp, 1},
367   {"irepc", s_irp, 1},
368   {"lcomm", s_lcomm, 0},
369   {"lflags", listing_flags, 0}, /* Listing flags.  */
370   {"linkonce", s_linkonce, 0},
371   {"list", listing_list, 1},    /* Turn listing on.  */
372   {"llen", listing_psize, 1},
373   {"long", cons, 4},
374   {"lsym", s_lsym, 0},
375   {"macro", s_macro, 0},
376   {"mexit", s_mexit, 0},
377   {"mri", s_mri, 0},
378   {".mri", s_mri, 0},   /* Special case so .mri works in MRI mode.  */
379   {"name", s_ignore, 0},
380   {"noaltmacro", s_altmacro, 0},
381   {"noformat", s_ignore, 0},
382   {"nolist", listing_list, 0},  /* Turn listing off.  */
383   {"nopage", listing_nopage, 0},
384   {"octa", cons, 16},
385   {"offset", s_struct, 0},
386   {"org", s_org, 0},
387   {"p2align", s_align_ptwo, 0},
388   {"p2alignw", s_align_ptwo, -2},
389   {"p2alignl", s_align_ptwo, -4},
390   {"page", listing_eject, 0},
391   {"plen", listing_psize, 0},
392   {"print", s_print, 0},
393   {"psize", listing_psize, 0},  /* Set paper size.  */
394   {"purgem", s_purgem, 0},
395   {"quad", cons, 8},
396   {"rep", s_rept, 0},
397   {"rept", s_rept, 0},
398   {"rva", s_rva, 4},
399   {"sbttl", listing_title, 1},  /* Subtitle of listing.  */
400 /* scl  */
401 /* sect  */
402   {"set", s_set, 0},
403   {"short", cons, 2},
404   {"single", float_cons, 'f'},
405 /* size  */
406   {"space", s_space, 0},
407   {"skip", s_space, 0},
408   {"sleb128", s_leb128, 1},
409   {"spc", s_ignore, 0},
410   {"stabd", s_stab, 'd'},
411   {"stabn", s_stab, 'n'},
412   {"stabs", s_stab, 's'},
413   {"string", stringer, 1},
414   {"struct", s_struct, 0},
415 /* tag  */
416   {"text", s_text, 0},
417
418   /* This is for gcc to use.  It's only just been added (2/94), so gcc
419      won't be able to use it for a while -- probably a year or more.
420      But once this has been released, check with gcc maintainers
421      before deleting it or even changing the spelling.  */
422   {"this_GCC_requires_the_GNU_assembler", s_ignore, 0},
423   /* If we're folding case -- done for some targets, not necessarily
424      all -- the above string in an input file will be converted to
425      this one.  Match it either way...  */
426   {"this_gcc_requires_the_gnu_assembler", s_ignore, 0},
427
428   {"title", listing_title, 0},  /* Listing title.  */
429   {"ttl", listing_title, 0},
430 /* type  */
431   {"uleb128", s_leb128, 0},
432 /* use  */
433 /* val  */
434   {"xcom", s_comm, 0},
435   {"xdef", s_globl, 0},
436   {"xref", s_ignore, 0},
437   {"xstabs", s_xstab, 's'},
438   {"warning", s_errwarn, 0},
439   {"word", cons, 2},
440   {"zero", s_space, 0},
441   {NULL, NULL, 0}                       /* End sentinel.  */
442 };
443
444 static offsetT
445 get_absolute_expr (expressionS *exp)
446 {
447   expression (exp);
448   if (exp->X_op != O_constant)
449     {
450       if (exp->X_op != O_absent)
451         as_bad (_("bad or irreducible absolute expression"));
452       exp->X_add_number = 0;
453     }
454   return exp->X_add_number;
455 }
456
457 offsetT
458 get_absolute_expression (void)
459 {
460   expressionS exp;
461
462   return get_absolute_expr (&exp);
463 }
464
465 static int pop_override_ok = 0;
466 static const char *pop_table_name;
467
468 void
469 pop_insert (const pseudo_typeS *table)
470 {
471   const char *errtxt;
472   const pseudo_typeS *pop;
473   for (pop = table; pop->poc_name; pop++)
474     {
475       errtxt = hash_insert (po_hash, pop->poc_name, (char *) pop);
476       if (errtxt && (!pop_override_ok || strcmp (errtxt, "exists")))
477         as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name,
478                   errtxt);
479     }
480 }
481
482 #ifndef md_pop_insert
483 #define md_pop_insert()         pop_insert(md_pseudo_table)
484 #endif
485
486 #ifndef obj_pop_insert
487 #define obj_pop_insert()        pop_insert(obj_pseudo_table)
488 #endif
489
490 #ifndef cfi_pop_insert
491 #define cfi_pop_insert()        pop_insert(cfi_pseudo_table)
492 #endif
493
494 static void
495 pobegin (void)
496 {
497   po_hash = hash_new ();
498
499   /* Do the target-specific pseudo ops.  */
500   pop_table_name = "md";
501   md_pop_insert ();
502
503   /* Now object specific.  Skip any that were in the target table.  */
504   pop_table_name = "obj";
505   pop_override_ok = 1;
506   obj_pop_insert ();
507
508   /* Now portable ones.  Skip any that we've seen already.  */
509   pop_table_name = "standard";
510   pop_insert (potable);
511
512 #ifdef TARGET_USE_CFIPOP
513   pop_table_name = "cfi";
514   pop_override_ok = 1;
515   cfi_pop_insert ();
516 #endif
517 }
518 \f
519 #define HANDLE_CONDITIONAL_ASSEMBLY()                                   \
520   if (ignore_input ())                                                  \
521     {                                                                   \
522       while (!is_end_of_line[(unsigned char) *input_line_pointer++])    \
523         if (input_line_pointer == buffer_limit)                         \
524           break;                                                        \
525       continue;                                                         \
526     }
527
528 /* This function is used when scrubbing the characters between #APP
529    and #NO_APP.  */
530
531 static char *scrub_string;
532 static char *scrub_string_end;
533
534 static int
535 scrub_from_string (char *buf, int buflen)
536 {
537   int copy;
538
539   copy = scrub_string_end - scrub_string;
540   if (copy > buflen)
541     copy = buflen;
542   memcpy (buf, scrub_string, copy);
543   scrub_string += copy;
544   return copy;
545 }
546
547 /* Helper function of read_a_source_file, which tries to expand a macro.  */
548 static int
549 try_macro (char term, const char *line)
550 {
551   sb out;
552   const char *err;
553   macro_entry *macro;
554
555   if (check_macro (line, &out, &err, &macro))
556     {
557       if (err != NULL)
558         as_bad ("%s", err);
559       *input_line_pointer++ = term;
560       input_scrub_include_sb (&out,
561                               input_line_pointer, 1);
562       sb_kill (&out);
563       buffer_limit =
564         input_scrub_next_buffer (&input_line_pointer);
565 #ifdef md_macro_info
566       md_macro_info (macro);
567 #endif
568       return 1;
569     }
570   return 0;
571 }
572
573 /* We read the file, putting things into a web that represents what we
574    have been reading.  */
575 void
576 read_a_source_file (char *name)
577 {
578   register char c;
579   register char *s;             /* String of symbol, '\0' appended.  */
580   register int temp;
581   pseudo_typeS *pop;
582
583 #ifdef WARN_COMMENTS
584   found_comment = 0;
585 #endif
586
587   buffer = input_scrub_new_file (name);
588
589   listing_file (name);
590   listing_newline (NULL);
591   register_dependency (name);
592
593   /* Generate debugging information before we've read anything in to denote
594      this file as the "main" source file and not a subordinate one
595      (e.g. N_SO vs N_SOL in stabs).  */
596   generate_file_debug ();
597
598   while ((buffer_limit = input_scrub_next_buffer (&input_line_pointer)) != 0)
599     {                           /* We have another line to parse.  */
600 #ifndef NO_LISTING
601       /* In order to avoid listing macro expansion lines with labels
602          multiple times, keep track of which line was last issued.  */
603       static char *last_eol;
604
605       last_eol = NULL;
606 #endif
607       know (buffer_limit[-1] == '\n');  /* Must have a sentinel.  */
608
609       while (input_line_pointer < buffer_limit)
610         {
611           /* We have more of this buffer to parse.  */
612
613           /* We now have input_line_pointer->1st char of next line.
614              If input_line_pointer [-1] == '\n' then we just
615              scanned another line: so bump line counters.  */
616           if (is_end_of_line[(unsigned char) input_line_pointer[-1]])
617             {
618 #ifdef md_start_line_hook
619               md_start_line_hook ();
620 #endif
621               if (input_line_pointer[-1] == '\n')
622                 bump_line_counters ();
623
624               line_label = NULL;
625
626               if (LABELS_WITHOUT_COLONS || flag_m68k_mri)
627                 {
628                   /* Text at the start of a line must be a label, we
629                      run down and stick a colon in.  */
630                   if (is_name_beginner (*input_line_pointer))
631                     {
632                       char *line_start = input_line_pointer;
633                       char c;
634                       int mri_line_macro;
635
636                       LISTING_NEWLINE ();
637                       HANDLE_CONDITIONAL_ASSEMBLY ();
638
639                       c = get_symbol_end ();
640
641                       /* In MRI mode, the EQU and MACRO pseudoops must
642                          be handled specially.  */
643                       mri_line_macro = 0;
644                       if (flag_m68k_mri)
645                         {
646                           char *rest = input_line_pointer + 1;
647
648                           if (*rest == ':')
649                             ++rest;
650                           if (*rest == ' ' || *rest == '\t')
651                             ++rest;
652                           if ((strncasecmp (rest, "EQU", 3) == 0
653                                || strncasecmp (rest, "SET", 3) == 0)
654                               && (rest[3] == ' ' || rest[3] == '\t'))
655                             {
656                               input_line_pointer = rest + 3;
657                               equals (line_start,
658                                       strncasecmp (rest, "SET", 3) == 0);
659                               continue;
660                             }
661                           if (strncasecmp (rest, "MACRO", 5) == 0
662                               && (rest[5] == ' '
663                                   || rest[5] == '\t'
664                                   || is_end_of_line[(unsigned char) rest[5]]))
665                             mri_line_macro = 1;
666                         }
667
668                       /* In MRI mode, we need to handle the MACRO
669                          pseudo-op specially: we don't want to put the
670                          symbol in the symbol table.  */
671                       if (!mri_line_macro
672 #ifdef TC_START_LABEL_WITHOUT_COLON
673                           && TC_START_LABEL_WITHOUT_COLON(c,
674                                                           input_line_pointer)
675 #endif
676                           )
677                         line_label = colon (line_start);
678                       else
679                         line_label = symbol_create (line_start,
680                                                     absolute_section,
681                                                     (valueT) 0,
682                                                     &zero_address_frag);
683
684                       *input_line_pointer = c;
685                       if (c == ':')
686                         input_line_pointer++;
687                     }
688                 }
689             }
690
691           /* We are at the beginning of a line, or similar place.
692              We expect a well-formed assembler statement.
693              A "symbol-name:" is a statement.
694
695              Depending on what compiler is used, the order of these tests
696              may vary to catch most common case 1st.
697              Each test is independent of all other tests at the (top) level.
698              PLEASE make a compiler that doesn't use this assembler.
699              It is crufty to waste a compiler's time encoding things for this
700              assembler, which then wastes more time decoding it.
701              (And communicating via (linear) files is silly!
702              If you must pass stuff, please pass a tree!)  */
703           if ((c = *input_line_pointer++) == '\t'
704               || c == ' '
705               || c == '\f'
706               || c == 0)
707             c = *input_line_pointer++;
708
709           know (c != ' ');      /* No further leading whitespace.  */
710
711 #ifndef NO_LISTING
712           /* If listing is on, and we are expanding a macro, then give
713              the listing code the contents of the expanded line.  */
714           if (listing)
715             {
716               if ((listing & LISTING_MACEXP) && macro_nest > 0)
717                 {
718                   char *copy;
719                   int len;
720
721                   /* Find the end of the current expanded macro line.  */
722                   for (s = input_line_pointer - 1; *s; ++s)
723                     if (is_end_of_line[(unsigned char) *s])
724                       break;
725
726                   if (s != last_eol)
727                     {
728                       last_eol = s;
729                       /* Copy it for safe keeping.  Also give an indication of
730                          how much macro nesting is involved at this point.  */
731                       len = s - (input_line_pointer - 1);
732                       copy = (char *) xmalloc (len + macro_nest + 2);
733                       memset (copy, '>', macro_nest);
734                       copy[macro_nest] = ' ';
735                       memcpy (copy + macro_nest + 1, input_line_pointer - 1, len);
736                       copy[macro_nest + 1 + len] = '\0';
737
738                       /* Install the line with the listing facility.  */
739                       listing_newline (copy);
740                     }
741                 }
742               else
743                 listing_newline (NULL);
744             }
745 #endif
746           /* C is the 1st significant character.
747              Input_line_pointer points after that character.  */
748           if (is_name_beginner (c))
749             {
750               /* Want user-defined label or pseudo/opcode.  */
751               HANDLE_CONDITIONAL_ASSEMBLY ();
752
753               s = --input_line_pointer;
754               c = get_symbol_end ();    /* name's delimiter.  */
755
756               /* C is character after symbol.
757                  That character's place in the input line is now '\0'.
758                  S points to the beginning of the symbol.
759                    [In case of pseudo-op, s->'.'.]
760                  Input_line_pointer->'\0' where c was.  */
761               if (TC_START_LABEL (c, input_line_pointer))
762                 {
763                   if (flag_m68k_mri)
764                     {
765                       char *rest = input_line_pointer + 1;
766
767                       /* In MRI mode, \tsym: set 0 is permitted.  */
768                       if (*rest == ':')
769                         ++rest;
770
771                       if (*rest == ' ' || *rest == '\t')
772                         ++rest;
773
774                       if ((strncasecmp (rest, "EQU", 3) == 0
775                            || strncasecmp (rest, "SET", 3) == 0)
776                           && (rest[3] == ' ' || rest[3] == '\t'))
777                         {
778                           input_line_pointer = rest + 3;
779                           equals (s, 1);
780                           continue;
781                         }
782                     }
783
784                   line_label = colon (s);       /* User-defined label.  */
785                   /* Put ':' back for error messages' sake.  */
786                   *input_line_pointer++ = ':';
787 #ifdef tc_check_label
788                   tc_check_label (line_label);
789 #endif
790                   /* Input_line_pointer->after ':'.  */
791                   SKIP_WHITESPACE ();
792                 }
793               else if ((c == '='
794                        || ((c == ' ' || c == '\t')
795                             && input_line_pointer[1] == '='))
796 #ifdef TC_EQUAL_IN_INSN
797                            && !TC_EQUAL_IN_INSN (c, s)
798 #endif
799                            )
800                 {
801                   equals (s, 1);
802                   demand_empty_rest_of_line ();
803                 }
804               else
805                 {
806                   /* Expect pseudo-op or machine instruction.  */
807                   pop = NULL;
808
809 #ifndef TC_CASE_SENSITIVE
810                   {
811                     char *s2 = s;
812
813                     strncpy (original_case_string, s2, sizeof (original_case_string));
814                     original_case_string[sizeof (original_case_string) - 1] = 0;
815
816                     while (*s2)
817                       {
818                         *s2 = TOLOWER (*s2);
819                         s2++;
820                       }
821                   }
822 #endif
823                   if (NO_PSEUDO_DOT || flag_m68k_mri)
824                     {
825                       /* The MRI assembler and the m88k use pseudo-ops
826                          without a period.  */
827                       pop = (pseudo_typeS *) hash_find (po_hash, s);
828                       if (pop != NULL && pop->poc_handler == NULL)
829                         pop = NULL;
830                     }
831
832                   if (pop != NULL
833                       || (!flag_m68k_mri && *s == '.'))
834                     {
835                       /* PSEUDO - OP.
836
837                          WARNING: c has next char, which may be end-of-line.
838                          We lookup the pseudo-op table with s+1 because we
839                          already know that the pseudo-op begins with a '.'.  */
840
841                       if (pop == NULL)
842                         pop = (pseudo_typeS *) hash_find (po_hash, s + 1);
843                       if (pop && !pop->poc_handler)
844                         pop = NULL;
845
846                       /* In MRI mode, we may need to insert an
847                          automatic alignment directive.  What a hack
848                          this is.  */
849                       if (mri_pending_align
850                           && (pop == NULL
851                               || !((pop->poc_handler == cons
852                                     && pop->poc_val == 1)
853                                    || (pop->poc_handler == s_space
854                                        && pop->poc_val == 1)
855 #ifdef tc_conditional_pseudoop
856                                    || tc_conditional_pseudoop (pop)
857 #endif
858                                    || pop->poc_handler == s_if
859                                    || pop->poc_handler == s_ifdef
860                                    || pop->poc_handler == s_ifc
861                                    || pop->poc_handler == s_ifeqs
862                                    || pop->poc_handler == s_else
863                                    || pop->poc_handler == s_endif
864                                    || pop->poc_handler == s_globl
865                                    || pop->poc_handler == s_ignore)))
866                         {
867                           do_align (1, (char *) NULL, 0, 0);
868                           mri_pending_align = 0;
869
870                           if (line_label != NULL)
871                             {
872                               symbol_set_frag (line_label, frag_now);
873                               S_SET_VALUE (line_label, frag_now_fix ());
874                             }
875                         }
876
877                       /* Print the error msg now, while we still can.  */
878                       if (pop == NULL)
879                         {
880                           char *end = input_line_pointer;
881
882                           *input_line_pointer = c;
883                           s_ignore (0);
884                           c = *--input_line_pointer;
885                           *input_line_pointer = '\0';
886                           if (! macro_defined || ! try_macro (c, s))
887                             {
888                               *end = '\0';
889                               as_bad (_("unknown pseudo-op: `%s'"), s);
890                               *input_line_pointer++ = c;
891                             }
892                           continue;
893                         }
894
895                       /* Put it back for error messages etc.  */
896                       *input_line_pointer = c;
897                       /* The following skip of whitespace is compulsory.
898                          A well shaped space is sometimes all that separates
899                          keyword from operands.  */
900                       if (c == ' ' || c == '\t')
901                         input_line_pointer++;
902
903                       /* Input_line is restored.
904                          Input_line_pointer->1st non-blank char
905                          after pseudo-operation.  */
906                       (*pop->poc_handler) (pop->poc_val);
907
908                       /* If that was .end, just get out now.  */
909                       if (pop->poc_handler == s_end)
910                         goto quit;
911                     }
912                   else
913                     {
914                       int inquote = 0;
915 #ifdef QUOTES_IN_INSN
916                       int inescape = 0;
917 #endif
918
919                       /* WARNING: c has char, which may be end-of-line.  */
920                       /* Also: input_line_pointer->`\0` where c was.  */
921                       *input_line_pointer = c;
922                       while (!is_end_of_line[(unsigned char) *input_line_pointer]
923                              || inquote
924 #ifdef TC_EOL_IN_INSN
925                              || TC_EOL_IN_INSN (input_line_pointer)
926 #endif
927                              )
928                         {
929                           if (flag_m68k_mri && *input_line_pointer == '\'')
930                             inquote = !inquote;
931 #ifdef QUOTES_IN_INSN
932                           if (inescape)
933                             inescape = 0;
934                           else if (*input_line_pointer == '"')
935                             inquote = !inquote;
936                           else if (*input_line_pointer == '\\')
937                             inescape = 1;
938 #endif
939                           input_line_pointer++;
940                         }
941
942                       c = *input_line_pointer;
943                       *input_line_pointer = '\0';
944
945                       generate_lineno_debug ();
946
947                       if (macro_defined && try_macro (c, s))
948                         continue;
949
950                       if (mri_pending_align)
951                         {
952                           do_align (1, (char *) NULL, 0, 0);
953                           mri_pending_align = 0;
954                           if (line_label != NULL)
955                             {
956                               symbol_set_frag (line_label, frag_now);
957                               S_SET_VALUE (line_label, frag_now_fix ());
958                             }
959                         }
960
961                       md_assemble (s);  /* Assemble 1 instruction.  */
962
963                       *input_line_pointer++ = c;
964
965                       /* We resume loop AFTER the end-of-line from
966                          this instruction.  */
967                     }
968                 }
969               continue;
970             }
971
972           /* Empty statement?  */
973           if (is_end_of_line[(unsigned char) c])
974             continue;
975
976           if ((LOCAL_LABELS_DOLLAR || LOCAL_LABELS_FB) && ISDIGIT (c))
977             {
978               /* local label  ("4:")  */
979               char *backup = input_line_pointer;
980
981               HANDLE_CONDITIONAL_ASSEMBLY ();
982
983               temp = c - '0';
984
985               /* Read the whole number.  */
986               while (ISDIGIT (*input_line_pointer))
987                 {
988                   temp = (temp * 10) + *input_line_pointer - '0';
989                   ++input_line_pointer;
990                 }
991
992               if (LOCAL_LABELS_DOLLAR
993                   && *input_line_pointer == '$'
994                   && *(input_line_pointer + 1) == ':')
995                 {
996                   input_line_pointer += 2;
997
998                   if (dollar_label_defined (temp))
999                     {
1000                       as_fatal (_("label \"%d$\" redefined"), temp);
1001                     }
1002
1003                   define_dollar_label (temp);
1004                   colon (dollar_label_name (temp, 0));
1005                   continue;
1006                 }
1007
1008               if (LOCAL_LABELS_FB
1009                   && *input_line_pointer++ == ':')
1010                 {
1011                   fb_label_instance_inc (temp);
1012                   colon (fb_label_name (temp, 0));
1013                   continue;
1014                 }
1015
1016               input_line_pointer = backup;
1017             }                   /* local label  ("4:") */
1018
1019           if (c && strchr (line_comment_chars, c))
1020             {                   /* Its a comment.  Better say APP or NO_APP.  */
1021               sb sbuf;
1022               char *ends;
1023               char *new_buf;
1024               char *new_tmp;
1025               unsigned int new_length;
1026               char *tmp_buf = 0;
1027
1028               bump_line_counters ();
1029               s = input_line_pointer;
1030               if (strncmp (s, "APP\n", 4))
1031                 continue;       /* We ignore it */
1032               s += 4;
1033
1034               sb_new (&sbuf);
1035               ends = strstr (s, "#NO_APP\n");
1036
1037               if (!ends)
1038                 {
1039                   unsigned int tmp_len;
1040                   unsigned int num;
1041
1042                   /* The end of the #APP wasn't in this buffer.  We
1043                      keep reading in buffers until we find the #NO_APP
1044                      that goes with this #APP  There is one.  The specs
1045                      guarantee it...  */
1046                   tmp_len = buffer_limit - s;
1047                   tmp_buf = xmalloc (tmp_len + 1);
1048                   memcpy (tmp_buf, s, tmp_len);
1049                   do
1050                     {
1051                       new_tmp = input_scrub_next_buffer (&buffer);
1052                       if (!new_tmp)
1053                         break;
1054                       else
1055                         buffer_limit = new_tmp;
1056                       input_line_pointer = buffer;
1057                       ends = strstr (buffer, "#NO_APP\n");
1058                       if (ends)
1059                         num = ends - buffer;
1060                       else
1061                         num = buffer_limit - buffer;
1062
1063                       tmp_buf = xrealloc (tmp_buf, tmp_len + num);
1064                       memcpy (tmp_buf + tmp_len, buffer, num);
1065                       tmp_len += num;
1066                     }
1067                   while (!ends);
1068
1069                   input_line_pointer = ends ? ends + 8 : NULL;
1070
1071                   s = tmp_buf;
1072                   ends = s + tmp_len;
1073
1074                 }
1075               else
1076                 {
1077                   input_line_pointer = ends + 8;
1078                 }
1079
1080               scrub_string = s;
1081               scrub_string_end = ends;
1082
1083               new_length = ends - s;
1084               new_buf = (char *) xmalloc (new_length);
1085               new_tmp = new_buf;
1086               for (;;)
1087                 {
1088                   int space;
1089                   int size;
1090
1091                   space = (new_buf + new_length) - new_tmp;
1092                   size = do_scrub_chars (scrub_from_string, new_tmp, space);
1093
1094                   if (size < space)
1095                     {
1096                       new_tmp[size] = 0;
1097                       break;
1098                     }
1099
1100                   new_buf = xrealloc (new_buf, new_length + 100);
1101                   new_tmp = new_buf + new_length;
1102                   new_length += 100;
1103                 }
1104
1105               if (tmp_buf)
1106                 free (tmp_buf);
1107
1108               /* We've "scrubbed" input to the preferred format.  In the
1109                  process we may have consumed the whole of the remaining
1110                  file (and included files).  We handle this formatted
1111                  input similar to that of macro expansion, letting
1112                  actual macro expansion (possibly nested) and other
1113                  input expansion work.  Beware that in messages, line
1114                  numbers and possibly file names will be incorrect.  */
1115               sb_add_string (&sbuf, new_buf);
1116               input_scrub_include_sb (&sbuf, input_line_pointer, 0);
1117               sb_kill (&sbuf);
1118               buffer_limit = input_scrub_next_buffer (&input_line_pointer);
1119               free (new_buf);
1120               continue;
1121             }
1122
1123           HANDLE_CONDITIONAL_ASSEMBLY ();
1124
1125 #ifdef tc_unrecognized_line
1126           if (tc_unrecognized_line (c))
1127             continue;
1128 #endif
1129           input_line_pointer--;
1130           /* Report unknown char as ignored.  */
1131           demand_empty_rest_of_line ();
1132         }
1133
1134 #ifdef md_after_pass_hook
1135       md_after_pass_hook ();
1136 #endif
1137     }
1138
1139  quit:
1140
1141 #ifdef md_cleanup
1142   md_cleanup ();
1143 #endif
1144   /* Close the input file.  */
1145   input_scrub_close ();
1146 #ifdef WARN_COMMENTS
1147   {
1148     if (warn_comment && found_comment)
1149       as_warn_where (found_comment_file, found_comment,
1150                      "first comment found here");
1151   }
1152 #endif
1153 }
1154
1155 /* Convert O_constant expression EXP into the equivalent O_big representation.
1156    Take the sign of the number from X_unsigned rather than X_add_number.  */
1157
1158 static void
1159 convert_to_bignum (expressionS *exp)
1160 {
1161   valueT value;
1162   unsigned int i;
1163
1164   value = exp->X_add_number;
1165   for (i = 0; i < sizeof (exp->X_add_number) / CHARS_PER_LITTLENUM; i++)
1166     {
1167       generic_bignum[i] = value & LITTLENUM_MASK;
1168       value >>= LITTLENUM_NUMBER_OF_BITS;
1169     }
1170   /* Add a sequence of sign bits if the top bit of X_add_number is not
1171      the sign of the original value.  */
1172   if ((exp->X_add_number < 0) != !exp->X_unsigned)
1173     generic_bignum[i++] = exp->X_unsigned ? 0 : LITTLENUM_MASK;
1174   exp->X_op = O_big;
1175   exp->X_add_number = i;
1176 }
1177
1178 /* For most MRI pseudo-ops, the line actually ends at the first
1179    nonquoted space.  This function looks for that point, stuffs a null
1180    in, and sets *STOPCP to the character that used to be there, and
1181    returns the location.
1182
1183    Until I hear otherwise, I am going to assume that this is only true
1184    for the m68k MRI assembler.  */
1185
1186 char *
1187 mri_comment_field (char *stopcp)
1188 {
1189   char *s;
1190 #ifdef TC_M68K
1191   int inquote = 0;
1192
1193   know (flag_m68k_mri);
1194
1195   for (s = input_line_pointer;
1196        ((!is_end_of_line[(unsigned char) *s] && *s != ' ' && *s != '\t')
1197         || inquote);
1198        s++)
1199     {
1200       if (*s == '\'')
1201         inquote = !inquote;
1202     }
1203 #else
1204   for (s = input_line_pointer;
1205        !is_end_of_line[(unsigned char) *s];
1206        s++)
1207     ;
1208 #endif
1209   *stopcp = *s;
1210   *s = '\0';
1211
1212   return s;
1213 }
1214
1215 /* Skip to the end of an MRI comment field.  */
1216
1217 void
1218 mri_comment_end (char *stop, int stopc)
1219 {
1220   know (flag_mri);
1221
1222   input_line_pointer = stop;
1223   *stop = stopc;
1224   while (!is_end_of_line[(unsigned char) *input_line_pointer])
1225     ++input_line_pointer;
1226 }
1227
1228 void
1229 s_abort (int ignore ATTRIBUTE_UNUSED)
1230 {
1231   as_fatal (_(".abort detected.  Abandoning ship."));
1232 }
1233
1234 /* Guts of .align directive.  N is the power of two to which to align.
1235    FILL may be NULL, or it may point to the bytes of the fill pattern.
1236    LEN is the length of whatever FILL points to, if anything.  MAX is
1237    the maximum number of characters to skip when doing the alignment,
1238    or 0 if there is no maximum.  */
1239
1240 static void
1241 do_align (int n, char *fill, int len, int max)
1242 {
1243   if (now_seg == absolute_section)
1244     {
1245       if (fill != NULL)
1246         while (len-- > 0)
1247           if (*fill++ != '\0')
1248             {
1249               as_warn (_("ignoring fill value in absolute section"));
1250               break;
1251             }
1252       fill = NULL;
1253       len = 0;
1254     }
1255
1256 #ifdef md_flush_pending_output
1257   md_flush_pending_output ();
1258 #endif
1259 #ifdef md_do_align
1260   md_do_align (n, fill, len, max, just_record_alignment);
1261 #endif
1262
1263   /* Only make a frag if we HAVE to...  */
1264   if (n != 0 && !need_pass_2)
1265     {
1266       if (fill == NULL)
1267         {
1268           if (subseg_text_p (now_seg))
1269             frag_align_code (n, max);
1270           else
1271             frag_align (n, 0, max);
1272         }
1273       else if (len <= 1)
1274         frag_align (n, *fill, max);
1275       else
1276         frag_align_pattern (n, fill, len, max);
1277     }
1278
1279 #ifdef md_do_align
1280  just_record_alignment: ATTRIBUTE_UNUSED_LABEL
1281 #endif
1282
1283   record_alignment (now_seg, n - OCTETS_PER_BYTE_POWER);
1284 }
1285
1286 /* Handle the .align pseudo-op.  A positive ARG is a default alignment
1287    (in bytes).  A negative ARG is the negative of the length of the
1288    fill pattern.  BYTES_P is non-zero if the alignment value should be
1289    interpreted as the byte boundary, rather than the power of 2.  */
1290
1291 #ifdef BFD_ASSEMBLER
1292 #define ALIGN_LIMIT (stdoutput->arch_info->bits_per_address - 1)
1293 #else
1294 #define ALIGN_LIMIT 15
1295 #endif
1296
1297 static void
1298 s_align (int arg, int bytes_p)
1299 {
1300   unsigned int align_limit = ALIGN_LIMIT;
1301   unsigned int align;
1302   char *stop = NULL;
1303   char stopc;
1304   offsetT fill = 0;
1305   int max;
1306   int fill_p;
1307
1308   if (flag_mri)
1309     stop = mri_comment_field (&stopc);
1310
1311   if (is_end_of_line[(unsigned char) *input_line_pointer])
1312     {
1313       if (arg < 0)
1314         align = 0;
1315       else
1316         align = arg;    /* Default value from pseudo-op table.  */
1317     }
1318   else
1319     {
1320       align = get_absolute_expression ();
1321       SKIP_WHITESPACE ();
1322     }
1323
1324   if (bytes_p)
1325     {
1326       /* Convert to a power of 2.  */
1327       if (align != 0)
1328         {
1329           unsigned int i;
1330
1331           for (i = 0; (align & 1) == 0; align >>= 1, ++i)
1332             ;
1333           if (align != 1)
1334             as_bad (_("alignment not a power of 2"));
1335
1336           align = i;
1337         }
1338     }
1339
1340   if (align > align_limit)
1341     {
1342       align = align_limit;
1343       as_warn (_("alignment too large: %u assumed"), align);
1344     }
1345
1346   if (*input_line_pointer != ',')
1347     {
1348       fill_p = 0;
1349       max = 0;
1350     }
1351   else
1352     {
1353       ++input_line_pointer;
1354       if (*input_line_pointer == ',')
1355         fill_p = 0;
1356       else
1357         {
1358           fill = get_absolute_expression ();
1359           SKIP_WHITESPACE ();
1360           fill_p = 1;
1361         }
1362
1363       if (*input_line_pointer != ',')
1364         max = 0;
1365       else
1366         {
1367           ++input_line_pointer;
1368           max = get_absolute_expression ();
1369         }
1370     }
1371
1372   if (!fill_p)
1373     {
1374       if (arg < 0)
1375         as_warn (_("expected fill pattern missing"));
1376       do_align (align, (char *) NULL, 0, max);
1377     }
1378   else
1379     {
1380       int fill_len;
1381
1382       if (arg >= 0)
1383         fill_len = 1;
1384       else
1385         fill_len = -arg;
1386       if (fill_len <= 1)
1387         {
1388           char fill_char;
1389
1390           fill_char = fill;
1391           do_align (align, &fill_char, fill_len, max);
1392         }
1393       else
1394         {
1395           char ab[16];
1396
1397           if ((size_t) fill_len > sizeof ab)
1398             abort ();
1399           md_number_to_chars (ab, fill, fill_len);
1400           do_align (align, ab, fill_len, max);
1401         }
1402     }
1403
1404   demand_empty_rest_of_line ();
1405
1406   if (flag_mri)
1407     mri_comment_end (stop, stopc);
1408 }
1409
1410 /* Handle the .align pseudo-op on machines where ".align 4" means
1411    align to a 4 byte boundary.  */
1412
1413 void
1414 s_align_bytes (int arg)
1415 {
1416   s_align (arg, 1);
1417 }
1418
1419 /* Handle the .align pseudo-op on machines where ".align 4" means align
1420    to a 2**4 boundary.  */
1421
1422 void
1423 s_align_ptwo (int arg)
1424 {
1425   s_align (arg, 0);
1426 }
1427
1428 /* Switch in and out of alternate macro mode.  */
1429
1430 void
1431 s_altmacro (int on)
1432 {
1433   demand_empty_rest_of_line ();
1434   macro_set_alternate (on);
1435 }
1436
1437 symbolS *
1438 s_comm_internal (int param,
1439                  symbolS *(*comm_parse_extra) (int, symbolS *, addressT))
1440 {
1441   char *name;
1442   char c;
1443   char *p;
1444   offsetT temp, size;
1445   symbolS *symbolP = NULL;
1446   char *stop = NULL;
1447   char stopc;
1448   expressionS exp;
1449
1450   if (flag_mri)
1451     stop = mri_comment_field (&stopc);
1452
1453   name = input_line_pointer;
1454   c = get_symbol_end ();
1455   /* Just after name is now '\0'.  */
1456   p = input_line_pointer;
1457   *p = c;
1458
1459   if (name == p)
1460     {
1461       as_bad (_("expected symbol name"));
1462       discard_rest_of_line ();
1463       goto out;
1464     }
1465
1466   SKIP_WHITESPACE ();
1467
1468   /* Accept an optional comma after the name.  The comma used to be
1469      required, but Irix 5 cc does not generate it for .lcomm.  */
1470   if (*input_line_pointer == ',')
1471     input_line_pointer++;
1472
1473   temp = get_absolute_expr (&exp);
1474   size = temp;
1475 #ifdef BFD_ASSEMBLER
1476   size &= ((offsetT) 2 << (stdoutput->arch_info->bits_per_address - 1)) - 1;
1477 #endif
1478   if (exp.X_op == O_absent)
1479     {
1480       as_bad (_("missing size expression"));
1481       ignore_rest_of_line ();
1482       goto out;
1483     }
1484   else if (temp != size || !exp.X_unsigned)
1485     {
1486       as_warn (_("size (%ld) out of range, ignored"), (long) temp);
1487       ignore_rest_of_line ();
1488       goto out;
1489     }
1490
1491   *p = 0;
1492   symbolP = symbol_find_or_make (name);
1493   if (S_IS_DEFINED (symbolP) && !S_IS_COMMON (symbolP))
1494     {
1495       symbolP = NULL;
1496       as_bad (_("symbol `%s' is already defined"), name);
1497       *p = c;
1498       ignore_rest_of_line ();
1499       goto out;
1500     }
1501
1502   size = S_GET_VALUE (symbolP);
1503   if (size == 0)
1504     size = temp;
1505   else if (size != temp)
1506     as_warn (_("size of \"%s\" is already %ld; not changing to %ld"),
1507              name, (long) size, (long) temp);
1508
1509   *p = c;
1510   if (comm_parse_extra != NULL)
1511     symbolP = (*comm_parse_extra) (param, symbolP, size);
1512   else
1513     {
1514       S_SET_VALUE (symbolP, (valueT) size);
1515       S_SET_EXTERNAL (symbolP);
1516 #ifdef OBJ_VMS
1517       {
1518         extern int flag_one;
1519         if (size == 0 || !flag_one)
1520           S_GET_OTHER (symbolP) = const_flag;
1521       }
1522 #endif
1523     }
1524
1525   demand_empty_rest_of_line ();
1526  out:
1527   if (flag_mri)
1528     mri_comment_end (stop, stopc);
1529   return symbolP;
1530 }
1531
1532 void
1533 s_comm (int ignore)
1534 {
1535   s_comm_internal (ignore, NULL);
1536 }
1537
1538 /* The MRI COMMON pseudo-op.  We handle this by creating a common
1539    symbol with the appropriate name.  We make s_space do the right
1540    thing by increasing the size.  */
1541
1542 void
1543 s_mri_common (int small ATTRIBUTE_UNUSED)
1544 {
1545   char *name;
1546   char c;
1547   char *alc = NULL;
1548   symbolS *sym;
1549   offsetT align;
1550   char *stop = NULL;
1551   char stopc;
1552
1553   if (!flag_mri)
1554     {
1555       s_comm (0);
1556       return;
1557     }
1558
1559   stop = mri_comment_field (&stopc);
1560
1561   SKIP_WHITESPACE ();
1562
1563   name = input_line_pointer;
1564   if (!ISDIGIT (*name))
1565     c = get_symbol_end ();
1566   else
1567     {
1568       do
1569         {
1570           ++input_line_pointer;
1571         }
1572       while (ISDIGIT (*input_line_pointer));
1573
1574       c = *input_line_pointer;
1575       *input_line_pointer = '\0';
1576
1577       if (line_label != NULL)
1578         {
1579           alc = (char *) xmalloc (strlen (S_GET_NAME (line_label))
1580                                   + (input_line_pointer - name)
1581                                   + 1);
1582           sprintf (alc, "%s%s", name, S_GET_NAME (line_label));
1583           name = alc;
1584         }
1585     }
1586
1587   sym = symbol_find_or_make (name);
1588   *input_line_pointer = c;
1589   if (alc != NULL)
1590     free (alc);
1591
1592   if (*input_line_pointer != ',')
1593     align = 0;
1594   else
1595     {
1596       ++input_line_pointer;
1597       align = get_absolute_expression ();
1598     }
1599
1600   if (S_IS_DEFINED (sym) && !S_IS_COMMON (sym))
1601     {
1602       as_bad (_("symbol `%s' is already defined"), S_GET_NAME (sym));
1603       ignore_rest_of_line ();
1604       mri_comment_end (stop, stopc);
1605       return;
1606     }
1607
1608   S_SET_EXTERNAL (sym);
1609   mri_common_symbol = sym;
1610
1611 #ifdef S_SET_ALIGN
1612   if (align != 0)
1613     S_SET_ALIGN (sym, align);
1614 #endif
1615
1616   if (line_label != NULL)
1617     {
1618       expressionS exp;
1619       exp.X_op = O_symbol;
1620       exp.X_add_symbol = sym;
1621       exp.X_add_number = 0;
1622       symbol_set_value_expression (line_label, &exp);
1623       symbol_set_frag (line_label, &zero_address_frag);
1624       S_SET_SEGMENT (line_label, expr_section);
1625     }
1626
1627   /* FIXME: We just ignore the small argument, which distinguishes
1628      COMMON and COMMON.S.  I don't know what we can do about it.  */
1629
1630   /* Ignore the type and hptype.  */
1631   if (*input_line_pointer == ',')
1632     input_line_pointer += 2;
1633   if (*input_line_pointer == ',')
1634     input_line_pointer += 2;
1635
1636   demand_empty_rest_of_line ();
1637
1638   mri_comment_end (stop, stopc);
1639 }
1640
1641 void
1642 s_data (int ignore ATTRIBUTE_UNUSED)
1643 {
1644   segT section;
1645   register int temp;
1646
1647   temp = get_absolute_expression ();
1648   if (flag_readonly_data_in_text)
1649     {
1650       section = text_section;
1651       temp += 1000;
1652     }
1653   else
1654     section = data_section;
1655
1656   subseg_set (section, (subsegT) temp);
1657
1658 #ifdef OBJ_VMS
1659   const_flag = 0;
1660 #endif
1661   demand_empty_rest_of_line ();
1662 }
1663
1664 /* Handle the .appfile pseudo-op.  This is automatically generated by
1665    do_scrub_chars when a preprocessor # line comment is seen with a
1666    file name.  This default definition may be overridden by the object
1667    or CPU specific pseudo-ops.  This function is also the default
1668    definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1669    .file.  */
1670
1671 void
1672 s_app_file_string (char *file, int appfile ATTRIBUTE_UNUSED)
1673 {
1674 #ifdef LISTING
1675   if (listing)
1676     listing_source_file (file);
1677 #endif
1678   register_dependency (file);
1679 #ifdef obj_app_file
1680   obj_app_file (file, appfile);
1681 #endif
1682 }
1683
1684 void
1685 s_app_file (int appfile)
1686 {
1687   register char *s;
1688   int length;
1689
1690   /* Some assemblers tolerate immediately following '"'.  */
1691   if ((s = demand_copy_string (&length)) != 0)
1692     {
1693       /* If this is a fake .appfile, a fake newline was inserted into
1694          the buffer.  Passing -2 to new_logical_line tells it to
1695          account for it.  */
1696       int may_omit
1697         = (!new_logical_line (s, appfile ? -2 : -1) && appfile);
1698
1699       /* In MRI mode, the preprocessor may have inserted an extraneous
1700          backquote.  */
1701       if (flag_m68k_mri
1702           && *input_line_pointer == '\''
1703           && is_end_of_line[(unsigned char) input_line_pointer[1]])
1704         ++input_line_pointer;
1705
1706       demand_empty_rest_of_line ();
1707       if (!may_omit)
1708         s_app_file_string (s, appfile);
1709     }
1710 }
1711
1712 /* Handle the .appline pseudo-op.  This is automatically generated by
1713    do_scrub_chars when a preprocessor # line comment is seen.  This
1714    default definition may be overridden by the object or CPU specific
1715    pseudo-ops.  */
1716
1717 void
1718 s_app_line (int ignore ATTRIBUTE_UNUSED)
1719 {
1720   int l;
1721
1722   /* The given number is that of the next line.  */
1723   l = get_absolute_expression () - 1;
1724   if (l < 0)
1725     /* Some of the back ends can't deal with non-positive line numbers.
1726        Besides, it's silly.  */
1727     as_warn (_("line numbers must be positive; line number %d rejected"),
1728              l + 1);
1729   else
1730     {
1731       new_logical_line ((char *) NULL, l);
1732 #ifdef LISTING
1733       if (listing)
1734         listing_source_line (l);
1735 #endif
1736     }
1737   demand_empty_rest_of_line ();
1738 }
1739
1740 /* Handle the .end pseudo-op.  Actually, the real work is done in
1741    read_a_source_file.  */
1742
1743 void
1744 s_end (int ignore ATTRIBUTE_UNUSED)
1745 {
1746   if (flag_mri)
1747     {
1748       /* The MRI assembler permits the start symbol to follow .end,
1749          but we don't support that.  */
1750       SKIP_WHITESPACE ();
1751       if (!is_end_of_line[(unsigned char) *input_line_pointer]
1752           && *input_line_pointer != '*'
1753           && *input_line_pointer != '!')
1754         as_warn (_("start address not supported"));
1755     }
1756 }
1757
1758 /* Handle the .err pseudo-op.  */
1759
1760 void
1761 s_err (int ignore ATTRIBUTE_UNUSED)
1762 {
1763   as_bad (_(".err encountered"));
1764   demand_empty_rest_of_line ();
1765 }
1766
1767 /* Handle the .error and .warning pseudo-ops.  */
1768
1769 void
1770 s_errwarn (int err)
1771 {
1772   int len;
1773   /* The purpose for the conditional assignment is not to
1774      internationalize the directive itself, but that we need a
1775      self-contained message, one that can be passed like the
1776      demand_copy_C_string return value, and with no assumption on the
1777      location of the name of the directive within the message.  */
1778   char *msg
1779     = (err ? _(".error directive invoked in source file")
1780        : _(".warning directive invoked in source file"));
1781
1782   if (!is_it_end_of_statement ())
1783     {
1784       if (*input_line_pointer != '\"')
1785         {
1786           as_bad (_("%s argument must be a string"),
1787                   err ? ".error" : ".warning");
1788           discard_rest_of_line ();
1789           return;
1790         }
1791
1792       msg = demand_copy_C_string (&len);
1793       if (msg == NULL)
1794         return;
1795     }
1796
1797   if (err)
1798     as_bad ("%s", msg);
1799   else
1800     as_warn ("%s", msg);
1801   demand_empty_rest_of_line ();
1802 }
1803
1804 /* Handle the MRI fail pseudo-op.  */
1805
1806 void
1807 s_fail (int ignore ATTRIBUTE_UNUSED)
1808 {
1809   offsetT temp;
1810   char *stop = NULL;
1811   char stopc;
1812
1813   if (flag_mri)
1814     stop = mri_comment_field (&stopc);
1815
1816   temp = get_absolute_expression ();
1817   if (temp >= 500)
1818     as_warn (_(".fail %ld encountered"), (long) temp);
1819   else
1820     as_bad (_(".fail %ld encountered"), (long) temp);
1821
1822   demand_empty_rest_of_line ();
1823
1824   if (flag_mri)
1825     mri_comment_end (stop, stopc);
1826 }
1827
1828 void
1829 s_fill (int ignore ATTRIBUTE_UNUSED)
1830 {
1831   expressionS rep_exp;
1832   long size = 1;
1833   register long fill = 0;
1834   char *p;
1835
1836 #ifdef md_flush_pending_output
1837   md_flush_pending_output ();
1838 #endif
1839
1840   get_known_segmented_expression (&rep_exp);
1841   if (*input_line_pointer == ',')
1842     {
1843       input_line_pointer++;
1844       size = get_absolute_expression ();
1845       if (*input_line_pointer == ',')
1846         {
1847           input_line_pointer++;
1848           fill = get_absolute_expression ();
1849         }
1850     }
1851
1852   /* This is to be compatible with BSD 4.2 AS, not for any rational reason.  */
1853 #define BSD_FILL_SIZE_CROCK_8 (8)
1854   if (size > BSD_FILL_SIZE_CROCK_8)
1855     {
1856       as_warn (_(".fill size clamped to %d"), BSD_FILL_SIZE_CROCK_8);
1857       size = BSD_FILL_SIZE_CROCK_8;
1858     }
1859   if (size < 0)
1860     {
1861       as_warn (_("size negative; .fill ignored"));
1862       size = 0;
1863     }
1864   else if (rep_exp.X_op == O_constant && rep_exp.X_add_number <= 0)
1865     {
1866       if (rep_exp.X_add_number < 0)
1867         as_warn (_("repeat < 0; .fill ignored"));
1868       size = 0;
1869     }
1870
1871   if (size && !need_pass_2)
1872     {
1873       if (rep_exp.X_op == O_constant)
1874         {
1875           p = frag_var (rs_fill, (int) size, (int) size,
1876                         (relax_substateT) 0, (symbolS *) 0,
1877                         (offsetT) rep_exp.X_add_number,
1878                         (char *) 0);
1879         }
1880       else
1881         {
1882           /* We don't have a constant repeat count, so we can't use
1883              rs_fill.  We can get the same results out of rs_space,
1884              but its argument is in bytes, so we must multiply the
1885              repeat count by size.  */
1886
1887           symbolS *rep_sym;
1888           rep_sym = make_expr_symbol (&rep_exp);
1889           if (size != 1)
1890             {
1891               expressionS size_exp;
1892               size_exp.X_op = O_constant;
1893               size_exp.X_add_number = size;
1894
1895               rep_exp.X_op = O_multiply;
1896               rep_exp.X_add_symbol = rep_sym;
1897               rep_exp.X_op_symbol = make_expr_symbol (&size_exp);
1898               rep_exp.X_add_number = 0;
1899               rep_sym = make_expr_symbol (&rep_exp);
1900             }
1901
1902           p = frag_var (rs_space, (int) size, (int) size,
1903                         (relax_substateT) 0, rep_sym, (offsetT) 0, (char *) 0);
1904         }
1905
1906       memset (p, 0, (unsigned int) size);
1907
1908       /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1909          flavoured AS.  The following bizarre behaviour is to be
1910          compatible with above.  I guess they tried to take up to 8
1911          bytes from a 4-byte expression and they forgot to sign
1912          extend.  */
1913 #define BSD_FILL_SIZE_CROCK_4 (4)
1914       md_number_to_chars (p, (valueT) fill,
1915                           (size > BSD_FILL_SIZE_CROCK_4
1916                            ? BSD_FILL_SIZE_CROCK_4
1917                            : (int) size));
1918       /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1919          but emits no error message because it seems a legal thing to do.
1920          It is a degenerate case of .fill but could be emitted by a
1921          compiler.  */
1922     }
1923   demand_empty_rest_of_line ();
1924 }
1925
1926 void
1927 s_globl (int ignore ATTRIBUTE_UNUSED)
1928 {
1929   char *name;
1930   int c;
1931   symbolS *symbolP;
1932   char *stop = NULL;
1933   char stopc;
1934
1935   if (flag_mri)
1936     stop = mri_comment_field (&stopc);
1937
1938   do
1939     {
1940       name = input_line_pointer;
1941       c = get_symbol_end ();
1942       symbolP = symbol_find_or_make (name);
1943       S_SET_EXTERNAL (symbolP);
1944
1945       *input_line_pointer = c;
1946       SKIP_WHITESPACE ();
1947       c = *input_line_pointer;
1948       if (c == ',')
1949         {
1950           input_line_pointer++;
1951           SKIP_WHITESPACE ();
1952           if (is_end_of_line[(unsigned char) *input_line_pointer])
1953             c = '\n';
1954         }
1955     }
1956   while (c == ',');
1957
1958   demand_empty_rest_of_line ();
1959
1960   if (flag_mri)
1961     mri_comment_end (stop, stopc);
1962 }
1963
1964 /* Handle the MRI IRP and IRPC pseudo-ops.  */
1965
1966 void
1967 s_irp (int irpc)
1968 {
1969   char *file;
1970   unsigned int line;
1971   sb s;
1972   const char *err;
1973   sb out;
1974
1975   as_where (&file, &line);
1976
1977   sb_new (&s);
1978   while (!is_end_of_line[(unsigned char) *input_line_pointer])
1979     sb_add_char (&s, *input_line_pointer++);
1980
1981   sb_new (&out);
1982
1983   err = expand_irp (irpc, 0, &s, &out, get_line_sb);
1984   if (err != NULL)
1985     as_bad_where (file, line, "%s", err);
1986
1987   sb_kill (&s);
1988
1989   input_scrub_include_sb (&out, input_line_pointer, 1);
1990   sb_kill (&out);
1991   buffer_limit = input_scrub_next_buffer (&input_line_pointer);
1992 }
1993
1994 /* Handle the .linkonce pseudo-op.  This tells the assembler to mark
1995    the section to only be linked once.  However, this is not supported
1996    by most object file formats.  This takes an optional argument,
1997    which is what to do about duplicates.  */
1998
1999 void
2000 s_linkonce (int ignore ATTRIBUTE_UNUSED)
2001 {
2002   enum linkonce_type type;
2003
2004   SKIP_WHITESPACE ();
2005
2006   type = LINKONCE_DISCARD;
2007
2008   if (!is_end_of_line[(unsigned char) *input_line_pointer])
2009     {
2010       char *s;
2011       char c;
2012
2013       s = input_line_pointer;
2014       c = get_symbol_end ();
2015       if (strcasecmp (s, "discard") == 0)
2016         type = LINKONCE_DISCARD;
2017       else if (strcasecmp (s, "one_only") == 0)
2018         type = LINKONCE_ONE_ONLY;
2019       else if (strcasecmp (s, "same_size") == 0)
2020         type = LINKONCE_SAME_SIZE;
2021       else if (strcasecmp (s, "same_contents") == 0)
2022         type = LINKONCE_SAME_CONTENTS;
2023       else
2024         as_warn (_("unrecognized .linkonce type `%s'"), s);
2025
2026       *input_line_pointer = c;
2027     }
2028
2029 #ifdef obj_handle_link_once
2030   obj_handle_link_once (type);
2031 #else /* ! defined (obj_handle_link_once) */
2032 #ifdef BFD_ASSEMBLER
2033   {
2034     flagword flags;
2035
2036     if ((bfd_applicable_section_flags (stdoutput) & SEC_LINK_ONCE) == 0)
2037       as_warn (_(".linkonce is not supported for this object file format"));
2038
2039     flags = bfd_get_section_flags (stdoutput, now_seg);
2040     flags |= SEC_LINK_ONCE;
2041     switch (type)
2042       {
2043       default:
2044         abort ();
2045       case LINKONCE_DISCARD:
2046         flags |= SEC_LINK_DUPLICATES_DISCARD;
2047         break;
2048       case LINKONCE_ONE_ONLY:
2049         flags |= SEC_LINK_DUPLICATES_ONE_ONLY;
2050         break;
2051       case LINKONCE_SAME_SIZE:
2052         flags |= SEC_LINK_DUPLICATES_SAME_SIZE;
2053         break;
2054       case LINKONCE_SAME_CONTENTS:
2055         flags |= SEC_LINK_DUPLICATES_SAME_CONTENTS;
2056         break;
2057       }
2058     if (!bfd_set_section_flags (stdoutput, now_seg, flags))
2059       as_bad (_("bfd_set_section_flags: %s"),
2060               bfd_errmsg (bfd_get_error ()));
2061   }
2062 #else /* ! defined (BFD_ASSEMBLER) */
2063   as_warn (_(".linkonce is not supported for this object file format"));
2064 #endif /* ! defined (BFD_ASSEMBLER) */
2065 #endif /* ! defined (obj_handle_link_once) */
2066
2067   demand_empty_rest_of_line ();
2068 }
2069
2070 void
2071 bss_alloc (symbolS *symbolP, addressT size, int align)
2072 {
2073   char *pfrag;
2074   segT current_seg = now_seg;
2075   subsegT current_subseg = now_subseg;
2076   segT bss_seg = bss_section;
2077
2078 #if defined (TC_MIPS) || defined (TC_ALPHA)
2079   if (OUTPUT_FLAVOR == bfd_target_ecoff_flavour
2080       || OUTPUT_FLAVOR == bfd_target_elf_flavour)
2081     {
2082       /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss.  */
2083       if (size <= bfd_get_gp_size (stdoutput))
2084         {
2085           bss_seg = subseg_new (".sbss", 1);
2086           seg_info (bss_seg)->bss = 1;
2087 #ifdef BFD_ASSEMBLER
2088           if (!bfd_set_section_flags (stdoutput, bss_seg, SEC_ALLOC))
2089             as_warn (_("error setting flags for \".sbss\": %s"),
2090                      bfd_errmsg (bfd_get_error ()));
2091 #endif
2092         }
2093     }
2094 #endif
2095   subseg_set (bss_seg, 1);
2096
2097   if (align)
2098     {
2099       record_alignment (bss_seg, align);
2100       frag_align (align, 0, 0);
2101     }
2102
2103   /* Detach from old frag.  */
2104   if (S_GET_SEGMENT (symbolP) == bss_seg)
2105     symbol_get_frag (symbolP)->fr_symbol = NULL;
2106
2107   symbol_set_frag (symbolP, frag_now);
2108   pfrag = frag_var (rs_org, 1, 1, 0, symbolP, size, NULL);
2109   *pfrag = 0;
2110
2111 #ifdef S_SET_SIZE
2112   S_SET_SIZE (symbolP, size);
2113 #endif
2114   S_SET_SEGMENT (symbolP, bss_seg);
2115
2116 #ifdef OBJ_COFF
2117   /* The symbol may already have been created with a preceding
2118      ".globl" directive -- be careful not to step on storage class
2119      in that case.  Otherwise, set it to static.  */
2120   if (S_GET_STORAGE_CLASS (symbolP) != C_EXT)
2121     S_SET_STORAGE_CLASS (symbolP, C_STAT);
2122 #endif /* OBJ_COFF */
2123
2124   subseg_set (current_seg, current_subseg);
2125 }
2126
2127 offsetT
2128 parse_align (int align_bytes)
2129 {
2130   expressionS exp;
2131   addressT align;
2132
2133   SKIP_WHITESPACE ();
2134   if (*input_line_pointer != ',')
2135     {
2136     no_align:
2137       as_bad (_("expected alignment after size"));
2138       ignore_rest_of_line ();
2139       return -1;
2140     }
2141
2142   input_line_pointer++;
2143   SKIP_WHITESPACE ();
2144
2145   align = get_absolute_expr (&exp);
2146   if (exp.X_op == O_absent)
2147     goto no_align;
2148
2149   if (!exp.X_unsigned)
2150     {
2151       as_warn (_("alignment negative; 0 assumed"));
2152       align = 0;
2153     }
2154
2155   if (align_bytes && align != 0)
2156     {
2157       /* convert to a power of 2 alignment */
2158       unsigned int alignp2 = 0;
2159       while ((align & 1) == 0)
2160         align >>= 1, ++alignp2;
2161       if (align != 1)
2162         {
2163           as_bad (_("alignment not a power of 2"));
2164           ignore_rest_of_line ();
2165           return -1;
2166         }
2167       align = alignp2;
2168     }
2169   return align;
2170 }
2171
2172 /* Called from s_comm_internal after symbol name and size have been
2173    parsed.  NEEDS_ALIGN is 0 if it was an ".lcomm" (2 args only),
2174    1 if this was a ".bss" directive which has a 3rd argument
2175    (alignment as a power of 2), or 2 if this was a ".bss" directive
2176    with alignment in bytes.  */
2177
2178 symbolS *
2179 s_lcomm_internal (int needs_align, symbolS *symbolP, addressT size)
2180 {
2181   addressT align = 0;
2182
2183   if (needs_align)
2184     {
2185       align = parse_align (needs_align - 1);
2186       if (align == (addressT) -1)
2187         return NULL;
2188     }
2189   else
2190     /* Assume some objects may require alignment on some systems.  */
2191     TC_IMPLICIT_LCOMM_ALIGNMENT (size, align);
2192
2193   bss_alloc (symbolP, size, align);
2194   return symbolP;
2195 }
2196
2197 void
2198 s_lcomm (int needs_align)
2199 {
2200   s_comm_internal (needs_align, s_lcomm_internal);
2201 }
2202
2203 void
2204 s_lcomm_bytes (int needs_align)
2205 {
2206   s_comm_internal (needs_align * 2, s_lcomm_internal);
2207 }
2208
2209 void
2210 s_lsym (int ignore ATTRIBUTE_UNUSED)
2211 {
2212   register char *name;
2213   register char c;
2214   register char *p;
2215   expressionS exp;
2216   register symbolS *symbolP;
2217
2218   /* We permit ANY defined expression: BSD4.2 demands constants.  */
2219   name = input_line_pointer;
2220   c = get_symbol_end ();
2221   p = input_line_pointer;
2222   *p = c;
2223
2224   if (name == p)
2225     {
2226       as_bad (_("expected symbol name"));
2227       discard_rest_of_line ();
2228       return;
2229     }
2230
2231   SKIP_WHITESPACE ();
2232
2233   if (*input_line_pointer != ',')
2234     {
2235       *p = 0;
2236       as_bad (_("expected comma after \"%s\""), name);
2237       *p = c;
2238       ignore_rest_of_line ();
2239       return;
2240     }
2241
2242   input_line_pointer++;
2243   expression (&exp);
2244
2245   if (exp.X_op != O_constant
2246       && exp.X_op != O_register)
2247     {
2248       as_bad (_("bad expression"));
2249       ignore_rest_of_line ();
2250       return;
2251     }
2252
2253   *p = 0;
2254   symbolP = symbol_find_or_make (name);
2255
2256   /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2257      symbolP->sy_desc == 0) out of this test because coff doesn't have
2258      those fields, and I can't see when they'd ever be tripped.  I
2259      don't think I understand why they were here so I may have
2260      introduced a bug. As recently as 1.37 didn't have this test
2261      anyway.  xoxorich.  */
2262
2263   if (S_GET_SEGMENT (symbolP) == undefined_section
2264       && S_GET_VALUE (symbolP) == 0)
2265     {
2266       /* The name might be an undefined .global symbol; be sure to
2267          keep the "external" bit.  */
2268       S_SET_SEGMENT (symbolP,
2269                      (exp.X_op == O_constant
2270                       ? absolute_section
2271                       : reg_section));
2272       S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
2273     }
2274   else
2275     {
2276       as_bad (_("symbol `%s' is already defined"), name);
2277     }
2278
2279   *p = c;
2280   demand_empty_rest_of_line ();
2281 }
2282
2283 /* Read a line into an sb.  Returns the character that ended the line
2284    or zero if there are no more lines.  */
2285
2286 static int
2287 get_line_sb (sb *line)
2288 {
2289   char quote1, quote2, inquote;
2290   unsigned char c;
2291
2292   if (input_line_pointer[-1] == '\n')
2293     bump_line_counters ();
2294
2295   if (input_line_pointer >= buffer_limit)
2296     {
2297       buffer_limit = input_scrub_next_buffer (&input_line_pointer);
2298       if (buffer_limit == 0)
2299         return 0;
2300     }
2301
2302   /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2303      code needs to be changed.  */
2304   if (!flag_m68k_mri)
2305     quote1 = '"';
2306   else
2307     quote1 = '\0';
2308
2309   quote2 = '\0';
2310   if (flag_m68k_mri)
2311     quote2 = '\'';
2312 #ifdef LEX_IS_STRINGQUOTE
2313   quote2 = '\'';
2314 #endif
2315
2316   inquote = '\0';
2317
2318   while ((c = * input_line_pointer ++) != 0
2319          && (!is_end_of_line[c]
2320              || (inquote != '\0' && c != '\n')))
2321     {
2322       if (inquote == c)
2323         inquote = '\0';
2324       else if (inquote == '\0')
2325         {
2326           if (c == quote1)
2327             inquote = quote1;
2328           else if (c == quote2)
2329             inquote = quote2;
2330         }
2331
2332       sb_add_char (line, c);
2333     }
2334
2335   /* Don't skip multiple end-of-line characters, because that breaks support
2336      for the IA-64 stop bit (;;) which looks like two consecutive end-of-line
2337      characters but isn't.  Instead just skip one end of line character and
2338      return the character skipped so that the caller can re-insert it if
2339      necessary.   */
2340   return c;
2341 }
2342
2343 /* Define a macro.  This is an interface to macro.c.  */
2344
2345 void
2346 s_macro (int ignore ATTRIBUTE_UNUSED)
2347 {
2348   char *file;
2349   unsigned int line;
2350   sb s;
2351   sb label;
2352   const char *err;
2353   const char *name;
2354
2355   as_where (&file, &line);
2356
2357   sb_new (&s);
2358   while (!is_end_of_line[(unsigned char) *input_line_pointer])
2359     sb_add_char (&s, *input_line_pointer++);
2360
2361   sb_new (&label);
2362   if (line_label != NULL)
2363     sb_add_string (&label, S_GET_NAME (line_label));
2364
2365   err = define_macro (0, &s, &label, get_line_sb, file, line, &name);
2366   if (err != NULL)
2367     as_bad_where (file, line, err, name);
2368   else
2369     {
2370       if (line_label != NULL)
2371         {
2372           S_SET_SEGMENT (line_label, absolute_section);
2373           S_SET_VALUE (line_label, 0);
2374           symbol_set_frag (line_label, &zero_address_frag);
2375         }
2376
2377       if (((NO_PSEUDO_DOT || flag_m68k_mri)
2378            && hash_find (po_hash, name) != NULL)
2379           || (!flag_m68k_mri
2380               && *name == '.'
2381               && hash_find (po_hash, name + 1) != NULL))
2382         as_warn_where (file,
2383                  line,
2384                  _("attempt to redefine pseudo-op `%s' ignored"),
2385                  name);
2386     }
2387
2388   sb_kill (&s);
2389 }
2390
2391 /* Handle the .mexit pseudo-op, which immediately exits a macro
2392    expansion.  */
2393
2394 void
2395 s_mexit (int ignore ATTRIBUTE_UNUSED)
2396 {
2397   cond_exit_macro (macro_nest);
2398   buffer_limit = input_scrub_next_buffer (&input_line_pointer);
2399 }
2400
2401 /* Switch in and out of MRI mode.  */
2402
2403 void
2404 s_mri (int ignore ATTRIBUTE_UNUSED)
2405 {
2406   int on, old_flag;
2407
2408   on = get_absolute_expression ();
2409   old_flag = flag_mri;
2410   if (on != 0)
2411     {
2412       flag_mri = 1;
2413 #ifdef TC_M68K
2414       flag_m68k_mri = 1;
2415 #endif
2416       macro_mri_mode (1);
2417     }
2418   else
2419     {
2420       flag_mri = 0;
2421 #ifdef TC_M68K
2422       flag_m68k_mri = 0;
2423 #endif
2424       macro_mri_mode (0);
2425     }
2426
2427   /* Operator precedence changes in m68k MRI mode, so we need to
2428      update the operator rankings.  */
2429   expr_set_precedence ();
2430
2431 #ifdef MRI_MODE_CHANGE
2432   if (on != old_flag)
2433     MRI_MODE_CHANGE (on);
2434 #endif
2435
2436   demand_empty_rest_of_line ();
2437 }
2438
2439 /* Handle changing the location counter.  */
2440
2441 static void
2442 do_org (segT segment, expressionS *exp, int fill)
2443 {
2444   if (segment != now_seg && segment != absolute_section)
2445     as_bad (_("invalid segment \"%s\""), segment_name (segment));
2446
2447   if (now_seg == absolute_section)
2448     {
2449       if (fill != 0)
2450         as_warn (_("ignoring fill value in absolute section"));
2451       if (exp->X_op != O_constant)
2452         {
2453           as_bad (_("only constant offsets supported in absolute section"));
2454           exp->X_add_number = 0;
2455         }
2456       abs_section_offset = exp->X_add_number;
2457     }
2458   else
2459     {
2460       char *p;
2461       symbolS *sym = exp->X_add_symbol;
2462       offsetT off = exp->X_add_number * OCTETS_PER_BYTE;
2463
2464       if (exp->X_op != O_constant && exp->X_op != O_symbol)
2465         {
2466           /* Handle complex expressions.  */
2467           sym = make_expr_symbol (exp);
2468           off = 0;
2469         }
2470
2471       p = frag_var (rs_org, 1, 1, (relax_substateT) 0, sym, off, (char *) 0);
2472       *p = fill;
2473     }
2474 }
2475
2476 void
2477 s_org (int ignore ATTRIBUTE_UNUSED)
2478 {
2479   register segT segment;
2480   expressionS exp;
2481   register long temp_fill;
2482
2483 #ifdef md_flush_pending_output
2484   md_flush_pending_output ();
2485 #endif
2486
2487   /* The m68k MRI assembler has a different meaning for .org.  It
2488      means to create an absolute section at a given address.  We can't
2489      support that--use a linker script instead.  */
2490   if (flag_m68k_mri)
2491     {
2492       as_bad (_("MRI style ORG pseudo-op not supported"));
2493       ignore_rest_of_line ();
2494       return;
2495     }
2496
2497   /* Don't believe the documentation of BSD 4.2 AS.  There is no such
2498      thing as a sub-segment-relative origin.  Any absolute origin is
2499      given a warning, then assumed to be segment-relative.  Any
2500      segmented origin expression ("foo+42") had better be in the right
2501      segment or the .org is ignored.
2502
2503      BSD 4.2 AS warns if you try to .org backwards. We cannot because
2504      we never know sub-segment sizes when we are reading code.  BSD
2505      will crash trying to emit negative numbers of filler bytes in
2506      certain .orgs. We don't crash, but see as-write for that code.
2507
2508      Don't make frag if need_pass_2==1.  */
2509   segment = get_known_segmented_expression (&exp);
2510   if (*input_line_pointer == ',')
2511     {
2512       input_line_pointer++;
2513       temp_fill = get_absolute_expression ();
2514     }
2515   else
2516     temp_fill = 0;
2517
2518   if (!need_pass_2)
2519     do_org (segment, &exp, temp_fill);
2520
2521   demand_empty_rest_of_line ();
2522 }
2523
2524 /* Handle parsing for the MRI SECT/SECTION pseudo-op.  This should be
2525    called by the obj-format routine which handles section changing
2526    when in MRI mode.  It will create a new section, and return it.  It
2527    will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2528    'M' (mixed), or 'R' (romable).  If BFD_ASSEMBLER is defined, the
2529    flags will be set in the section.  */
2530
2531 void
2532 s_mri_sect (char *type ATTRIBUTE_UNUSED)
2533 {
2534 #ifdef TC_M68K
2535
2536   char *name;
2537   char c;
2538   segT seg;
2539
2540   SKIP_WHITESPACE ();
2541
2542   name = input_line_pointer;
2543   if (!ISDIGIT (*name))
2544     c = get_symbol_end ();
2545   else
2546     {
2547       do
2548         {
2549           ++input_line_pointer;
2550         }
2551       while (ISDIGIT (*input_line_pointer));
2552
2553       c = *input_line_pointer;
2554       *input_line_pointer = '\0';
2555     }
2556
2557   name = xstrdup (name);
2558
2559   *input_line_pointer = c;
2560
2561   seg = subseg_new (name, 0);
2562
2563   if (*input_line_pointer == ',')
2564     {
2565       int align;
2566
2567       ++input_line_pointer;
2568       align = get_absolute_expression ();
2569       record_alignment (seg, align);
2570     }
2571
2572   *type = 'C';
2573   if (*input_line_pointer == ',')
2574     {
2575       c = *++input_line_pointer;
2576       c = TOUPPER (c);
2577       if (c == 'C' || c == 'D' || c == 'M' || c == 'R')
2578         *type = c;
2579       else
2580         as_bad (_("unrecognized section type"));
2581       ++input_line_pointer;
2582
2583 #ifdef BFD_ASSEMBLER
2584       {
2585         flagword flags;
2586
2587         flags = SEC_NO_FLAGS;
2588         if (*type == 'C')
2589           flags = SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE;
2590         else if (*type == 'D' || *type == 'M')
2591           flags = SEC_ALLOC | SEC_LOAD | SEC_DATA;
2592         else if (*type == 'R')
2593           flags = SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_READONLY | SEC_ROM;
2594         if (flags != SEC_NO_FLAGS)
2595           {
2596             if (!bfd_set_section_flags (stdoutput, seg, flags))
2597               as_warn (_("error setting flags for \"%s\": %s"),
2598                        bfd_section_name (stdoutput, seg),
2599                        bfd_errmsg (bfd_get_error ()));
2600           }
2601       }
2602 #endif
2603     }
2604
2605   /* Ignore the HP type.  */
2606   if (*input_line_pointer == ',')
2607     input_line_pointer += 2;
2608
2609   demand_empty_rest_of_line ();
2610
2611 #else /* ! TC_M68K */
2612 #ifdef TC_I960
2613
2614   char *name;
2615   char c;
2616   segT seg;
2617
2618   SKIP_WHITESPACE ();
2619
2620   name = input_line_pointer;
2621   c = get_symbol_end ();
2622
2623   name = xstrdup (name);
2624
2625   *input_line_pointer = c;
2626
2627   seg = subseg_new (name, 0);
2628
2629   if (*input_line_pointer != ',')
2630     *type = 'C';
2631   else
2632     {
2633       char *sectype;
2634
2635       ++input_line_pointer;
2636       SKIP_WHITESPACE ();
2637       sectype = input_line_pointer;
2638       c = get_symbol_end ();
2639       if (*sectype == '\0')
2640         *type = 'C';
2641       else if (strcasecmp (sectype, "text") == 0)
2642         *type = 'C';
2643       else if (strcasecmp (sectype, "data") == 0)
2644         *type = 'D';
2645       else if (strcasecmp (sectype, "romdata") == 0)
2646         *type = 'R';
2647       else
2648         as_warn (_("unrecognized section type `%s'"), sectype);
2649       *input_line_pointer = c;
2650     }
2651
2652   if (*input_line_pointer == ',')
2653     {
2654       char *seccmd;
2655
2656       ++input_line_pointer;
2657       SKIP_WHITESPACE ();
2658       seccmd = input_line_pointer;
2659       c = get_symbol_end ();
2660       if (strcasecmp (seccmd, "absolute") == 0)
2661         {
2662           as_bad (_("absolute sections are not supported"));
2663           *input_line_pointer = c;
2664           ignore_rest_of_line ();
2665           return;
2666         }
2667       else if (strcasecmp (seccmd, "align") == 0)
2668         {
2669           int align;
2670
2671           *input_line_pointer = c;
2672           align = get_absolute_expression ();
2673           record_alignment (seg, align);
2674         }
2675       else
2676         {
2677           as_warn (_("unrecognized section command `%s'"), seccmd);
2678           *input_line_pointer = c;
2679         }
2680     }
2681
2682   demand_empty_rest_of_line ();
2683
2684 #else /* ! TC_I960 */
2685   /* The MRI assembler seems to use different forms of .sect for
2686      different targets.  */
2687   as_bad ("MRI mode not supported for this target");
2688   ignore_rest_of_line ();
2689 #endif /* ! TC_I960 */
2690 #endif /* ! TC_M68K */
2691 }
2692
2693 /* Handle the .print pseudo-op.  */
2694
2695 void
2696 s_print (int ignore ATTRIBUTE_UNUSED)
2697 {
2698   char *s;
2699   int len;
2700
2701   s = demand_copy_C_string (&len);
2702   if (s != NULL)
2703     printf ("%s\n", s);
2704   demand_empty_rest_of_line ();
2705 }
2706
2707 /* Handle the .purgem pseudo-op.  */
2708
2709 void
2710 s_purgem (int ignore ATTRIBUTE_UNUSED)
2711 {
2712   if (is_it_end_of_statement ())
2713     {
2714       demand_empty_rest_of_line ();
2715       return;
2716     }
2717
2718   do
2719     {
2720       char *name;
2721       char c;
2722
2723       SKIP_WHITESPACE ();
2724       name = input_line_pointer;
2725       c = get_symbol_end ();
2726       delete_macro (name);
2727       *input_line_pointer = c;
2728       SKIP_WHITESPACE ();
2729     }
2730   while (*input_line_pointer++ == ',');
2731
2732   --input_line_pointer;
2733   demand_empty_rest_of_line ();
2734 }
2735
2736 /* Handle the .endm/.endr pseudo-ops.  */
2737
2738 static void
2739 s_bad_end (int endr)
2740 {
2741   as_warn (_(".end%c encountered without preceeding %s"),
2742            endr ? 'r' : 'm',
2743            endr ? ".rept, .irp, or .irpc" : ".macro");
2744   demand_empty_rest_of_line ();
2745 }
2746
2747 /* Handle the .rept pseudo-op.  */
2748
2749 void
2750 s_rept (int ignore ATTRIBUTE_UNUSED)
2751 {
2752   int count;
2753
2754   count = get_absolute_expression ();
2755
2756   do_repeat (count, "REPT", "ENDR");
2757 }
2758
2759 /* This function provides a generic repeat block implementation.   It allows
2760    different directives to be used as the start/end keys.  */
2761
2762 void
2763 do_repeat (int count, const char *start, const char *end)
2764 {
2765   sb one;
2766   sb many;
2767
2768   sb_new (&one);
2769   if (!buffer_and_nest (start, end, &one, get_line_sb))
2770     {
2771       as_bad (_("%s without %s"), start, end);
2772       return;
2773     }
2774
2775   sb_new (&many);
2776   while (count-- > 0)
2777     sb_add_sb (&many, &one);
2778
2779   sb_kill (&one);
2780
2781   input_scrub_include_sb (&many, input_line_pointer, 1);
2782   sb_kill (&many);
2783   buffer_limit = input_scrub_next_buffer (&input_line_pointer);
2784 }
2785
2786 /* Skip to end of current repeat loop; EXTRA indicates how many additional
2787    input buffers to skip.  Assumes that conditionals preceding the loop end
2788    are properly nested.
2789
2790    This function makes it easier to implement a premature "break" out of the
2791    loop.  The EXTRA arg accounts for other buffers we might have inserted,
2792    such as line substitutions.  */
2793
2794 void
2795 end_repeat (int extra)
2796 {
2797   cond_exit_macro (macro_nest);
2798   while (extra-- >= 0)
2799     buffer_limit = input_scrub_next_buffer (&input_line_pointer);
2800 }
2801
2802 static void
2803 assign_symbol (char *name, int no_reassign)
2804 {
2805   symbolS *symbolP;
2806
2807   if (name[0] == '.' && name[1] == '\0')
2808     {
2809       /* Turn '. = mumble' into a .org mumble.  */
2810       segT segment;
2811       expressionS exp;
2812
2813       segment = get_known_segmented_expression (&exp);
2814
2815       if (!need_pass_2)
2816         do_org (segment, &exp, 0);
2817
2818       return;
2819     }
2820
2821   if ((symbolP = symbol_find (name)) == NULL
2822       && (symbolP = md_undefined_symbol (name)) == NULL)
2823     {
2824       symbolP = symbol_find_or_make (name);
2825 #ifndef NO_LISTING
2826       /* When doing symbol listings, play games with dummy fragments living
2827          outside the normal fragment chain to record the file and line info
2828          for this symbol.  */
2829       if (listing & LISTING_SYMBOLS)
2830         {
2831           extern struct list_info_struct *listing_tail;
2832           fragS *dummy_frag = (fragS *) xcalloc (1, sizeof (fragS));
2833           dummy_frag->line = listing_tail;
2834           dummy_frag->fr_symbol = symbolP;
2835           symbol_set_frag (symbolP, dummy_frag);
2836         }
2837 #endif
2838 #ifdef OBJ_COFF
2839       /* "set" symbols are local unless otherwise specified.  */
2840       SF_SET_LOCAL (symbolP);
2841 #endif
2842     }
2843
2844   /* Permit register names to be redefined.  */
2845   if (no_reassign
2846       && S_IS_DEFINED (symbolP)
2847       && S_GET_SEGMENT (symbolP) != reg_section)
2848     as_bad (_("symbol `%s' is already defined"), name);
2849
2850   pseudo_set (symbolP);
2851 }
2852
2853 /* Handle the .equ, .equiv and .set directives.  If EQUIV is 1, then
2854    this is .equiv, and it is an error if the symbol is already
2855    defined.  */
2856
2857 void
2858 s_set (int equiv)
2859 {
2860   char *name;
2861   char delim;
2862   char *end_name;
2863
2864   /* Especial apologies for the random logic:
2865      this just grew, and could be parsed much more simply!
2866      Dean in haste.  */
2867   name = input_line_pointer;
2868   delim = get_symbol_end ();
2869   end_name = input_line_pointer;
2870   *end_name = delim;
2871
2872   if (name == end_name)
2873     {
2874       as_bad (_("expected symbol name"));
2875       discard_rest_of_line ();
2876       return;
2877     }
2878
2879   SKIP_WHITESPACE ();
2880
2881   if (*input_line_pointer != ',')
2882     {
2883       *end_name = 0;
2884       as_bad (_("expected comma after \"%s\""), name);
2885       *end_name = delim;
2886       ignore_rest_of_line ();
2887       return;
2888     }
2889
2890   input_line_pointer++;
2891   *end_name = 0;
2892
2893   assign_symbol (name, equiv);
2894   *end_name = delim;
2895
2896   demand_empty_rest_of_line ();
2897 }
2898
2899 void
2900 s_space (int mult)
2901 {
2902   expressionS exp;
2903   expressionS val;
2904   char *p = 0;
2905   char *stop = NULL;
2906   char stopc;
2907   int bytes;
2908
2909 #ifdef md_flush_pending_output
2910   md_flush_pending_output ();
2911 #endif
2912
2913   if (flag_mri)
2914     stop = mri_comment_field (&stopc);
2915
2916   /* In m68k MRI mode, we need to align to a word boundary, unless
2917      this is ds.b.  */
2918   if (flag_m68k_mri && mult > 1)
2919     {
2920       if (now_seg == absolute_section)
2921         {
2922           abs_section_offset += abs_section_offset & 1;
2923           if (line_label != NULL)
2924             S_SET_VALUE (line_label, abs_section_offset);
2925         }
2926       else if (mri_common_symbol != NULL)
2927         {
2928           valueT val;
2929
2930           val = S_GET_VALUE (mri_common_symbol);
2931           if ((val & 1) != 0)
2932             {
2933               S_SET_VALUE (mri_common_symbol, val + 1);
2934               if (line_label != NULL)
2935                 {
2936                   expressionS *symexp;
2937
2938                   symexp = symbol_get_value_expression (line_label);
2939                   know (symexp->X_op == O_symbol);
2940                   know (symexp->X_add_symbol == mri_common_symbol);
2941                   symexp->X_add_number += 1;
2942                 }
2943             }
2944         }
2945       else
2946         {
2947           do_align (1, (char *) NULL, 0, 0);
2948           if (line_label != NULL)
2949             {
2950               symbol_set_frag (line_label, frag_now);
2951               S_SET_VALUE (line_label, frag_now_fix ());
2952             }
2953         }
2954     }
2955
2956   bytes = mult;
2957
2958   expression (&exp);
2959
2960   SKIP_WHITESPACE ();
2961   if (*input_line_pointer == ',')
2962     {
2963       ++input_line_pointer;
2964       expression (&val);
2965     }
2966   else
2967     {
2968       val.X_op = O_constant;
2969       val.X_add_number = 0;
2970     }
2971
2972   if (val.X_op != O_constant
2973       || val.X_add_number < - 0x80
2974       || val.X_add_number > 0xff
2975       || (mult != 0 && mult != 1 && val.X_add_number != 0))
2976     {
2977       if (exp.X_op != O_constant)
2978         as_bad (_("unsupported variable size or fill value"));
2979       else
2980         {
2981           offsetT i;
2982
2983           if (mult == 0)
2984             mult = 1;
2985           bytes = mult * exp.X_add_number;
2986           for (i = 0; i < exp.X_add_number; i++)
2987             emit_expr (&val, mult);
2988         }
2989     }
2990   else
2991     {
2992       if (exp.X_op == O_constant)
2993         {
2994           long repeat;
2995
2996           repeat = exp.X_add_number;
2997           if (mult)
2998             repeat *= mult;
2999           bytes = repeat;
3000           if (repeat <= 0)
3001             {
3002               if (!flag_mri)
3003                 as_warn (_(".space repeat count is zero, ignored"));
3004               else if (repeat < 0)
3005                 as_warn (_(".space repeat count is negative, ignored"));
3006               goto getout;
3007             }
3008
3009           /* If we are in the absolute section, just bump the offset.  */
3010           if (now_seg == absolute_section)
3011             {
3012               abs_section_offset += repeat;
3013               goto getout;
3014             }
3015
3016           /* If we are secretly in an MRI common section, then
3017              creating space just increases the size of the common
3018              symbol.  */
3019           if (mri_common_symbol != NULL)
3020             {
3021               S_SET_VALUE (mri_common_symbol,
3022                            S_GET_VALUE (mri_common_symbol) + repeat);
3023               goto getout;
3024             }
3025
3026           if (!need_pass_2)
3027             p = frag_var (rs_fill, 1, 1, (relax_substateT) 0, (symbolS *) 0,
3028                           (offsetT) repeat, (char *) 0);
3029         }
3030       else
3031         {
3032           if (now_seg == absolute_section)
3033             {
3034               as_bad (_("space allocation too complex in absolute section"));
3035               subseg_set (text_section, 0);
3036             }
3037
3038           if (mri_common_symbol != NULL)
3039             {
3040               as_bad (_("space allocation too complex in common section"));
3041               mri_common_symbol = NULL;
3042             }
3043
3044           if (!need_pass_2)
3045             p = frag_var (rs_space, 1, 1, (relax_substateT) 0,
3046                           make_expr_symbol (&exp), (offsetT) 0, (char *) 0);
3047         }
3048
3049       if (p)
3050         *p = val.X_add_number;
3051     }
3052
3053  getout:
3054
3055   /* In MRI mode, after an odd number of bytes, we must align to an
3056      even word boundary, unless the next instruction is a dc.b, ds.b
3057      or dcb.b.  */
3058   if (flag_mri && (bytes & 1) != 0)
3059     mri_pending_align = 1;
3060
3061   demand_empty_rest_of_line ();
3062
3063   if (flag_mri)
3064     mri_comment_end (stop, stopc);
3065 }
3066
3067 /* This is like s_space, but the value is a floating point number with
3068    the given precision.  This is for the MRI dcb.s pseudo-op and
3069    friends.  */
3070
3071 void
3072 s_float_space (int float_type)
3073 {
3074   offsetT count;
3075   int flen;
3076   char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT];
3077   char *stop = NULL;
3078   char stopc;
3079
3080   if (flag_mri)
3081     stop = mri_comment_field (&stopc);
3082
3083   count = get_absolute_expression ();
3084
3085   SKIP_WHITESPACE ();
3086   if (*input_line_pointer != ',')
3087     {
3088       as_bad (_("missing value"));
3089       ignore_rest_of_line ();
3090       if (flag_mri)
3091         mri_comment_end (stop, stopc);
3092       return;
3093     }
3094
3095   ++input_line_pointer;
3096
3097   SKIP_WHITESPACE ();
3098
3099   /* Skip any 0{letter} that may be present.  Don't even check if the
3100    * letter is legal.  */
3101   if (input_line_pointer[0] == '0'
3102       && ISALPHA (input_line_pointer[1]))
3103     input_line_pointer += 2;
3104
3105   /* Accept :xxxx, where the x's are hex digits, for a floating point
3106      with the exact digits specified.  */
3107   if (input_line_pointer[0] == ':')
3108     {
3109       flen = hex_float (float_type, temp);
3110       if (flen < 0)
3111         {
3112           ignore_rest_of_line ();
3113           if (flag_mri)
3114             mri_comment_end (stop, stopc);
3115           return;
3116         }
3117     }
3118   else
3119     {
3120       char *err;
3121
3122       err = md_atof (float_type, temp, &flen);
3123       know (flen <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
3124       know (flen > 0);
3125       if (err)
3126         {
3127           as_bad (_("bad floating literal: %s"), err);
3128           ignore_rest_of_line ();
3129           if (flag_mri)
3130             mri_comment_end (stop, stopc);
3131           return;
3132         }
3133     }
3134
3135   while (--count >= 0)
3136     {
3137       char *p;
3138
3139       p = frag_more (flen);
3140       memcpy (p, temp, (unsigned int) flen);
3141     }
3142
3143   demand_empty_rest_of_line ();
3144
3145   if (flag_mri)
3146     mri_comment_end (stop, stopc);
3147 }
3148
3149 /* Handle the .struct pseudo-op, as found in MIPS assemblers.  */
3150
3151 void
3152 s_struct (int ignore ATTRIBUTE_UNUSED)
3153 {
3154   char *stop = NULL;
3155   char stopc;
3156
3157   if (flag_mri)
3158     stop = mri_comment_field (&stopc);
3159   abs_section_offset = get_absolute_expression ();
3160   subseg_set (absolute_section, 0);
3161   demand_empty_rest_of_line ();
3162   if (flag_mri)
3163     mri_comment_end (stop, stopc);
3164 }
3165
3166 void
3167 s_text (int ignore ATTRIBUTE_UNUSED)
3168 {
3169   register int temp;
3170
3171   temp = get_absolute_expression ();
3172   subseg_set (text_section, (subsegT) temp);
3173   demand_empty_rest_of_line ();
3174 #ifdef OBJ_VMS
3175   const_flag &= ~IN_DEFAULT_SECTION;
3176 #endif
3177 }
3178 \f
3179
3180 /* Verify that we are at the end of a line.  If not, issue an error and
3181    skip to EOL.  */
3182
3183 void
3184 demand_empty_rest_of_line (void)
3185 {
3186   SKIP_WHITESPACE ();
3187   if (is_end_of_line[(unsigned char) *input_line_pointer])
3188     input_line_pointer++;
3189   else
3190     {
3191       if (ISPRINT (*input_line_pointer))
3192         as_bad (_("junk at end of line, first unrecognized character is `%c'"),
3193                  *input_line_pointer);
3194       else
3195         as_bad (_("junk at end of line, first unrecognized character valued 0x%x"),
3196                  *input_line_pointer);
3197       ignore_rest_of_line ();
3198     }
3199   
3200   /* Return pointing just after end-of-line.  */
3201   know (is_end_of_line[(unsigned char) input_line_pointer[-1]]);
3202 }
3203
3204 /* Silently advance to the end of line.  Use this after already having
3205    issued an error about something bad.  */
3206
3207 void
3208 ignore_rest_of_line (void)
3209 {
3210   while (input_line_pointer < buffer_limit
3211          && !is_end_of_line[(unsigned char) *input_line_pointer])
3212     input_line_pointer++;
3213
3214   input_line_pointer++;
3215
3216   /* Return pointing just after end-of-line.  */
3217   know (is_end_of_line[(unsigned char) input_line_pointer[-1]]);
3218 }
3219
3220 void
3221 discard_rest_of_line (void)
3222 {
3223   while (input_line_pointer < buffer_limit
3224          && !is_end_of_line[(unsigned char) *input_line_pointer])
3225     input_line_pointer++;
3226
3227   input_line_pointer++;
3228
3229   /* Return pointing just after end-of-line.  */
3230   know (is_end_of_line[(unsigned char) input_line_pointer[-1]]);
3231 }
3232
3233 /* Sets frag for given symbol to zero_address_frag, except when the
3234    symbol frag is already set to a dummy listing frag.  */
3235
3236 static void
3237 set_zero_frag (symbolS *symbolP)
3238 {
3239   if (symbol_get_frag (symbolP)->fr_type != rs_dummy)
3240     symbol_set_frag (symbolP, &zero_address_frag);
3241 }
3242
3243 /* In:  Pointer to a symbol.
3244         Input_line_pointer->expression.
3245
3246    Out: Input_line_pointer->just after any whitespace after expression.
3247         Tried to set symbol to value of expression.
3248         Will change symbols type, value, and frag;  */
3249
3250 void
3251 pseudo_set (symbolS *symbolP)
3252 {
3253   expressionS exp;
3254   segT seg;
3255 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3256   int ext;
3257 #endif /* OBJ_AOUT or OBJ_BOUT */
3258
3259   know (symbolP);               /* NULL pointer is logic error.  */
3260
3261   (void) expression (&exp);
3262
3263   if (exp.X_op == O_illegal)
3264     as_bad (_("illegal expression"));
3265   else if (exp.X_op == O_absent)
3266     as_bad (_("missing expression"));
3267   else if (exp.X_op == O_big)
3268     {
3269       if (exp.X_add_number > 0)
3270         as_bad (_("bignum invalid"));
3271       else
3272         as_bad (_("floating point number invalid"));
3273     }
3274   else if (exp.X_op == O_subtract
3275            && SEG_NORMAL (S_GET_SEGMENT (exp.X_add_symbol))
3276            && (symbol_get_frag (exp.X_add_symbol)
3277                == symbol_get_frag (exp.X_op_symbol)))
3278     {
3279       exp.X_op = O_constant;
3280       exp.X_add_number = (S_GET_VALUE (exp.X_add_symbol)
3281                           - S_GET_VALUE (exp.X_op_symbol));
3282     }
3283
3284   if (symbol_section_p (symbolP))
3285     {
3286       as_bad ("attempt to set value of section symbol");
3287       return;
3288     }
3289 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3290   ext = S_IS_EXTERNAL (symbolP);
3291 #endif /* OBJ_AOUT or OBJ_BOUT */
3292
3293   switch (exp.X_op)
3294     {
3295     case O_illegal:
3296     case O_absent:
3297     case O_big:
3298       exp.X_add_number = 0;
3299       /* Fall through.  */
3300     case O_constant:
3301       S_SET_SEGMENT (symbolP, absolute_section);
3302       S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
3303       set_zero_frag (symbolP);
3304       break;
3305
3306     case O_register:
3307       S_SET_SEGMENT (symbolP, reg_section);
3308       S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
3309       set_zero_frag (symbolP);
3310       break;
3311
3312     case O_symbol:
3313       seg = S_GET_SEGMENT (exp.X_add_symbol);
3314       /* For x=undef+const, create an expression symbol.
3315          For x=x+const, just update x except when x is an undefined symbol
3316          For x=defined+const, evaluate x.  */
3317       if (symbolP == exp.X_add_symbol
3318           && (seg != undefined_section
3319               || !symbol_constant_p (symbolP)))
3320         {
3321           *symbol_X_add_number (symbolP) += exp.X_add_number;
3322           break;
3323         }
3324       else if (seg != undefined_section)
3325         {
3326           symbolS *s = exp.X_add_symbol;
3327
3328           if (S_IS_COMMON (s))
3329             as_bad (_("`%s' can't be equated to common symbol '%s'"),
3330                     S_GET_NAME (symbolP), S_GET_NAME (s));
3331
3332           S_SET_SEGMENT (symbolP, seg);
3333           S_SET_VALUE (symbolP, exp.X_add_number + S_GET_VALUE (s));
3334           symbol_set_frag (symbolP, symbol_get_frag (s));
3335           copy_symbol_attributes (symbolP, s);
3336           break;
3337         }
3338       /* Fall thru */
3339
3340     default:
3341       /* The value is some complex expression.
3342          Set segment and frag back to that of a newly created symbol.  */
3343       S_SET_SEGMENT (symbolP, undefined_section);
3344       symbol_set_value_expression (symbolP, &exp);
3345       set_zero_frag (symbolP);
3346       break;
3347     }
3348
3349 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3350   if (ext)
3351     S_SET_EXTERNAL (symbolP);
3352   else
3353     S_CLEAR_EXTERNAL (symbolP);
3354 #endif /* OBJ_AOUT or OBJ_BOUT */
3355 }
3356 \f
3357 /*                      cons()
3358
3359    CONStruct more frag of .bytes, or .words etc.
3360    Should need_pass_2 be 1 then emit no frag(s).
3361    This understands EXPRESSIONS.
3362
3363    Bug (?)
3364
3365    This has a split personality. We use expression() to read the
3366    value. We can detect if the value won't fit in a byte or word.
3367    But we can't detect if expression() discarded significant digits
3368    in the case of a long. Not worth the crocks required to fix it.  */
3369
3370 /* Select a parser for cons expressions.  */
3371
3372 /* Some targets need to parse the expression in various fancy ways.
3373    You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3374    (for example, the HPPA does this).  Otherwise, you can define
3375    BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3376    REPEAT_CONS_EXPRESSIONS to permit repeat counts.  If none of these
3377    are defined, which is the normal case, then only simple expressions
3378    are permitted.  */
3379
3380 #ifdef TC_M68K
3381 static void
3382 parse_mri_cons (expressionS *exp, unsigned int nbytes);
3383 #endif
3384
3385 #ifndef TC_PARSE_CONS_EXPRESSION
3386 #ifdef BITFIELD_CONS_EXPRESSIONS
3387 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3388 static void
3389 parse_bitfield_cons (expressionS *exp, unsigned int nbytes);
3390 #endif
3391 #ifdef REPEAT_CONS_EXPRESSIONS
3392 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3393 static void
3394 parse_repeat_cons (expressionS *exp, unsigned int nbytes);
3395 #endif
3396
3397 /* If we haven't gotten one yet, just call expression.  */
3398 #ifndef TC_PARSE_CONS_EXPRESSION
3399 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3400 #endif
3401 #endif
3402
3403 void
3404 do_parse_cons_expression (expressionS *exp,
3405                           int nbytes ATTRIBUTE_UNUSED)
3406 {
3407   TC_PARSE_CONS_EXPRESSION (exp, nbytes);
3408 }
3409
3410
3411 /* Worker to do .byte etc statements.
3412    Clobbers input_line_pointer and checks end-of-line.  */
3413
3414 static void
3415 cons_worker (register int nbytes,       /* 1=.byte, 2=.word, 4=.long.  */
3416              int rva)
3417 {
3418   int c;
3419   expressionS exp;
3420   char *stop = NULL;
3421   char stopc;
3422
3423 #ifdef md_flush_pending_output
3424   md_flush_pending_output ();
3425 #endif
3426
3427   if (flag_mri)
3428     stop = mri_comment_field (&stopc);
3429
3430   if (is_it_end_of_statement ())
3431     {
3432       demand_empty_rest_of_line ();
3433       if (flag_mri)
3434         mri_comment_end (stop, stopc);
3435       return;
3436     }
3437
3438 #ifdef TC_ADDRESS_BYTES
3439   if (nbytes == 0)
3440     nbytes = TC_ADDRESS_BYTES ();
3441 #endif
3442
3443 #ifdef md_cons_align
3444   md_cons_align (nbytes);
3445 #endif
3446
3447   c = 0;
3448   do
3449     {
3450 #ifdef TC_M68K
3451       if (flag_m68k_mri)
3452         parse_mri_cons (&exp, (unsigned int) nbytes);
3453       else
3454 #endif
3455         TC_PARSE_CONS_EXPRESSION (&exp, (unsigned int) nbytes);
3456
3457       if (rva)
3458         {
3459           if (exp.X_op == O_symbol)
3460             exp.X_op = O_symbol_rva;
3461           else
3462             as_fatal (_("rva without symbol"));
3463         }
3464       emit_expr (&exp, (unsigned int) nbytes);
3465       ++c;
3466     }
3467   while (*input_line_pointer++ == ',');
3468
3469   /* In MRI mode, after an odd number of bytes, we must align to an
3470      even word boundary, unless the next instruction is a dc.b, ds.b
3471      or dcb.b.  */
3472   if (flag_mri && nbytes == 1 && (c & 1) != 0)
3473     mri_pending_align = 1;
3474
3475   input_line_pointer--;         /* Put terminator back into stream.  */
3476
3477   demand_empty_rest_of_line ();
3478
3479   if (flag_mri)
3480     mri_comment_end (stop, stopc);
3481 }
3482
3483 void
3484 cons (int size)
3485 {
3486   cons_worker (size, 0);
3487 }
3488
3489 void
3490 s_rva (int size)
3491 {
3492   cons_worker (size, 1);
3493 }
3494
3495 /* Put the contents of expression EXP into the object file using
3496    NBYTES bytes.  If need_pass_2 is 1, this does nothing.  */
3497
3498 void
3499 emit_expr (expressionS *exp, unsigned int nbytes)
3500 {
3501   operatorT op;
3502   register char *p;
3503   valueT extra_digit = 0;
3504
3505   /* Don't do anything if we are going to make another pass.  */
3506   if (need_pass_2)
3507     return;
3508
3509   dot_value = frag_now_fix ();
3510
3511 #ifndef NO_LISTING
3512 #ifdef OBJ_ELF
3513   /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3514      appear as a four byte positive constant in the .line section,
3515      followed by a 2 byte 0xffff.  Look for that case here.  */
3516   {
3517     static int dwarf_line = -1;
3518
3519     if (strcmp (segment_name (now_seg), ".line") != 0)
3520       dwarf_line = -1;
3521     else if (dwarf_line >= 0
3522              && nbytes == 2
3523              && exp->X_op == O_constant
3524              && (exp->X_add_number == -1 || exp->X_add_number == 0xffff))
3525       listing_source_line ((unsigned int) dwarf_line);
3526     else if (nbytes == 4
3527              && exp->X_op == O_constant
3528              && exp->X_add_number >= 0)
3529       dwarf_line = exp->X_add_number;
3530     else
3531       dwarf_line = -1;
3532   }
3533
3534   /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3535      appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3536      AT_sibling (0x12) followed by a four byte address of the sibling
3537      followed by a 2 byte AT_name (0x38) followed by the name of the
3538      file.  We look for that case here.  */
3539   {
3540     static int dwarf_file = 0;
3541
3542     if (strcmp (segment_name (now_seg), ".debug") != 0)
3543       dwarf_file = 0;
3544     else if (dwarf_file == 0
3545              && nbytes == 2
3546              && exp->X_op == O_constant
3547              && exp->X_add_number == 0x11)
3548       dwarf_file = 1;
3549     else if (dwarf_file == 1
3550              && nbytes == 2
3551              && exp->X_op == O_constant
3552              && exp->X_add_number == 0x12)
3553       dwarf_file = 2;
3554     else if (dwarf_file == 2
3555              && nbytes == 4)
3556       dwarf_file = 3;
3557     else if (dwarf_file == 3
3558              && nbytes == 2
3559              && exp->X_op == O_constant
3560              && exp->X_add_number == 0x38)
3561       dwarf_file = 4;
3562     else
3563       dwarf_file = 0;
3564
3565     /* The variable dwarf_file_string tells stringer that the string
3566        may be the name of the source file.  */
3567     if (dwarf_file == 4)
3568       dwarf_file_string = 1;
3569     else
3570       dwarf_file_string = 0;
3571   }
3572 #endif
3573 #endif
3574
3575   if (check_eh_frame (exp, &nbytes))
3576     return;
3577
3578   op = exp->X_op;
3579
3580   /* Allow `.word 0' in the absolute section.  */
3581   if (now_seg == absolute_section)
3582     {
3583       if (op != O_constant || exp->X_add_number != 0)
3584         as_bad (_("attempt to store value in absolute section"));
3585       abs_section_offset += nbytes;
3586       return;
3587     }
3588
3589   /* Handle a negative bignum.  */
3590   if (op == O_uminus
3591       && exp->X_add_number == 0
3592       && symbol_get_value_expression (exp->X_add_symbol)->X_op == O_big
3593       && symbol_get_value_expression (exp->X_add_symbol)->X_add_number > 0)
3594     {
3595       int i;
3596       unsigned long carry;
3597
3598       exp = symbol_get_value_expression (exp->X_add_symbol);
3599
3600       /* Negate the bignum: one's complement each digit and add 1.  */
3601       carry = 1;
3602       for (i = 0; i < exp->X_add_number; i++)
3603         {
3604           unsigned long next;
3605
3606           next = (((~(generic_bignum[i] & LITTLENUM_MASK))
3607                    & LITTLENUM_MASK)
3608                   + carry);
3609           generic_bignum[i] = next & LITTLENUM_MASK;
3610           carry = next >> LITTLENUM_NUMBER_OF_BITS;
3611         }
3612
3613       /* We can ignore any carry out, because it will be handled by
3614          extra_digit if it is needed.  */
3615
3616       extra_digit = (valueT) -1;
3617       op = O_big;
3618     }
3619
3620   if (op == O_absent || op == O_illegal)
3621     {
3622       as_warn (_("zero assumed for missing expression"));
3623       exp->X_add_number = 0;
3624       op = O_constant;
3625     }
3626   else if (op == O_big && exp->X_add_number <= 0)
3627     {
3628       as_bad (_("floating point number invalid"));
3629       exp->X_add_number = 0;
3630       op = O_constant;
3631     }
3632   else if (op == O_register)
3633     {
3634       as_warn (_("register value used as expression"));
3635       op = O_constant;
3636     }
3637
3638   p = frag_more ((int) nbytes);
3639
3640 #ifndef WORKING_DOT_WORD
3641   /* If we have the difference of two symbols in a word, save it on
3642      the broken_words list.  See the code in write.c.  */
3643   if (op == O_subtract && nbytes == 2)
3644     {
3645       struct broken_word *x;
3646
3647       x = (struct broken_word *) xmalloc (sizeof (struct broken_word));
3648       x->next_broken_word = broken_words;
3649       broken_words = x;
3650       x->seg = now_seg;
3651       x->subseg = now_subseg;
3652       x->frag = frag_now;
3653       x->word_goes_here = p;
3654       x->dispfrag = 0;
3655       x->add = exp->X_add_symbol;
3656       x->sub = exp->X_op_symbol;
3657       x->addnum = exp->X_add_number;
3658       x->added = 0;
3659       x->use_jump = 0;
3660       new_broken_words++;
3661       return;
3662     }
3663 #endif
3664
3665   /* If we have an integer, but the number of bytes is too large to
3666      pass to md_number_to_chars, handle it as a bignum.  */
3667   if (op == O_constant && nbytes > sizeof (valueT))
3668     {
3669       extra_digit = exp->X_unsigned ? 0 : -1;
3670       convert_to_bignum (exp);
3671       op = O_big;
3672     }
3673
3674   if (op == O_constant)
3675     {
3676       register valueT get;
3677       register valueT use;
3678       register valueT mask;
3679       valueT hibit;
3680       register valueT unmask;
3681
3682       /* JF << of >= number of bits in the object is undefined.  In
3683          particular SPARC (Sun 4) has problems.  */
3684       if (nbytes >= sizeof (valueT))
3685         {
3686           mask = 0;
3687           if (nbytes > sizeof (valueT))
3688             hibit = 0;
3689           else
3690             hibit = (valueT) 1 << (nbytes * BITS_PER_CHAR - 1);
3691         }
3692       else
3693         {
3694           /* Don't store these bits.  */
3695           mask = ~(valueT) 0 << (BITS_PER_CHAR * nbytes);
3696           hibit = (valueT) 1 << (nbytes * BITS_PER_CHAR - 1);
3697         }
3698
3699       unmask = ~mask;           /* Do store these bits.  */
3700
3701 #ifdef NEVER
3702       "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3703       mask = ~(unmask >> 1);    /* Includes sign bit now.  */
3704 #endif
3705
3706       get = exp->X_add_number;
3707       use = get & unmask;
3708       if ((get & mask) != 0
3709           && ((get & mask) != mask
3710               || (get & hibit) == 0))
3711         {               /* Leading bits contain both 0s & 1s.  */
3712           as_warn (_("value 0x%lx truncated to 0x%lx"),
3713                    (unsigned long) get, (unsigned long) use);
3714         }
3715       /* Put bytes in right order.  */
3716       md_number_to_chars (p, use, (int) nbytes);
3717     }
3718   else if (op == O_big)
3719     {
3720       unsigned int size;
3721       LITTLENUM_TYPE *nums;
3722
3723       know (nbytes % CHARS_PER_LITTLENUM == 0);
3724
3725       size = exp->X_add_number * CHARS_PER_LITTLENUM;
3726       if (nbytes < size)
3727         {
3728           as_warn (_("bignum truncated to %d bytes"), nbytes);
3729           size = nbytes;
3730         }
3731
3732       if (target_big_endian)
3733         {
3734           while (nbytes > size)
3735             {
3736               md_number_to_chars (p, extra_digit, CHARS_PER_LITTLENUM);
3737               nbytes -= CHARS_PER_LITTLENUM;
3738               p += CHARS_PER_LITTLENUM;
3739             }
3740
3741           nums = generic_bignum + size / CHARS_PER_LITTLENUM;
3742           while (size >= CHARS_PER_LITTLENUM)
3743             {
3744               --nums;
3745               md_number_to_chars (p, (valueT) *nums, CHARS_PER_LITTLENUM);
3746               size -= CHARS_PER_LITTLENUM;
3747               p += CHARS_PER_LITTLENUM;
3748             }
3749         }
3750       else
3751         {
3752           nums = generic_bignum;
3753           while (size >= CHARS_PER_LITTLENUM)
3754             {
3755               md_number_to_chars (p, (valueT) *nums, CHARS_PER_LITTLENUM);
3756               ++nums;
3757               size -= CHARS_PER_LITTLENUM;
3758               p += CHARS_PER_LITTLENUM;
3759               nbytes -= CHARS_PER_LITTLENUM;
3760             }
3761
3762           while (nbytes >= CHARS_PER_LITTLENUM)
3763             {
3764               md_number_to_chars (p, extra_digit, CHARS_PER_LITTLENUM);
3765               nbytes -= CHARS_PER_LITTLENUM;
3766               p += CHARS_PER_LITTLENUM;
3767             }
3768         }
3769     }
3770   else
3771     {
3772       memset (p, 0, nbytes);
3773
3774       /* Now we need to generate a fixS to record the symbol value.
3775          This is easy for BFD.  For other targets it can be more
3776          complex.  For very complex cases (currently, the HPPA and
3777          NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3778          want.  For simpler cases, you can define TC_CONS_RELOC to be
3779          the name of the reloc code that should be stored in the fixS.
3780          If neither is defined, the code uses NO_RELOC if it is
3781          defined, and otherwise uses 0.  */
3782
3783 #ifdef BFD_ASSEMBLER
3784 #ifdef TC_CONS_FIX_NEW
3785       TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp);
3786 #else
3787       {
3788         bfd_reloc_code_real_type r;
3789
3790         switch (nbytes)
3791           {
3792           case 1:
3793             r = BFD_RELOC_8;
3794             break;
3795           case 2:
3796             r = BFD_RELOC_16;
3797             break;
3798           case 4:
3799             r = BFD_RELOC_32;
3800             break;
3801           case 8:
3802             r = BFD_RELOC_64;
3803             break;
3804           default:
3805             as_bad (_("unsupported BFD relocation size %u"), nbytes);
3806             r = BFD_RELOC_32;
3807             break;
3808           }
3809         fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp,
3810                      0, r);
3811       }
3812 #endif
3813 #else
3814 #ifdef TC_CONS_FIX_NEW
3815       TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp);
3816 #else
3817       /* Figure out which reloc number to use.  Use TC_CONS_RELOC if
3818          it is defined, otherwise use NO_RELOC if it is defined,
3819          otherwise use 0.  */
3820 #ifndef TC_CONS_RELOC
3821 #ifdef NO_RELOC
3822 #define TC_CONS_RELOC NO_RELOC
3823 #else
3824 #define TC_CONS_RELOC 0
3825 #endif
3826 #endif
3827       fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp, 0,
3828                    TC_CONS_RELOC);
3829 #endif /* TC_CONS_FIX_NEW */
3830 #endif /* BFD_ASSEMBLER */
3831     }
3832 }
3833 \f
3834 #ifdef BITFIELD_CONS_EXPRESSIONS
3835
3836 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3837    w:x,y:z, where w and y are bitwidths and x and y are values.  They
3838    then pack them all together. We do a little better in that we allow
3839    them in words, longs, etc. and we'll pack them in target byte order
3840    for you.
3841
3842    The rules are: pack least significant bit first, if a field doesn't
3843    entirely fit, put it in the next unit.  Overflowing the bitfield is
3844    explicitly *not* even a warning.  The bitwidth should be considered
3845    a "mask".
3846
3847    To use this function the tc-XXX.h file should define
3848    BITFIELD_CONS_EXPRESSIONS.  */
3849
3850 static void
3851 parse_bitfield_cons (exp, nbytes)
3852      expressionS *exp;
3853      unsigned int nbytes;
3854 {
3855   unsigned int bits_available = BITS_PER_CHAR * nbytes;
3856   char *hold = input_line_pointer;
3857
3858   (void) expression (exp);
3859
3860   if (*input_line_pointer == ':')
3861     {
3862       /* Bitfields.  */
3863       long value = 0;
3864
3865       for (;;)
3866         {
3867           unsigned long width;
3868
3869           if (*input_line_pointer != ':')
3870             {
3871               input_line_pointer = hold;
3872               break;
3873             }                   /* Next piece is not a bitfield.  */
3874
3875           /* In the general case, we can't allow
3876              full expressions with symbol
3877              differences and such.  The relocation
3878              entries for symbols not defined in this
3879              assembly would require arbitrary field
3880              widths, positions, and masks which most
3881              of our current object formats don't
3882              support.
3883
3884              In the specific case where a symbol
3885              *is* defined in this assembly, we
3886              *could* build fixups and track it, but
3887              this could lead to confusion for the
3888              backends.  I'm lazy. I'll take any
3889              SEG_ABSOLUTE. I think that means that
3890              you can use a previous .set or
3891              .equ type symbol.  xoxorich.  */
3892
3893           if (exp->X_op == O_absent)
3894             {
3895               as_warn (_("using a bit field width of zero"));
3896               exp->X_add_number = 0;
3897               exp->X_op = O_constant;
3898             }                   /* Implied zero width bitfield.  */
3899
3900           if (exp->X_op != O_constant)
3901             {
3902               *input_line_pointer = '\0';
3903               as_bad (_("field width \"%s\" too complex for a bitfield"), hold);
3904               *input_line_pointer = ':';
3905               demand_empty_rest_of_line ();
3906               return;
3907             }                   /* Too complex.  */
3908
3909           if ((width = exp->X_add_number) > (BITS_PER_CHAR * nbytes))
3910             {
3911               as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3912                        width, nbytes, (BITS_PER_CHAR * nbytes));
3913               width = BITS_PER_CHAR * nbytes;
3914             }                   /* Too big.  */
3915
3916           if (width > bits_available)
3917             {
3918               /* FIXME-SOMEDAY: backing up and reparsing is wasteful.  */
3919               input_line_pointer = hold;
3920               exp->X_add_number = value;
3921               break;
3922             }                   /* Won't fit.  */
3923
3924           /* Skip ':'.  */
3925           hold = ++input_line_pointer;
3926
3927           (void) expression (exp);
3928           if (exp->X_op != O_constant)
3929             {
3930               char cache = *input_line_pointer;
3931
3932               *input_line_pointer = '\0';
3933               as_bad (_("field value \"%s\" too complex for a bitfield"), hold);
3934               *input_line_pointer = cache;
3935               demand_empty_rest_of_line ();
3936               return;
3937             }                   /* Too complex.  */
3938
3939           value |= ((~(-1 << width) & exp->X_add_number)
3940                     << ((BITS_PER_CHAR * nbytes) - bits_available));
3941
3942           if ((bits_available -= width) == 0
3943               || is_it_end_of_statement ()
3944               || *input_line_pointer != ',')
3945             {
3946               break;
3947             }                   /* All the bitfields we're gonna get.  */
3948
3949           hold = ++input_line_pointer;
3950           (void) expression (exp);
3951         }
3952
3953       exp->X_add_number = value;
3954       exp->X_op = O_constant;
3955       exp->X_unsigned = 1;
3956     }
3957 }
3958
3959 #endif /* BITFIELD_CONS_EXPRESSIONS */
3960 \f
3961 /* Handle an MRI style string expression.  */
3962
3963 #ifdef TC_M68K
3964 static void
3965 parse_mri_cons (exp, nbytes)
3966      expressionS *exp;
3967      unsigned int nbytes;
3968 {
3969   if (*input_line_pointer != '\''
3970       && (input_line_pointer[1] != '\''
3971           || (*input_line_pointer != 'A'
3972               && *input_line_pointer != 'E')))
3973     TC_PARSE_CONS_EXPRESSION (exp, nbytes);
3974   else
3975     {
3976       unsigned int scan;
3977       unsigned int result = 0;
3978
3979       /* An MRI style string.  Cut into as many bytes as will fit into
3980          a nbyte chunk, left justify if necessary, and separate with
3981          commas so we can try again later.  */
3982       if (*input_line_pointer == 'A')
3983         ++input_line_pointer;
3984       else if (*input_line_pointer == 'E')
3985         {
3986           as_bad (_("EBCDIC constants are not supported"));
3987           ++input_line_pointer;
3988         }
3989
3990       input_line_pointer++;
3991       for (scan = 0; scan < nbytes; scan++)
3992         {
3993           if (*input_line_pointer == '\'')
3994             {
3995               if (input_line_pointer[1] == '\'')
3996                 {
3997                   input_line_pointer++;
3998                 }
3999               else
4000                 break;
4001             }
4002           result = (result << 8) | (*input_line_pointer++);
4003         }
4004
4005       /* Left justify.  */
4006       while (scan < nbytes)
4007         {
4008           result <<= 8;
4009           scan++;
4010         }
4011
4012       /* Create correct expression.  */
4013       exp->X_op = O_constant;
4014       exp->X_add_number = result;
4015
4016       /* Fake it so that we can read the next char too.  */
4017       if (input_line_pointer[0] != '\'' ||
4018           (input_line_pointer[0] == '\'' && input_line_pointer[1] == '\''))
4019         {
4020           input_line_pointer -= 2;
4021           input_line_pointer[0] = ',';
4022           input_line_pointer[1] = '\'';
4023         }
4024       else
4025         input_line_pointer++;
4026     }
4027 }
4028 #endif /* TC_M68K */
4029 \f
4030 #ifdef REPEAT_CONS_EXPRESSIONS
4031
4032 /* Parse a repeat expression for cons.  This is used by the MIPS
4033    assembler.  The format is NUMBER:COUNT; NUMBER appears in the
4034    object file COUNT times.
4035
4036    To use this for a target, define REPEAT_CONS_EXPRESSIONS.  */
4037
4038 static void
4039 parse_repeat_cons (exp, nbytes)
4040      expressionS *exp;
4041      unsigned int nbytes;
4042 {
4043   expressionS count;
4044   register int i;
4045
4046   expression (exp);
4047
4048   if (*input_line_pointer != ':')
4049     {
4050       /* No repeat count.  */
4051       return;
4052     }
4053
4054   ++input_line_pointer;
4055   expression (&count);
4056   if (count.X_op != O_constant
4057       || count.X_add_number <= 0)
4058     {
4059       as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4060       return;
4061     }
4062
4063   /* The cons function is going to output this expression once.  So we
4064      output it count - 1 times.  */
4065   for (i = count.X_add_number - 1; i > 0; i--)
4066     emit_expr (exp, nbytes);
4067 }
4068
4069 #endif /* REPEAT_CONS_EXPRESSIONS */
4070 \f
4071 /* Parse a floating point number represented as a hex constant.  This
4072    permits users to specify the exact bits they want in the floating
4073    point number.  */
4074
4075 static int
4076 hex_float (int float_type, char *bytes)
4077 {
4078   int length;
4079   int i;
4080
4081   switch (float_type)
4082     {
4083     case 'f':
4084     case 'F':
4085     case 's':
4086     case 'S':
4087       length = 4;
4088       break;
4089
4090     case 'd':
4091     case 'D':
4092     case 'r':
4093     case 'R':
4094       length = 8;
4095       break;
4096
4097     case 'x':
4098     case 'X':
4099       length = 12;
4100       break;
4101
4102     case 'p':
4103     case 'P':
4104       length = 12;
4105       break;
4106
4107     default:
4108       as_bad (_("unknown floating type type '%c'"), float_type);
4109       return -1;
4110     }
4111
4112   /* It would be nice if we could go through expression to parse the
4113      hex constant, but if we get a bignum it's a pain to sort it into
4114      the buffer correctly.  */
4115   i = 0;
4116   while (hex_p (*input_line_pointer) || *input_line_pointer == '_')
4117     {
4118       int d;
4119
4120       /* The MRI assembler accepts arbitrary underscores strewn about
4121          through the hex constant, so we ignore them as well.  */
4122       if (*input_line_pointer == '_')
4123         {
4124           ++input_line_pointer;
4125           continue;
4126         }
4127
4128       if (i >= length)
4129         {
4130           as_warn (_("floating point constant too large"));
4131           return -1;
4132         }
4133       d = hex_value (*input_line_pointer) << 4;
4134       ++input_line_pointer;
4135       while (*input_line_pointer == '_')
4136         ++input_line_pointer;
4137       if (hex_p (*input_line_pointer))
4138         {
4139           d += hex_value (*input_line_pointer);
4140           ++input_line_pointer;
4141         }
4142       if (target_big_endian)
4143         bytes[i] = d;
4144       else
4145         bytes[length - i - 1] = d;
4146       ++i;
4147     }
4148
4149   if (i < length)
4150     {
4151       if (target_big_endian)
4152         memset (bytes + i, 0, length - i);
4153       else
4154         memset (bytes, 0, length - i);
4155     }
4156
4157   return length;
4158 }
4159
4160 /*                      float_cons()
4161
4162    CONStruct some more frag chars of .floats .ffloats etc.
4163    Makes 0 or more new frags.
4164    If need_pass_2 == 1, no frags are emitted.
4165    This understands only floating literals, not expressions. Sorry.
4166
4167    A floating constant is defined by atof_generic(), except it is preceded
4168    by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4169    reading, I decided to be incompatible. This always tries to give you
4170    rounded bits to the precision of the pseudo-op. Former AS did premature
4171    truncation, restored noisy bits instead of trailing 0s AND gave you
4172    a choice of 2 flavours of noise according to which of 2 floating-point
4173    scanners you directed AS to use.
4174
4175    In:  input_line_pointer->whitespace before, or '0' of flonum.  */
4176
4177 void
4178 float_cons (/* Clobbers input_line-pointer, checks end-of-line.  */
4179             register int float_type     /* 'f':.ffloat ... 'F':.float ...  */)
4180 {
4181   register char *p;
4182   int length;                   /* Number of chars in an object.  */
4183   register char *err;           /* Error from scanning floating literal.  */
4184   char temp[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT];
4185
4186   if (is_it_end_of_statement ())
4187     {
4188       demand_empty_rest_of_line ();
4189       return;
4190     }
4191
4192 #ifdef md_flush_pending_output
4193   md_flush_pending_output ();
4194 #endif
4195
4196   do
4197     {
4198       /* input_line_pointer->1st char of a flonum (we hope!).  */
4199       SKIP_WHITESPACE ();
4200
4201       /* Skip any 0{letter} that may be present. Don't even check if the
4202          letter is legal. Someone may invent a "z" format and this routine
4203          has no use for such information. Lusers beware: you get
4204          diagnostics if your input is ill-conditioned.  */
4205       if (input_line_pointer[0] == '0'
4206           && ISALPHA (input_line_pointer[1]))
4207         input_line_pointer += 2;
4208
4209       /* Accept :xxxx, where the x's are hex digits, for a floating
4210          point with the exact digits specified.  */
4211       if (input_line_pointer[0] == ':')
4212         {
4213           ++input_line_pointer;
4214           length = hex_float (float_type, temp);
4215           if (length < 0)
4216             {
4217               ignore_rest_of_line ();
4218               return;
4219             }
4220         }
4221       else
4222         {
4223           err = md_atof (float_type, temp, &length);
4224           know (length <= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT);
4225           know (length > 0);
4226           if (err)
4227             {
4228               as_bad (_("bad floating literal: %s"), err);
4229               ignore_rest_of_line ();
4230               return;
4231             }
4232         }
4233
4234       if (!need_pass_2)
4235         {
4236           int count;
4237
4238           count = 1;
4239
4240 #ifdef REPEAT_CONS_EXPRESSIONS
4241           if (*input_line_pointer == ':')
4242             {
4243               expressionS count_exp;
4244
4245               ++input_line_pointer;
4246               expression (&count_exp);
4247
4248               if (count_exp.X_op != O_constant
4249                   || count_exp.X_add_number <= 0)
4250                 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4251               else
4252                 count = count_exp.X_add_number;
4253             }
4254 #endif
4255
4256           while (--count >= 0)
4257             {
4258               p = frag_more (length);
4259               memcpy (p, temp, (unsigned int) length);
4260             }
4261         }
4262       SKIP_WHITESPACE ();
4263     }
4264   while (*input_line_pointer++ == ',');
4265
4266   /* Put terminator back into stream.  */
4267   --input_line_pointer;
4268   demand_empty_rest_of_line ();
4269 }
4270 \f
4271 /* Return the size of a LEB128 value.  */
4272
4273 static inline int
4274 sizeof_sleb128 (offsetT value)
4275 {
4276   register int size = 0;
4277   register unsigned byte;
4278
4279   do
4280     {
4281       byte = (value & 0x7f);
4282       /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4283          Fortunately, we can structure things so that the extra work reduces
4284          to a noop on systems that do things "properly".  */
4285       value = (value >> 7) | ~(-(offsetT)1 >> 7);
4286       size += 1;
4287     }
4288   while (!(((value == 0) && ((byte & 0x40) == 0))
4289            || ((value == -1) && ((byte & 0x40) != 0))));
4290
4291   return size;
4292 }
4293
4294 static inline int
4295 sizeof_uleb128 (valueT value)
4296 {
4297   register int size = 0;
4298   register unsigned byte;
4299
4300   do
4301     {
4302       byte = (value & 0x7f);
4303       value >>= 7;
4304       size += 1;
4305     }
4306   while (value != 0);
4307
4308   return size;
4309 }
4310
4311 int
4312 sizeof_leb128 (valueT value, int sign)
4313 {
4314   if (sign)
4315     return sizeof_sleb128 ((offsetT) value);
4316   else
4317     return sizeof_uleb128 (value);
4318 }
4319
4320 /* Output a LEB128 value.  */
4321
4322 static inline int
4323 output_sleb128 (char *p, offsetT value)
4324 {
4325   register char *orig = p;
4326   register int more;
4327
4328   do
4329     {
4330       unsigned byte = (value & 0x7f);
4331
4332       /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4333          Fortunately, we can structure things so that the extra work reduces
4334          to a noop on systems that do things "properly".  */
4335       value = (value >> 7) | ~(-(offsetT)1 >> 7);
4336
4337       more = !((((value == 0) && ((byte & 0x40) == 0))
4338                 || ((value == -1) && ((byte & 0x40) != 0))));
4339       if (more)
4340         byte |= 0x80;
4341
4342       *p++ = byte;
4343     }
4344   while (more);
4345
4346   return p - orig;
4347 }
4348
4349 static inline int
4350 output_uleb128 (char *p, valueT value)
4351 {
4352   char *orig = p;
4353
4354   do
4355     {
4356       unsigned byte = (value & 0x7f);
4357       value >>= 7;
4358       if (value != 0)
4359         /* More bytes to follow.  */
4360         byte |= 0x80;
4361
4362       *p++ = byte;
4363     }
4364   while (value != 0);
4365
4366   return p - orig;
4367 }
4368
4369 int
4370 output_leb128 (char *p, valueT value, int sign)
4371 {
4372   if (sign)
4373     return output_sleb128 (p, (offsetT) value);
4374   else
4375     return output_uleb128 (p, value);
4376 }
4377
4378 /* Do the same for bignums.  We combine sizeof with output here in that
4379    we don't output for NULL values of P.  It isn't really as critical as
4380    for "normal" values that this be streamlined.  */
4381
4382 static inline int
4383 output_big_sleb128 (char *p, LITTLENUM_TYPE *bignum, int size)
4384 {
4385   char *orig = p;
4386   valueT val = 0;
4387   int loaded = 0;
4388   unsigned byte;
4389
4390   /* Strip leading sign extensions off the bignum.  */
4391   while (size > 1
4392          && bignum[size - 1] == LITTLENUM_MASK
4393          && bignum[size - 2] > LITTLENUM_MASK / 2)
4394     size--;
4395
4396   do
4397     {
4398       /* OR in the next part of the littlenum.  */
4399       val |= (*bignum << loaded);
4400       loaded += LITTLENUM_NUMBER_OF_BITS;
4401       size--;
4402       bignum++;
4403
4404       /* Add bytes until there are less than 7 bits left in VAL
4405          or until every non-sign bit has been written.  */
4406       do
4407         {
4408           byte = val & 0x7f;
4409           loaded -= 7;
4410           val >>= 7;
4411           if (size > 0
4412               || val != ((byte & 0x40) == 0 ? 0 : ((valueT) 1 << loaded) - 1))
4413             byte |= 0x80;
4414
4415           if (orig)
4416             *p = byte;
4417           p++;
4418         }
4419       while ((byte & 0x80) != 0 && loaded >= 7);
4420     }
4421   while (size > 0);
4422
4423   /* Mop up any left-over bits (of which there will be less than 7).  */
4424   if ((byte & 0x80) != 0)
4425     {
4426       /* Sign-extend VAL.  */
4427       if (val & (1 << (loaded - 1)))
4428         val |= ~0 << loaded;
4429       if (orig)
4430         *p = val & 0x7f;
4431       p++;
4432     }
4433
4434   return p - orig;
4435 }
4436
4437 static inline int
4438 output_big_uleb128 (char *p, LITTLENUM_TYPE *bignum, int size)
4439 {
4440   char *orig = p;
4441   valueT val = 0;
4442   int loaded = 0;
4443   unsigned byte;
4444
4445   /* Strip leading zeros off the bignum.  */
4446   /* XXX: Is this needed?  */
4447   while (size > 0 && bignum[size - 1] == 0)
4448     size--;
4449
4450   do
4451     {
4452       if (loaded < 7 && size > 0)
4453         {
4454           val |= (*bignum << loaded);
4455           loaded += 8 * CHARS_PER_LITTLENUM;
4456           size--;
4457           bignum++;
4458         }
4459
4460       byte = val & 0x7f;
4461       loaded -= 7;
4462       val >>= 7;
4463
4464       if (size > 0 || val)
4465         byte |= 0x80;
4466
4467       if (orig)
4468         *p = byte;
4469       p++;
4470     }
4471   while (byte & 0x80);
4472
4473   return p - orig;
4474 }
4475
4476 static int
4477 output_big_leb128 (char *p, LITTLENUM_TYPE *bignum, int size, int sign)
4478 {
4479   if (sign)
4480     return output_big_sleb128 (p, bignum, size);
4481   else
4482     return output_big_uleb128 (p, bignum, size);
4483 }
4484
4485 /* Generate the appropriate fragments for a given expression to emit a
4486    leb128 value.  */
4487
4488 static void
4489 emit_leb128_expr (expressionS *exp, int sign)
4490 {
4491   operatorT op = exp->X_op;
4492   unsigned int nbytes;
4493
4494   if (op == O_absent || op == O_illegal)
4495     {
4496       as_warn (_("zero assumed for missing expression"));
4497       exp->X_add_number = 0;
4498       op = O_constant;
4499     }
4500   else if (op == O_big && exp->X_add_number <= 0)
4501     {
4502       as_bad (_("floating point number invalid"));
4503       exp->X_add_number = 0;
4504       op = O_constant;
4505     }
4506   else if (op == O_register)
4507     {
4508       as_warn (_("register value used as expression"));
4509       op = O_constant;
4510     }
4511   else if (op == O_constant
4512            && sign
4513            && (exp->X_add_number < 0) != !exp->X_unsigned)
4514     {
4515       /* We're outputting a signed leb128 and the sign of X_add_number
4516          doesn't reflect the sign of the original value.  Convert EXP
4517          to a correctly-extended bignum instead.  */
4518       convert_to_bignum (exp);
4519       op = O_big;
4520     }
4521
4522   /* Let check_eh_frame know that data is being emitted.  nbytes == -1 is
4523      a signal that this is leb128 data.  It shouldn't optimize this away.  */
4524   nbytes = (unsigned int) -1;
4525   if (check_eh_frame (exp, &nbytes))
4526     abort ();
4527
4528   /* Let the backend know that subsequent data may be byte aligned.  */
4529 #ifdef md_cons_align
4530   md_cons_align (1);
4531 #endif
4532
4533   if (op == O_constant)
4534     {
4535       /* If we've got a constant, emit the thing directly right now.  */
4536
4537       valueT value = exp->X_add_number;
4538       int size;
4539       char *p;
4540
4541       size = sizeof_leb128 (value, sign);
4542       p = frag_more (size);
4543       output_leb128 (p, value, sign);
4544     }
4545   else if (op == O_big)
4546     {
4547       /* O_big is a different sort of constant.  */
4548
4549       int size;
4550       char *p;
4551
4552       size = output_big_leb128 (NULL, generic_bignum, exp->X_add_number, sign);
4553       p = frag_more (size);
4554       output_big_leb128 (p, generic_bignum, exp->X_add_number, sign);
4555     }
4556   else
4557     {
4558       /* Otherwise, we have to create a variable sized fragment and
4559          resolve things later.  */
4560
4561       frag_var (rs_leb128, sizeof_uleb128 (~(valueT) 0), 0, sign,
4562                 make_expr_symbol (exp), 0, (char *) NULL);
4563     }
4564 }
4565
4566 /* Parse the .sleb128 and .uleb128 pseudos.  */
4567
4568 void
4569 s_leb128 (int sign)
4570 {
4571   expressionS exp;
4572
4573 #ifdef md_flush_pending_output
4574   md_flush_pending_output ();
4575 #endif
4576
4577   do
4578     {
4579       expression (&exp);
4580       emit_leb128_expr (&exp, sign);
4581     }
4582   while (*input_line_pointer++ == ',');
4583
4584   input_line_pointer--;
4585   demand_empty_rest_of_line ();
4586 }
4587 \f
4588 /* We read 0 or more ',' separated, double-quoted strings.
4589    Caller should have checked need_pass_2 is FALSE because we don't
4590    check it.  */
4591
4592 void
4593 stringer (/* Worker to do .ascii etc statements.  */
4594           /* Checks end-of-line.  */
4595           register int append_zero      /* 0: don't append '\0', else 1.  */)
4596 {
4597   register unsigned int c;
4598   char *start;
4599
4600 #ifdef md_flush_pending_output
4601   md_flush_pending_output ();
4602 #endif
4603
4604   /* The following awkward logic is to parse ZERO or more strings,
4605      comma separated. Recall a string expression includes spaces
4606      before the opening '\"' and spaces after the closing '\"'.
4607      We fake a leading ',' if there is (supposed to be)
4608      a 1st, expression. We keep demanding expressions for each ','.  */
4609   if (is_it_end_of_statement ())
4610     {
4611       c = 0;                    /* Skip loop.  */
4612       ++input_line_pointer;     /* Compensate for end of loop.  */
4613     }
4614   else
4615     {
4616       c = ',';                  /* Do loop.  */
4617     }
4618   /* If we have been switched into the abs_section then we
4619      will not have an obstack onto which we can hang strings.  */
4620   if (now_seg == absolute_section)
4621     {
4622       as_bad (_("strings must be placed into a section"));
4623       c = 0;
4624       ignore_rest_of_line ();
4625     }
4626
4627   while (c == ',' || c == '<' || c == '"')
4628     {
4629       SKIP_WHITESPACE ();
4630       switch (*input_line_pointer)
4631         {
4632         case '\"':
4633           ++input_line_pointer; /*->1st char of string.  */
4634           start = input_line_pointer;
4635           while (is_a_char (c = next_char_of_string ()))
4636             {
4637               FRAG_APPEND_1_CHAR (c);
4638             }
4639           if (append_zero)
4640             {
4641               FRAG_APPEND_1_CHAR (0);
4642             }
4643           know (input_line_pointer[-1] == '\"');
4644
4645 #ifndef NO_LISTING
4646 #ifdef OBJ_ELF
4647           /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4648              will emit .string with a filename in the .debug section
4649              after a sequence of constants.  See the comment in
4650              emit_expr for the sequence.  emit_expr will set
4651              dwarf_file_string to non-zero if this string might be a
4652              source file name.  */
4653           if (strcmp (segment_name (now_seg), ".debug") != 0)
4654             dwarf_file_string = 0;
4655           else if (dwarf_file_string)
4656             {
4657               c = input_line_pointer[-1];
4658               input_line_pointer[-1] = '\0';
4659               listing_source_file (start);
4660               input_line_pointer[-1] = c;
4661             }
4662 #endif
4663 #endif
4664
4665           break;
4666         case '<':
4667           input_line_pointer++;
4668           c = get_single_number ();
4669           FRAG_APPEND_1_CHAR (c);
4670           if (*input_line_pointer != '>')
4671             {
4672               as_bad (_("expected <nn>"));
4673             }
4674           input_line_pointer++;
4675           break;
4676         case ',':
4677           input_line_pointer++;
4678           break;
4679         }
4680       SKIP_WHITESPACE ();
4681       c = *input_line_pointer;
4682     }
4683
4684   demand_empty_rest_of_line ();
4685 }                               /* stringer() */
4686 \f
4687 /* FIXME-SOMEDAY: I had trouble here on characters with the
4688     high bits set.  We'll probably also have trouble with
4689     multibyte chars, wide chars, etc.  Also be careful about
4690     returning values bigger than 1 byte.  xoxorich.  */
4691
4692 unsigned int
4693 next_char_of_string (void)
4694 {
4695   register unsigned int c;
4696
4697   c = *input_line_pointer++ & CHAR_MASK;
4698   switch (c)
4699     {
4700     case '\"':
4701       c = NOT_A_CHAR;
4702       break;
4703
4704     case '\n':
4705       as_warn (_("unterminated string; newline inserted"));
4706       bump_line_counters ();
4707       break;
4708
4709 #ifndef NO_STRING_ESCAPES
4710     case '\\':
4711       switch (c = *input_line_pointer++)
4712         {
4713         case 'b':
4714           c = '\b';
4715           break;
4716
4717         case 'f':
4718           c = '\f';
4719           break;
4720
4721         case 'n':
4722           c = '\n';
4723           break;
4724
4725         case 'r':
4726           c = '\r';
4727           break;
4728
4729         case 't':
4730           c = '\t';
4731           break;
4732
4733         case 'v':
4734           c = '\013';
4735           break;
4736
4737         case '\\':
4738         case '"':
4739           break;                /* As itself.  */
4740
4741         case '0':
4742         case '1':
4743         case '2':
4744         case '3':
4745         case '4':
4746         case '5':
4747         case '6':
4748         case '7':
4749         case '8':
4750         case '9':
4751           {
4752             long number;
4753             int i;
4754
4755             for (i = 0, number = 0;
4756                  ISDIGIT (c) && i < 3;
4757                  c = *input_line_pointer++, i++)
4758               {
4759                 number = number * 8 + c - '0';
4760               }
4761
4762             c = number & 0xff;
4763           }
4764           --input_line_pointer;
4765           break;
4766
4767         case 'x':
4768         case 'X':
4769           {
4770             long number;
4771
4772             number = 0;
4773             c = *input_line_pointer++;
4774             while (ISXDIGIT (c))
4775               {
4776                 if (ISDIGIT (c))
4777                   number = number * 16 + c - '0';
4778                 else if (ISUPPER (c))
4779                   number = number * 16 + c - 'A' + 10;
4780                 else
4781                   number = number * 16 + c - 'a' + 10;
4782                 c = *input_line_pointer++;
4783               }
4784             c = number & 0xff;
4785             --input_line_pointer;
4786           }
4787           break;
4788
4789         case '\n':
4790           /* To be compatible with BSD 4.2 as: give the luser a linefeed!!  */
4791           as_warn (_("unterminated string; newline inserted"));
4792           c = '\n';
4793           bump_line_counters ();
4794           break;
4795
4796         default:
4797
4798 #ifdef ONLY_STANDARD_ESCAPES
4799           as_bad (_("bad escaped character in string"));
4800           c = '?';
4801 #endif /* ONLY_STANDARD_ESCAPES */
4802
4803           break;
4804         }
4805       break;
4806 #endif /* ! defined (NO_STRING_ESCAPES) */
4807
4808     default:
4809       break;
4810     }
4811   return (c);
4812 }
4813 \f
4814 static segT
4815 get_segmented_expression (register expressionS *expP)
4816 {
4817   register segT retval;
4818
4819   retval = expression (expP);
4820   if (expP->X_op == O_illegal
4821       || expP->X_op == O_absent
4822       || expP->X_op == O_big)
4823     {
4824       as_bad (_("expected address expression"));
4825       expP->X_op = O_constant;
4826       expP->X_add_number = 0;
4827       retval = absolute_section;
4828     }
4829   return retval;
4830 }
4831
4832 static segT
4833 get_known_segmented_expression (register expressionS *expP)
4834 {
4835   register segT retval;
4836
4837   if ((retval = get_segmented_expression (expP)) == undefined_section)
4838     {
4839       /* There is no easy way to extract the undefined symbol from the
4840          expression.  */
4841       if (expP->X_add_symbol != NULL
4842           && S_GET_SEGMENT (expP->X_add_symbol) != expr_section)
4843         as_warn (_("symbol \"%s\" undefined; zero assumed"),
4844                  S_GET_NAME (expP->X_add_symbol));
4845       else
4846         as_warn (_("some symbol undefined; zero assumed"));
4847       retval = absolute_section;
4848       expP->X_op = O_constant;
4849       expP->X_add_number = 0;
4850     }
4851   know (retval == absolute_section || SEG_NORMAL (retval));
4852   return (retval);
4853 }
4854
4855 char                            /* Return terminator.  */
4856 get_absolute_expression_and_terminator (long *val_pointer /* Return value of expression.  */)
4857 {
4858   /* FIXME: val_pointer should probably be offsetT *.  */
4859   *val_pointer = (long) get_absolute_expression ();
4860   return (*input_line_pointer++);
4861 }
4862 \f
4863 /* Like demand_copy_string, but return NULL if the string contains any '\0's.
4864    Give a warning if that happens.  */
4865
4866 char *
4867 demand_copy_C_string (int *len_pointer)
4868 {
4869   register char *s;
4870
4871   if ((s = demand_copy_string (len_pointer)) != 0)
4872     {
4873       register int len;
4874
4875       for (len = *len_pointer; len > 0; len--)
4876         {
4877           if (*s == 0)
4878             {
4879               s = 0;
4880               len = 1;
4881               *len_pointer = 0;
4882               as_bad (_("this string may not contain \'\\0\'"));
4883             }
4884         }
4885     }
4886
4887   return s;
4888 }
4889 \f
4890 /* Demand string, but return a safe (=private) copy of the string.
4891    Return NULL if we can't read a string here.  */
4892
4893 char *
4894 demand_copy_string (int *lenP)
4895 {
4896   register unsigned int c;
4897   register int len;
4898   char *retval;
4899
4900   len = 0;
4901   SKIP_WHITESPACE ();
4902   if (*input_line_pointer == '\"')
4903     {
4904       input_line_pointer++;     /* Skip opening quote.  */
4905
4906       while (is_a_char (c = next_char_of_string ()))
4907         {
4908           obstack_1grow (&notes, c);
4909           len++;
4910         }
4911       /* JF this next line is so demand_copy_C_string will return a
4912          null terminated string.  */
4913       obstack_1grow (&notes, '\0');
4914       retval = obstack_finish (&notes);
4915     }
4916   else
4917     {
4918       as_bad (_("missing string"));
4919       retval = NULL;
4920       ignore_rest_of_line ();
4921     }
4922   *lenP = len;
4923   return (retval);
4924 }
4925 \f
4926 /* In:  Input_line_pointer->next character.
4927
4928    Do:  Skip input_line_pointer over all whitespace.
4929
4930    Out: 1 if input_line_pointer->end-of-line.  */
4931
4932 int
4933 is_it_end_of_statement (void)
4934 {
4935   SKIP_WHITESPACE ();
4936   return (is_end_of_line[(unsigned char) *input_line_pointer]);
4937 }
4938
4939 void
4940 equals (char *sym_name, int reassign)
4941 {
4942   char *stop = NULL;
4943   char stopc;
4944
4945   input_line_pointer++;
4946   if (*input_line_pointer == '=')
4947     input_line_pointer++;
4948
4949   while (*input_line_pointer == ' ' || *input_line_pointer == '\t')
4950     input_line_pointer++;
4951
4952   if (flag_mri)
4953     stop = mri_comment_field (&stopc);
4954
4955   assign_symbol (sym_name, !reassign);
4956
4957   if (flag_mri)
4958     {
4959       demand_empty_rest_of_line ();
4960       mri_comment_end (stop, stopc);
4961     }
4962 }
4963
4964 /* .incbin -- include a file verbatim at the current location.  */
4965
4966 void
4967 s_incbin (int x ATTRIBUTE_UNUSED)
4968 {
4969   FILE * binfile;
4970   char * path;
4971   char * filename;
4972   char * binfrag;
4973   long   skip = 0;
4974   long   count = 0;
4975   long   bytes;
4976   int    len;
4977
4978 #ifdef md_flush_pending_output
4979   md_flush_pending_output ();
4980 #endif
4981
4982   SKIP_WHITESPACE ();
4983   filename = demand_copy_string (& len);
4984   if (filename == NULL)
4985     return;
4986
4987   SKIP_WHITESPACE ();
4988
4989   /* Look for optional skip and count.  */
4990   if (* input_line_pointer == ',')
4991     {
4992       ++ input_line_pointer;
4993       skip = get_absolute_expression ();
4994
4995       SKIP_WHITESPACE ();
4996
4997       if (* input_line_pointer == ',')
4998         {
4999           ++ input_line_pointer;
5000
5001           count = get_absolute_expression ();
5002           if (count == 0)
5003             as_warn (_(".incbin count zero, ignoring `%s'"), filename);
5004
5005           SKIP_WHITESPACE ();
5006         }
5007     }
5008
5009   demand_empty_rest_of_line ();
5010
5011   /* Try opening absolute path first, then try include dirs.  */
5012   binfile = fopen (filename, FOPEN_RB);
5013   if (binfile == NULL)
5014     {
5015       int i;
5016
5017       path = xmalloc ((unsigned long) len + include_dir_maxlen + 5);
5018
5019       for (i = 0; i < include_dir_count; i++)
5020         {
5021           sprintf (path, "%s/%s", include_dirs[i], filename);
5022
5023           binfile = fopen (path, FOPEN_RB);
5024           if (binfile != NULL)
5025             break;
5026         }
5027
5028       if (binfile == NULL)
5029         as_bad (_("file not found: %s"), filename);
5030     }
5031   else
5032     path = xstrdup (filename);
5033
5034   if (binfile)
5035     {
5036       long   file_len;
5037
5038       register_dependency (path);
5039
5040       /* Compute the length of the file.  */
5041       if (fseek (binfile, 0, SEEK_END) != 0)
5042         {
5043           as_bad (_("seek to end of .incbin file failed `%s'"), path);
5044           goto done;
5045         }
5046       file_len = ftell (binfile);
5047
5048       /* If a count was not specified use the remainder of the file.  */
5049       if (count == 0)
5050         count = file_len - skip;
5051
5052       if (skip < 0 || count < 0 || file_len < 0 || skip + count > file_len)
5053         {
5054           as_bad (_("skip (%ld) or count (%ld) invalid for file size (%ld)"),
5055                   skip, count, file_len);
5056           goto done;
5057         }
5058
5059       if (fseek (binfile, skip, SEEK_SET) != 0)
5060         {
5061           as_bad (_("could not skip to %ld in file `%s'"), skip, path);
5062           goto done;
5063         }
5064
5065       /* Allocate frag space and store file contents in it.  */
5066       binfrag = frag_more (count);
5067
5068       bytes = fread (binfrag, 1, count, binfile);
5069       if (bytes < count)
5070         as_warn (_("truncated file `%s', %ld of %ld bytes read"),
5071                  path, bytes, count);
5072     }
5073 done:
5074   if (binfile != NULL)
5075     fclose (binfile);
5076   if (path)
5077     free (path);
5078 }
5079
5080 /* .include -- include a file at this point.  */
5081
5082 void
5083 s_include (int arg ATTRIBUTE_UNUSED)
5084 {
5085   char *filename;
5086   int i;
5087   FILE *try;
5088   char *path;
5089
5090   if (!flag_m68k_mri)
5091     {
5092       filename = demand_copy_string (&i);
5093       if (filename == NULL)
5094         {
5095           /* demand_copy_string has already printed an error and
5096              called ignore_rest_of_line.  */
5097           return;
5098         }
5099     }
5100   else
5101     {
5102       SKIP_WHITESPACE ();
5103       i = 0;
5104       while (!is_end_of_line[(unsigned char) *input_line_pointer]
5105              && *input_line_pointer != ' '
5106              && *input_line_pointer != '\t')
5107         {
5108           obstack_1grow (&notes, *input_line_pointer);
5109           ++input_line_pointer;
5110           ++i;
5111         }
5112
5113       obstack_1grow (&notes, '\0');
5114       filename = obstack_finish (&notes);
5115       while (!is_end_of_line[(unsigned char) *input_line_pointer])
5116         ++input_line_pointer;
5117     }
5118
5119   demand_empty_rest_of_line ();
5120   path = xmalloc ((unsigned long) i + include_dir_maxlen + 5 /* slop */ );
5121
5122   for (i = 0; i < include_dir_count; i++)
5123     {
5124       strcpy (path, include_dirs[i]);
5125       strcat (path, "/");
5126       strcat (path, filename);
5127       if (0 != (try = fopen (path, FOPEN_RT)))
5128         {
5129           fclose (try);
5130           goto gotit;
5131         }
5132     }
5133
5134   free (path);
5135   path = filename;
5136 gotit:
5137   /* malloc Storage leak when file is found on path.  FIXME-SOMEDAY.  */
5138   register_dependency (path);
5139   input_scrub_insert_file (path);
5140 }
5141
5142 void
5143 add_include_dir (char *path)
5144 {
5145   int i;
5146
5147   if (include_dir_count == 0)
5148     {
5149       include_dirs = (char **) xmalloc (2 * sizeof (*include_dirs));
5150       include_dirs[0] = ".";    /* Current dir.  */
5151       include_dir_count = 2;
5152     }
5153   else
5154     {
5155       include_dir_count++;
5156       include_dirs =
5157         (char **) realloc (include_dirs,
5158                            include_dir_count * sizeof (*include_dirs));
5159     }
5160
5161   include_dirs[include_dir_count - 1] = path;   /* New one.  */
5162
5163   i = strlen (path);
5164   if (i > include_dir_maxlen)
5165     include_dir_maxlen = i;
5166 }
5167 \f
5168 /* Output debugging information to denote the source file.  */
5169
5170 static void
5171 generate_file_debug (void)
5172 {
5173   if (debug_type == DEBUG_STABS)
5174     stabs_generate_asm_file ();
5175 }
5176
5177 /* Output line number debugging information for the current source line.  */
5178
5179 void
5180 generate_lineno_debug (void)
5181 {
5182   switch (debug_type)
5183     {
5184     case DEBUG_UNSPECIFIED:
5185     case DEBUG_NONE:
5186     case DEBUG_DWARF:
5187       break;
5188     case DEBUG_STABS:
5189       stabs_generate_asm_lineno ();
5190       break;
5191     case DEBUG_ECOFF:
5192       ecoff_generate_asm_lineno ();
5193       break;
5194     case DEBUG_DWARF2:
5195       /* ??? We could here indicate to dwarf2dbg.c that something
5196          has changed.  However, since there is additional backend
5197          support that is required (calling dwarf2_emit_insn), we
5198          let dwarf2dbg.c call as_where on its own.  */
5199       break;
5200     }
5201 }
5202
5203 /* Output debugging information to mark a function entry point or end point.
5204    END_P is zero for .func, and non-zero for .endfunc.  */
5205
5206 void
5207 s_func (int end_p)
5208 {
5209   do_s_func (end_p, NULL);
5210 }
5211
5212 /* Subroutine of s_func so targets can choose a different default prefix.
5213    If DEFAULT_PREFIX is NULL, use the target's "leading char".  */
5214
5215 static void
5216 do_s_func (int end_p, const char *default_prefix)
5217 {
5218   /* Record the current function so that we can issue an error message for
5219      misplaced .func,.endfunc, and also so that .endfunc needs no
5220      arguments.  */
5221   static char *current_name;
5222   static char *current_label;
5223
5224   if (end_p)
5225     {
5226       if (current_name == NULL)
5227         {
5228           as_bad (_("missing .func"));
5229           ignore_rest_of_line ();
5230           return;
5231         }
5232
5233       if (debug_type == DEBUG_STABS)
5234         stabs_generate_asm_endfunc (current_name, current_label);
5235
5236       current_name = current_label = NULL;
5237     }
5238   else /* ! end_p */
5239     {
5240       char *name, *label;
5241       char delim1, delim2;
5242
5243       if (current_name != NULL)
5244         {
5245           as_bad (_(".endfunc missing for previous .func"));
5246           ignore_rest_of_line ();
5247           return;
5248         }
5249
5250       name = input_line_pointer;
5251       delim1 = get_symbol_end ();
5252       name = xstrdup (name);
5253       *input_line_pointer = delim1;
5254       SKIP_WHITESPACE ();
5255       if (*input_line_pointer != ',')
5256         {
5257           if (default_prefix)
5258             asprintf (&label, "%s%s", default_prefix, name);
5259           else
5260             {
5261               char leading_char = 0;
5262 #ifdef BFD_ASSEMBLER
5263               leading_char = bfd_get_symbol_leading_char (stdoutput);
5264 #endif
5265               /* Missing entry point, use function's name with the leading
5266                  char prepended.  */
5267               if (leading_char)
5268                 asprintf (&label, "%c%s", leading_char, name);
5269               else
5270                 label = name;
5271             }
5272         }
5273       else
5274         {
5275           ++input_line_pointer;
5276           SKIP_WHITESPACE ();
5277           label = input_line_pointer;
5278           delim2 = get_symbol_end ();
5279           label = xstrdup (label);
5280           *input_line_pointer = delim2;
5281         }
5282
5283       if (debug_type == DEBUG_STABS)
5284         stabs_generate_asm_func (name, label);
5285
5286       current_name = name;
5287       current_label = label;
5288     }
5289
5290   demand_empty_rest_of_line ();
5291 }
5292 \f
5293 void
5294 s_ignore (int arg ATTRIBUTE_UNUSED)
5295 {
5296   while (!is_end_of_line[(unsigned char) *input_line_pointer])
5297     {
5298       ++input_line_pointer;
5299     }
5300   ++input_line_pointer;
5301 }
5302
5303 void
5304 read_print_statistics (FILE *file)
5305 {
5306   hash_print_statistics (file, "pseudo-op table", po_hash);
5307 }
5308
5309 /* Inserts the given line into the input stream.
5310
5311    This call avoids macro/conditionals nesting checking, since the contents of
5312    the line are assumed to replace the contents of a line already scanned.
5313
5314    An appropriate use of this function would be substitution of input lines when
5315    called by md_start_line_hook().  The given line is assumed to already be
5316    properly scrubbed.  */
5317
5318 void
5319 input_scrub_insert_line (const char *line)
5320 {
5321   sb newline;
5322   sb_new (&newline);
5323   sb_add_string (&newline, line);
5324   input_scrub_include_sb (&newline, input_line_pointer, 0);
5325   sb_kill (&newline);
5326   buffer_limit = input_scrub_next_buffer (&input_line_pointer);
5327 }
5328
5329 /* Insert a file into the input stream; the path must resolve to an actual
5330    file; no include path searching or dependency registering is performed.  */
5331
5332 void
5333 input_scrub_insert_file (char *path)
5334 {
5335   input_scrub_include_file (path, input_line_pointer);
5336   buffer_limit = input_scrub_next_buffer (&input_line_pointer);
5337 }