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