1 /* read.c - read a source file -
2 Copyright (C) 1986, 87, 90, 91, 92, 93, 94, 95, 96, 97, 1998
3 Free Software Foundation, Inc.
5 This file is part of GAS, the GNU Assembler.
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #define MASK_CHAR (0xFF) /* If your chars aren't 8 bits, you will
24 change this a bit. But then, GNU isn't
25 spozed to run on your machine anyway.
26 (RMS is so shortsighted sometimes.)
29 #define MASK_CHAR ((int)(unsigned char)-1)
33 /* This is the largest known floating point format (for now). It will
34 grow when we do 4361 style flonums. */
36 #define MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT (16)
38 /* Routines that read assembler source text to build spagetti in memory.
39 Another group of these functions is in the expr.c module. */
52 #ifndef TC_START_LABEL
53 #define TC_START_LABEL(x,y) (x==':')
56 /* The NOP_OPCODE is for the alignment fill value.
57 * fill it a nop instruction so that the disassembler does not choke
61 #define NOP_OPCODE 0x00
64 char *input_line_pointer
; /*->next char of source file to parse. */
66 #if BITS_PER_CHAR != 8
67 /* The following table is indexed by[(char)] and will break if
68 a char does not have exactly 256 states (hopefully 0:255!)! */
73 /* The m88k unfortunately uses @ as a label beginner. */
78 /* The RS/6000 assembler uses {,},[,] as parts of symbol names. */
83 /* The Delta 68k assembler permits % inside label names. */
88 /* The PowerPC Windows NT assemblers permits ? inside label names. */
93 /* The a29k assembler does not permits labels to start with $. */
98 /* The Delta 68k assembler permits ~ at start of label names. */
102 /* used by is_... macros. our ctype[] */
105 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* @ABCDEFGHIJKLMNO */
106 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ[\]^_ */
107 0, 0, 0, 0, LEX_DOLLAR
, LEX_PCT
, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, /* _!"#$%&'()*+,-./ */
108 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, LEX_QM
, /* 0123456789:;<=>? */
109 LEX_AT
, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* @ABCDEFGHIJKLMNO */
110 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, 0, 3, /* PQRSTUVWXYZ[\]^_ */
111 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* `abcdefghijklmno */
112 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, LEX_BR
, 0, LEX_BR
, LEX_TILDE
, 0, /* pqrstuvwxyz{|}~. */
113 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
114 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
115 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
116 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
117 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
118 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
119 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
125 * Out: 1 if this character ends a line.
128 char is_end_of_line
[256] =
131 99, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, 99, Z_
, Z_
, 99, Z_
, Z_
, /* @abcdefghijklmno */
133 99, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, 99, Z_
, Z_
, Z_
, Z_
, Z_
, /* @abcdefghijklmno */
135 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
137 Z_
,99, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* _!"#$%&'()*+,-./ */
138 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* 0123456789:;<=>? */
140 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
141 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, 99, Z_
, Z_
, Z_
, Z_
, /* 0123456789:;<=>? */
143 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
144 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
145 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
146 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
147 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
148 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
149 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
150 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
151 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
155 /* Functions private to this file. */
157 static char *buffer
; /* 1st char of each buffer of lines is here. */
158 static char *buffer_limit
; /*->1 + last char in buffer. */
160 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1 in the
161 tc-<CPU>.h file. See the "Porting GAS" section of the internals manual. */
162 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
164 static char *old_buffer
; /* JF a hack */
165 static char *old_input
;
166 static char *old_limit
;
168 /* Variables for handling include file directory table. */
170 char **include_dirs
; /* Table of pointers to directories to
171 search for .include's */
172 int include_dir_count
; /* How many are in the table */
173 int include_dir_maxlen
= 1;/* Length of longest in table */
175 #ifndef WORKING_DOT_WORD
176 struct broken_word
*broken_words
;
177 int new_broken_words
;
180 /* The current offset into the absolute section. We don't try to
181 build frags in the absolute section, since no data can be stored
182 there. We just keep track of the current offset. */
183 addressT abs_section_offset
;
185 /* If this line had an MRI style label, it is stored in this variable.
186 This is used by some of the MRI pseudo-ops. */
189 /* This global variable is used to support MRI common sections. We
190 translate such sections into a common symbol. This variable is
191 non-NULL when we are in an MRI common section. */
192 symbolS
*mri_common_symbol
;
194 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
195 need to align to an even byte boundary unless the next pseudo-op is
196 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
198 static int mri_pending_align
;
202 /* This variable is set to be non-zero if the next string we see might
203 be the name of the source file in DWARF debugging information. See
204 the comment in emit_expr for the format we look for. */
205 static int dwarf_file_string
;
209 static void cons_worker
PARAMS ((int, int));
210 static int scrub_from_string
PARAMS ((char **));
211 static void do_align
PARAMS ((int, char *, int, int));
212 static void s_align
PARAMS ((int, int));
213 static int hex_float
PARAMS ((int, char *));
214 static void do_org
PARAMS ((segT
, expressionS
*, int));
215 char *demand_copy_string
PARAMS ((int *lenP
));
216 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
217 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
218 static void pobegin
PARAMS ((void));
219 static int get_line_sb
PARAMS ((sb
*));
220 static void generate_file_debug
PARAMS ((void));
221 static void generate_lineno_debug
PARAMS ((void));
230 obj_read_begin_hook ();
232 /* Something close -- but not too close -- to a multiple of 1024.
233 The debugging malloc I'm using has 24 bytes of overhead. */
234 obstack_begin (¬es
, chunksize
);
235 obstack_begin (&cond_obstack
, chunksize
);
237 /* Use machine dependent syntax */
238 for (p
= line_separator_chars
; *p
; p
++)
239 is_end_of_line
[(unsigned char) *p
] = 1;
240 /* Use more. FIXME-SOMEDAY. */
246 /* set up pseudo-op tables */
248 static struct hash_control
*po_hash
;
250 static const pseudo_typeS potable
[] =
252 {"abort", s_abort
, 0},
253 {"align", s_align_ptwo
, 0},
254 {"ascii", stringer
, 0},
255 {"asciz", stringer
, 1},
256 {"balign", s_align_bytes
, 0},
257 {"balignw", s_align_bytes
, -2},
258 {"balignl", s_align_bytes
, -4},
262 {"common", s_mri_common
, 0},
263 {"common.s", s_mri_common
, 1},
267 {"dc.d", float_cons
, 'd'},
269 {"dc.s", float_cons
, 'f'},
271 {"dc.x", float_cons
, 'x'},
273 {"dcb.b", s_space
, 1},
274 {"dcb.d", s_float_space
, 'd'},
275 {"dcb.l", s_space
, 4},
276 {"dcb.s", s_float_space
, 'f'},
277 {"dcb.w", s_space
, 2},
278 {"dcb.x", s_float_space
, 'x'},
280 {"ds.b", s_space
, 1},
281 {"ds.d", s_space
, 8},
282 {"ds.l", s_space
, 4},
283 {"ds.p", s_space
, 12},
284 {"ds.s", s_space
, 4},
285 {"ds.w", s_space
, 2},
286 {"ds.x", s_space
, 12},
287 {"debug", s_ignore
, 0},
292 {"double", float_cons
, 'd'},
294 {"eject", listing_eject
, 0}, /* Formfeed listing */
296 {"elsec", s_else
, 0},
298 {"endc", s_endif
, 0},
299 {"endif", s_endif
, 0},
304 {"exitm", s_mexit
, 0},
306 {"extern", s_ignore
, 0}, /* We treat all undef as ext */
307 {"appfile", s_app_file
, 1},
308 {"appline", s_app_line
, 0},
310 {"file", s_app_file
, 0},
312 {"float", float_cons
, 'f'},
313 {"format", s_ignore
, 0},
314 {"global", s_globl
, 0},
315 {"globl", s_globl
, 0},
317 {"if", s_if
, (int) O_ne
},
319 {"ifdef", s_ifdef
, 0},
320 {"ifeq", s_if
, (int) O_eq
},
321 {"ifeqs", s_ifeqs
, 0},
322 {"ifge", s_if
, (int) O_ge
},
323 {"ifgt", s_if
, (int) O_gt
},
324 {"ifle", s_if
, (int) O_le
},
325 {"iflt", s_if
, (int) O_lt
},
327 {"ifndef", s_ifdef
, 1},
328 {"ifne", s_if
, (int) O_ne
},
329 {"ifnes", s_ifeqs
, 1},
330 {"ifnotdef", s_ifdef
, 1},
331 {"include", s_include
, 0},
337 {"lcomm", s_lcomm
, 0},
338 {"lflags", listing_flags
, 0}, /* Listing flags */
339 {"linkonce", s_linkonce
, 0},
340 {"list", listing_list
, 1}, /* Turn listing on */
341 {"llen", listing_psize
, 1},
344 {"macro", s_macro
, 0},
345 {"mexit", s_mexit
, 0},
347 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
348 {"name", s_ignore
, 0},
349 {"noformat", s_ignore
, 0},
350 {"nolist", listing_list
, 0}, /* Turn listing off */
351 {"nopage", listing_nopage
, 0},
353 {"offset", s_struct
, 0},
355 {"p2align", s_align_ptwo
, 0},
356 {"p2alignw", s_align_ptwo
, -2},
357 {"p2alignl", s_align_ptwo
, -4},
358 {"page", listing_eject
, 0},
359 {"plen", listing_psize
, 0},
360 {"print", s_print
, 0},
361 {"psize", listing_psize
, 0}, /* set paper size */
362 {"purgem", s_purgem
, 0},
367 {"sbttl", listing_title
, 1}, /* Subtitle of listing */
372 {"single", float_cons
, 'f'},
374 {"space", s_space
, 0},
375 {"skip", s_space
, 0},
376 {"sleb128", s_leb128
, 1},
377 {"spc", s_ignore
, 0},
378 {"stabd", s_stab
, 'd'},
379 {"stabn", s_stab
, 'n'},
380 {"stabs", s_stab
, 's'},
381 {"string", stringer
, 1},
382 {"struct", s_struct
, 0},
386 /* This is for gcc to use. It's only just been added (2/94), so gcc
387 won't be able to use it for a while -- probably a year or more.
388 But once this has been released, check with gcc maintainers
389 before deleting it or even changing the spelling. */
390 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
391 /* If we're folding case -- done for some targets, not necessarily
392 all -- the above string in an input file will be converted to
393 this one. Match it either way... */
394 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
396 {"title", listing_title
, 0}, /* Listing title */
397 {"ttl", listing_title
, 0},
399 {"uleb128", s_leb128
, 0},
403 {"xdef", s_globl
, 0},
404 {"xref", s_ignore
, 0},
405 {"xstabs", s_xstab
, 's'},
407 {"zero", s_space
, 0},
408 {NULL
} /* end sentinel */
411 static int pop_override_ok
= 0;
412 static const char *pop_table_name
;
416 const pseudo_typeS
*table
;
419 const pseudo_typeS
*pop
;
420 for (pop
= table
; pop
->poc_name
; pop
++)
422 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
423 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
424 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name
,
429 #ifndef md_pop_insert
430 #define md_pop_insert() pop_insert(md_pseudo_table)
433 #ifndef obj_pop_insert
434 #define obj_pop_insert() pop_insert(obj_pseudo_table)
440 po_hash
= hash_new ();
442 /* Do the target-specific pseudo ops. */
443 pop_table_name
= "md";
446 /* Now object specific. Skip any that were in the target table. */
447 pop_table_name
= "obj";
451 /* Now portable ones. Skip any that we've seen already. */
452 pop_table_name
= "standard";
453 pop_insert (potable
);
456 #define HANDLE_CONDITIONAL_ASSEMBLY() \
457 if (ignore_input ()) \
459 while (! is_end_of_line[(unsigned char) *input_line_pointer++]) \
460 if (input_line_pointer == buffer_limit) \
466 /* This function is used when scrubbing the characters between #APP
469 static char *scrub_string
;
470 static char *scrub_string_end
;
473 scrub_from_string (from
)
478 *from
= scrub_string
;
479 size
= scrub_string_end
- scrub_string
;
480 scrub_string
= scrub_string_end
;
484 /* read_a_source_file()
486 * We read the file, putting things into a web that
487 * represents what we have been reading.
490 read_a_source_file (name
)
494 register char *s
; /* string of symbol, '\0' appended */
498 buffer
= input_scrub_new_file (name
);
501 listing_newline (NULL
);
502 register_dependency (name
);
504 /* Generate debugging information before we've read anything in to denote
505 this file as the "main" source file and not a subordinate one
506 (e.g. N_SO vs N_SOL in stabs). */
507 generate_file_debug ();
509 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
510 { /* We have another line to parse. */
511 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
512 contin
: /* JF this goto is my fault I admit it.
513 Someone brave please re-write the whole
514 input section here? Pleeze??? */
515 while (input_line_pointer
< buffer_limit
)
517 /* We have more of this buffer to parse. */
520 * We now have input_line_pointer->1st char of next line.
521 * If input_line_pointer [-1] == '\n' then we just
522 * scanned another line: so bump line counters.
524 if (is_end_of_line
[(unsigned char) input_line_pointer
[-1]])
526 #ifdef md_start_line_hook
527 md_start_line_hook ();
530 if (input_line_pointer
[-1] == '\n')
531 bump_line_counters ();
536 #ifdef LABELS_WITHOUT_COLONS
541 /* Text at the start of a line must be a label, we
542 run down and stick a colon in. */
543 if (is_name_beginner (*input_line_pointer
))
545 char *line_start
= input_line_pointer
;
550 HANDLE_CONDITIONAL_ASSEMBLY ();
552 c
= get_symbol_end ();
554 /* In MRI mode, the EQU and MACRO pseudoops must
555 be handled specially. */
559 char *rest
= input_line_pointer
+ 1;
563 if (*rest
== ' ' || *rest
== '\t')
565 if ((strncasecmp (rest
, "EQU", 3) == 0
566 || strncasecmp (rest
, "SET", 3) == 0)
567 && (rest
[3] == ' ' || rest
[3] == '\t'))
569 input_line_pointer
= rest
+ 3;
571 strncasecmp (rest
, "SET", 3) == 0);
574 if (strncasecmp (rest
, "MACRO", 5) == 0
577 || is_end_of_line
[(unsigned char) rest
[5]]))
581 /* In MRI mode, we need to handle the MACRO
582 pseudo-op specially: we don't want to put the
583 symbol in the symbol table. */
584 if (! mri_line_macro
)
585 line_label
= colon (line_start
);
587 line_label
= symbol_create (line_start
,
592 *input_line_pointer
= c
;
594 input_line_pointer
++;
600 * We are at the begining of a line, or similar place.
601 * We expect a well-formed assembler statement.
602 * A "symbol-name:" is a statement.
604 * Depending on what compiler is used, the order of these tests
605 * may vary to catch most common case 1st.
606 * Each test is independent of all other tests at the (top) level.
607 * PLEASE make a compiler that doesn't use this assembler.
608 * It is crufty to waste a compiler's time encoding things for this
609 * assembler, which then wastes more time decoding it.
610 * (And communicating via (linear) files is silly!
611 * If you must pass stuff, please pass a tree!)
613 if ((c
= *input_line_pointer
++) == '\t'
618 c
= *input_line_pointer
++;
620 know (c
!= ' '); /* No further leading whitespace. */
623 /* If listing is on, and we are expanding a macro, then give
624 the listing code the contents of the expanded line. */
627 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
632 /* Find the end of the current expanded macro line. */
633 for (s
= input_line_pointer
-1; *s
; ++s
)
634 if (is_end_of_line
[(unsigned char) *s
])
637 /* Copy it for safe keeping. Also give an indication of
638 how much macro nesting is involved at this point. */
639 len
= s
- (input_line_pointer
-1);
640 copy
= (char *) xmalloc (len
+ macro_nest
+ 2);
641 memset (copy
, '>', macro_nest
);
642 copy
[macro_nest
] = ' ';
643 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
-1, len
);
644 copy
[macro_nest
+1+len
] = '\0';
646 /* Install the line with the listing facility. */
647 listing_newline (copy
);
650 listing_newline (NULL
);
655 * C is the 1st significant character.
656 * Input_line_pointer points after that character.
658 if (is_name_beginner (c
))
660 /* want user-defined label or pseudo/opcode */
661 HANDLE_CONDITIONAL_ASSEMBLY ();
663 s
= --input_line_pointer
;
664 c
= get_symbol_end (); /* name's delimiter */
666 * C is character after symbol.
667 * That character's place in the input line is now '\0'.
668 * S points to the beginning of the symbol.
669 * [In case of pseudo-op, s->'.'.]
670 * Input_line_pointer->'\0' where c was.
672 if (TC_START_LABEL(c
, input_line_pointer
))
676 char *rest
= input_line_pointer
+ 1;
678 /* In MRI mode, \tsym: set 0 is permitted. */
682 if (*rest
== ' ' || *rest
== '\t')
684 if ((strncasecmp (rest
, "EQU", 3) == 0
685 || strncasecmp (rest
, "SET", 3) == 0)
686 && (rest
[3] == ' ' || rest
[3] == '\t'))
688 input_line_pointer
= rest
+ 3;
694 line_label
= colon (s
); /* user-defined label */
695 *input_line_pointer
++ = ':'; /* Put ':' back for error messages' sake. */
696 /* Input_line_pointer->after ':'. */
702 || ((c
== ' ' || c
== '\t')
703 && input_line_pointer
[1] == '='
704 #ifdef TC_EQUAL_IN_INSN
705 && ! TC_EQUAL_IN_INSN (c
, input_line_pointer
)
710 demand_empty_rest_of_line ();
713 { /* expect pseudo-op or machine instruction */
716 #define IGNORE_OPCODE_CASE
717 #ifdef IGNORE_OPCODE_CASE
722 if (isupper ((unsigned char) *s2
))
735 /* The MRI assembler and the m88k use pseudo-ops
737 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
738 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
743 || (! flag_m68k_mri
&& *s
== '.'))
748 * WARNING: c has next char, which may be end-of-line.
749 * We lookup the pseudo-op table with s+1 because we
750 * already know that the pseudo-op begins with a '.'.
754 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
756 /* In MRI mode, we may need to insert an
757 automatic alignment directive. What a hack
759 if (mri_pending_align
761 || ! ((pop
->poc_handler
== cons
762 && pop
->poc_val
== 1)
763 || (pop
->poc_handler
== s_space
764 && pop
->poc_val
== 1)
765 #ifdef tc_conditional_pseudoop
766 || tc_conditional_pseudoop (pop
)
768 || pop
->poc_handler
== s_if
769 || pop
->poc_handler
== s_ifdef
770 || pop
->poc_handler
== s_ifc
771 || pop
->poc_handler
== s_ifeqs
772 || pop
->poc_handler
== s_else
773 || pop
->poc_handler
== s_endif
774 || pop
->poc_handler
== s_globl
775 || pop
->poc_handler
== s_ignore
)))
777 do_align (1, (char *) NULL
, 0, 0);
778 mri_pending_align
= 0;
779 if (line_label
!= NULL
)
781 line_label
->sy_frag
= frag_now
;
782 S_SET_VALUE (line_label
, frag_now_fix ());
786 /* Print the error msg now, while we still can */
789 as_bad (_("Unknown pseudo-op: `%s'"), s
);
790 *input_line_pointer
= c
;
795 /* Put it back for error messages etc. */
796 *input_line_pointer
= c
;
797 /* The following skip of whitespace is compulsory.
798 A well shaped space is sometimes all that separates
799 keyword from operands. */
800 if (c
== ' ' || c
== '\t')
801 input_line_pointer
++;
803 * Input_line is restored.
804 * Input_line_pointer->1st non-blank char
805 * after pseudo-operation.
807 (*pop
->poc_handler
) (pop
->poc_val
);
809 /* If that was .end, just get out now. */
810 if (pop
->poc_handler
== s_end
)
817 /* WARNING: c has char, which may be end-of-line. */
818 /* Also: input_line_pointer->`\0` where c was. */
819 *input_line_pointer
= c
;
820 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
822 #ifdef TC_EOL_IN_INSN
823 || TC_EOL_IN_INSN (input_line_pointer
)
827 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
829 input_line_pointer
++;
832 c
= *input_line_pointer
;
833 *input_line_pointer
= '\0';
835 generate_lineno_debug ();
842 if (check_macro (s
, &out
, '\0', &err
))
846 *input_line_pointer
++ = c
;
847 input_scrub_include_sb (&out
,
851 input_scrub_next_buffer (&input_line_pointer
);
856 if (mri_pending_align
)
858 do_align (1, (char *) NULL
, 0, 0);
859 mri_pending_align
= 0;
860 if (line_label
!= NULL
)
862 line_label
->sy_frag
= frag_now
;
863 S_SET_VALUE (line_label
, frag_now_fix ());
867 md_assemble (s
); /* Assemble 1 instruction. */
869 *input_line_pointer
++ = c
;
871 /* We resume loop AFTER the end-of-line from
876 } /* if (is_name_beginner(c) */
879 /* Empty statement? */
880 if (is_end_of_line
[(unsigned char) c
])
883 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
)
884 && isdigit ((unsigned char) c
))
886 /* local label ("4:") */
887 char *backup
= input_line_pointer
;
889 HANDLE_CONDITIONAL_ASSEMBLY ();
893 while (isdigit ((unsigned char) *input_line_pointer
))
895 temp
= (temp
* 10) + *input_line_pointer
- '0';
896 ++input_line_pointer
;
897 } /* read the whole number */
899 if (LOCAL_LABELS_DOLLAR
900 && *input_line_pointer
== '$'
901 && *(input_line_pointer
+ 1) == ':')
903 input_line_pointer
+= 2;
905 if (dollar_label_defined (temp
))
907 as_fatal (_("label \"%d$\" redefined"), temp
);
910 define_dollar_label (temp
);
911 colon (dollar_label_name (temp
, 0));
916 && *input_line_pointer
++ == ':')
918 fb_label_instance_inc (temp
);
919 colon (fb_label_name (temp
, 0));
923 input_line_pointer
= backup
;
924 } /* local label ("4:") */
926 if (c
&& strchr (line_comment_chars
, c
))
927 { /* Its a comment. Better say APP or NO_APP */
931 unsigned int new_length
;
934 bump_line_counters ();
935 s
= input_line_pointer
;
936 if (strncmp (s
, "APP\n", 4))
937 continue; /* We ignore it */
940 ends
= strstr (s
, "#NO_APP\n");
944 unsigned int tmp_len
;
947 /* The end of the #APP wasn't in this buffer. We
948 keep reading in buffers until we find the #NO_APP
949 that goes with this #APP There is one. The specs
951 tmp_len
= buffer_limit
- s
;
952 tmp_buf
= xmalloc (tmp_len
+ 1);
953 memcpy (tmp_buf
, s
, tmp_len
);
956 new_tmp
= input_scrub_next_buffer (&buffer
);
960 buffer_limit
= new_tmp
;
961 input_line_pointer
= buffer
;
962 ends
= strstr (buffer
, "#NO_APP\n");
966 num
= buffer_limit
- buffer
;
968 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
969 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
974 input_line_pointer
= ends
? ends
+ 8 : NULL
;
982 input_line_pointer
= ends
+ 8;
986 scrub_string_end
= ends
;
988 new_length
= ends
- s
;
989 new_buf
= (char *) xmalloc (new_length
);
996 space
= (new_buf
+ new_length
) - new_tmp
;
997 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
1005 new_buf
= xrealloc (new_buf
, new_length
+ 100);
1006 new_tmp
= new_buf
+ new_length
;
1012 old_buffer
= buffer
;
1013 old_input
= input_line_pointer
;
1014 old_limit
= buffer_limit
;
1016 input_line_pointer
= new_buf
;
1017 buffer_limit
= new_tmp
;
1021 HANDLE_CONDITIONAL_ASSEMBLY ();
1023 #ifdef tc_unrecognized_line
1024 if (tc_unrecognized_line (c
))
1028 /* as_warn("Junk character %d.",c); Now done by ignore_rest */
1029 input_line_pointer
--; /* Report unknown char as ignored. */
1030 ignore_rest_of_line ();
1031 } /* while (input_line_pointer<buffer_limit) */
1033 #ifdef md_after_pass_hook
1034 md_after_pass_hook ();
1040 bump_line_counters ();
1043 buffer
= old_buffer
;
1044 input_line_pointer
= old_input
;
1045 buffer_limit
= old_limit
;
1050 } /* while (more buffers to scan) */
1057 input_scrub_close (); /* Close the input file */
1060 /* For most MRI pseudo-ops, the line actually ends at the first
1061 nonquoted space. This function looks for that point, stuffs a null
1062 in, and sets *STOPCP to the character that used to be there, and
1063 returns the location.
1065 Until I hear otherwise, I am going to assume that this is only true
1066 for the m68k MRI assembler. */
1069 mri_comment_field (stopcp
)
1077 know (flag_m68k_mri
);
1079 for (s
= input_line_pointer
;
1080 ((! is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1085 inquote
= ! inquote
;
1095 for (s
= input_line_pointer
; ! is_end_of_line
[(unsigned char) *s
]; s
++)
1105 /* Skip to the end of an MRI comment field. */
1108 mri_comment_end (stop
, stopc
)
1114 input_line_pointer
= stop
;
1116 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1117 ++input_line_pointer
;
1124 as_fatal (_(".abort detected. Abandoning ship."));
1127 /* Guts of .align directive. N is the power of two to which to align.
1128 FILL may be NULL, or it may point to the bytes of the fill pattern.
1129 LEN is the length of whatever FILL points to, if anything. MAX is
1130 the maximum number of characters to skip when doing the alignment,
1131 or 0 if there is no maximum. */
1134 do_align (n
, fill
, len
, max
)
1143 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1150 #ifdef BFD_ASSEMBLER
1151 if ((bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
) != 0)
1156 if (now_seg
!= data_section
&& now_seg
!= bss_section
)
1163 default_fill
= NOP_OPCODE
;
1166 fill
= &default_fill
;
1170 /* Only make a frag if we HAVE to. . . */
1171 if (n
!= 0 && !need_pass_2
)
1174 frag_align (n
, *fill
, max
);
1176 frag_align_pattern (n
, fill
, len
, max
);
1180 just_record_alignment
:
1183 record_alignment (now_seg
, n
);
1186 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1187 (in bytes). A negative ARG is the negative of the length of the
1188 fill pattern. BYTES_P is non-zero if the alignment value should be
1189 interpreted as the byte boundary, rather than the power of 2. */
1192 s_align (arg
, bytes_p
)
1196 register unsigned int align
;
1204 stop
= mri_comment_field (&stopc
);
1206 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1211 align
= arg
; /* Default value from pseudo-op table */
1215 align
= get_absolute_expression ();
1221 /* Convert to a power of 2. */
1226 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1229 as_bad (_("Alignment not a power of 2"));
1237 as_bad (_("Alignment too large: %u assumed"), align
);
1240 if (*input_line_pointer
!= ',')
1247 ++input_line_pointer
;
1248 if (*input_line_pointer
== ',')
1252 fill
= get_absolute_expression ();
1257 if (*input_line_pointer
!= ',')
1261 ++input_line_pointer
;
1262 max
= get_absolute_expression ();
1269 as_warn (_("expected fill pattern missing"));
1270 do_align (align
, (char *) NULL
, 0, max
);
1285 do_align (align
, &fill_char
, fill_len
, max
);
1291 if ((size_t) fill_len
> sizeof ab
)
1293 md_number_to_chars (ab
, fill
, fill_len
);
1294 do_align (align
, ab
, fill_len
, max
);
1299 mri_comment_end (stop
, stopc
);
1301 demand_empty_rest_of_line ();
1304 /* Handle the .align pseudo-op on machines where ".align 4" means
1305 align to a 4 byte boundary. */
1314 /* Handle the .align pseudo-op on machines where ".align 4" means align
1315 to a 2**4 boundary. */
1328 register char *name
;
1332 register symbolS
*symbolP
;
1337 stop
= mri_comment_field (&stopc
);
1339 name
= input_line_pointer
;
1340 c
= get_symbol_end ();
1341 /* just after name is now '\0' */
1342 p
= input_line_pointer
;
1345 if (*input_line_pointer
!= ',')
1347 as_bad (_("Expected comma after symbol-name: rest of line ignored."));
1349 mri_comment_end (stop
, stopc
);
1350 ignore_rest_of_line ();
1353 input_line_pointer
++; /* skip ',' */
1354 if ((temp
= get_absolute_expression ()) < 0)
1356 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp
);
1358 mri_comment_end (stop
, stopc
);
1359 ignore_rest_of_line ();
1363 symbolP
= symbol_find_or_make (name
);
1365 if (S_IS_DEFINED (symbolP
) && ! S_IS_COMMON (symbolP
))
1367 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
1368 S_GET_NAME (symbolP
));
1370 mri_comment_end (stop
, stopc
);
1371 ignore_rest_of_line ();
1374 if (S_GET_VALUE (symbolP
))
1376 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1377 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
1378 S_GET_NAME (symbolP
),
1379 (long) S_GET_VALUE (symbolP
),
1384 S_SET_VALUE (symbolP
, (valueT
) temp
);
1385 S_SET_EXTERNAL (symbolP
);
1389 extern int flag_one
;
1390 if ( (!temp
) || !flag_one
)
1391 S_GET_OTHER(symbolP
) = const_flag
;
1393 #endif /* not OBJ_VMS */
1394 know (symbolP
->sy_frag
== &zero_address_frag
);
1397 mri_comment_end (stop
, stopc
);
1399 demand_empty_rest_of_line ();
1402 /* The MRI COMMON pseudo-op. We handle this by creating a common
1403 symbol with the appropriate name. We make s_space do the right
1404 thing by increasing the size. */
1407 s_mri_common (small
)
1424 stop
= mri_comment_field (&stopc
);
1428 name
= input_line_pointer
;
1429 if (! isdigit ((unsigned char) *name
))
1430 c
= get_symbol_end ();
1435 ++input_line_pointer
;
1437 while (isdigit ((unsigned char) *input_line_pointer
));
1438 c
= *input_line_pointer
;
1439 *input_line_pointer
= '\0';
1441 if (line_label
!= NULL
)
1443 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1444 + (input_line_pointer
- name
)
1446 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1451 sym
= symbol_find_or_make (name
);
1452 *input_line_pointer
= c
;
1456 if (*input_line_pointer
!= ',')
1460 ++input_line_pointer
;
1461 align
= get_absolute_expression ();
1464 if (S_IS_DEFINED (sym
) && ! S_IS_COMMON (sym
))
1466 as_bad (_("attempt to re-define symbol `%s'"), S_GET_NAME (sym
));
1467 mri_comment_end (stop
, stopc
);
1468 ignore_rest_of_line ();
1472 S_SET_EXTERNAL (sym
);
1473 mri_common_symbol
= sym
;
1477 S_SET_ALIGN (sym
, align
);
1480 if (line_label
!= NULL
)
1482 line_label
->sy_value
.X_op
= O_symbol
;
1483 line_label
->sy_value
.X_add_symbol
= sym
;
1484 line_label
->sy_value
.X_add_number
= S_GET_VALUE (sym
);
1485 line_label
->sy_frag
= &zero_address_frag
;
1486 S_SET_SEGMENT (line_label
, expr_section
);
1489 /* FIXME: We just ignore the small argument, which distinguishes
1490 COMMON and COMMON.S. I don't know what we can do about it. */
1492 /* Ignore the type and hptype. */
1493 if (*input_line_pointer
== ',')
1494 input_line_pointer
+= 2;
1495 if (*input_line_pointer
== ',')
1496 input_line_pointer
+= 2;
1498 mri_comment_end (stop
, stopc
);
1500 demand_empty_rest_of_line ();
1510 temp
= get_absolute_expression ();
1511 if (flag_readonly_data_in_text
)
1513 section
= text_section
;
1517 section
= data_section
;
1519 subseg_set (section
, (subsegT
) temp
);
1524 demand_empty_rest_of_line ();
1527 /* Handle the .appfile pseudo-op. This is automatically generated by
1528 do_scrub_chars when a preprocessor # line comment is seen with a
1529 file name. This default definition may be overridden by the object
1530 or CPU specific pseudo-ops. This function is also the default
1531 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1535 s_app_file (appfile
)
1541 /* Some assemblers tolerate immediately following '"' */
1542 if ((s
= demand_copy_string (&length
)) != 0)
1544 /* If this is a fake .appfile, a fake newline was inserted into
1545 the buffer. Passing -2 to new_logical_line tells it to
1548 = (! new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1550 /* In MRI mode, the preprocessor may have inserted an extraneous
1553 && *input_line_pointer
== '\''
1554 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1555 ++input_line_pointer
;
1557 demand_empty_rest_of_line ();
1562 listing_source_file (s
);
1564 register_dependency (s
);
1572 /* Handle the .appline pseudo-op. This is automatically generated by
1573 do_scrub_chars when a preprocessor # line comment is seen. This
1574 default definition may be overridden by the object or CPU specific
1583 /* The given number is that of the next line. */
1584 l
= get_absolute_expression () - 1;
1586 /* Some of the back ends can't deal with non-positive line numbers.
1587 Besides, it's silly. */
1588 as_warn (_("Line numbers must be positive; line number %d rejected."), l
+1);
1591 new_logical_line ((char *) NULL
, l
);
1594 listing_source_line (l
);
1597 demand_empty_rest_of_line ();
1600 /* Handle the .end pseudo-op. Actually, the real work is done in
1601 read_a_source_file. */
1609 /* The MRI assembler permits the start symbol to follow .end,
1610 but we don't support that. */
1612 if (! is_end_of_line
[(unsigned char) *input_line_pointer
]
1613 && *input_line_pointer
!= '*'
1614 && *input_line_pointer
!= '!')
1615 as_warn (_("start address not supported"));
1619 /* Handle the .err pseudo-op. */
1625 as_bad (_(".err encountered"));
1626 demand_empty_rest_of_line ();
1629 /* Handle the MRI fail pseudo-op. */
1640 stop
= mri_comment_field (&stopc
);
1642 temp
= get_absolute_expression ();
1644 as_warn (_(".fail %ld encountered"), (long) temp
);
1646 as_bad (_(".fail %ld encountered"), (long) temp
);
1649 mri_comment_end (stop
, stopc
);
1651 demand_empty_rest_of_line ();
1658 expressionS rep_exp
;
1660 register long fill
= 0;
1663 #ifdef md_flush_pending_output
1664 md_flush_pending_output ();
1667 get_known_segmented_expression (&rep_exp
);
1668 if (*input_line_pointer
== ',')
1670 input_line_pointer
++;
1671 size
= get_absolute_expression ();
1672 if (*input_line_pointer
== ',')
1674 input_line_pointer
++;
1675 fill
= get_absolute_expression ();
1679 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1680 #define BSD_FILL_SIZE_CROCK_8 (8)
1681 if (size
> BSD_FILL_SIZE_CROCK_8
)
1683 as_warn (_(".fill size clamped to %d."), BSD_FILL_SIZE_CROCK_8
);
1684 size
= BSD_FILL_SIZE_CROCK_8
;
1688 as_warn (_("Size negative: .fill ignored."));
1691 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1693 if (rep_exp
.X_add_number
< 0)
1694 as_warn (_("Repeat < 0, .fill ignored"));
1698 if (size
&& !need_pass_2
)
1700 if (rep_exp
.X_op
== O_constant
)
1702 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1703 (relax_substateT
) 0, (symbolS
*) 0,
1704 (offsetT
) rep_exp
.X_add_number
,
1709 /* We don't have a constant repeat count, so we can't use
1710 rs_fill. We can get the same results out of rs_space,
1711 but its argument is in bytes, so we must multiply the
1712 repeat count by size. */
1715 rep_sym
= make_expr_symbol (&rep_exp
);
1718 expressionS size_exp
;
1719 size_exp
.X_op
= O_constant
;
1720 size_exp
.X_add_number
= size
;
1722 rep_exp
.X_op
= O_multiply
;
1723 rep_exp
.X_add_symbol
= rep_sym
;
1724 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1725 rep_exp
.X_add_number
= 0;
1726 rep_sym
= make_expr_symbol (&rep_exp
);
1729 p
= frag_var (rs_space
, (int) size
, (int) size
,
1730 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1732 memset (p
, 0, (unsigned int) size
);
1733 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1734 * flavoured AS. The following bizzare behaviour is to be
1735 * compatible with above. I guess they tried to take up to 8
1736 * bytes from a 4-byte expression and they forgot to sign
1737 * extend. Un*x Sux. */
1738 #define BSD_FILL_SIZE_CROCK_4 (4)
1739 md_number_to_chars (p
, (valueT
) fill
,
1740 (size
> BSD_FILL_SIZE_CROCK_4
1741 ? BSD_FILL_SIZE_CROCK_4
1743 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1744 * but emits no error message because it seems a legal thing to do.
1745 * It is a degenerate case of .fill but could be emitted by a compiler.
1748 demand_empty_rest_of_line ();
1762 stop
= mri_comment_field (&stopc
);
1766 name
= input_line_pointer
;
1767 c
= get_symbol_end ();
1768 symbolP
= symbol_find_or_make (name
);
1769 *input_line_pointer
= c
;
1771 S_SET_EXTERNAL (symbolP
);
1774 input_line_pointer
++;
1776 if (*input_line_pointer
== '\n')
1783 mri_comment_end (stop
, stopc
);
1785 demand_empty_rest_of_line ();
1788 /* Handle the MRI IRP and IRPC pseudo-ops. */
1800 as_where (&file
, &line
);
1803 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1804 sb_add_char (&s
, *input_line_pointer
++);
1808 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1810 as_bad_where (file
, line
, "%s", err
);
1814 input_scrub_include_sb (&out
, input_line_pointer
);
1816 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1819 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1820 the section to only be linked once. However, this is not supported
1821 by most object file formats. This takes an optional argument,
1822 which is what to do about duplicates. */
1828 enum linkonce_type type
;
1832 type
= LINKONCE_DISCARD
;
1834 if (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1839 s
= input_line_pointer
;
1840 c
= get_symbol_end ();
1841 if (strcasecmp (s
, "discard") == 0)
1842 type
= LINKONCE_DISCARD
;
1843 else if (strcasecmp (s
, "one_only") == 0)
1844 type
= LINKONCE_ONE_ONLY
;
1845 else if (strcasecmp (s
, "same_size") == 0)
1846 type
= LINKONCE_SAME_SIZE
;
1847 else if (strcasecmp (s
, "same_contents") == 0)
1848 type
= LINKONCE_SAME_CONTENTS
;
1850 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1852 *input_line_pointer
= c
;
1855 #ifdef obj_handle_link_once
1856 obj_handle_link_once (type
);
1857 #else /* ! defined (obj_handle_link_once) */
1858 #ifdef BFD_ASSEMBLER
1862 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1863 as_warn (_(".linkonce is not supported for this object file format"));
1865 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1866 flags
|= SEC_LINK_ONCE
;
1871 case LINKONCE_DISCARD
:
1872 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1874 case LINKONCE_ONE_ONLY
:
1875 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1877 case LINKONCE_SAME_SIZE
:
1878 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1880 case LINKONCE_SAME_CONTENTS
:
1881 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1884 if (! bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1885 as_bad (_("bfd_set_section_flags: %s"),
1886 bfd_errmsg (bfd_get_error ()));
1888 #else /* ! defined (BFD_ASSEMBLER) */
1889 as_warn (_(".linkonce is not supported for this object file format"));
1890 #endif /* ! defined (BFD_ASSEMBLER) */
1891 #endif /* ! defined (obj_handle_link_once) */
1893 demand_empty_rest_of_line ();
1897 s_lcomm_internal (needs_align
, bytes_p
)
1898 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1899 (alignment); 0 if it was an ".lcomm" (2 args only) */
1901 /* 1 if the alignment value should be interpreted as the byte boundary,
1902 rather than the power of 2. */
1905 register char *name
;
1909 register symbolS
*symbolP
;
1910 segT current_seg
= now_seg
;
1911 subsegT current_subseg
= now_subseg
;
1912 const int max_alignment
= 15;
1914 segT bss_seg
= bss_section
;
1916 name
= input_line_pointer
;
1917 c
= get_symbol_end ();
1918 p
= input_line_pointer
;
1922 /* Accept an optional comma after the name. The comma used to be
1923 required, but Irix 5 cc does not generate it. */
1924 if (*input_line_pointer
== ',')
1926 ++input_line_pointer
;
1930 if (*input_line_pointer
== '\n')
1932 as_bad (_("Missing size expression"));
1936 if ((temp
= get_absolute_expression ()) < 0)
1938 as_warn (_("BSS length (%d.) <0! Ignored."), temp
);
1939 ignore_rest_of_line ();
1943 #if defined (TC_MIPS) || defined (TC_ALPHA)
1944 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1945 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1947 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1948 if (temp
<= bfd_get_gp_size (stdoutput
))
1950 bss_seg
= subseg_new (".sbss", 1);
1951 seg_info (bss_seg
)->bss
= 1;
1952 #ifdef BFD_ASSEMBLER
1953 if (! bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
1954 as_warn (_("error setting flags for \".sbss\": %s"),
1955 bfd_errmsg (bfd_get_error ()));
1962 /* FIXME. This needs to be machine independent. */
1973 /* FIXME: This needs to be done in a more general fashion. */
1977 record_alignment(bss_seg
, align
);
1984 if (*input_line_pointer
!= ',')
1986 as_bad (_("Expected comma after size"));
1987 ignore_rest_of_line ();
1990 input_line_pointer
++;
1992 if (*input_line_pointer
== '\n')
1994 as_bad (_("Missing alignment"));
1997 align
= get_absolute_expression ();
2000 /* Convert to a power of 2. */
2005 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2008 as_bad (_("Alignment not a power of 2"));
2012 if (align
> max_alignment
)
2014 align
= max_alignment
;
2015 as_warn (_("Alignment too large: %d. assumed."), align
);
2020 as_warn (_("Alignment negative. 0 assumed."));
2022 record_alignment (bss_seg
, align
);
2023 } /* if needs align */
2026 /* Assume some objects may require alignment on some systems. */
2027 #if defined (TC_ALPHA) && ! defined (VMS)
2030 align
= ffs (temp
) - 1;
2031 if (temp
% (1 << align
))
2038 symbolP
= symbol_find_or_make (name
);
2042 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
2043 S_GET_OTHER (symbolP
) == 0 &&
2044 S_GET_DESC (symbolP
) == 0 &&
2045 #endif /* OBJ_AOUT or OBJ_BOUT */
2046 (S_GET_SEGMENT (symbolP
) == bss_seg
2047 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2051 subseg_set (bss_seg
, 1);
2054 frag_align (align
, 0, 0);
2055 /* detach from old frag */
2056 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2057 symbolP
->sy_frag
->fr_symbol
= NULL
;
2059 symbolP
->sy_frag
= frag_now
;
2060 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
)0, symbolP
,
2061 (offsetT
) temp
, (char *) 0);
2064 S_SET_SEGMENT (symbolP
, bss_seg
);
2067 /* The symbol may already have been created with a preceding
2068 ".globl" directive -- be careful not to step on storage class
2069 in that case. Otherwise, set it to static. */
2070 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2072 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2074 #endif /* OBJ_COFF */
2077 S_SET_SIZE (symbolP
, temp
);
2081 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
2082 S_GET_NAME (symbolP
));
2084 subseg_set (current_seg
, current_subseg
);
2086 demand_empty_rest_of_line ();
2087 } /* s_lcomm_internal() */
2090 s_lcomm (needs_align
)
2093 s_lcomm_internal (needs_align
, 0);
2096 void s_lcomm_bytes (needs_align
)
2099 s_lcomm_internal (needs_align
, 1);
2106 register char *name
;
2110 register symbolS
*symbolP
;
2112 /* we permit ANY defined expression: BSD4.2 demands constants */
2113 name
= input_line_pointer
;
2114 c
= get_symbol_end ();
2115 p
= input_line_pointer
;
2118 if (*input_line_pointer
!= ',')
2121 as_bad (_("Expected comma after name \"%s\""), name
);
2123 ignore_rest_of_line ();
2126 input_line_pointer
++;
2128 if (exp
.X_op
!= O_constant
2129 && exp
.X_op
!= O_register
)
2131 as_bad (_("bad expression"));
2132 ignore_rest_of_line ();
2136 symbolP
= symbol_find_or_make (name
);
2138 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2139 symbolP->sy_desc == 0) out of this test because coff doesn't have
2140 those fields, and I can't see when they'd ever be tripped. I
2141 don't think I understand why they were here so I may have
2142 introduced a bug. As recently as 1.37 didn't have this test
2143 anyway. xoxorich. */
2145 if (S_GET_SEGMENT (symbolP
) == undefined_section
2146 && S_GET_VALUE (symbolP
) == 0)
2148 /* The name might be an undefined .global symbol; be sure to
2149 keep the "external" bit. */
2150 S_SET_SEGMENT (symbolP
,
2151 (exp
.X_op
== O_constant
2154 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2158 as_bad (_("Symbol %s already defined"), name
);
2161 demand_empty_rest_of_line ();
2164 /* Read a line into an sb. */
2170 char quote1
, quote2
, inquote
;
2172 if (input_line_pointer
[-1] == '\n')
2173 bump_line_counters ();
2175 if (input_line_pointer
>= buffer_limit
)
2177 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2178 if (buffer_limit
== 0)
2182 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2183 code needs to be changed. */
2184 if (! flag_m68k_mri
)
2192 #ifdef LEX_IS_STRINGQUOTE
2197 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
2198 || (inquote
!= '\0' && *input_line_pointer
!= '\n'))
2200 if (inquote
== *input_line_pointer
)
2202 else if (inquote
== '\0')
2204 if (*input_line_pointer
== quote1
)
2206 else if (*input_line_pointer
== quote2
)
2209 sb_add_char (line
, *input_line_pointer
++);
2211 while (input_line_pointer
< buffer_limit
2212 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2214 if (input_line_pointer
[-1] == '\n')
2215 bump_line_counters ();
2216 ++input_line_pointer
;
2221 /* Define a macro. This is an interface to macro.c, which is shared
2222 between gas and gasp. */
2235 as_where (&file
, &line
);
2238 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
2239 sb_add_char (&s
, *input_line_pointer
++);
2242 if (line_label
!= NULL
)
2243 sb_add_string (&label
, S_GET_NAME (line_label
));
2245 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2247 as_bad_where (file
, line
, "%s", err
);
2250 if (line_label
!= NULL
)
2252 S_SET_SEGMENT (line_label
, undefined_section
);
2253 S_SET_VALUE (line_label
, 0);
2254 line_label
->sy_frag
= &zero_address_frag
;
2258 #ifdef NO_PSEUDO_DOT
2262 && hash_find (po_hash
, name
) != NULL
)
2265 && hash_find (po_hash
, name
+ 1) != NULL
))
2266 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2273 /* Handle the .mexit pseudo-op, which immediately exits a macro
2280 cond_exit_macro (macro_nest
);
2281 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2284 /* Switch in and out of MRI mode. */
2292 on
= get_absolute_expression ();
2293 old_flag
= flag_mri
;
2307 #ifdef MRI_MODE_CHANGE
2309 MRI_MODE_CHANGE (on
);
2312 demand_empty_rest_of_line ();
2315 /* Handle changing the location counter. */
2318 do_org (segment
, exp
, fill
)
2323 if (segment
!= now_seg
&& segment
!= absolute_section
)
2324 as_bad (_("invalid segment \"%s\"; segment \"%s\" assumed"),
2325 segment_name (segment
), segment_name (now_seg
));
2327 if (now_seg
== absolute_section
)
2330 as_warn (_("ignoring fill value in absolute section"));
2331 if (exp
->X_op
!= O_constant
)
2333 as_bad (_("only constant offsets supported in absolute section"));
2334 exp
->X_add_number
= 0;
2336 abs_section_offset
= exp
->X_add_number
;
2342 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
->X_add_symbol
,
2343 exp
->X_add_number
, (char *) NULL
);
2352 register segT segment
;
2354 register long temp_fill
;
2356 /* The m68k MRI assembler has a different meaning for .org. It
2357 means to create an absolute section at a given address. We can't
2358 support that--use a linker script instead. */
2361 as_bad (_("MRI style ORG pseudo-op not supported"));
2362 ignore_rest_of_line ();
2366 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2367 thing as a sub-segment-relative origin. Any absolute origin is
2368 given a warning, then assumed to be segment-relative. Any
2369 segmented origin expression ("foo+42") had better be in the right
2370 segment or the .org is ignored.
2372 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2373 we never know sub-segment sizes when we are reading code. BSD
2374 will crash trying to emit negative numbers of filler bytes in
2375 certain .orgs. We don't crash, but see as-write for that code.
2377 Don't make frag if need_pass_2==1. */
2378 segment
= get_known_segmented_expression (&exp
);
2379 if (*input_line_pointer
== ',')
2381 input_line_pointer
++;
2382 temp_fill
= get_absolute_expression ();
2388 do_org (segment
, &exp
, temp_fill
);
2390 demand_empty_rest_of_line ();
2393 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2394 called by the obj-format routine which handles section changing
2395 when in MRI mode. It will create a new section, and return it. It
2396 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2397 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2398 flags will be set in the section. */
2412 name
= input_line_pointer
;
2413 if (! isdigit ((unsigned char) *name
))
2414 c
= get_symbol_end ();
2419 ++input_line_pointer
;
2421 while (isdigit ((unsigned char) *input_line_pointer
));
2422 c
= *input_line_pointer
;
2423 *input_line_pointer
= '\0';
2426 name
= xstrdup (name
);
2428 *input_line_pointer
= c
;
2430 seg
= subseg_new (name
, 0);
2432 if (*input_line_pointer
== ',')
2436 ++input_line_pointer
;
2437 align
= get_absolute_expression ();
2438 record_alignment (seg
, align
);
2442 if (*input_line_pointer
== ',')
2444 c
= *++input_line_pointer
;
2445 c
= toupper ((unsigned char) c
);
2446 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2449 as_bad (_("unrecognized section type"));
2450 ++input_line_pointer
;
2452 #ifdef BFD_ASSEMBLER
2456 flags
= SEC_NO_FLAGS
;
2458 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2459 else if (*type
== 'D' || *type
== 'M')
2460 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2461 else if (*type
== 'R')
2462 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2463 if (flags
!= SEC_NO_FLAGS
)
2465 if (! bfd_set_section_flags (stdoutput
, seg
, flags
))
2466 as_warn (_("error setting flags for \"%s\": %s"),
2467 bfd_section_name (stdoutput
, seg
),
2468 bfd_errmsg (bfd_get_error ()));
2474 /* Ignore the HP type. */
2475 if (*input_line_pointer
== ',')
2476 input_line_pointer
+= 2;
2478 demand_empty_rest_of_line ();
2480 #else /* ! TC_M68K */
2489 name
= input_line_pointer
;
2490 c
= get_symbol_end ();
2492 name
= xstrdup (name
);
2494 *input_line_pointer
= c
;
2496 seg
= subseg_new (name
, 0);
2498 if (*input_line_pointer
!= ',')
2504 ++input_line_pointer
;
2506 sectype
= input_line_pointer
;
2507 c
= get_symbol_end ();
2508 if (*sectype
== '\0')
2510 else if (strcasecmp (sectype
, "text") == 0)
2512 else if (strcasecmp (sectype
, "data") == 0)
2514 else if (strcasecmp (sectype
, "romdata") == 0)
2517 as_warn (_("unrecognized section type `%s'"), sectype
);
2518 *input_line_pointer
= c
;
2521 if (*input_line_pointer
== ',')
2525 ++input_line_pointer
;
2527 seccmd
= input_line_pointer
;
2528 c
= get_symbol_end ();
2529 if (strcasecmp (seccmd
, "absolute") == 0)
2531 as_bad (_("absolute sections are not supported"));
2532 *input_line_pointer
= c
;
2533 ignore_rest_of_line ();
2536 else if (strcasecmp (seccmd
, "align") == 0)
2540 *input_line_pointer
= c
;
2541 align
= get_absolute_expression ();
2542 record_alignment (seg
, align
);
2546 as_warn (_("unrecognized section command `%s'"), seccmd
);
2547 *input_line_pointer
= c
;
2551 demand_empty_rest_of_line ();
2553 #else /* ! TC_I960 */
2554 /* The MRI assembler seems to use different forms of .sect for
2555 different targets. */
2556 as_bad ("MRI mode not supported for this target");
2557 ignore_rest_of_line ();
2558 #endif /* ! TC_I960 */
2559 #endif /* ! TC_M68K */
2562 /* Handle the .print pseudo-op. */
2571 s
= demand_copy_C_string (&len
);
2573 demand_empty_rest_of_line ();
2576 /* Handle the .purgem pseudo-op. */
2582 if (is_it_end_of_statement ())
2584 demand_empty_rest_of_line ();
2594 name
= input_line_pointer
;
2595 c
= get_symbol_end ();
2596 delete_macro (name
);
2597 *input_line_pointer
= c
;
2600 while (*input_line_pointer
++ == ',');
2602 --input_line_pointer
;
2603 demand_empty_rest_of_line ();
2606 /* Handle the .rept pseudo-op. */
2616 count
= get_absolute_expression ();
2619 if (! buffer_and_nest ("REPT", "ENDR", &one
, get_line_sb
))
2621 as_bad (_("rept without endr"));
2627 sb_add_sb (&many
, &one
);
2631 input_scrub_include_sb (&many
, input_line_pointer
);
2633 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2636 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2637 this is .equiv, and it is an error if the symbol is already
2644 register char *name
;
2645 register char delim
;
2646 register char *end_name
;
2647 register symbolS
*symbolP
;
2650 * Especial apologies for the random logic:
2651 * this just grew, and could be parsed much more simply!
2654 name
= input_line_pointer
;
2655 delim
= get_symbol_end ();
2656 end_name
= input_line_pointer
;
2660 if (*input_line_pointer
!= ',')
2663 as_bad (_("Expected comma after name \"%s\""), name
);
2665 ignore_rest_of_line ();
2669 input_line_pointer
++;
2672 if (name
[0] == '.' && name
[1] == '\0')
2674 /* Turn '. = mumble' into a .org mumble */
2675 register segT segment
;
2678 segment
= get_known_segmented_expression (&exp
);
2681 do_org (segment
, &exp
, 0);
2687 if ((symbolP
= symbol_find (name
)) == NULL
2688 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2691 /* When doing symbol listings, play games with dummy fragments living
2692 outside the normal fragment chain to record the file and line info
2694 if (listing
& LISTING_SYMBOLS
)
2696 extern struct list_info_struct
*listing_tail
;
2697 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof(fragS
));
2698 memset (dummy_frag
, 0, sizeof(fragS
));
2699 dummy_frag
->fr_type
= rs_fill
;
2700 dummy_frag
->line
= listing_tail
;
2701 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2702 dummy_frag
->fr_symbol
= symbolP
;
2706 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2709 /* "set" symbols are local unless otherwise specified. */
2710 SF_SET_LOCAL (symbolP
);
2711 #endif /* OBJ_COFF */
2713 } /* make a new symbol */
2715 symbol_table_insert (symbolP
);
2720 && S_IS_DEFINED (symbolP
)
2721 && S_GET_SEGMENT (symbolP
) != reg_section
)
2722 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
2724 pseudo_set (symbolP
);
2725 demand_empty_rest_of_line ();
2739 #ifdef md_flush_pending_output
2740 md_flush_pending_output ();
2744 stop
= mri_comment_field (&stopc
);
2746 /* In m68k MRI mode, we need to align to a word boundary, unless
2748 if (flag_m68k_mri
&& mult
> 1)
2750 if (now_seg
== absolute_section
)
2752 abs_section_offset
+= abs_section_offset
& 1;
2753 if (line_label
!= NULL
)
2754 S_SET_VALUE (line_label
, abs_section_offset
);
2756 else if (mri_common_symbol
!= NULL
)
2760 val
= S_GET_VALUE (mri_common_symbol
);
2763 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2764 if (line_label
!= NULL
)
2766 know (line_label
->sy_value
.X_op
== O_symbol
);
2767 know (line_label
->sy_value
.X_add_symbol
== mri_common_symbol
);
2768 line_label
->sy_value
.X_add_number
+= 1;
2774 do_align (1, (char *) NULL
, 0, 0);
2775 if (line_label
!= NULL
)
2777 line_label
->sy_frag
= frag_now
;
2778 S_SET_VALUE (line_label
, frag_now_fix ());
2788 if (*input_line_pointer
== ',')
2790 ++input_line_pointer
;
2795 val
.X_op
= O_constant
;
2796 val
.X_add_number
= 0;
2799 if (val
.X_op
!= O_constant
2800 || val
.X_add_number
< - 0x80
2801 || val
.X_add_number
> 0xff
2802 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2804 if (exp
.X_op
!= O_constant
)
2805 as_bad (_("Unsupported variable size or fill value"));
2812 bytes
= mult
* exp
.X_add_number
;
2813 for (i
= 0; i
< exp
.X_add_number
; i
++)
2814 emit_expr (&val
, mult
);
2819 if (exp
.X_op
== O_constant
)
2823 repeat
= exp
.X_add_number
;
2830 as_warn (_(".space repeat count is zero, ignored"));
2831 else if (repeat
< 0)
2832 as_warn (_(".space repeat count is negative, ignored"));
2836 /* If we are in the absolute section, just bump the offset. */
2837 if (now_seg
== absolute_section
)
2839 abs_section_offset
+= repeat
;
2843 /* If we are secretly in an MRI common section, then
2844 creating space just increases the size of the common
2846 if (mri_common_symbol
!= NULL
)
2848 S_SET_VALUE (mri_common_symbol
,
2849 S_GET_VALUE (mri_common_symbol
) + repeat
);
2854 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2855 (offsetT
) repeat
, (char *) 0);
2859 if (now_seg
== absolute_section
)
2861 as_bad (_("space allocation too complex in absolute section"));
2862 subseg_set (text_section
, 0);
2864 if (mri_common_symbol
!= NULL
)
2866 as_bad (_("space allocation too complex in common section"));
2867 mri_common_symbol
= NULL
;
2870 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2871 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
2875 *p
= val
.X_add_number
;
2880 /* In MRI mode, after an odd number of bytes, we must align to an
2881 even word boundary, unless the next instruction is a dc.b, ds.b
2883 if (flag_mri
&& (bytes
& 1) != 0)
2884 mri_pending_align
= 1;
2887 mri_comment_end (stop
, stopc
);
2889 demand_empty_rest_of_line ();
2892 /* This is like s_space, but the value is a floating point number with
2893 the given precision. This is for the MRI dcb.s pseudo-op and
2897 s_float_space (float_type
)
2902 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
2907 stop
= mri_comment_field (&stopc
);
2909 count
= get_absolute_expression ();
2912 if (*input_line_pointer
!= ',')
2914 as_bad (_("missing value"));
2916 mri_comment_end (stop
, stopc
);
2917 ignore_rest_of_line ();
2921 ++input_line_pointer
;
2925 /* Skip any 0{letter} that may be present. Don't even check if the
2926 * letter is legal. */
2927 if (input_line_pointer
[0] == '0'
2928 && isalpha ((unsigned char) input_line_pointer
[1]))
2929 input_line_pointer
+= 2;
2931 /* Accept :xxxx, where the x's are hex digits, for a floating point
2932 with the exact digits specified. */
2933 if (input_line_pointer
[0] == ':')
2935 flen
= hex_float (float_type
, temp
);
2939 mri_comment_end (stop
, stopc
);
2940 ignore_rest_of_line ();
2948 err
= md_atof (float_type
, temp
, &flen
);
2949 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
2953 as_bad (_("Bad floating literal: %s"), err
);
2955 mri_comment_end (stop
, stopc
);
2956 ignore_rest_of_line ();
2961 while (--count
>= 0)
2965 p
= frag_more (flen
);
2966 memcpy (p
, temp
, (unsigned int) flen
);
2970 mri_comment_end (stop
, stopc
);
2972 demand_empty_rest_of_line ();
2975 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
2985 stop
= mri_comment_field (&stopc
);
2986 abs_section_offset
= get_absolute_expression ();
2987 subseg_set (absolute_section
, 0);
2989 mri_comment_end (stop
, stopc
);
2990 demand_empty_rest_of_line ();
2999 temp
= get_absolute_expression ();
3000 subseg_set (text_section
, (subsegT
) temp
);
3001 demand_empty_rest_of_line ();
3003 const_flag
&= ~IN_DEFAULT_SECTION
;
3009 demand_empty_rest_of_line ()
3012 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3014 input_line_pointer
++;
3018 ignore_rest_of_line ();
3020 /* Return having already swallowed end-of-line. */
3021 } /* Return pointing just after end-of-line. */
3024 ignore_rest_of_line () /* For suspect lines: gives warning. */
3026 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3028 if (isprint ((unsigned char) *input_line_pointer
))
3029 as_bad (_("Rest of line ignored. First ignored character is `%c'."),
3030 *input_line_pointer
);
3032 as_bad (_("Rest of line ignored. First ignored character valued 0x%x."),
3033 *input_line_pointer
);
3034 while (input_line_pointer
< buffer_limit
3035 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3037 input_line_pointer
++;
3040 input_line_pointer
++; /* Return pointing just after end-of-line. */
3041 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3047 * In: Pointer to a symbol.
3048 * Input_line_pointer->expression.
3050 * Out: Input_line_pointer->just after any whitespace after expression.
3051 * Tried to set symbol to value of expression.
3052 * Will change symbols type, value, and frag;
3055 pseudo_set (symbolP
)
3059 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3061 #endif /* OBJ_AOUT or OBJ_BOUT */
3063 know (symbolP
); /* NULL pointer is logic error. */
3064 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3065 ext
= S_IS_EXTERNAL (symbolP
);
3066 #endif /* OBJ_AOUT or OBJ_BOUT */
3068 (void) expression (&exp
);
3070 if (exp
.X_op
== O_illegal
)
3071 as_bad (_("illegal expression; zero assumed"));
3072 else if (exp
.X_op
== O_absent
)
3073 as_bad (_("missing expression; zero assumed"));
3074 else if (exp
.X_op
== O_big
)
3076 if (exp
.X_add_number
> 0)
3077 as_bad (_("bignum invalid; zero assumed"));
3079 as_bad (_("floating point number invalid; zero assumed"));
3081 else if (exp
.X_op
== O_subtract
3082 && (S_GET_SEGMENT (exp
.X_add_symbol
)
3083 == S_GET_SEGMENT (exp
.X_op_symbol
))
3084 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3085 && exp
.X_add_symbol
->sy_frag
== exp
.X_op_symbol
->sy_frag
)
3087 exp
.X_op
= O_constant
;
3088 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3089 - S_GET_VALUE (exp
.X_op_symbol
));
3097 exp
.X_add_number
= 0;
3100 S_SET_SEGMENT (symbolP
, absolute_section
);
3101 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3103 S_SET_EXTERNAL (symbolP
);
3105 S_CLEAR_EXTERNAL (symbolP
);
3106 #endif /* OBJ_AOUT or OBJ_BOUT */
3107 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3108 if (exp
.X_op
!= O_constant
)
3109 symbolP
->sy_frag
= &zero_address_frag
;
3113 S_SET_SEGMENT (symbolP
, reg_section
);
3114 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3115 symbolP
->sy_frag
= &zero_address_frag
;
3119 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3120 || exp
.X_add_number
!= 0)
3121 symbolP
->sy_value
= exp
;
3124 symbolS
*s
= exp
.X_add_symbol
;
3126 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3127 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3129 S_SET_EXTERNAL (symbolP
);
3131 S_CLEAR_EXTERNAL (symbolP
);
3132 #endif /* OBJ_AOUT or OBJ_BOUT */
3133 S_SET_VALUE (symbolP
,
3134 exp
.X_add_number
+ S_GET_VALUE (s
));
3135 symbolP
->sy_frag
= s
->sy_frag
;
3136 copy_symbol_attributes (symbolP
, s
);
3141 /* The value is some complex expression.
3142 FIXME: Should we set the segment to anything? */
3143 symbolP
->sy_value
= exp
;
3151 * CONStruct more frag of .bytes, or .words etc.
3152 * Should need_pass_2 be 1 then emit no frag(s).
3153 * This understands EXPRESSIONS.
3157 * This has a split personality. We use expression() to read the
3158 * value. We can detect if the value won't fit in a byte or word.
3159 * But we can't detect if expression() discarded significant digits
3160 * in the case of a long. Not worth the crocks required to fix it.
3163 /* Select a parser for cons expressions. */
3165 /* Some targets need to parse the expression in various fancy ways.
3166 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3167 (for example, the HPPA does this). Otherwise, you can define
3168 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3169 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3170 are defined, which is the normal case, then only simple expressions
3174 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3176 #ifndef TC_PARSE_CONS_EXPRESSION
3177 #ifdef BITFIELD_CONS_EXPRESSIONS
3178 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3180 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3182 #ifdef REPEAT_CONS_EXPRESSIONS
3183 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3185 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3188 /* If we haven't gotten one yet, just call expression. */
3189 #ifndef TC_PARSE_CONS_EXPRESSION
3190 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3194 /* worker to do .byte etc statements */
3195 /* clobbers input_line_pointer, checks */
3198 cons_worker (nbytes
, rva
)
3199 register int nbytes
; /* 1=.byte, 2=.word, 4=.long */
3207 #ifdef md_flush_pending_output
3208 md_flush_pending_output ();
3212 stop
= mri_comment_field (&stopc
);
3214 if (is_it_end_of_statement ())
3217 mri_comment_end (stop
, stopc
);
3218 demand_empty_rest_of_line ();
3222 #ifdef md_cons_align
3223 md_cons_align (nbytes
);
3230 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3232 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3236 if (exp
.X_op
== O_symbol
)
3237 exp
.X_op
= O_symbol_rva
;
3239 as_fatal (_("rva without symbol"));
3241 emit_expr (&exp
, (unsigned int) nbytes
);
3244 while (*input_line_pointer
++ == ',');
3246 /* In MRI mode, after an odd number of bytes, we must align to an
3247 even word boundary, unless the next instruction is a dc.b, ds.b
3249 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3250 mri_pending_align
= 1;
3252 input_line_pointer
--; /* Put terminator back into stream. */
3255 mri_comment_end (stop
, stopc
);
3257 demand_empty_rest_of_line ();
3265 cons_worker (size
, 0);
3272 cons_worker (size
, 1);
3275 /* Put the contents of expression EXP into the object file using
3276 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3279 emit_expr (exp
, nbytes
)
3281 unsigned int nbytes
;
3285 valueT extra_digit
= 0;
3287 /* Don't do anything if we are going to make another pass. */
3293 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3294 appear as a four byte positive constant in the .line section,
3295 followed by a 2 byte 0xffff. Look for that case here. */
3297 static int dwarf_line
= -1;
3299 if (strcmp (segment_name (now_seg
), ".line") != 0)
3301 else if (dwarf_line
>= 0
3303 && exp
->X_op
== O_constant
3304 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3305 listing_source_line ((unsigned int) dwarf_line
);
3306 else if (nbytes
== 4
3307 && exp
->X_op
== O_constant
3308 && exp
->X_add_number
>= 0)
3309 dwarf_line
= exp
->X_add_number
;
3314 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3315 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3316 AT_sibling (0x12) followed by a four byte address of the sibling
3317 followed by a 2 byte AT_name (0x38) followed by the name of the
3318 file. We look for that case here. */
3320 static int dwarf_file
= 0;
3322 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3324 else if (dwarf_file
== 0
3326 && exp
->X_op
== O_constant
3327 && exp
->X_add_number
== 0x11)
3329 else if (dwarf_file
== 1
3331 && exp
->X_op
== O_constant
3332 && exp
->X_add_number
== 0x12)
3334 else if (dwarf_file
== 2
3337 else if (dwarf_file
== 3
3339 && exp
->X_op
== O_constant
3340 && exp
->X_add_number
== 0x38)
3345 /* The variable dwarf_file_string tells stringer that the string
3346 may be the name of the source file. */
3347 if (dwarf_file
== 4)
3348 dwarf_file_string
= 1;
3350 dwarf_file_string
= 0;
3355 if (check_eh_frame (exp
, &nbytes
))
3360 /* Allow `.word 0' in the absolute section. */
3361 if (now_seg
== absolute_section
)
3363 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3364 as_bad (_("attempt to store value in absolute section"));
3365 abs_section_offset
+= nbytes
;
3369 /* Handle a negative bignum. */
3371 && exp
->X_add_number
== 0
3372 && exp
->X_add_symbol
->sy_value
.X_op
== O_big
3373 && exp
->X_add_symbol
->sy_value
.X_add_number
> 0)
3376 unsigned long carry
;
3378 exp
= &exp
->X_add_symbol
->sy_value
;
3380 /* Negate the bignum: one's complement each digit and add 1. */
3382 for (i
= 0; i
< exp
->X_add_number
; i
++)
3386 next
= (((~ (generic_bignum
[i
] & LITTLENUM_MASK
))
3389 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3390 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3393 /* We can ignore any carry out, because it will be handled by
3394 extra_digit if it is needed. */
3396 extra_digit
= (valueT
) -1;
3400 if (op
== O_absent
|| op
== O_illegal
)
3402 as_warn (_("zero assumed for missing expression"));
3403 exp
->X_add_number
= 0;
3406 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3408 as_bad (_("floating point number invalid; zero assumed"));
3409 exp
->X_add_number
= 0;
3412 else if (op
== O_register
)
3414 as_warn (_("register value used as expression"));
3418 p
= frag_more ((int) nbytes
);
3420 #ifndef WORKING_DOT_WORD
3421 /* If we have the difference of two symbols in a word, save it on
3422 the broken_words list. See the code in write.c. */
3423 if (op
== O_subtract
&& nbytes
== 2)
3425 struct broken_word
*x
;
3427 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3428 x
->next_broken_word
= broken_words
;
3431 x
->word_goes_here
= p
;
3433 x
->add
= exp
->X_add_symbol
;
3434 x
->sub
= exp
->X_op_symbol
;
3435 x
->addnum
= exp
->X_add_number
;
3442 /* If we have an integer, but the number of bytes is too large to
3443 pass to md_number_to_chars, handle it as a bignum. */
3444 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3449 if (! exp
->X_unsigned
&& exp
->X_add_number
< 0)
3450 extra_digit
= (valueT
) -1;
3451 val
= (valueT
) exp
->X_add_number
;
3455 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3456 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3460 op
= exp
->X_op
= O_big
;
3461 exp
->X_add_number
= gencnt
;
3464 if (op
== O_constant
)
3466 register valueT get
;
3467 register valueT use
;
3468 register valueT mask
;
3470 register valueT unmask
;
3472 /* JF << of >= number of bits in the object is undefined. In
3473 particular SPARC (Sun 4) has problems */
3474 if (nbytes
>= sizeof (valueT
))
3477 if (nbytes
> sizeof (valueT
))
3480 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3484 /* Don't store these bits. */
3485 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3486 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3489 unmask
= ~mask
; /* Do store these bits. */
3492 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3493 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3496 get
= exp
->X_add_number
;
3498 if ((get
& mask
) != 0
3499 && ((get
& mask
) != mask
3500 || (get
& hibit
) == 0))
3501 { /* Leading bits contain both 0s & 1s. */
3502 as_warn (_("Value 0x%lx truncated to 0x%lx."),
3503 (unsigned long) get
, (unsigned long) use
);
3505 /* put bytes in right order. */
3506 md_number_to_chars (p
, use
, (int) nbytes
);
3508 else if (op
== O_big
)
3511 LITTLENUM_TYPE
*nums
;
3513 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3515 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3518 as_warn (_("Bignum truncated to %d bytes"), nbytes
);
3522 if (target_big_endian
)
3524 while (nbytes
> size
)
3526 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3527 nbytes
-= CHARS_PER_LITTLENUM
;
3528 p
+= CHARS_PER_LITTLENUM
;
3531 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3535 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3536 size
-= CHARS_PER_LITTLENUM
;
3537 p
+= CHARS_PER_LITTLENUM
;
3542 nums
= generic_bignum
;
3545 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3547 size
-= CHARS_PER_LITTLENUM
;
3548 p
+= CHARS_PER_LITTLENUM
;
3549 nbytes
-= CHARS_PER_LITTLENUM
;
3554 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3555 nbytes
-= CHARS_PER_LITTLENUM
;
3556 p
+= CHARS_PER_LITTLENUM
;
3562 memset (p
, 0, nbytes
);
3564 /* Now we need to generate a fixS to record the symbol value.
3565 This is easy for BFD. For other targets it can be more
3566 complex. For very complex cases (currently, the HPPA and
3567 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3568 want. For simpler cases, you can define TC_CONS_RELOC to be
3569 the name of the reloc code that should be stored in the fixS.
3570 If neither is defined, the code uses NO_RELOC if it is
3571 defined, and otherwise uses 0. */
3573 #ifdef BFD_ASSEMBLER
3574 #ifdef TC_CONS_FIX_NEW
3575 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3578 bfd_reloc_code_real_type r
;
3595 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3599 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3604 #ifdef TC_CONS_FIX_NEW
3605 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3607 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3608 it is defined, otherwise use NO_RELOC if it is defined,
3610 #ifndef TC_CONS_RELOC
3612 #define TC_CONS_RELOC NO_RELOC
3614 #define TC_CONS_RELOC 0
3617 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3619 #endif /* TC_CONS_FIX_NEW */
3620 #endif /* BFD_ASSEMBLER */
3624 #ifdef BITFIELD_CONS_EXPRESSIONS
3626 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3627 w:x,y:z, where w and y are bitwidths and x and y are values. They
3628 then pack them all together. We do a little better in that we allow
3629 them in words, longs, etc. and we'll pack them in target byte order
3632 The rules are: pack least significat bit first, if a field doesn't
3633 entirely fit, put it in the next unit. Overflowing the bitfield is
3634 explicitly *not* even a warning. The bitwidth should be considered
3637 To use this function the tc-XXX.h file should define
3638 BITFIELD_CONS_EXPRESSIONS. */
3641 parse_bitfield_cons (exp
, nbytes
)
3643 unsigned int nbytes
;
3645 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3646 char *hold
= input_line_pointer
;
3648 (void) expression (exp
);
3650 if (*input_line_pointer
== ':')
3656 unsigned long width
;
3658 if (*input_line_pointer
!= ':')
3660 input_line_pointer
= hold
;
3662 } /* next piece is not a bitfield */
3664 /* In the general case, we can't allow
3665 full expressions with symbol
3666 differences and such. The relocation
3667 entries for symbols not defined in this
3668 assembly would require arbitrary field
3669 widths, positions, and masks which most
3670 of our current object formats don't
3673 In the specific case where a symbol
3674 *is* defined in this assembly, we
3675 *could* build fixups and track it, but
3676 this could lead to confusion for the
3677 backends. I'm lazy. I'll take any
3678 SEG_ABSOLUTE. I think that means that
3679 you can use a previous .set or
3680 .equ type symbol. xoxorich. */
3682 if (exp
->X_op
== O_absent
)
3684 as_warn (_("using a bit field width of zero"));
3685 exp
->X_add_number
= 0;
3686 exp
->X_op
= O_constant
;
3687 } /* implied zero width bitfield */
3689 if (exp
->X_op
!= O_constant
)
3691 *input_line_pointer
= '\0';
3692 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3693 *input_line_pointer
= ':';
3694 demand_empty_rest_of_line ();
3698 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3700 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3701 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3702 width
= BITS_PER_CHAR
* nbytes
;
3705 if (width
> bits_available
)
3707 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3708 input_line_pointer
= hold
;
3709 exp
->X_add_number
= value
;
3713 hold
= ++input_line_pointer
; /* skip ':' */
3715 (void) expression (exp
);
3716 if (exp
->X_op
!= O_constant
)
3718 char cache
= *input_line_pointer
;
3720 *input_line_pointer
= '\0';
3721 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3722 *input_line_pointer
= cache
;
3723 demand_empty_rest_of_line ();
3727 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3728 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3730 if ((bits_available
-= width
) == 0
3731 || is_it_end_of_statement ()
3732 || *input_line_pointer
!= ',')
3735 } /* all the bitfields we're gonna get */
3737 hold
= ++input_line_pointer
;
3738 (void) expression (exp
);
3739 } /* forever loop */
3741 exp
->X_add_number
= value
;
3742 exp
->X_op
= O_constant
;
3743 exp
->X_unsigned
= 1;
3744 } /* if looks like a bitfield */
3745 } /* parse_bitfield_cons() */
3747 #endif /* BITFIELD_CONS_EXPRESSIONS */
3749 /* Handle an MRI style string expression. */
3752 parse_mri_cons (exp
, nbytes
)
3754 unsigned int nbytes
;
3756 if (*input_line_pointer
!= '\''
3757 && (input_line_pointer
[1] != '\''
3758 || (*input_line_pointer
!= 'A'
3759 && *input_line_pointer
!= 'E')))
3760 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3764 unsigned int result
= 0;
3766 /* An MRI style string. Cut into as many bytes as will fit into
3767 a nbyte chunk, left justify if necessary, and separate with
3768 commas so we can try again later. */
3769 if (*input_line_pointer
== 'A')
3770 ++input_line_pointer
;
3771 else if (*input_line_pointer
== 'E')
3773 as_bad (_("EBCDIC constants are not supported"));
3774 ++input_line_pointer
;
3777 input_line_pointer
++;
3778 for (scan
= 0; scan
< nbytes
; scan
++)
3780 if (*input_line_pointer
== '\'')
3782 if (input_line_pointer
[1] == '\'')
3784 input_line_pointer
++;
3789 result
= (result
<< 8) | (*input_line_pointer
++);
3793 while (scan
< nbytes
)
3798 /* Create correct expression */
3799 exp
->X_op
= O_constant
;
3800 exp
->X_add_number
= result
;
3801 /* Fake it so that we can read the next char too */
3802 if (input_line_pointer
[0] != '\'' ||
3803 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3805 input_line_pointer
-= 2;
3806 input_line_pointer
[0] = ',';
3807 input_line_pointer
[1] = '\'';
3810 input_line_pointer
++;
3814 #ifdef REPEAT_CONS_EXPRESSIONS
3816 /* Parse a repeat expression for cons. This is used by the MIPS
3817 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3818 object file COUNT times.
3820 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3823 parse_repeat_cons (exp
, nbytes
)
3825 unsigned int nbytes
;
3832 if (*input_line_pointer
!= ':')
3834 /* No repeat count. */
3838 ++input_line_pointer
;
3839 expression (&count
);
3840 if (count
.X_op
!= O_constant
3841 || count
.X_add_number
<= 0)
3843 as_warn (_("Unresolvable or nonpositive repeat count; using 1"));
3847 /* The cons function is going to output this expression once. So we
3848 output it count - 1 times. */
3849 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3850 emit_expr (exp
, nbytes
);
3853 #endif /* REPEAT_CONS_EXPRESSIONS */
3855 /* Parse a floating point number represented as a hex constant. This
3856 permits users to specify the exact bits they want in the floating
3860 hex_float (float_type
, bytes
)
3894 as_bad (_("Unknown floating type type '%c'"), float_type
);
3898 /* It would be nice if we could go through expression to parse the
3899 hex constant, but if we get a bignum it's a pain to sort it into
3900 the buffer correctly. */
3902 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
3906 /* The MRI assembler accepts arbitrary underscores strewn about
3907 through the hex constant, so we ignore them as well. */
3908 if (*input_line_pointer
== '_')
3910 ++input_line_pointer
;
3916 as_warn (_("Floating point constant too large"));
3919 d
= hex_value (*input_line_pointer
) << 4;
3920 ++input_line_pointer
;
3921 while (*input_line_pointer
== '_')
3922 ++input_line_pointer
;
3923 if (hex_p (*input_line_pointer
))
3925 d
+= hex_value (*input_line_pointer
);
3926 ++input_line_pointer
;
3928 if (target_big_endian
)
3931 bytes
[length
- i
- 1] = d
;
3937 if (target_big_endian
)
3938 memset (bytes
+ i
, 0, length
- i
);
3940 memset (bytes
, 0, length
- i
);
3949 * CONStruct some more frag chars of .floats .ffloats etc.
3950 * Makes 0 or more new frags.
3951 * If need_pass_2 == 1, no frags are emitted.
3952 * This understands only floating literals, not expressions. Sorry.
3954 * A floating constant is defined by atof_generic(), except it is preceded
3955 * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
3956 * reading, I decided to be incompatible. This always tries to give you
3957 * rounded bits to the precision of the pseudo-op. Former AS did premature
3958 * truncatation, restored noisy bits instead of trailing 0s AND gave you
3959 * a choice of 2 flavours of noise according to which of 2 floating-point
3960 * scanners you directed AS to use.
3962 * In: input_line_pointer->whitespace before, or '0' of flonum.
3967 float_cons (float_type
)
3968 /* Clobbers input_line-pointer, checks end-of-line. */
3969 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
3972 int length
; /* Number of chars in an object. */
3973 register char *err
; /* Error from scanning floating literal. */
3974 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
3976 if (is_it_end_of_statement ())
3978 demand_empty_rest_of_line ();
3982 #ifdef md_flush_pending_output
3983 md_flush_pending_output ();
3988 /* input_line_pointer->1st char of a flonum (we hope!). */
3991 /* Skip any 0{letter} that may be present. Don't even check if the
3992 * letter is legal. Someone may invent a "z" format and this routine
3993 * has no use for such information. Lusers beware: you get
3994 * diagnostics if your input is ill-conditioned.
3996 if (input_line_pointer
[0] == '0'
3997 && isalpha ((unsigned char) input_line_pointer
[1]))
3998 input_line_pointer
+= 2;
4000 /* Accept :xxxx, where the x's are hex digits, for a floating
4001 point with the exact digits specified. */
4002 if (input_line_pointer
[0] == ':')
4004 ++input_line_pointer
;
4005 length
= hex_float (float_type
, temp
);
4008 ignore_rest_of_line ();
4014 err
= md_atof (float_type
, temp
, &length
);
4015 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4019 as_bad (_("Bad floating literal: %s"), err
);
4020 ignore_rest_of_line ();
4031 #ifdef REPEAT_CONS_EXPRESSIONS
4032 if (*input_line_pointer
== ':')
4034 expressionS count_exp
;
4036 ++input_line_pointer
;
4037 expression (&count_exp
);
4038 if (count_exp
.X_op
!= O_constant
4039 || count_exp
.X_add_number
<= 0)
4041 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4044 count
= count_exp
.X_add_number
;
4048 while (--count
>= 0)
4050 p
= frag_more (length
);
4051 memcpy (p
, temp
, (unsigned int) length
);
4056 while (*input_line_pointer
++ == ',');
4058 --input_line_pointer
; /* Put terminator back into stream. */
4059 demand_empty_rest_of_line ();
4060 } /* float_cons() */
4062 /* Return the size of a LEB128 value */
4065 sizeof_sleb128 (value
)
4068 register int size
= 0;
4069 register unsigned byte
;
4073 byte
= (value
& 0x7f);
4074 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4075 Fortunately, we can structure things so that the extra work reduces
4076 to a noop on systems that do things "properly". */
4077 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4080 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4081 || ((value
== -1) && ((byte
& 0x40) != 0))));
4087 sizeof_uleb128 (value
)
4090 register int size
= 0;
4091 register unsigned byte
;
4095 byte
= (value
& 0x7f);
4105 sizeof_leb128 (value
, sign
)
4110 return sizeof_sleb128 ((offsetT
) value
);
4112 return sizeof_uleb128 (value
);
4115 /* Output a LEB128 value. */
4118 output_sleb128 (p
, value
)
4122 register char *orig
= p
;
4127 unsigned byte
= (value
& 0x7f);
4129 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4130 Fortunately, we can structure things so that the extra work reduces
4131 to a noop on systems that do things "properly". */
4132 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4134 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4135 || ((value
== -1) && ((byte
& 0x40) != 0))));
4147 output_uleb128 (p
, value
)
4155 unsigned byte
= (value
& 0x7f);
4158 /* More bytes to follow. */
4169 output_leb128 (p
, value
, sign
)
4175 return output_sleb128 (p
, (offsetT
) value
);
4177 return output_uleb128 (p
, value
);
4180 /* Do the same for bignums. We combine sizeof with output here in that
4181 we don't output for NULL values of P. It isn't really as critical as
4182 for "normal" values that this be streamlined. */
4185 output_big_sleb128 (p
, bignum
, size
)
4187 LITTLENUM_TYPE
*bignum
;
4195 /* Strip leading sign extensions off the bignum. */
4196 while (size
> 0 && bignum
[size
-1] == (LITTLENUM_TYPE
)-1)
4201 if (loaded
< 7 && size
> 0)
4203 val
|= (*bignum
<< loaded
);
4204 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4215 if ((val
== 0 && (byte
& 0x40) == 0)
4216 || (~(val
| ~(((valueT
)1 << loaded
) - 1)) == 0
4217 && (byte
& 0x40) != 0))
4225 while (byte
& 0x80);
4231 output_big_uleb128 (p
, bignum
, size
)
4233 LITTLENUM_TYPE
*bignum
;
4241 /* Strip leading zeros off the bignum. */
4242 /* XXX: Is this needed? */
4243 while (size
> 0 && bignum
[size
-1] == 0)
4248 if (loaded
< 7 && size
> 0)
4250 val
|= (*bignum
<< loaded
);
4251 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4260 if (size
> 0 || val
)
4267 while (byte
& 0x80);
4273 output_big_leb128 (p
, bignum
, size
, sign
)
4275 LITTLENUM_TYPE
*bignum
;
4279 return output_big_sleb128 (p
, bignum
, size
);
4281 return output_big_uleb128 (p
, bignum
, size
);
4284 /* Generate the appropriate fragments for a given expression to emit a
4288 emit_leb128_expr(exp
, sign
)
4292 operatorT op
= exp
->X_op
;
4294 if (op
== O_absent
|| op
== O_illegal
)
4296 as_warn (_("zero assumed for missing expression"));
4297 exp
->X_add_number
= 0;
4300 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4302 as_bad (_("floating point number invalid; zero assumed"));
4303 exp
->X_add_number
= 0;
4306 else if (op
== O_register
)
4308 as_warn (_("register value used as expression"));
4312 if (op
== O_constant
)
4314 /* If we've got a constant, emit the thing directly right now. */
4316 valueT value
= exp
->X_add_number
;
4320 size
= sizeof_leb128 (value
, sign
);
4321 p
= frag_more (size
);
4322 output_leb128 (p
, value
, sign
);
4324 else if (op
== O_big
)
4326 /* O_big is a different sort of constant. */
4331 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4332 p
= frag_more (size
);
4333 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4337 /* Otherwise, we have to create a variable sized fragment and
4338 resolve things later. */
4340 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
)0), 0, sign
,
4341 make_expr_symbol (exp
), 0, (char *) NULL
);
4345 /* Parse the .sleb128 and .uleb128 pseudos. */
4355 emit_leb128_expr (&exp
, sign
);
4356 } while (*input_line_pointer
++ == ',');
4358 input_line_pointer
--;
4359 demand_empty_rest_of_line ();
4365 * We read 0 or more ',' seperated, double-quoted strings.
4367 * Caller should have checked need_pass_2 is FALSE because we don't check it.
4372 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4373 /* Checks end-of-line. */
4374 register int append_zero
; /* 0: don't append '\0', else 1 */
4376 register unsigned int c
;
4379 #ifdef md_flush_pending_output
4380 md_flush_pending_output ();
4384 * The following awkward logic is to parse ZERO or more strings,
4385 * comma seperated. Recall a string expression includes spaces
4386 * before the opening '\"' and spaces after the closing '\"'.
4387 * We fake a leading ',' if there is (supposed to be)
4388 * a 1st, expression. We keep demanding expressions for each
4391 if (is_it_end_of_statement ())
4393 c
= 0; /* Skip loop. */
4394 ++input_line_pointer
; /* Compensate for end of loop. */
4398 c
= ','; /* Do loop. */
4400 while (c
== ',' || c
== '<' || c
== '"')
4403 switch (*input_line_pointer
)
4406 ++input_line_pointer
; /*->1st char of string. */
4407 start
= input_line_pointer
;
4408 while (is_a_char (c
= next_char_of_string ()))
4410 FRAG_APPEND_1_CHAR (c
);
4414 FRAG_APPEND_1_CHAR (0);
4416 know (input_line_pointer
[-1] == '\"');
4420 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4421 will emit .string with a filename in the .debug section
4422 after a sequence of constants. See the comment in
4423 emit_expr for the sequence. emit_expr will set
4424 dwarf_file_string to non-zero if this string might be a
4425 source file name. */
4426 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4427 dwarf_file_string
= 0;
4428 else if (dwarf_file_string
)
4430 c
= input_line_pointer
[-1];
4431 input_line_pointer
[-1] = '\0';
4432 listing_source_file (start
);
4433 input_line_pointer
[-1] = c
;
4440 input_line_pointer
++;
4441 c
= get_single_number ();
4442 FRAG_APPEND_1_CHAR (c
);
4443 if (*input_line_pointer
!= '>')
4445 as_bad (_("Expected <nn>"));
4447 input_line_pointer
++;
4450 input_line_pointer
++;
4454 c
= *input_line_pointer
;
4457 demand_empty_rest_of_line ();
4460 /* FIXME-SOMEDAY: I had trouble here on characters with the
4461 high bits set. We'll probably also have trouble with
4462 multibyte chars, wide chars, etc. Also be careful about
4463 returning values bigger than 1 byte. xoxorich. */
4466 next_char_of_string ()
4468 register unsigned int c
;
4470 c
= *input_line_pointer
++ & CHAR_MASK
;
4478 as_warn (_("Unterminated string: Newline inserted."));
4479 bump_line_counters ();
4482 #ifndef NO_STRING_ESCAPES
4484 switch (c
= *input_line_pointer
++)
4512 break; /* As itself. */
4528 for (i
= 0, number
= 0; isdigit (c
) && i
< 3; c
= *input_line_pointer
++, i
++)
4530 number
= number
* 8 + c
- '0';
4534 --input_line_pointer
;
4543 c
= *input_line_pointer
++;
4544 while (isxdigit (c
))
4547 number
= number
* 16 + c
- '0';
4548 else if (isupper (c
))
4549 number
= number
* 16 + c
- 'A' + 10;
4551 number
= number
* 16 + c
- 'a' + 10;
4552 c
= *input_line_pointer
++;
4555 --input_line_pointer
;
4560 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4561 as_warn (_("Unterminated string: Newline inserted."));
4563 bump_line_counters ();
4568 #ifdef ONLY_STANDARD_ESCAPES
4569 as_bad (_("Bad escaped character in string, '?' assumed"));
4571 #endif /* ONLY_STANDARD_ESCAPES */
4574 } /* switch on escaped char */
4576 #endif /* ! defined (NO_STRING_ESCAPES) */
4580 } /* switch on char */
4582 } /* next_char_of_string() */
4585 get_segmented_expression (expP
)
4586 register expressionS
*expP
;
4588 register segT retval
;
4590 retval
= expression (expP
);
4591 if (expP
->X_op
== O_illegal
4592 || expP
->X_op
== O_absent
4593 || expP
->X_op
== O_big
)
4595 as_bad (_("expected address expression; zero assumed"));
4596 expP
->X_op
= O_constant
;
4597 expP
->X_add_number
= 0;
4598 retval
= absolute_section
;
4604 get_known_segmented_expression (expP
)
4605 register expressionS
*expP
;
4607 register segT retval
;
4609 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4611 /* There is no easy way to extract the undefined symbol from the
4613 if (expP
->X_add_symbol
!= NULL
4614 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4615 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4616 S_GET_NAME (expP
->X_add_symbol
));
4618 as_warn (_("some symbol undefined; zero assumed"));
4619 retval
= absolute_section
;
4620 expP
->X_op
= O_constant
;
4621 expP
->X_add_number
= 0;
4623 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4625 } /* get_known_segmented_expression() */
4628 get_absolute_expression ()
4633 if (exp
.X_op
!= O_constant
)
4635 if (exp
.X_op
!= O_absent
)
4636 as_bad (_("bad or irreducible absolute expression; zero assumed"));
4637 exp
.X_add_number
= 0;
4639 return exp
.X_add_number
;
4642 char /* return terminator */
4643 get_absolute_expression_and_terminator (val_pointer
)
4644 long *val_pointer
; /* return value of expression */
4646 /* FIXME: val_pointer should probably be offsetT *. */
4647 *val_pointer
= (long) get_absolute_expression ();
4648 return (*input_line_pointer
++);
4652 * demand_copy_C_string()
4654 * Like demand_copy_string, but return NULL if the string contains any '\0's.
4655 * Give a warning if that happens.
4658 demand_copy_C_string (len_pointer
)
4663 if ((s
= demand_copy_string (len_pointer
)) != 0)
4667 for (len
= *len_pointer
; len
> 0; len
--)
4674 as_bad (_("This string may not contain \'\\0\'"));
4682 * demand_copy_string()
4684 * Demand string, but return a safe (=private) copy of the string.
4685 * Return NULL if we can't read a string here.
4688 demand_copy_string (lenP
)
4691 register unsigned int c
;
4697 if (*input_line_pointer
== '\"')
4699 input_line_pointer
++; /* Skip opening quote. */
4701 while (is_a_char (c
= next_char_of_string ()))
4703 obstack_1grow (¬es
, c
);
4706 /* JF this next line is so demand_copy_C_string will return a
4707 null terminated string. */
4708 obstack_1grow (¬es
, '\0');
4709 retval
= obstack_finish (¬es
);
4713 as_warn (_("Missing string"));
4715 ignore_rest_of_line ();
4719 } /* demand_copy_string() */
4722 * is_it_end_of_statement()
4724 * In: Input_line_pointer->next character.
4726 * Do: Skip input_line_pointer over all whitespace.
4728 * Out: 1 if input_line_pointer->end-of-line.
4731 is_it_end_of_statement ()
4734 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4735 } /* is_it_end_of_statement() */
4738 equals (sym_name
, reassign
)
4742 register symbolS
*symbolP
; /* symbol we are working with */
4746 input_line_pointer
++;
4747 if (*input_line_pointer
== '=')
4748 input_line_pointer
++;
4750 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4751 input_line_pointer
++;
4754 stop
= mri_comment_field (&stopc
);
4756 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4758 /* Turn '. = mumble' into a .org mumble */
4759 register segT segment
;
4762 segment
= get_known_segmented_expression (&exp
);
4764 do_org (segment
, &exp
, 0);
4768 symbolP
= symbol_find_or_make (sym_name
);
4769 /* Permit register names to be redefined. */
4771 && S_IS_DEFINED (symbolP
)
4772 && S_GET_SEGMENT (symbolP
) != reg_section
)
4773 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
4774 pseudo_set (symbolP
);
4778 mri_comment_end (stop
, stopc
);
4781 /* .include -- include a file at this point. */
4794 if (! flag_m68k_mri
)
4796 filename
= demand_copy_string (&i
);
4797 if (filename
== NULL
)
4799 /* demand_copy_string has already printed an error and
4800 called ignore_rest_of_line. */
4808 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
4809 && *input_line_pointer
!= ' '
4810 && *input_line_pointer
!= '\t')
4812 obstack_1grow (¬es
, *input_line_pointer
);
4813 ++input_line_pointer
;
4816 obstack_1grow (¬es
, '\0');
4817 filename
= obstack_finish (¬es
);
4818 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
4819 ++input_line_pointer
;
4821 demand_empty_rest_of_line ();
4822 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
4823 for (i
= 0; i
< include_dir_count
; i
++)
4825 strcpy (path
, include_dirs
[i
]);
4827 strcat (path
, filename
);
4828 if (0 != (try = fopen (path
, "r")))
4837 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
4838 register_dependency (path
);
4839 newbuf
= input_scrub_include_file (path
, input_line_pointer
);
4840 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
4844 add_include_dir (path
)
4849 if (include_dir_count
== 0)
4851 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
4852 include_dirs
[0] = "."; /* Current dir */
4853 include_dir_count
= 2;
4857 include_dir_count
++;
4858 include_dirs
= (char **) realloc (include_dirs
,
4859 include_dir_count
* sizeof (*include_dirs
));
4862 include_dirs
[include_dir_count
- 1] = path
; /* New one */
4865 if (i
> include_dir_maxlen
)
4866 include_dir_maxlen
= i
;
4867 } /* add_include_dir() */
4869 /* Output debugging information to denote the source file. */
4872 generate_file_debug ()
4874 if (debug_type
== DEBUG_STABS
)
4875 stabs_generate_asm_file ();
4878 /* Output line number debugging information for the current source line. */
4881 generate_lineno_debug ()
4883 if (debug_type
== DEBUG_STABS
)
4884 stabs_generate_asm_lineno ();
4886 #ifdef OBJ_GENERATE_ASM_LINENO
4887 #ifdef ECOFF_DEBUGGING
4888 /* ECOFF assemblers automatically generate
4889 debugging information. FIXME: This should
4890 probably be handled elsewhere. */
4891 if (debug_type
== DEBUG_NONE
)
4893 if (ecoff_no_current_file ())
4894 debug_type
= DEBUG_ECOFF
;
4897 if (debug_type
== DEBUG_ECOFF
)
4899 unsigned int lineno
;
4902 as_where (&s
, &lineno
);
4903 OBJ_GENERATE_ASM_LINENO (s
, lineno
);
4913 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
4915 ++input_line_pointer
;
4917 ++input_line_pointer
;
4922 read_print_statistics (file
)
4925 hash_print_statistics (file
, "pseudo-op table", po_hash
);