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