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