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