1 /* read.c - read a source file -
2 Copyright (C) 1986, 87, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999
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 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
114 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
115 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
116 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
117 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
118 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
119 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
120 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3
126 * Out: 1 if this character ends a line.
129 char is_end_of_line
[256] =
132 99, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, 99, Z_
, Z_
, 99, Z_
, Z_
, /* @abcdefghijklmno */
134 99, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, 99, Z_
, Z_
, Z_
, Z_
, Z_
, /* @abcdefghijklmno */
136 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
138 Z_
,99, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* _!"#$%&'()*+,-./ */
139 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* 0123456789:;<=>? */
141 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
142 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, 99, Z_
, Z_
, Z_
, Z_
, /* 0123456789:;<=>? */
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_
, /* */
152 Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, Z_
, /* */
156 /* Functions private to this file. */
158 static char *buffer
; /* 1st char of each buffer of lines is here. */
159 static char *buffer_limit
; /*->1 + last char in buffer. */
161 /* TARGET_BYTES_BIG_ENDIAN is required to be defined to either 0 or 1 in the
162 tc-<CPU>.h file. See the "Porting GAS" section of the internals manual. */
163 int target_big_endian
= TARGET_BYTES_BIG_ENDIAN
;
165 static char *old_buffer
; /* JF a hack */
166 static char *old_input
;
167 static char *old_limit
;
169 /* Variables for handling include file directory table. */
171 char **include_dirs
; /* Table of pointers to directories to
172 search for .include's */
173 int include_dir_count
; /* How many are in the table */
174 int include_dir_maxlen
= 1;/* Length of longest in table */
176 #ifndef WORKING_DOT_WORD
177 struct broken_word
*broken_words
;
178 int new_broken_words
;
181 /* The current offset into the absolute section. We don't try to
182 build frags in the absolute section, since no data can be stored
183 there. We just keep track of the current offset. */
184 addressT abs_section_offset
;
186 /* If this line had an MRI style label, it is stored in this variable.
187 This is used by some of the MRI pseudo-ops. */
190 /* This global variable is used to support MRI common sections. We
191 translate such sections into a common symbol. This variable is
192 non-NULL when we are in an MRI common section. */
193 symbolS
*mri_common_symbol
;
195 /* In MRI mode, after a dc.b pseudo-op with an odd number of bytes, we
196 need to align to an even byte boundary unless the next pseudo-op is
197 dc.b, ds.b, or dcb.b. This variable is set to 1 if an alignment
199 static int mri_pending_align
;
203 /* This variable is set to be non-zero if the next string we see might
204 be the name of the source file in DWARF debugging information. See
205 the comment in emit_expr for the format we look for. */
206 static int dwarf_file_string
;
210 static void cons_worker
PARAMS ((int, int));
211 static int scrub_from_string
PARAMS ((char *, int));
212 static void do_align
PARAMS ((int, char *, int, int));
213 static void s_align
PARAMS ((int, int));
214 static void s_lcomm_internal
PARAMS ((int, int));
215 static int hex_float
PARAMS ((int, char *));
216 static inline int sizeof_sleb128
PARAMS ((offsetT
));
217 static inline int sizeof_uleb128
PARAMS ((valueT
));
218 static inline int output_sleb128
PARAMS ((char *, offsetT
));
219 static inline int output_uleb128
PARAMS ((char *, valueT
));
220 static inline int output_big_sleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
221 static inline int output_big_uleb128
PARAMS ((char *, LITTLENUM_TYPE
*, int));
222 static int output_big_leb128
PARAMS ((char *, LITTLENUM_TYPE
*, int, int));
223 static void do_org
PARAMS ((segT
, expressionS
*, int));
224 char *demand_copy_string
PARAMS ((int *lenP
));
225 static segT get_segmented_expression
PARAMS ((expressionS
*expP
));
226 static segT get_known_segmented_expression
PARAMS ((expressionS
* expP
));
227 static void pobegin
PARAMS ((void));
228 static int get_line_sb
PARAMS ((sb
*));
229 static void generate_file_debug
PARAMS ((void));
238 obj_read_begin_hook ();
240 /* Something close -- but not too close -- to a multiple of 1024.
241 The debugging malloc I'm using has 24 bytes of overhead. */
242 obstack_begin (¬es
, chunksize
);
243 obstack_begin (&cond_obstack
, chunksize
);
245 /* Use machine dependent syntax */
246 for (p
= line_separator_chars
; *p
; p
++)
247 is_end_of_line
[(unsigned char) *p
] = 1;
248 /* Use more. FIXME-SOMEDAY. */
254 /* set up pseudo-op tables */
256 static struct hash_control
*po_hash
;
258 static const pseudo_typeS potable
[] =
260 {"abort", s_abort
, 0},
261 {"align", s_align_ptwo
, 0},
262 {"ascii", stringer
, 0},
263 {"asciz", stringer
, 1},
264 {"balign", s_align_bytes
, 0},
265 {"balignw", s_align_bytes
, -2},
266 {"balignl", s_align_bytes
, -4},
270 {"common", s_mri_common
, 0},
271 {"common.s", s_mri_common
, 1},
275 {"dc.d", float_cons
, 'd'},
277 {"dc.s", float_cons
, 'f'},
279 {"dc.x", float_cons
, 'x'},
281 {"dcb.b", s_space
, 1},
282 {"dcb.d", s_float_space
, 'd'},
283 {"dcb.l", s_space
, 4},
284 {"dcb.s", s_float_space
, 'f'},
285 {"dcb.w", s_space
, 2},
286 {"dcb.x", s_float_space
, 'x'},
288 {"ds.b", s_space
, 1},
289 {"ds.d", s_space
, 8},
290 {"ds.l", s_space
, 4},
291 {"ds.p", s_space
, 12},
292 {"ds.s", s_space
, 4},
293 {"ds.w", s_space
, 2},
294 {"ds.x", s_space
, 12},
295 {"debug", s_ignore
, 0},
300 {"double", float_cons
, 'd'},
302 {"eject", listing_eject
, 0}, /* Formfeed listing */
304 {"elsec", s_else
, 0},
306 {"endc", s_endif
, 0},
307 {"endfunc", s_func
, 1},
308 {"endif", s_endif
, 0},
313 {"exitm", s_mexit
, 0},
315 {"extern", s_ignore
, 0}, /* We treat all undef as ext */
316 {"appfile", s_app_file
, 1},
317 {"appline", s_app_line
, 0},
319 {"file", s_app_file
, 0},
321 {"float", float_cons
, 'f'},
322 {"format", s_ignore
, 0},
324 {"global", s_globl
, 0},
325 {"globl", s_globl
, 0},
327 {"if", s_if
, (int) O_ne
},
329 {"ifdef", s_ifdef
, 0},
330 {"ifeq", s_if
, (int) O_eq
},
331 {"ifeqs", s_ifeqs
, 0},
332 {"ifge", s_if
, (int) O_ge
},
333 {"ifgt", s_if
, (int) O_gt
},
334 {"ifle", s_if
, (int) O_le
},
335 {"iflt", s_if
, (int) O_lt
},
337 {"ifndef", s_ifdef
, 1},
338 {"ifne", s_if
, (int) O_ne
},
339 {"ifnes", s_ifeqs
, 1},
340 {"ifnotdef", s_ifdef
, 1},
341 {"include", s_include
, 0},
347 {"lcomm", s_lcomm
, 0},
348 {"lflags", listing_flags
, 0}, /* Listing flags */
349 {"linkonce", s_linkonce
, 0},
350 {"list", listing_list
, 1}, /* Turn listing on */
351 {"llen", listing_psize
, 1},
354 {"macro", s_macro
, 0},
355 {"mexit", s_mexit
, 0},
357 {".mri", s_mri
, 0}, /* Special case so .mri works in MRI mode. */
358 {"name", s_ignore
, 0},
359 {"noformat", s_ignore
, 0},
360 {"nolist", listing_list
, 0}, /* Turn listing off */
361 {"nopage", listing_nopage
, 0},
363 {"offset", s_struct
, 0},
365 {"p2align", s_align_ptwo
, 0},
366 {"p2alignw", s_align_ptwo
, -2},
367 {"p2alignl", s_align_ptwo
, -4},
368 {"page", listing_eject
, 0},
369 {"plen", listing_psize
, 0},
370 {"print", s_print
, 0},
371 {"psize", listing_psize
, 0}, /* set paper size */
372 {"purgem", s_purgem
, 0},
377 {"sbttl", listing_title
, 1}, /* Subtitle of listing */
382 {"single", float_cons
, 'f'},
384 {"space", s_space
, 0},
385 {"skip", s_space
, 0},
386 {"sleb128", s_leb128
, 1},
387 {"spc", s_ignore
, 0},
388 {"stabd", s_stab
, 'd'},
389 {"stabn", s_stab
, 'n'},
390 {"stabs", s_stab
, 's'},
391 {"string", stringer
, 1},
392 {"struct", s_struct
, 0},
396 /* This is for gcc to use. It's only just been added (2/94), so gcc
397 won't be able to use it for a while -- probably a year or more.
398 But once this has been released, check with gcc maintainers
399 before deleting it or even changing the spelling. */
400 {"this_GCC_requires_the_GNU_assembler", s_ignore
, 0},
401 /* If we're folding case -- done for some targets, not necessarily
402 all -- the above string in an input file will be converted to
403 this one. Match it either way... */
404 {"this_gcc_requires_the_gnu_assembler", s_ignore
, 0},
406 {"title", listing_title
, 0}, /* Listing title */
407 {"ttl", listing_title
, 0},
409 {"uleb128", s_leb128
, 0},
413 {"xdef", s_globl
, 0},
414 {"xref", s_ignore
, 0},
415 {"xstabs", s_xstab
, 's'},
417 {"zero", s_space
, 0},
418 {NULL
} /* end sentinel */
421 static int pop_override_ok
= 0;
422 static const char *pop_table_name
;
426 const pseudo_typeS
*table
;
429 const pseudo_typeS
*pop
;
430 for (pop
= table
; pop
->poc_name
; pop
++)
432 errtxt
= hash_insert (po_hash
, pop
->poc_name
, (char *) pop
);
433 if (errtxt
&& (!pop_override_ok
|| strcmp (errtxt
, "exists")))
434 as_fatal (_("error constructing %s pseudo-op table: %s"), pop_table_name
,
439 #ifndef md_pop_insert
440 #define md_pop_insert() pop_insert(md_pseudo_table)
443 #ifndef obj_pop_insert
444 #define obj_pop_insert() pop_insert(obj_pseudo_table)
450 po_hash
= hash_new ();
452 /* Do the target-specific pseudo ops. */
453 pop_table_name
= "md";
456 /* Now object specific. Skip any that were in the target table. */
457 pop_table_name
= "obj";
461 /* Now portable ones. Skip any that we've seen already. */
462 pop_table_name
= "standard";
463 pop_insert (potable
);
466 #define HANDLE_CONDITIONAL_ASSEMBLY() \
467 if (ignore_input ()) \
469 while (! is_end_of_line[(unsigned char) *input_line_pointer++]) \
470 if (input_line_pointer == buffer_limit) \
476 /* This function is used when scrubbing the characters between #APP
479 static char *scrub_string
;
480 static char *scrub_string_end
;
483 scrub_from_string (buf
, buflen
)
489 copy
= scrub_string_end
- scrub_string
;
492 memcpy (buf
, scrub_string
, copy
);
493 scrub_string
+= copy
;
497 /* read_a_source_file()
499 * We read the file, putting things into a web that
500 * represents what we have been reading.
503 read_a_source_file (name
)
507 register char *s
; /* string of symbol, '\0' appended */
511 buffer
= input_scrub_new_file (name
);
514 listing_newline (NULL
);
515 register_dependency (name
);
517 /* Generate debugging information before we've read anything in to denote
518 this file as the "main" source file and not a subordinate one
519 (e.g. N_SO vs N_SOL in stabs). */
520 generate_file_debug ();
522 while ((buffer_limit
= input_scrub_next_buffer (&input_line_pointer
)) != 0)
523 { /* We have another line to parse. */
524 know (buffer_limit
[-1] == '\n'); /* Must have a sentinel. */
525 contin
: /* JF this goto is my fault I admit it.
526 Someone brave please re-write the whole
527 input section here? Pleeze??? */
528 while (input_line_pointer
< buffer_limit
)
530 /* We have more of this buffer to parse. */
533 * We now have input_line_pointer->1st char of next line.
534 * If input_line_pointer [-1] == '\n' then we just
535 * scanned another line: so bump line counters.
537 if (is_end_of_line
[(unsigned char) input_line_pointer
[-1]])
539 #ifdef md_start_line_hook
540 md_start_line_hook ();
543 if (input_line_pointer
[-1] == '\n')
544 bump_line_counters ();
549 #ifdef LABELS_WITHOUT_COLONS
554 /* Text at the start of a line must be a label, we
555 run down and stick a colon in. */
556 if (is_name_beginner (*input_line_pointer
))
558 char *line_start
= input_line_pointer
;
563 HANDLE_CONDITIONAL_ASSEMBLY ();
565 c
= get_symbol_end ();
567 /* In MRI mode, the EQU and MACRO pseudoops must
568 be handled specially. */
572 char *rest
= input_line_pointer
+ 1;
576 if (*rest
== ' ' || *rest
== '\t')
578 if ((strncasecmp (rest
, "EQU", 3) == 0
579 || strncasecmp (rest
, "SET", 3) == 0)
580 && (rest
[3] == ' ' || rest
[3] == '\t'))
582 input_line_pointer
= rest
+ 3;
584 strncasecmp (rest
, "SET", 3) == 0);
587 if (strncasecmp (rest
, "MACRO", 5) == 0
590 || is_end_of_line
[(unsigned char) rest
[5]]))
594 /* In MRI mode, we need to handle the MACRO
595 pseudo-op specially: we don't want to put the
596 symbol in the symbol table. */
597 if (! mri_line_macro
)
598 line_label
= colon (line_start
);
600 line_label
= symbol_create (line_start
,
605 *input_line_pointer
= c
;
607 input_line_pointer
++;
613 * We are at the begining of a line, or similar place.
614 * We expect a well-formed assembler statement.
615 * A "symbol-name:" is a statement.
617 * Depending on what compiler is used, the order of these tests
618 * may vary to catch most common case 1st.
619 * Each test is independent of all other tests at the (top) level.
620 * PLEASE make a compiler that doesn't use this assembler.
621 * It is crufty to waste a compiler's time encoding things for this
622 * assembler, which then wastes more time decoding it.
623 * (And communicating via (linear) files is silly!
624 * If you must pass stuff, please pass a tree!)
626 if ((c
= *input_line_pointer
++) == '\t'
631 c
= *input_line_pointer
++;
633 know (c
!= ' '); /* No further leading whitespace. */
636 /* If listing is on, and we are expanding a macro, then give
637 the listing code the contents of the expanded line. */
640 if ((listing
& LISTING_MACEXP
) && macro_nest
> 0)
645 /* Find the end of the current expanded macro line. */
646 for (s
= input_line_pointer
-1; *s
; ++s
)
647 if (is_end_of_line
[(unsigned char) *s
])
650 /* Copy it for safe keeping. Also give an indication of
651 how much macro nesting is involved at this point. */
652 len
= s
- (input_line_pointer
-1);
653 copy
= (char *) xmalloc (len
+ macro_nest
+ 2);
654 memset (copy
, '>', macro_nest
);
655 copy
[macro_nest
] = ' ';
656 memcpy (copy
+ macro_nest
+ 1, input_line_pointer
-1, len
);
657 copy
[macro_nest
+1+len
] = '\0';
659 /* Install the line with the listing facility. */
660 listing_newline (copy
);
663 listing_newline (NULL
);
668 * C is the 1st significant character.
669 * Input_line_pointer points after that character.
671 if (is_name_beginner (c
))
673 /* want user-defined label or pseudo/opcode */
674 HANDLE_CONDITIONAL_ASSEMBLY ();
676 s
= --input_line_pointer
;
677 c
= get_symbol_end (); /* name's delimiter */
679 * C is character after symbol.
680 * That character's place in the input line is now '\0'.
681 * S points to the beginning of the symbol.
682 * [In case of pseudo-op, s->'.'.]
683 * Input_line_pointer->'\0' where c was.
685 if (TC_START_LABEL(c
, input_line_pointer
))
689 char *rest
= input_line_pointer
+ 1;
691 /* In MRI mode, \tsym: set 0 is permitted. */
695 if (*rest
== ' ' || *rest
== '\t')
697 if ((strncasecmp (rest
, "EQU", 3) == 0
698 || strncasecmp (rest
, "SET", 3) == 0)
699 && (rest
[3] == ' ' || rest
[3] == '\t'))
701 input_line_pointer
= rest
+ 3;
707 line_label
= colon (s
); /* user-defined label */
708 *input_line_pointer
++ = ':'; /* Put ':' back for error messages' sake. */
709 /* Input_line_pointer->after ':'. */
715 || ((c
== ' ' || c
== '\t')
716 && input_line_pointer
[1] == '='
717 #ifdef TC_EQUAL_IN_INSN
718 && ! TC_EQUAL_IN_INSN (c
, input_line_pointer
)
723 demand_empty_rest_of_line ();
726 { /* expect pseudo-op or machine instruction */
729 #define IGNORE_OPCODE_CASE
730 #ifdef IGNORE_OPCODE_CASE
735 if (isupper ((unsigned char) *s2
))
748 /* The MRI assembler and the m88k use pseudo-ops
750 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
);
751 if (pop
!= NULL
&& pop
->poc_handler
== NULL
)
756 || (! flag_m68k_mri
&& *s
== '.'))
761 * WARNING: c has next char, which may be end-of-line.
762 * We lookup the pseudo-op table with s+1 because we
763 * already know that the pseudo-op begins with a '.'.
767 pop
= (pseudo_typeS
*) hash_find (po_hash
, s
+ 1);
769 /* In MRI mode, we may need to insert an
770 automatic alignment directive. What a hack
772 if (mri_pending_align
774 || ! ((pop
->poc_handler
== cons
775 && pop
->poc_val
== 1)
776 || (pop
->poc_handler
== s_space
777 && pop
->poc_val
== 1)
778 #ifdef tc_conditional_pseudoop
779 || tc_conditional_pseudoop (pop
)
781 || pop
->poc_handler
== s_if
782 || pop
->poc_handler
== s_ifdef
783 || pop
->poc_handler
== s_ifc
784 || pop
->poc_handler
== s_ifeqs
785 || pop
->poc_handler
== s_else
786 || pop
->poc_handler
== s_endif
787 || pop
->poc_handler
== s_globl
788 || pop
->poc_handler
== s_ignore
)))
790 do_align (1, (char *) NULL
, 0, 0);
791 mri_pending_align
= 0;
792 if (line_label
!= NULL
)
794 symbol_set_frag (line_label
, frag_now
);
795 S_SET_VALUE (line_label
, frag_now_fix ());
799 /* Print the error msg now, while we still can */
802 as_bad (_("Unknown pseudo-op: `%s'"), s
);
803 *input_line_pointer
= c
;
808 /* Put it back for error messages etc. */
809 *input_line_pointer
= c
;
810 /* The following skip of whitespace is compulsory.
811 A well shaped space is sometimes all that separates
812 keyword from operands. */
813 if (c
== ' ' || c
== '\t')
814 input_line_pointer
++;
816 * Input_line is restored.
817 * Input_line_pointer->1st non-blank char
818 * after pseudo-operation.
820 (*pop
->poc_handler
) (pop
->poc_val
);
822 /* If that was .end, just get out now. */
823 if (pop
->poc_handler
== s_end
)
828 int inquote
= 0, inescape
= 0;
830 /* WARNING: c has char, which may be end-of-line. */
831 /* Also: input_line_pointer->`\0` where c was. */
832 *input_line_pointer
= c
;
833 while (!is_end_of_line
[(unsigned char) *input_line_pointer
]
835 #ifdef TC_EOL_IN_INSN
836 || TC_EOL_IN_INSN (input_line_pointer
)
840 if (flag_m68k_mri
&& *input_line_pointer
== '\'')
842 #ifdef QUOTES_IN_INSN
845 else if (*input_line_pointer
== '"')
847 else if (*input_line_pointer
== '\\')
850 input_line_pointer
++;
853 c
= *input_line_pointer
;
854 *input_line_pointer
= '\0';
856 generate_lineno_debug ();
863 if (check_macro (s
, &out
, '\0', &err
))
867 *input_line_pointer
++ = c
;
868 input_scrub_include_sb (&out
,
872 input_scrub_next_buffer (&input_line_pointer
);
877 if (mri_pending_align
)
879 do_align (1, (char *) NULL
, 0, 0);
880 mri_pending_align
= 0;
881 if (line_label
!= NULL
)
883 symbol_set_frag (line_label
, frag_now
);
884 S_SET_VALUE (line_label
, frag_now_fix ());
888 md_assemble (s
); /* Assemble 1 instruction. */
890 *input_line_pointer
++ = c
;
892 /* We resume loop AFTER the end-of-line from
897 } /* if (is_name_beginner(c) */
900 /* Empty statement? */
901 if (is_end_of_line
[(unsigned char) c
])
904 if ((LOCAL_LABELS_DOLLAR
|| LOCAL_LABELS_FB
)
905 && isdigit ((unsigned char) c
))
907 /* local label ("4:") */
908 char *backup
= input_line_pointer
;
910 HANDLE_CONDITIONAL_ASSEMBLY ();
914 while (isdigit ((unsigned char) *input_line_pointer
))
916 temp
= (temp
* 10) + *input_line_pointer
- '0';
917 ++input_line_pointer
;
918 } /* read the whole number */
920 if (LOCAL_LABELS_DOLLAR
921 && *input_line_pointer
== '$'
922 && *(input_line_pointer
+ 1) == ':')
924 input_line_pointer
+= 2;
926 if (dollar_label_defined (temp
))
928 as_fatal (_("label \"%d$\" redefined"), temp
);
931 define_dollar_label (temp
);
932 colon (dollar_label_name (temp
, 0));
937 && *input_line_pointer
++ == ':')
939 fb_label_instance_inc (temp
);
940 colon (fb_label_name (temp
, 0));
944 input_line_pointer
= backup
;
945 } /* local label ("4:") */
947 if (c
&& strchr (line_comment_chars
, c
))
948 { /* Its a comment. Better say APP or NO_APP */
952 unsigned int new_length
;
955 bump_line_counters ();
956 s
= input_line_pointer
;
957 if (strncmp (s
, "APP\n", 4))
958 continue; /* We ignore it */
961 ends
= strstr (s
, "#NO_APP\n");
965 unsigned int tmp_len
;
968 /* The end of the #APP wasn't in this buffer. We
969 keep reading in buffers until we find the #NO_APP
970 that goes with this #APP There is one. The specs
972 tmp_len
= buffer_limit
- s
;
973 tmp_buf
= xmalloc (tmp_len
+ 1);
974 memcpy (tmp_buf
, s
, tmp_len
);
977 new_tmp
= input_scrub_next_buffer (&buffer
);
981 buffer_limit
= new_tmp
;
982 input_line_pointer
= buffer
;
983 ends
= strstr (buffer
, "#NO_APP\n");
987 num
= buffer_limit
- buffer
;
989 tmp_buf
= xrealloc (tmp_buf
, tmp_len
+ num
);
990 memcpy (tmp_buf
+ tmp_len
, buffer
, num
);
995 input_line_pointer
= ends
? ends
+ 8 : NULL
;
1003 input_line_pointer
= ends
+ 8;
1007 scrub_string_end
= ends
;
1009 new_length
= ends
- s
;
1010 new_buf
= (char *) xmalloc (new_length
);
1017 space
= (new_buf
+ new_length
) - new_tmp
;
1018 size
= do_scrub_chars (scrub_from_string
, new_tmp
, space
);
1026 new_buf
= xrealloc (new_buf
, new_length
+ 100);
1027 new_tmp
= new_buf
+ new_length
;
1033 old_buffer
= buffer
;
1034 old_input
= input_line_pointer
;
1035 old_limit
= buffer_limit
;
1037 input_line_pointer
= new_buf
;
1038 buffer_limit
= new_tmp
;
1042 HANDLE_CONDITIONAL_ASSEMBLY ();
1044 #ifdef tc_unrecognized_line
1045 if (tc_unrecognized_line (c
))
1049 /* as_warn("Junk character %d.",c); Now done by ignore_rest */
1050 input_line_pointer
--; /* Report unknown char as ignored. */
1051 ignore_rest_of_line ();
1052 } /* while (input_line_pointer<buffer_limit) */
1054 #ifdef md_after_pass_hook
1055 md_after_pass_hook ();
1061 bump_line_counters ();
1064 buffer
= old_buffer
;
1065 input_line_pointer
= old_input
;
1066 buffer_limit
= old_limit
;
1071 } /* while (more buffers to scan) */
1078 input_scrub_close (); /* Close the input file */
1081 /* For most MRI pseudo-ops, the line actually ends at the first
1082 nonquoted space. This function looks for that point, stuffs a null
1083 in, and sets *STOPCP to the character that used to be there, and
1084 returns the location.
1086 Until I hear otherwise, I am going to assume that this is only true
1087 for the m68k MRI assembler. */
1090 mri_comment_field (stopcp
)
1098 know (flag_m68k_mri
);
1100 for (s
= input_line_pointer
;
1101 ((! is_end_of_line
[(unsigned char) *s
] && *s
!= ' ' && *s
!= '\t')
1106 inquote
= ! inquote
;
1116 for (s
= input_line_pointer
; ! is_end_of_line
[(unsigned char) *s
]; s
++)
1126 /* Skip to the end of an MRI comment field. */
1129 mri_comment_end (stop
, stopc
)
1135 input_line_pointer
= stop
;
1137 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1138 ++input_line_pointer
;
1145 as_fatal (_(".abort detected. Abandoning ship."));
1148 /* Guts of .align directive. N is the power of two to which to align.
1149 FILL may be NULL, or it may point to the bytes of the fill pattern.
1150 LEN is the length of whatever FILL points to, if anything. MAX is
1151 the maximum number of characters to skip when doing the alignment,
1152 or 0 if there is no maximum. */
1155 do_align (n
, fill
, len
, max
)
1164 md_do_align (n
, fill
, len
, max
, just_record_alignment
);
1171 #ifdef BFD_ASSEMBLER
1172 if ((bfd_get_section_flags (stdoutput
, now_seg
) & SEC_CODE
) != 0)
1177 if (now_seg
!= data_section
&& now_seg
!= bss_section
)
1184 default_fill
= NOP_OPCODE
;
1187 fill
= &default_fill
;
1191 /* Only make a frag if we HAVE to. . . */
1192 if (n
!= 0 && !need_pass_2
)
1195 frag_align (n
, *fill
, max
);
1197 frag_align_pattern (n
, fill
, len
, max
);
1201 just_record_alignment
:
1204 record_alignment (now_seg
, n
);
1207 /* Handle the .align pseudo-op. A positive ARG is a default alignment
1208 (in bytes). A negative ARG is the negative of the length of the
1209 fill pattern. BYTES_P is non-zero if the alignment value should be
1210 interpreted as the byte boundary, rather than the power of 2. */
1213 s_align (arg
, bytes_p
)
1217 register unsigned int align
;
1225 stop
= mri_comment_field (&stopc
);
1227 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
1232 align
= arg
; /* Default value from pseudo-op table */
1236 align
= get_absolute_expression ();
1242 /* Convert to a power of 2. */
1247 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
1250 as_bad (_("Alignment not a power of 2"));
1258 as_bad (_("Alignment too large: %u assumed"), align
);
1261 if (*input_line_pointer
!= ',')
1268 ++input_line_pointer
;
1269 if (*input_line_pointer
== ',')
1273 fill
= get_absolute_expression ();
1278 if (*input_line_pointer
!= ',')
1282 ++input_line_pointer
;
1283 max
= get_absolute_expression ();
1290 as_warn (_("expected fill pattern missing"));
1291 do_align (align
, (char *) NULL
, 0, max
);
1306 do_align (align
, &fill_char
, fill_len
, max
);
1312 if ((size_t) fill_len
> sizeof ab
)
1314 md_number_to_chars (ab
, fill
, fill_len
);
1315 do_align (align
, ab
, fill_len
, max
);
1319 demand_empty_rest_of_line ();
1322 mri_comment_end (stop
, stopc
);
1325 /* Handle the .align pseudo-op on machines where ".align 4" means
1326 align to a 4 byte boundary. */
1335 /* Handle the .align pseudo-op on machines where ".align 4" means align
1336 to a 2**4 boundary. */
1349 register char *name
;
1353 register symbolS
*symbolP
;
1358 stop
= mri_comment_field (&stopc
);
1360 name
= input_line_pointer
;
1361 c
= get_symbol_end ();
1362 /* just after name is now '\0' */
1363 p
= input_line_pointer
;
1366 if (*input_line_pointer
!= ',')
1368 as_bad (_("Expected comma after symbol-name: rest of line ignored."));
1369 ignore_rest_of_line ();
1371 mri_comment_end (stop
, stopc
);
1374 input_line_pointer
++; /* skip ',' */
1375 if ((temp
= get_absolute_expression ()) < 0)
1377 as_warn (_(".COMMon length (%ld.) <0! Ignored."), (long) temp
);
1378 ignore_rest_of_line ();
1380 mri_comment_end (stop
, stopc
);
1384 symbolP
= symbol_find_or_make (name
);
1386 if (S_IS_DEFINED (symbolP
) && ! S_IS_COMMON (symbolP
))
1388 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
1389 S_GET_NAME (symbolP
));
1390 ignore_rest_of_line ();
1392 mri_comment_end (stop
, stopc
);
1395 if (S_GET_VALUE (symbolP
))
1397 if (S_GET_VALUE (symbolP
) != (valueT
) temp
)
1398 as_bad (_("Length of .comm \"%s\" is already %ld. Not changed to %ld."),
1399 S_GET_NAME (symbolP
),
1400 (long) S_GET_VALUE (symbolP
),
1405 S_SET_VALUE (symbolP
, (valueT
) temp
);
1406 S_SET_EXTERNAL (symbolP
);
1410 extern int flag_one
;
1411 if ( (!temp
) || !flag_one
)
1412 S_GET_OTHER(symbolP
) = const_flag
;
1414 #endif /* not OBJ_VMS */
1415 know (symbolP
->sy_frag
== &zero_address_frag
);
1417 demand_empty_rest_of_line ();
1420 mri_comment_end (stop
, stopc
);
1423 /* The MRI COMMON pseudo-op. We handle this by creating a common
1424 symbol with the appropriate name. We make s_space do the right
1425 thing by increasing the size. */
1428 s_mri_common (small
)
1445 stop
= mri_comment_field (&stopc
);
1449 name
= input_line_pointer
;
1450 if (! isdigit ((unsigned char) *name
))
1451 c
= get_symbol_end ();
1456 ++input_line_pointer
;
1458 while (isdigit ((unsigned char) *input_line_pointer
));
1459 c
= *input_line_pointer
;
1460 *input_line_pointer
= '\0';
1462 if (line_label
!= NULL
)
1464 alc
= (char *) xmalloc (strlen (S_GET_NAME (line_label
))
1465 + (input_line_pointer
- name
)
1467 sprintf (alc
, "%s%s", name
, S_GET_NAME (line_label
));
1472 sym
= symbol_find_or_make (name
);
1473 *input_line_pointer
= c
;
1477 if (*input_line_pointer
!= ',')
1481 ++input_line_pointer
;
1482 align
= get_absolute_expression ();
1485 if (S_IS_DEFINED (sym
) && ! S_IS_COMMON (sym
))
1487 as_bad (_("attempt to re-define symbol `%s'"), S_GET_NAME (sym
));
1488 ignore_rest_of_line ();
1489 mri_comment_end (stop
, stopc
);
1493 S_SET_EXTERNAL (sym
);
1494 mri_common_symbol
= sym
;
1498 S_SET_ALIGN (sym
, align
);
1501 if (line_label
!= NULL
)
1504 exp
.X_op
= O_symbol
;
1505 exp
.X_add_symbol
= sym
;
1506 exp
.X_add_number
= 0;
1507 symbol_set_value_expression (line_label
, &exp
);
1508 symbol_set_frag (line_label
, &zero_address_frag
);
1509 S_SET_SEGMENT (line_label
, expr_section
);
1512 /* FIXME: We just ignore the small argument, which distinguishes
1513 COMMON and COMMON.S. I don't know what we can do about it. */
1515 /* Ignore the type and hptype. */
1516 if (*input_line_pointer
== ',')
1517 input_line_pointer
+= 2;
1518 if (*input_line_pointer
== ',')
1519 input_line_pointer
+= 2;
1521 demand_empty_rest_of_line ();
1523 mri_comment_end (stop
, stopc
);
1533 temp
= get_absolute_expression ();
1534 if (flag_readonly_data_in_text
)
1536 section
= text_section
;
1540 section
= data_section
;
1542 subseg_set (section
, (subsegT
) temp
);
1547 demand_empty_rest_of_line ();
1550 /* Handle the .appfile pseudo-op. This is automatically generated by
1551 do_scrub_chars when a preprocessor # line comment is seen with a
1552 file name. This default definition may be overridden by the object
1553 or CPU specific pseudo-ops. This function is also the default
1554 definition for .file; the APPFILE argument is 1 for .appfile, 0 for
1558 s_app_file (appfile
)
1564 /* Some assemblers tolerate immediately following '"' */
1565 if ((s
= demand_copy_string (&length
)) != 0)
1567 /* If this is a fake .appfile, a fake newline was inserted into
1568 the buffer. Passing -2 to new_logical_line tells it to
1571 = (! new_logical_line (s
, appfile
? -2 : -1) && appfile
);
1573 /* In MRI mode, the preprocessor may have inserted an extraneous
1576 && *input_line_pointer
== '\''
1577 && is_end_of_line
[(unsigned char) input_line_pointer
[1]])
1578 ++input_line_pointer
;
1580 demand_empty_rest_of_line ();
1585 listing_source_file (s
);
1587 register_dependency (s
);
1595 /* Handle the .appline pseudo-op. This is automatically generated by
1596 do_scrub_chars when a preprocessor # line comment is seen. This
1597 default definition may be overridden by the object or CPU specific
1606 /* The given number is that of the next line. */
1607 l
= get_absolute_expression () - 1;
1609 /* Some of the back ends can't deal with non-positive line numbers.
1610 Besides, it's silly. */
1611 as_warn (_("Line numbers must be positive; line number %d rejected."), l
+1);
1614 new_logical_line ((char *) NULL
, l
);
1617 listing_source_line (l
);
1620 demand_empty_rest_of_line ();
1623 /* Handle the .end pseudo-op. Actually, the real work is done in
1624 read_a_source_file. */
1632 /* The MRI assembler permits the start symbol to follow .end,
1633 but we don't support that. */
1635 if (! is_end_of_line
[(unsigned char) *input_line_pointer
]
1636 && *input_line_pointer
!= '*'
1637 && *input_line_pointer
!= '!')
1638 as_warn (_("start address not supported"));
1642 /* Handle the .err pseudo-op. */
1648 as_bad (_(".err encountered"));
1649 demand_empty_rest_of_line ();
1652 /* Handle the MRI fail pseudo-op. */
1663 stop
= mri_comment_field (&stopc
);
1665 temp
= get_absolute_expression ();
1667 as_warn (_(".fail %ld encountered"), (long) temp
);
1669 as_bad (_(".fail %ld encountered"), (long) temp
);
1671 demand_empty_rest_of_line ();
1674 mri_comment_end (stop
, stopc
);
1681 expressionS rep_exp
;
1683 register long fill
= 0;
1686 #ifdef md_flush_pending_output
1687 md_flush_pending_output ();
1690 get_known_segmented_expression (&rep_exp
);
1691 if (*input_line_pointer
== ',')
1693 input_line_pointer
++;
1694 size
= get_absolute_expression ();
1695 if (*input_line_pointer
== ',')
1697 input_line_pointer
++;
1698 fill
= get_absolute_expression ();
1702 /* This is to be compatible with BSD 4.2 AS, not for any rational reason. */
1703 #define BSD_FILL_SIZE_CROCK_8 (8)
1704 if (size
> BSD_FILL_SIZE_CROCK_8
)
1706 as_warn (_(".fill size clamped to %d."), BSD_FILL_SIZE_CROCK_8
);
1707 size
= BSD_FILL_SIZE_CROCK_8
;
1711 as_warn (_("Size negative: .fill ignored."));
1714 else if (rep_exp
.X_op
== O_constant
&& rep_exp
.X_add_number
<= 0)
1716 if (rep_exp
.X_add_number
< 0)
1717 as_warn (_("Repeat < 0, .fill ignored"));
1721 if (size
&& !need_pass_2
)
1723 if (rep_exp
.X_op
== O_constant
)
1725 p
= frag_var (rs_fill
, (int) size
, (int) size
,
1726 (relax_substateT
) 0, (symbolS
*) 0,
1727 (offsetT
) rep_exp
.X_add_number
,
1732 /* We don't have a constant repeat count, so we can't use
1733 rs_fill. We can get the same results out of rs_space,
1734 but its argument is in bytes, so we must multiply the
1735 repeat count by size. */
1738 rep_sym
= make_expr_symbol (&rep_exp
);
1741 expressionS size_exp
;
1742 size_exp
.X_op
= O_constant
;
1743 size_exp
.X_add_number
= size
;
1745 rep_exp
.X_op
= O_multiply
;
1746 rep_exp
.X_add_symbol
= rep_sym
;
1747 rep_exp
.X_op_symbol
= make_expr_symbol (&size_exp
);
1748 rep_exp
.X_add_number
= 0;
1749 rep_sym
= make_expr_symbol (&rep_exp
);
1752 p
= frag_var (rs_space
, (int) size
, (int) size
,
1753 (relax_substateT
) 0, rep_sym
, (offsetT
) 0, (char *) 0);
1755 memset (p
, 0, (unsigned int) size
);
1756 /* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
1757 * flavoured AS. The following bizzare behaviour is to be
1758 * compatible with above. I guess they tried to take up to 8
1759 * bytes from a 4-byte expression and they forgot to sign
1760 * extend. Un*x Sux. */
1761 #define BSD_FILL_SIZE_CROCK_4 (4)
1762 md_number_to_chars (p
, (valueT
) fill
,
1763 (size
> BSD_FILL_SIZE_CROCK_4
1764 ? BSD_FILL_SIZE_CROCK_4
1766 /* Note: .fill (),0 emits no frag (since we are asked to .fill 0 bytes)
1767 * but emits no error message because it seems a legal thing to do.
1768 * It is a degenerate case of .fill but could be emitted by a compiler.
1771 demand_empty_rest_of_line ();
1785 stop
= mri_comment_field (&stopc
);
1789 name
= input_line_pointer
;
1790 c
= get_symbol_end ();
1791 symbolP
= symbol_find_or_make (name
);
1792 *input_line_pointer
= c
;
1794 S_SET_EXTERNAL (symbolP
);
1797 input_line_pointer
++;
1799 if (*input_line_pointer
== '\n')
1805 demand_empty_rest_of_line ();
1808 mri_comment_end (stop
, stopc
);
1811 /* Handle the MRI IRP and IRPC pseudo-ops. */
1823 as_where (&file
, &line
);
1826 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1827 sb_add_char (&s
, *input_line_pointer
++);
1831 err
= expand_irp (irpc
, 0, &s
, &out
, get_line_sb
, '\0');
1833 as_bad_where (file
, line
, "%s", err
);
1837 input_scrub_include_sb (&out
, input_line_pointer
);
1839 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
1842 /* Handle the .linkonce pseudo-op. This tells the assembler to mark
1843 the section to only be linked once. However, this is not supported
1844 by most object file formats. This takes an optional argument,
1845 which is what to do about duplicates. */
1851 enum linkonce_type type
;
1855 type
= LINKONCE_DISCARD
;
1857 if (! is_end_of_line
[(unsigned char) *input_line_pointer
])
1862 s
= input_line_pointer
;
1863 c
= get_symbol_end ();
1864 if (strcasecmp (s
, "discard") == 0)
1865 type
= LINKONCE_DISCARD
;
1866 else if (strcasecmp (s
, "one_only") == 0)
1867 type
= LINKONCE_ONE_ONLY
;
1868 else if (strcasecmp (s
, "same_size") == 0)
1869 type
= LINKONCE_SAME_SIZE
;
1870 else if (strcasecmp (s
, "same_contents") == 0)
1871 type
= LINKONCE_SAME_CONTENTS
;
1873 as_warn (_("unrecognized .linkonce type `%s'"), s
);
1875 *input_line_pointer
= c
;
1878 #ifdef obj_handle_link_once
1879 obj_handle_link_once (type
);
1880 #else /* ! defined (obj_handle_link_once) */
1881 #ifdef BFD_ASSEMBLER
1885 if ((bfd_applicable_section_flags (stdoutput
) & SEC_LINK_ONCE
) == 0)
1886 as_warn (_(".linkonce is not supported for this object file format"));
1888 flags
= bfd_get_section_flags (stdoutput
, now_seg
);
1889 flags
|= SEC_LINK_ONCE
;
1894 case LINKONCE_DISCARD
:
1895 flags
|= SEC_LINK_DUPLICATES_DISCARD
;
1897 case LINKONCE_ONE_ONLY
:
1898 flags
|= SEC_LINK_DUPLICATES_ONE_ONLY
;
1900 case LINKONCE_SAME_SIZE
:
1901 flags
|= SEC_LINK_DUPLICATES_SAME_SIZE
;
1903 case LINKONCE_SAME_CONTENTS
:
1904 flags
|= SEC_LINK_DUPLICATES_SAME_CONTENTS
;
1907 if (! bfd_set_section_flags (stdoutput
, now_seg
, flags
))
1908 as_bad (_("bfd_set_section_flags: %s"),
1909 bfd_errmsg (bfd_get_error ()));
1911 #else /* ! defined (BFD_ASSEMBLER) */
1912 as_warn (_(".linkonce is not supported for this object file format"));
1913 #endif /* ! defined (BFD_ASSEMBLER) */
1914 #endif /* ! defined (obj_handle_link_once) */
1916 demand_empty_rest_of_line ();
1920 s_lcomm_internal (needs_align
, bytes_p
)
1921 /* 1 if this was a ".bss" directive, which may require a 3rd argument
1922 (alignment); 0 if it was an ".lcomm" (2 args only) */
1924 /* 1 if the alignment value should be interpreted as the byte boundary,
1925 rather than the power of 2. */
1928 register char *name
;
1932 register symbolS
*symbolP
;
1933 segT current_seg
= now_seg
;
1934 subsegT current_subseg
= now_subseg
;
1935 const int max_alignment
= 15;
1937 segT bss_seg
= bss_section
;
1939 name
= input_line_pointer
;
1940 c
= get_symbol_end ();
1941 p
= input_line_pointer
;
1945 /* Accept an optional comma after the name. The comma used to be
1946 required, but Irix 5 cc does not generate it. */
1947 if (*input_line_pointer
== ',')
1949 ++input_line_pointer
;
1953 if (*input_line_pointer
== '\n')
1955 as_bad (_("Missing size expression"));
1959 if ((temp
= get_absolute_expression ()) < 0)
1961 as_warn (_("BSS length (%d.) <0! Ignored."), temp
);
1962 ignore_rest_of_line ();
1966 #if defined (TC_MIPS) || defined (TC_ALPHA)
1967 if (OUTPUT_FLAVOR
== bfd_target_ecoff_flavour
1968 || OUTPUT_FLAVOR
== bfd_target_elf_flavour
)
1970 /* For MIPS and Alpha ECOFF or ELF, small objects are put in .sbss. */
1971 if (temp
<= bfd_get_gp_size (stdoutput
))
1973 bss_seg
= subseg_new (".sbss", 1);
1974 seg_info (bss_seg
)->bss
= 1;
1975 #ifdef BFD_ASSEMBLER
1976 if (! bfd_set_section_flags (stdoutput
, bss_seg
, SEC_ALLOC
))
1977 as_warn (_("error setting flags for \".sbss\": %s"),
1978 bfd_errmsg (bfd_get_error ()));
1985 /* FIXME. This needs to be machine independent. */
1996 /* FIXME: This needs to be done in a more general fashion. */
2000 record_alignment(bss_seg
, align
);
2007 if (*input_line_pointer
!= ',')
2009 as_bad (_("Expected comma after size"));
2010 ignore_rest_of_line ();
2013 input_line_pointer
++;
2015 if (*input_line_pointer
== '\n')
2017 as_bad (_("Missing alignment"));
2020 align
= get_absolute_expression ();
2023 /* Convert to a power of 2. */
2028 for (i
= 0; (align
& 1) == 0; align
>>= 1, ++i
)
2031 as_bad (_("Alignment not a power of 2"));
2035 if (align
> max_alignment
)
2037 align
= max_alignment
;
2038 as_warn (_("Alignment too large: %d. assumed."), align
);
2043 as_warn (_("Alignment negative. 0 assumed."));
2045 record_alignment (bss_seg
, align
);
2046 } /* if needs align */
2049 /* Assume some objects may require alignment on some systems. */
2050 #if defined (TC_ALPHA) && ! defined (VMS)
2053 align
= ffs (temp
) - 1;
2054 if (temp
% (1 << align
))
2061 symbolP
= symbol_find_or_make (name
);
2065 #if defined(OBJ_AOUT) | defined(OBJ_BOUT)
2066 S_GET_OTHER (symbolP
) == 0 &&
2067 S_GET_DESC (symbolP
) == 0 &&
2068 #endif /* OBJ_AOUT or OBJ_BOUT */
2069 (S_GET_SEGMENT (symbolP
) == bss_seg
2070 || (!S_IS_DEFINED (symbolP
) && S_GET_VALUE (symbolP
) == 0)))
2074 subseg_set (bss_seg
, 1);
2077 frag_align (align
, 0, 0);
2078 /* detach from old frag */
2079 if (S_GET_SEGMENT (symbolP
) == bss_seg
)
2080 symbol_get_frag (symbolP
)->fr_symbol
= NULL
;
2082 symbol_set_frag (symbolP
, frag_now
);
2083 pfrag
= frag_var (rs_org
, 1, 1, (relax_substateT
)0, symbolP
,
2084 (offsetT
) temp
, (char *) 0);
2087 S_SET_SEGMENT (symbolP
, bss_seg
);
2090 /* The symbol may already have been created with a preceding
2091 ".globl" directive -- be careful not to step on storage class
2092 in that case. Otherwise, set it to static. */
2093 if (S_GET_STORAGE_CLASS (symbolP
) != C_EXT
)
2095 S_SET_STORAGE_CLASS (symbolP
, C_STAT
);
2097 #endif /* OBJ_COFF */
2100 S_SET_SIZE (symbolP
, temp
);
2104 as_bad (_("Ignoring attempt to re-define symbol `%s'."),
2105 S_GET_NAME (symbolP
));
2107 subseg_set (current_seg
, current_subseg
);
2109 demand_empty_rest_of_line ();
2110 } /* s_lcomm_internal() */
2113 s_lcomm (needs_align
)
2116 s_lcomm_internal (needs_align
, 0);
2119 void s_lcomm_bytes (needs_align
)
2122 s_lcomm_internal (needs_align
, 1);
2129 register char *name
;
2133 register symbolS
*symbolP
;
2135 /* we permit ANY defined expression: BSD4.2 demands constants */
2136 name
= input_line_pointer
;
2137 c
= get_symbol_end ();
2138 p
= input_line_pointer
;
2141 if (*input_line_pointer
!= ',')
2144 as_bad (_("Expected comma after name \"%s\""), name
);
2146 ignore_rest_of_line ();
2149 input_line_pointer
++;
2151 if (exp
.X_op
!= O_constant
2152 && exp
.X_op
!= O_register
)
2154 as_bad (_("bad expression"));
2155 ignore_rest_of_line ();
2159 symbolP
= symbol_find_or_make (name
);
2161 /* FIXME-SOON I pulled a (&& symbolP->sy_other == 0 &&
2162 symbolP->sy_desc == 0) out of this test because coff doesn't have
2163 those fields, and I can't see when they'd ever be tripped. I
2164 don't think I understand why they were here so I may have
2165 introduced a bug. As recently as 1.37 didn't have this test
2166 anyway. xoxorich. */
2168 if (S_GET_SEGMENT (symbolP
) == undefined_section
2169 && S_GET_VALUE (symbolP
) == 0)
2171 /* The name might be an undefined .global symbol; be sure to
2172 keep the "external" bit. */
2173 S_SET_SEGMENT (symbolP
,
2174 (exp
.X_op
== O_constant
2177 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
2181 as_bad (_("Symbol %s already defined"), name
);
2184 demand_empty_rest_of_line ();
2187 /* Read a line into an sb. */
2193 char quote1
, quote2
, inquote
;
2195 if (input_line_pointer
[-1] == '\n')
2196 bump_line_counters ();
2198 if (input_line_pointer
>= buffer_limit
)
2200 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2201 if (buffer_limit
== 0)
2205 /* If app.c sets any other characters to LEX_IS_STRINGQUOTE, this
2206 code needs to be changed. */
2207 if (! flag_m68k_mri
)
2215 #ifdef LEX_IS_STRINGQUOTE
2220 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
2221 || (inquote
!= '\0' && *input_line_pointer
!= '\n'))
2223 if (inquote
== *input_line_pointer
)
2225 else if (inquote
== '\0')
2227 if (*input_line_pointer
== quote1
)
2229 else if (*input_line_pointer
== quote2
)
2232 sb_add_char (line
, *input_line_pointer
++);
2234 while (input_line_pointer
< buffer_limit
2235 && is_end_of_line
[(unsigned char) *input_line_pointer
])
2237 if (input_line_pointer
[-1] == '\n')
2238 bump_line_counters ();
2239 ++input_line_pointer
;
2244 /* Define a macro. This is an interface to macro.c, which is shared
2245 between gas and gasp. */
2258 as_where (&file
, &line
);
2261 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
2262 sb_add_char (&s
, *input_line_pointer
++);
2265 if (line_label
!= NULL
)
2266 sb_add_string (&label
, S_GET_NAME (line_label
));
2268 err
= define_macro (0, &s
, &label
, get_line_sb
, &name
);
2270 as_bad_where (file
, line
, "%s", err
);
2273 if (line_label
!= NULL
)
2275 S_SET_SEGMENT (line_label
, undefined_section
);
2276 S_SET_VALUE (line_label
, 0);
2277 symbol_set_frag (line_label
, &zero_address_frag
);
2281 #ifdef NO_PSEUDO_DOT
2285 && hash_find (po_hash
, name
) != NULL
)
2288 && hash_find (po_hash
, name
+ 1) != NULL
))
2289 as_warn (_("attempt to redefine pseudo-op `%s' ignored"),
2296 /* Handle the .mexit pseudo-op, which immediately exits a macro
2303 cond_exit_macro (macro_nest
);
2304 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2307 /* Switch in and out of MRI mode. */
2315 on
= get_absolute_expression ();
2316 old_flag
= flag_mri
;
2332 /* Operator precedence changes in m68k MRI mode, so we need to
2333 update the operator rankings. */
2334 expr_set_precedence ();
2336 #ifdef MRI_MODE_CHANGE
2338 MRI_MODE_CHANGE (on
);
2341 demand_empty_rest_of_line ();
2344 /* Handle changing the location counter. */
2347 do_org (segment
, exp
, fill
)
2352 if (segment
!= now_seg
&& segment
!= absolute_section
)
2353 as_bad (_("invalid segment \"%s\"; segment \"%s\" assumed"),
2354 segment_name (segment
), segment_name (now_seg
));
2356 if (now_seg
== absolute_section
)
2359 as_warn (_("ignoring fill value in absolute section"));
2360 if (exp
->X_op
!= O_constant
)
2362 as_bad (_("only constant offsets supported in absolute section"));
2363 exp
->X_add_number
= 0;
2365 abs_section_offset
= exp
->X_add_number
;
2371 p
= frag_var (rs_org
, 1, 1, (relax_substateT
) 0, exp
->X_add_symbol
,
2372 exp
->X_add_number
, (char *) NULL
);
2381 register segT segment
;
2383 register long temp_fill
;
2385 #ifdef md_flush_pending_output
2386 md_flush_pending_output ();
2389 /* The m68k MRI assembler has a different meaning for .org. It
2390 means to create an absolute section at a given address. We can't
2391 support that--use a linker script instead. */
2394 as_bad (_("MRI style ORG pseudo-op not supported"));
2395 ignore_rest_of_line ();
2399 /* Don't believe the documentation of BSD 4.2 AS. There is no such
2400 thing as a sub-segment-relative origin. Any absolute origin is
2401 given a warning, then assumed to be segment-relative. Any
2402 segmented origin expression ("foo+42") had better be in the right
2403 segment or the .org is ignored.
2405 BSD 4.2 AS warns if you try to .org backwards. We cannot because
2406 we never know sub-segment sizes when we are reading code. BSD
2407 will crash trying to emit negative numbers of filler bytes in
2408 certain .orgs. We don't crash, but see as-write for that code.
2410 Don't make frag if need_pass_2==1. */
2411 segment
= get_known_segmented_expression (&exp
);
2412 if (*input_line_pointer
== ',')
2414 input_line_pointer
++;
2415 temp_fill
= get_absolute_expression ();
2421 do_org (segment
, &exp
, temp_fill
);
2423 demand_empty_rest_of_line ();
2426 /* Handle parsing for the MRI SECT/SECTION pseudo-op. This should be
2427 called by the obj-format routine which handles section changing
2428 when in MRI mode. It will create a new section, and return it. It
2429 will set *TYPE to the section type: one of 'C' (code), 'D' (data),
2430 'M' (mixed), or 'R' (romable). If BFD_ASSEMBLER is defined, the
2431 flags will be set in the section. */
2445 name
= input_line_pointer
;
2446 if (! isdigit ((unsigned char) *name
))
2447 c
= get_symbol_end ();
2452 ++input_line_pointer
;
2454 while (isdigit ((unsigned char) *input_line_pointer
));
2455 c
= *input_line_pointer
;
2456 *input_line_pointer
= '\0';
2459 name
= xstrdup (name
);
2461 *input_line_pointer
= c
;
2463 seg
= subseg_new (name
, 0);
2465 if (*input_line_pointer
== ',')
2469 ++input_line_pointer
;
2470 align
= get_absolute_expression ();
2471 record_alignment (seg
, align
);
2475 if (*input_line_pointer
== ',')
2477 c
= *++input_line_pointer
;
2478 c
= toupper ((unsigned char) c
);
2479 if (c
== 'C' || c
== 'D' || c
== 'M' || c
== 'R')
2482 as_bad (_("unrecognized section type"));
2483 ++input_line_pointer
;
2485 #ifdef BFD_ASSEMBLER
2489 flags
= SEC_NO_FLAGS
;
2491 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_READONLY
| SEC_CODE
;
2492 else if (*type
== 'D' || *type
== 'M')
2493 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
;
2494 else if (*type
== 'R')
2495 flags
= SEC_ALLOC
| SEC_LOAD
| SEC_DATA
| SEC_READONLY
| SEC_ROM
;
2496 if (flags
!= SEC_NO_FLAGS
)
2498 if (! bfd_set_section_flags (stdoutput
, seg
, flags
))
2499 as_warn (_("error setting flags for \"%s\": %s"),
2500 bfd_section_name (stdoutput
, seg
),
2501 bfd_errmsg (bfd_get_error ()));
2507 /* Ignore the HP type. */
2508 if (*input_line_pointer
== ',')
2509 input_line_pointer
+= 2;
2511 demand_empty_rest_of_line ();
2513 #else /* ! TC_M68K */
2522 name
= input_line_pointer
;
2523 c
= get_symbol_end ();
2525 name
= xstrdup (name
);
2527 *input_line_pointer
= c
;
2529 seg
= subseg_new (name
, 0);
2531 if (*input_line_pointer
!= ',')
2537 ++input_line_pointer
;
2539 sectype
= input_line_pointer
;
2540 c
= get_symbol_end ();
2541 if (*sectype
== '\0')
2543 else if (strcasecmp (sectype
, "text") == 0)
2545 else if (strcasecmp (sectype
, "data") == 0)
2547 else if (strcasecmp (sectype
, "romdata") == 0)
2550 as_warn (_("unrecognized section type `%s'"), sectype
);
2551 *input_line_pointer
= c
;
2554 if (*input_line_pointer
== ',')
2558 ++input_line_pointer
;
2560 seccmd
= input_line_pointer
;
2561 c
= get_symbol_end ();
2562 if (strcasecmp (seccmd
, "absolute") == 0)
2564 as_bad (_("absolute sections are not supported"));
2565 *input_line_pointer
= c
;
2566 ignore_rest_of_line ();
2569 else if (strcasecmp (seccmd
, "align") == 0)
2573 *input_line_pointer
= c
;
2574 align
= get_absolute_expression ();
2575 record_alignment (seg
, align
);
2579 as_warn (_("unrecognized section command `%s'"), seccmd
);
2580 *input_line_pointer
= c
;
2584 demand_empty_rest_of_line ();
2586 #else /* ! TC_I960 */
2587 /* The MRI assembler seems to use different forms of .sect for
2588 different targets. */
2589 as_bad ("MRI mode not supported for this target");
2590 ignore_rest_of_line ();
2591 #endif /* ! TC_I960 */
2592 #endif /* ! TC_M68K */
2595 /* Handle the .print pseudo-op. */
2604 s
= demand_copy_C_string (&len
);
2606 demand_empty_rest_of_line ();
2609 /* Handle the .purgem pseudo-op. */
2615 if (is_it_end_of_statement ())
2617 demand_empty_rest_of_line ();
2627 name
= input_line_pointer
;
2628 c
= get_symbol_end ();
2629 delete_macro (name
);
2630 *input_line_pointer
= c
;
2633 while (*input_line_pointer
++ == ',');
2635 --input_line_pointer
;
2636 demand_empty_rest_of_line ();
2639 /* Handle the .rept pseudo-op. */
2649 count
= get_absolute_expression ();
2652 if (! buffer_and_nest ("REPT", "ENDR", &one
, get_line_sb
))
2654 as_bad (_("rept without endr"));
2660 sb_add_sb (&many
, &one
);
2664 input_scrub_include_sb (&many
, input_line_pointer
);
2666 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
2669 /* Handle the .equ, .equiv and .set directives. If EQUIV is 1, then
2670 this is .equiv, and it is an error if the symbol is already
2677 register char *name
;
2678 register char delim
;
2679 register char *end_name
;
2680 register symbolS
*symbolP
;
2683 * Especial apologies for the random logic:
2684 * this just grew, and could be parsed much more simply!
2687 name
= input_line_pointer
;
2688 delim
= get_symbol_end ();
2689 end_name
= input_line_pointer
;
2693 if (*input_line_pointer
!= ',')
2696 as_bad (_("Expected comma after name \"%s\""), name
);
2698 ignore_rest_of_line ();
2702 input_line_pointer
++;
2705 if (name
[0] == '.' && name
[1] == '\0')
2707 /* Turn '. = mumble' into a .org mumble */
2708 register segT segment
;
2711 segment
= get_known_segmented_expression (&exp
);
2714 do_org (segment
, &exp
, 0);
2720 if ((symbolP
= symbol_find (name
)) == NULL
2721 && (symbolP
= md_undefined_symbol (name
)) == NULL
)
2724 /* When doing symbol listings, play games with dummy fragments living
2725 outside the normal fragment chain to record the file and line info
2727 if (listing
& LISTING_SYMBOLS
)
2729 extern struct list_info_struct
*listing_tail
;
2730 fragS
*dummy_frag
= (fragS
*) xmalloc (sizeof(fragS
));
2731 memset (dummy_frag
, 0, sizeof(fragS
));
2732 dummy_frag
->fr_type
= rs_fill
;
2733 dummy_frag
->line
= listing_tail
;
2734 symbolP
= symbol_new (name
, undefined_section
, 0, dummy_frag
);
2735 dummy_frag
->fr_symbol
= symbolP
;
2739 symbolP
= symbol_new (name
, undefined_section
, 0, &zero_address_frag
);
2742 /* "set" symbols are local unless otherwise specified. */
2743 SF_SET_LOCAL (symbolP
);
2744 #endif /* OBJ_COFF */
2746 } /* make a new symbol */
2748 symbol_table_insert (symbolP
);
2753 && S_IS_DEFINED (symbolP
)
2754 && S_GET_SEGMENT (symbolP
) != reg_section
)
2755 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
2757 pseudo_set (symbolP
);
2758 demand_empty_rest_of_line ();
2772 #ifdef md_flush_pending_output
2773 md_flush_pending_output ();
2777 stop
= mri_comment_field (&stopc
);
2779 /* In m68k MRI mode, we need to align to a word boundary, unless
2781 if (flag_m68k_mri
&& mult
> 1)
2783 if (now_seg
== absolute_section
)
2785 abs_section_offset
+= abs_section_offset
& 1;
2786 if (line_label
!= NULL
)
2787 S_SET_VALUE (line_label
, abs_section_offset
);
2789 else if (mri_common_symbol
!= NULL
)
2793 val
= S_GET_VALUE (mri_common_symbol
);
2796 S_SET_VALUE (mri_common_symbol
, val
+ 1);
2797 if (line_label
!= NULL
)
2799 expressionS
*symexp
;
2801 symexp
= symbol_get_value_expression (line_label
);
2802 know (symexp
->X_op
== O_symbol
);
2803 know (symexp
->X_add_symbol
== mri_common_symbol
);
2804 symexp
->X_add_number
+= 1;
2810 do_align (1, (char *) NULL
, 0, 0);
2811 if (line_label
!= NULL
)
2813 symbol_set_frag (line_label
, frag_now
);
2814 S_SET_VALUE (line_label
, frag_now_fix ());
2824 if (*input_line_pointer
== ',')
2826 ++input_line_pointer
;
2831 val
.X_op
= O_constant
;
2832 val
.X_add_number
= 0;
2835 if (val
.X_op
!= O_constant
2836 || val
.X_add_number
< - 0x80
2837 || val
.X_add_number
> 0xff
2838 || (mult
!= 0 && mult
!= 1 && val
.X_add_number
!= 0))
2840 if (exp
.X_op
!= O_constant
)
2841 as_bad (_("Unsupported variable size or fill value"));
2848 bytes
= mult
* exp
.X_add_number
;
2849 for (i
= 0; i
< exp
.X_add_number
; i
++)
2850 emit_expr (&val
, mult
);
2855 if (exp
.X_op
== O_constant
)
2859 repeat
= exp
.X_add_number
;
2866 as_warn (_(".space repeat count is zero, ignored"));
2867 else if (repeat
< 0)
2868 as_warn (_(".space repeat count is negative, ignored"));
2872 /* If we are in the absolute section, just bump the offset. */
2873 if (now_seg
== absolute_section
)
2875 abs_section_offset
+= repeat
;
2879 /* If we are secretly in an MRI common section, then
2880 creating space just increases the size of the common
2882 if (mri_common_symbol
!= NULL
)
2884 S_SET_VALUE (mri_common_symbol
,
2885 S_GET_VALUE (mri_common_symbol
) + repeat
);
2890 p
= frag_var (rs_fill
, 1, 1, (relax_substateT
) 0, (symbolS
*) 0,
2891 (offsetT
) repeat
, (char *) 0);
2895 if (now_seg
== absolute_section
)
2897 as_bad (_("space allocation too complex in absolute section"));
2898 subseg_set (text_section
, 0);
2900 if (mri_common_symbol
!= NULL
)
2902 as_bad (_("space allocation too complex in common section"));
2903 mri_common_symbol
= NULL
;
2906 p
= frag_var (rs_space
, 1, 1, (relax_substateT
) 0,
2907 make_expr_symbol (&exp
), (offsetT
) 0, (char *) 0);
2911 *p
= val
.X_add_number
;
2916 /* In MRI mode, after an odd number of bytes, we must align to an
2917 even word boundary, unless the next instruction is a dc.b, ds.b
2919 if (flag_mri
&& (bytes
& 1) != 0)
2920 mri_pending_align
= 1;
2922 demand_empty_rest_of_line ();
2925 mri_comment_end (stop
, stopc
);
2928 /* This is like s_space, but the value is a floating point number with
2929 the given precision. This is for the MRI dcb.s pseudo-op and
2933 s_float_space (float_type
)
2938 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
2943 stop
= mri_comment_field (&stopc
);
2945 count
= get_absolute_expression ();
2948 if (*input_line_pointer
!= ',')
2950 as_bad (_("missing value"));
2951 ignore_rest_of_line ();
2953 mri_comment_end (stop
, stopc
);
2957 ++input_line_pointer
;
2961 /* Skip any 0{letter} that may be present. Don't even check if the
2962 * letter is legal. */
2963 if (input_line_pointer
[0] == '0'
2964 && isalpha ((unsigned char) input_line_pointer
[1]))
2965 input_line_pointer
+= 2;
2967 /* Accept :xxxx, where the x's are hex digits, for a floating point
2968 with the exact digits specified. */
2969 if (input_line_pointer
[0] == ':')
2971 flen
= hex_float (float_type
, temp
);
2974 ignore_rest_of_line ();
2976 mri_comment_end (stop
, stopc
);
2984 err
= md_atof (float_type
, temp
, &flen
);
2985 know (flen
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
2989 as_bad (_("Bad floating literal: %s"), err
);
2990 ignore_rest_of_line ();
2992 mri_comment_end (stop
, stopc
);
2997 while (--count
>= 0)
3001 p
= frag_more (flen
);
3002 memcpy (p
, temp
, (unsigned int) flen
);
3005 demand_empty_rest_of_line ();
3008 mri_comment_end (stop
, stopc
);
3011 /* Handle the .struct pseudo-op, as found in MIPS assemblers. */
3021 stop
= mri_comment_field (&stopc
);
3022 abs_section_offset
= get_absolute_expression ();
3023 subseg_set (absolute_section
, 0);
3024 demand_empty_rest_of_line ();
3026 mri_comment_end (stop
, stopc
);
3035 temp
= get_absolute_expression ();
3036 subseg_set (text_section
, (subsegT
) temp
);
3037 demand_empty_rest_of_line ();
3039 const_flag
&= ~IN_DEFAULT_SECTION
;
3045 demand_empty_rest_of_line ()
3048 if (is_end_of_line
[(unsigned char) *input_line_pointer
])
3050 input_line_pointer
++;
3054 ignore_rest_of_line ();
3056 /* Return having already swallowed end-of-line. */
3057 } /* Return pointing just after end-of-line. */
3060 ignore_rest_of_line () /* For suspect lines: gives warning. */
3062 if (!is_end_of_line
[(unsigned char) *input_line_pointer
])
3064 if (isprint ((unsigned char) *input_line_pointer
))
3065 as_bad (_("Rest of line ignored. First ignored character is `%c'."),
3066 *input_line_pointer
);
3068 as_bad (_("Rest of line ignored. First ignored character valued 0x%x."),
3069 *input_line_pointer
);
3070 while (input_line_pointer
< buffer_limit
3071 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3073 input_line_pointer
++;
3076 input_line_pointer
++; /* Return pointing just after end-of-line. */
3077 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3081 discard_rest_of_line ()
3083 while (input_line_pointer
< buffer_limit
3084 && !is_end_of_line
[(unsigned char) *input_line_pointer
])
3086 input_line_pointer
++;
3088 input_line_pointer
++; /* Return pointing just after end-of-line. */
3089 know (is_end_of_line
[(unsigned char) input_line_pointer
[-1]]);
3095 * In: Pointer to a symbol.
3096 * Input_line_pointer->expression.
3098 * Out: Input_line_pointer->just after any whitespace after expression.
3099 * Tried to set symbol to value of expression.
3100 * Will change symbols type, value, and frag;
3103 pseudo_set (symbolP
)
3107 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3109 #endif /* OBJ_AOUT or OBJ_BOUT */
3111 know (symbolP
); /* NULL pointer is logic error. */
3112 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3113 ext
= S_IS_EXTERNAL (symbolP
);
3114 #endif /* OBJ_AOUT or OBJ_BOUT */
3116 (void) expression (&exp
);
3118 if (exp
.X_op
== O_illegal
)
3119 as_bad (_("illegal expression; zero assumed"));
3120 else if (exp
.X_op
== O_absent
)
3121 as_bad (_("missing expression; zero assumed"));
3122 else if (exp
.X_op
== O_big
)
3124 if (exp
.X_add_number
> 0)
3125 as_bad (_("bignum invalid; zero assumed"));
3127 as_bad (_("floating point number invalid; zero assumed"));
3129 else if (exp
.X_op
== O_subtract
3130 && (S_GET_SEGMENT (exp
.X_add_symbol
)
3131 == S_GET_SEGMENT (exp
.X_op_symbol
))
3132 && SEG_NORMAL (S_GET_SEGMENT (exp
.X_add_symbol
))
3133 && (symbol_get_frag (exp
.X_add_symbol
)
3134 == symbol_get_frag (exp
.X_op_symbol
)))
3136 exp
.X_op
= O_constant
;
3137 exp
.X_add_number
= (S_GET_VALUE (exp
.X_add_symbol
)
3138 - S_GET_VALUE (exp
.X_op_symbol
));
3146 exp
.X_add_number
= 0;
3149 S_SET_SEGMENT (symbolP
, absolute_section
);
3150 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3152 S_SET_EXTERNAL (symbolP
);
3154 S_CLEAR_EXTERNAL (symbolP
);
3155 #endif /* OBJ_AOUT or OBJ_BOUT */
3156 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3157 if (exp
.X_op
!= O_constant
)
3158 symbol_set_frag (symbolP
, &zero_address_frag
);
3162 S_SET_SEGMENT (symbolP
, reg_section
);
3163 S_SET_VALUE (symbolP
, (valueT
) exp
.X_add_number
);
3164 symbol_set_frag (symbolP
, &zero_address_frag
);
3168 if (S_GET_SEGMENT (exp
.X_add_symbol
) == undefined_section
3169 || exp
.X_add_number
!= 0)
3170 symbol_set_value_expression (symbolP
, &exp
);
3173 symbolS
*s
= exp
.X_add_symbol
;
3175 S_SET_SEGMENT (symbolP
, S_GET_SEGMENT (s
));
3176 #if (defined (OBJ_AOUT) || defined (OBJ_BOUT)) && ! defined (BFD_ASSEMBLER)
3178 S_SET_EXTERNAL (symbolP
);
3180 S_CLEAR_EXTERNAL (symbolP
);
3181 #endif /* OBJ_AOUT or OBJ_BOUT */
3182 S_SET_VALUE (symbolP
,
3183 exp
.X_add_number
+ S_GET_VALUE (s
));
3184 symbol_set_frag (symbolP
, symbol_get_frag (s
));
3185 copy_symbol_attributes (symbolP
, s
);
3190 /* The value is some complex expression.
3191 FIXME: Should we set the segment to anything? */
3192 symbol_set_value_expression (symbolP
, &exp
);
3200 * CONStruct more frag of .bytes, or .words etc.
3201 * Should need_pass_2 be 1 then emit no frag(s).
3202 * This understands EXPRESSIONS.
3206 * This has a split personality. We use expression() to read the
3207 * value. We can detect if the value won't fit in a byte or word.
3208 * But we can't detect if expression() discarded significant digits
3209 * in the case of a long. Not worth the crocks required to fix it.
3212 /* Select a parser for cons expressions. */
3214 /* Some targets need to parse the expression in various fancy ways.
3215 You can define TC_PARSE_CONS_EXPRESSION to do whatever you like
3216 (for example, the HPPA does this). Otherwise, you can define
3217 BITFIELD_CONS_EXPRESSIONS to permit bitfields to be specified, or
3218 REPEAT_CONS_EXPRESSIONS to permit repeat counts. If none of these
3219 are defined, which is the normal case, then only simple expressions
3223 parse_mri_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3225 #ifndef TC_PARSE_CONS_EXPRESSION
3226 #ifdef BITFIELD_CONS_EXPRESSIONS
3227 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_bitfield_cons (EXP, NBYTES)
3229 parse_bitfield_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3231 #ifdef REPEAT_CONS_EXPRESSIONS
3232 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) parse_repeat_cons (EXP, NBYTES)
3234 parse_repeat_cons
PARAMS ((expressionS
*exp
, unsigned int nbytes
));
3237 /* If we haven't gotten one yet, just call expression. */
3238 #ifndef TC_PARSE_CONS_EXPRESSION
3239 #define TC_PARSE_CONS_EXPRESSION(EXP, NBYTES) expression (EXP)
3243 /* worker to do .byte etc statements */
3244 /* clobbers input_line_pointer, checks */
3247 cons_worker (nbytes
, rva
)
3248 register int nbytes
; /* 1=.byte, 2=.word, 4=.long */
3256 #ifdef md_flush_pending_output
3257 md_flush_pending_output ();
3261 stop
= mri_comment_field (&stopc
);
3263 if (is_it_end_of_statement ())
3265 demand_empty_rest_of_line ();
3267 mri_comment_end (stop
, stopc
);
3271 #ifdef md_cons_align
3272 md_cons_align (nbytes
);
3279 parse_mri_cons (&exp
, (unsigned int) nbytes
);
3281 TC_PARSE_CONS_EXPRESSION (&exp
, (unsigned int) nbytes
);
3285 if (exp
.X_op
== O_symbol
)
3286 exp
.X_op
= O_symbol_rva
;
3288 as_fatal (_("rva without symbol"));
3290 emit_expr (&exp
, (unsigned int) nbytes
);
3293 while (*input_line_pointer
++ == ',');
3295 /* In MRI mode, after an odd number of bytes, we must align to an
3296 even word boundary, unless the next instruction is a dc.b, ds.b
3298 if (flag_mri
&& nbytes
== 1 && (c
& 1) != 0)
3299 mri_pending_align
= 1;
3301 input_line_pointer
--; /* Put terminator back into stream. */
3303 demand_empty_rest_of_line ();
3306 mri_comment_end (stop
, stopc
);
3314 cons_worker (size
, 0);
3321 cons_worker (size
, 1);
3324 /* Put the contents of expression EXP into the object file using
3325 NBYTES bytes. If need_pass_2 is 1, this does nothing. */
3328 emit_expr (exp
, nbytes
)
3330 unsigned int nbytes
;
3334 valueT extra_digit
= 0;
3336 /* Don't do anything if we are going to make another pass. */
3342 /* When gcc emits DWARF 1 debugging pseudo-ops, a line number will
3343 appear as a four byte positive constant in the .line section,
3344 followed by a 2 byte 0xffff. Look for that case here. */
3346 static int dwarf_line
= -1;
3348 if (strcmp (segment_name (now_seg
), ".line") != 0)
3350 else if (dwarf_line
>= 0
3352 && exp
->X_op
== O_constant
3353 && (exp
->X_add_number
== -1 || exp
->X_add_number
== 0xffff))
3354 listing_source_line ((unsigned int) dwarf_line
);
3355 else if (nbytes
== 4
3356 && exp
->X_op
== O_constant
3357 && exp
->X_add_number
>= 0)
3358 dwarf_line
= exp
->X_add_number
;
3363 /* When gcc emits DWARF 1 debugging pseudo-ops, a file name will
3364 appear as a 2 byte TAG_compile_unit (0x11) followed by a 2 byte
3365 AT_sibling (0x12) followed by a four byte address of the sibling
3366 followed by a 2 byte AT_name (0x38) followed by the name of the
3367 file. We look for that case here. */
3369 static int dwarf_file
= 0;
3371 if (strcmp (segment_name (now_seg
), ".debug") != 0)
3373 else if (dwarf_file
== 0
3375 && exp
->X_op
== O_constant
3376 && exp
->X_add_number
== 0x11)
3378 else if (dwarf_file
== 1
3380 && exp
->X_op
== O_constant
3381 && exp
->X_add_number
== 0x12)
3383 else if (dwarf_file
== 2
3386 else if (dwarf_file
== 3
3388 && exp
->X_op
== O_constant
3389 && exp
->X_add_number
== 0x38)
3394 /* The variable dwarf_file_string tells stringer that the string
3395 may be the name of the source file. */
3396 if (dwarf_file
== 4)
3397 dwarf_file_string
= 1;
3399 dwarf_file_string
= 0;
3404 if (check_eh_frame (exp
, &nbytes
))
3409 /* Allow `.word 0' in the absolute section. */
3410 if (now_seg
== absolute_section
)
3412 if (op
!= O_constant
|| exp
->X_add_number
!= 0)
3413 as_bad (_("attempt to store value in absolute section"));
3414 abs_section_offset
+= nbytes
;
3418 /* Handle a negative bignum. */
3420 && exp
->X_add_number
== 0
3421 && symbol_get_value_expression (exp
->X_add_symbol
)->X_op
== O_big
3422 && symbol_get_value_expression (exp
->X_add_symbol
)->X_add_number
> 0)
3425 unsigned long carry
;
3427 exp
= symbol_get_value_expression (exp
->X_add_symbol
);
3429 /* Negate the bignum: one's complement each digit and add 1. */
3431 for (i
= 0; i
< exp
->X_add_number
; i
++)
3435 next
= (((~ (generic_bignum
[i
] & LITTLENUM_MASK
))
3438 generic_bignum
[i
] = next
& LITTLENUM_MASK
;
3439 carry
= next
>> LITTLENUM_NUMBER_OF_BITS
;
3442 /* We can ignore any carry out, because it will be handled by
3443 extra_digit if it is needed. */
3445 extra_digit
= (valueT
) -1;
3449 if (op
== O_absent
|| op
== O_illegal
)
3451 as_warn (_("zero assumed for missing expression"));
3452 exp
->X_add_number
= 0;
3455 else if (op
== O_big
&& exp
->X_add_number
<= 0)
3457 as_bad (_("floating point number invalid; zero assumed"));
3458 exp
->X_add_number
= 0;
3461 else if (op
== O_register
)
3463 as_warn (_("register value used as expression"));
3467 p
= frag_more ((int) nbytes
);
3469 #ifndef WORKING_DOT_WORD
3470 /* If we have the difference of two symbols in a word, save it on
3471 the broken_words list. See the code in write.c. */
3472 if (op
== O_subtract
&& nbytes
== 2)
3474 struct broken_word
*x
;
3476 x
= (struct broken_word
*) xmalloc (sizeof (struct broken_word
));
3477 x
->next_broken_word
= broken_words
;
3480 x
->subseg
= now_subseg
;
3482 x
->word_goes_here
= p
;
3484 x
->add
= exp
->X_add_symbol
;
3485 x
->sub
= exp
->X_op_symbol
;
3486 x
->addnum
= exp
->X_add_number
;
3493 /* If we have an integer, but the number of bytes is too large to
3494 pass to md_number_to_chars, handle it as a bignum. */
3495 if (op
== O_constant
&& nbytes
> sizeof (valueT
))
3500 if (! exp
->X_unsigned
&& exp
->X_add_number
< 0)
3501 extra_digit
= (valueT
) -1;
3502 val
= (valueT
) exp
->X_add_number
;
3506 generic_bignum
[gencnt
] = val
& LITTLENUM_MASK
;
3507 val
>>= LITTLENUM_NUMBER_OF_BITS
;
3511 op
= exp
->X_op
= O_big
;
3512 exp
->X_add_number
= gencnt
;
3515 if (op
== O_constant
)
3517 register valueT get
;
3518 register valueT use
;
3519 register valueT mask
;
3521 register valueT unmask
;
3523 /* JF << of >= number of bits in the object is undefined. In
3524 particular SPARC (Sun 4) has problems */
3525 if (nbytes
>= sizeof (valueT
))
3528 if (nbytes
> sizeof (valueT
))
3531 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3535 /* Don't store these bits. */
3536 mask
= ~(valueT
) 0 << (BITS_PER_CHAR
* nbytes
);
3537 hibit
= (valueT
) 1 << (nbytes
* BITS_PER_CHAR
- 1);
3540 unmask
= ~mask
; /* Do store these bits. */
3543 "Do this mod if you want every overflow check to assume SIGNED 2's complement data.";
3544 mask
= ~(unmask
>> 1); /* Includes sign bit now. */
3547 get
= exp
->X_add_number
;
3549 if ((get
& mask
) != 0
3550 && ((get
& mask
) != mask
3551 || (get
& hibit
) == 0))
3552 { /* Leading bits contain both 0s & 1s. */
3553 as_warn (_("Value 0x%lx truncated to 0x%lx."),
3554 (unsigned long) get
, (unsigned long) use
);
3556 /* put bytes in right order. */
3557 md_number_to_chars (p
, use
, (int) nbytes
);
3559 else if (op
== O_big
)
3562 LITTLENUM_TYPE
*nums
;
3564 know (nbytes
% CHARS_PER_LITTLENUM
== 0);
3566 size
= exp
->X_add_number
* CHARS_PER_LITTLENUM
;
3569 as_warn (_("Bignum truncated to %d bytes"), nbytes
);
3573 if (target_big_endian
)
3575 while (nbytes
> size
)
3577 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3578 nbytes
-= CHARS_PER_LITTLENUM
;
3579 p
+= CHARS_PER_LITTLENUM
;
3582 nums
= generic_bignum
+ size
/ CHARS_PER_LITTLENUM
;
3586 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3587 size
-= CHARS_PER_LITTLENUM
;
3588 p
+= CHARS_PER_LITTLENUM
;
3593 nums
= generic_bignum
;
3596 md_number_to_chars (p
, (valueT
) *nums
, CHARS_PER_LITTLENUM
);
3598 size
-= CHARS_PER_LITTLENUM
;
3599 p
+= CHARS_PER_LITTLENUM
;
3600 nbytes
-= CHARS_PER_LITTLENUM
;
3605 md_number_to_chars (p
, extra_digit
, CHARS_PER_LITTLENUM
);
3606 nbytes
-= CHARS_PER_LITTLENUM
;
3607 p
+= CHARS_PER_LITTLENUM
;
3613 memset (p
, 0, nbytes
);
3615 /* Now we need to generate a fixS to record the symbol value.
3616 This is easy for BFD. For other targets it can be more
3617 complex. For very complex cases (currently, the HPPA and
3618 NS32K), you can define TC_CONS_FIX_NEW to do whatever you
3619 want. For simpler cases, you can define TC_CONS_RELOC to be
3620 the name of the reloc code that should be stored in the fixS.
3621 If neither is defined, the code uses NO_RELOC if it is
3622 defined, and otherwise uses 0. */
3624 #ifdef BFD_ASSEMBLER
3625 #ifdef TC_CONS_FIX_NEW
3626 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3629 bfd_reloc_code_real_type r
;
3646 as_bad (_("unsupported BFD relocation size %u"), nbytes
);
3650 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
,
3655 #ifdef TC_CONS_FIX_NEW
3656 TC_CONS_FIX_NEW (frag_now
, p
- frag_now
->fr_literal
, nbytes
, exp
);
3658 /* Figure out which reloc number to use. Use TC_CONS_RELOC if
3659 it is defined, otherwise use NO_RELOC if it is defined,
3661 #ifndef TC_CONS_RELOC
3663 #define TC_CONS_RELOC NO_RELOC
3665 #define TC_CONS_RELOC 0
3668 fix_new_exp (frag_now
, p
- frag_now
->fr_literal
, (int) nbytes
, exp
, 0,
3670 #endif /* TC_CONS_FIX_NEW */
3671 #endif /* BFD_ASSEMBLER */
3675 #ifdef BITFIELD_CONS_EXPRESSIONS
3677 /* i960 assemblers, (eg, asm960), allow bitfields after ".byte" as
3678 w:x,y:z, where w and y are bitwidths and x and y are values. They
3679 then pack them all together. We do a little better in that we allow
3680 them in words, longs, etc. and we'll pack them in target byte order
3683 The rules are: pack least significat bit first, if a field doesn't
3684 entirely fit, put it in the next unit. Overflowing the bitfield is
3685 explicitly *not* even a warning. The bitwidth should be considered
3688 To use this function the tc-XXX.h file should define
3689 BITFIELD_CONS_EXPRESSIONS. */
3692 parse_bitfield_cons (exp
, nbytes
)
3694 unsigned int nbytes
;
3696 unsigned int bits_available
= BITS_PER_CHAR
* nbytes
;
3697 char *hold
= input_line_pointer
;
3699 (void) expression (exp
);
3701 if (*input_line_pointer
== ':')
3707 unsigned long width
;
3709 if (*input_line_pointer
!= ':')
3711 input_line_pointer
= hold
;
3713 } /* next piece is not a bitfield */
3715 /* In the general case, we can't allow
3716 full expressions with symbol
3717 differences and such. The relocation
3718 entries for symbols not defined in this
3719 assembly would require arbitrary field
3720 widths, positions, and masks which most
3721 of our current object formats don't
3724 In the specific case where a symbol
3725 *is* defined in this assembly, we
3726 *could* build fixups and track it, but
3727 this could lead to confusion for the
3728 backends. I'm lazy. I'll take any
3729 SEG_ABSOLUTE. I think that means that
3730 you can use a previous .set or
3731 .equ type symbol. xoxorich. */
3733 if (exp
->X_op
== O_absent
)
3735 as_warn (_("using a bit field width of zero"));
3736 exp
->X_add_number
= 0;
3737 exp
->X_op
= O_constant
;
3738 } /* implied zero width bitfield */
3740 if (exp
->X_op
!= O_constant
)
3742 *input_line_pointer
= '\0';
3743 as_bad (_("field width \"%s\" too complex for a bitfield"), hold
);
3744 *input_line_pointer
= ':';
3745 demand_empty_rest_of_line ();
3749 if ((width
= exp
->X_add_number
) > (BITS_PER_CHAR
* nbytes
))
3751 as_warn (_("field width %lu too big to fit in %d bytes: truncated to %d bits"),
3752 width
, nbytes
, (BITS_PER_CHAR
* nbytes
));
3753 width
= BITS_PER_CHAR
* nbytes
;
3756 if (width
> bits_available
)
3758 /* FIXME-SOMEDAY: backing up and reparsing is wasteful. */
3759 input_line_pointer
= hold
;
3760 exp
->X_add_number
= value
;
3764 hold
= ++input_line_pointer
; /* skip ':' */
3766 (void) expression (exp
);
3767 if (exp
->X_op
!= O_constant
)
3769 char cache
= *input_line_pointer
;
3771 *input_line_pointer
= '\0';
3772 as_bad (_("field value \"%s\" too complex for a bitfield"), hold
);
3773 *input_line_pointer
= cache
;
3774 demand_empty_rest_of_line ();
3778 value
|= ((~(-1 << width
) & exp
->X_add_number
)
3779 << ((BITS_PER_CHAR
* nbytes
) - bits_available
));
3781 if ((bits_available
-= width
) == 0
3782 || is_it_end_of_statement ()
3783 || *input_line_pointer
!= ',')
3786 } /* all the bitfields we're gonna get */
3788 hold
= ++input_line_pointer
;
3789 (void) expression (exp
);
3790 } /* forever loop */
3792 exp
->X_add_number
= value
;
3793 exp
->X_op
= O_constant
;
3794 exp
->X_unsigned
= 1;
3795 } /* if looks like a bitfield */
3796 } /* parse_bitfield_cons() */
3798 #endif /* BITFIELD_CONS_EXPRESSIONS */
3800 /* Handle an MRI style string expression. */
3803 parse_mri_cons (exp
, nbytes
)
3805 unsigned int nbytes
;
3807 if (*input_line_pointer
!= '\''
3808 && (input_line_pointer
[1] != '\''
3809 || (*input_line_pointer
!= 'A'
3810 && *input_line_pointer
!= 'E')))
3811 TC_PARSE_CONS_EXPRESSION (exp
, nbytes
);
3815 unsigned int result
= 0;
3817 /* An MRI style string. Cut into as many bytes as will fit into
3818 a nbyte chunk, left justify if necessary, and separate with
3819 commas so we can try again later. */
3820 if (*input_line_pointer
== 'A')
3821 ++input_line_pointer
;
3822 else if (*input_line_pointer
== 'E')
3824 as_bad (_("EBCDIC constants are not supported"));
3825 ++input_line_pointer
;
3828 input_line_pointer
++;
3829 for (scan
= 0; scan
< nbytes
; scan
++)
3831 if (*input_line_pointer
== '\'')
3833 if (input_line_pointer
[1] == '\'')
3835 input_line_pointer
++;
3840 result
= (result
<< 8) | (*input_line_pointer
++);
3844 while (scan
< nbytes
)
3849 /* Create correct expression */
3850 exp
->X_op
= O_constant
;
3851 exp
->X_add_number
= result
;
3852 /* Fake it so that we can read the next char too */
3853 if (input_line_pointer
[0] != '\'' ||
3854 (input_line_pointer
[0] == '\'' && input_line_pointer
[1] == '\''))
3856 input_line_pointer
-= 2;
3857 input_line_pointer
[0] = ',';
3858 input_line_pointer
[1] = '\'';
3861 input_line_pointer
++;
3865 #ifdef REPEAT_CONS_EXPRESSIONS
3867 /* Parse a repeat expression for cons. This is used by the MIPS
3868 assembler. The format is NUMBER:COUNT; NUMBER appears in the
3869 object file COUNT times.
3871 To use this for a target, define REPEAT_CONS_EXPRESSIONS. */
3874 parse_repeat_cons (exp
, nbytes
)
3876 unsigned int nbytes
;
3883 if (*input_line_pointer
!= ':')
3885 /* No repeat count. */
3889 ++input_line_pointer
;
3890 expression (&count
);
3891 if (count
.X_op
!= O_constant
3892 || count
.X_add_number
<= 0)
3894 as_warn (_("Unresolvable or nonpositive repeat count; using 1"));
3898 /* The cons function is going to output this expression once. So we
3899 output it count - 1 times. */
3900 for (i
= count
.X_add_number
- 1; i
> 0; i
--)
3901 emit_expr (exp
, nbytes
);
3904 #endif /* REPEAT_CONS_EXPRESSIONS */
3906 /* Parse a floating point number represented as a hex constant. This
3907 permits users to specify the exact bits they want in the floating
3911 hex_float (float_type
, bytes
)
3945 as_bad (_("Unknown floating type type '%c'"), float_type
);
3949 /* It would be nice if we could go through expression to parse the
3950 hex constant, but if we get a bignum it's a pain to sort it into
3951 the buffer correctly. */
3953 while (hex_p (*input_line_pointer
) || *input_line_pointer
== '_')
3957 /* The MRI assembler accepts arbitrary underscores strewn about
3958 through the hex constant, so we ignore them as well. */
3959 if (*input_line_pointer
== '_')
3961 ++input_line_pointer
;
3967 as_warn (_("Floating point constant too large"));
3970 d
= hex_value (*input_line_pointer
) << 4;
3971 ++input_line_pointer
;
3972 while (*input_line_pointer
== '_')
3973 ++input_line_pointer
;
3974 if (hex_p (*input_line_pointer
))
3976 d
+= hex_value (*input_line_pointer
);
3977 ++input_line_pointer
;
3979 if (target_big_endian
)
3982 bytes
[length
- i
- 1] = d
;
3988 if (target_big_endian
)
3989 memset (bytes
+ i
, 0, length
- i
);
3991 memset (bytes
, 0, length
- i
);
4000 * CONStruct some more frag chars of .floats .ffloats etc.
4001 * Makes 0 or more new frags.
4002 * If need_pass_2 == 1, no frags are emitted.
4003 * This understands only floating literals, not expressions. Sorry.
4005 * A floating constant is defined by atof_generic(), except it is preceded
4006 * by 0d 0f 0g or 0h. After observing the STRANGE way my BSD AS does its
4007 * reading, I decided to be incompatible. This always tries to give you
4008 * rounded bits to the precision of the pseudo-op. Former AS did premature
4009 * truncatation, restored noisy bits instead of trailing 0s AND gave you
4010 * a choice of 2 flavours of noise according to which of 2 floating-point
4011 * scanners you directed AS to use.
4013 * In: input_line_pointer->whitespace before, or '0' of flonum.
4018 float_cons (float_type
)
4019 /* Clobbers input_line-pointer, checks end-of-line. */
4020 register int float_type
; /* 'f':.ffloat ... 'F':.float ... */
4023 int length
; /* Number of chars in an object. */
4024 register char *err
; /* Error from scanning floating literal. */
4025 char temp
[MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
];
4027 if (is_it_end_of_statement ())
4029 demand_empty_rest_of_line ();
4033 #ifdef md_flush_pending_output
4034 md_flush_pending_output ();
4039 /* input_line_pointer->1st char of a flonum (we hope!). */
4042 /* Skip any 0{letter} that may be present. Don't even check if the
4043 * letter is legal. Someone may invent a "z" format and this routine
4044 * has no use for such information. Lusers beware: you get
4045 * diagnostics if your input is ill-conditioned.
4047 if (input_line_pointer
[0] == '0'
4048 && isalpha ((unsigned char) input_line_pointer
[1]))
4049 input_line_pointer
+= 2;
4051 /* Accept :xxxx, where the x's are hex digits, for a floating
4052 point with the exact digits specified. */
4053 if (input_line_pointer
[0] == ':')
4055 ++input_line_pointer
;
4056 length
= hex_float (float_type
, temp
);
4059 ignore_rest_of_line ();
4065 err
= md_atof (float_type
, temp
, &length
);
4066 know (length
<= MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT
);
4070 as_bad (_("Bad floating literal: %s"), err
);
4071 ignore_rest_of_line ();
4082 #ifdef REPEAT_CONS_EXPRESSIONS
4083 if (*input_line_pointer
== ':')
4085 expressionS count_exp
;
4087 ++input_line_pointer
;
4088 expression (&count_exp
);
4089 if (count_exp
.X_op
!= O_constant
4090 || count_exp
.X_add_number
<= 0)
4092 as_warn (_("unresolvable or nonpositive repeat count; using 1"));
4095 count
= count_exp
.X_add_number
;
4099 while (--count
>= 0)
4101 p
= frag_more (length
);
4102 memcpy (p
, temp
, (unsigned int) length
);
4107 while (*input_line_pointer
++ == ',');
4109 --input_line_pointer
; /* Put terminator back into stream. */
4110 demand_empty_rest_of_line ();
4111 } /* float_cons() */
4113 /* Return the size of a LEB128 value */
4116 sizeof_sleb128 (value
)
4119 register int size
= 0;
4120 register unsigned byte
;
4124 byte
= (value
& 0x7f);
4125 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4126 Fortunately, we can structure things so that the extra work reduces
4127 to a noop on systems that do things "properly". */
4128 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4131 while (!(((value
== 0) && ((byte
& 0x40) == 0))
4132 || ((value
== -1) && ((byte
& 0x40) != 0))));
4138 sizeof_uleb128 (value
)
4141 register int size
= 0;
4142 register unsigned byte
;
4146 byte
= (value
& 0x7f);
4156 sizeof_leb128 (value
, sign
)
4161 return sizeof_sleb128 ((offsetT
) value
);
4163 return sizeof_uleb128 (value
);
4166 /* Output a LEB128 value. */
4169 output_sleb128 (p
, value
)
4173 register char *orig
= p
;
4178 unsigned byte
= (value
& 0x7f);
4180 /* Sadly, we cannot rely on typical arithmetic right shift behaviour.
4181 Fortunately, we can structure things so that the extra work reduces
4182 to a noop on systems that do things "properly". */
4183 value
= (value
>> 7) | ~(-(offsetT
)1 >> 7);
4185 more
= !((((value
== 0) && ((byte
& 0x40) == 0))
4186 || ((value
== -1) && ((byte
& 0x40) != 0))));
4198 output_uleb128 (p
, value
)
4206 unsigned byte
= (value
& 0x7f);
4209 /* More bytes to follow. */
4220 output_leb128 (p
, value
, sign
)
4226 return output_sleb128 (p
, (offsetT
) value
);
4228 return output_uleb128 (p
, value
);
4231 /* Do the same for bignums. We combine sizeof with output here in that
4232 we don't output for NULL values of P. It isn't really as critical as
4233 for "normal" values that this be streamlined. */
4236 output_big_sleb128 (p
, bignum
, size
)
4238 LITTLENUM_TYPE
*bignum
;
4246 /* Strip leading sign extensions off the bignum. */
4247 while (size
> 0 && bignum
[size
-1] == (LITTLENUM_TYPE
)-1)
4252 if (loaded
< 7 && size
> 0)
4254 val
|= (*bignum
<< loaded
);
4255 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4266 if ((val
== 0 && (byte
& 0x40) == 0)
4267 || (~(val
| ~(((valueT
)1 << loaded
) - 1)) == 0
4268 && (byte
& 0x40) != 0))
4276 while (byte
& 0x80);
4282 output_big_uleb128 (p
, bignum
, size
)
4284 LITTLENUM_TYPE
*bignum
;
4292 /* Strip leading zeros off the bignum. */
4293 /* XXX: Is this needed? */
4294 while (size
> 0 && bignum
[size
-1] == 0)
4299 if (loaded
< 7 && size
> 0)
4301 val
|= (*bignum
<< loaded
);
4302 loaded
+= 8 * CHARS_PER_LITTLENUM
;
4311 if (size
> 0 || val
)
4318 while (byte
& 0x80);
4324 output_big_leb128 (p
, bignum
, size
, sign
)
4326 LITTLENUM_TYPE
*bignum
;
4330 return output_big_sleb128 (p
, bignum
, size
);
4332 return output_big_uleb128 (p
, bignum
, size
);
4335 /* Generate the appropriate fragments for a given expression to emit a
4339 emit_leb128_expr(exp
, sign
)
4343 operatorT op
= exp
->X_op
;
4345 if (op
== O_absent
|| op
== O_illegal
)
4347 as_warn (_("zero assumed for missing expression"));
4348 exp
->X_add_number
= 0;
4351 else if (op
== O_big
&& exp
->X_add_number
<= 0)
4353 as_bad (_("floating point number invalid; zero assumed"));
4354 exp
->X_add_number
= 0;
4357 else if (op
== O_register
)
4359 as_warn (_("register value used as expression"));
4363 if (op
== O_constant
)
4365 /* If we've got a constant, emit the thing directly right now. */
4367 valueT value
= exp
->X_add_number
;
4371 size
= sizeof_leb128 (value
, sign
);
4372 p
= frag_more (size
);
4373 output_leb128 (p
, value
, sign
);
4375 else if (op
== O_big
)
4377 /* O_big is a different sort of constant. */
4382 size
= output_big_leb128 (NULL
, generic_bignum
, exp
->X_add_number
, sign
);
4383 p
= frag_more (size
);
4384 output_big_leb128 (p
, generic_bignum
, exp
->X_add_number
, sign
);
4388 /* Otherwise, we have to create a variable sized fragment and
4389 resolve things later. */
4391 frag_var (rs_leb128
, sizeof_uleb128 (~(valueT
)0), 0, sign
,
4392 make_expr_symbol (exp
), 0, (char *) NULL
);
4396 /* Parse the .sleb128 and .uleb128 pseudos. */
4406 emit_leb128_expr (&exp
, sign
);
4407 } while (*input_line_pointer
++ == ',');
4409 input_line_pointer
--;
4410 demand_empty_rest_of_line ();
4416 * We read 0 or more ',' separated, double-quoted strings.
4418 * Caller should have checked need_pass_2 is FALSE because we don't check it.
4423 stringer (append_zero
) /* Worker to do .ascii etc statements. */
4424 /* Checks end-of-line. */
4425 register int append_zero
; /* 0: don't append '\0', else 1 */
4427 register unsigned int c
;
4430 #ifdef md_flush_pending_output
4431 md_flush_pending_output ();
4435 * The following awkward logic is to parse ZERO or more strings,
4436 * comma separated. Recall a string expression includes spaces
4437 * before the opening '\"' and spaces after the closing '\"'.
4438 * We fake a leading ',' if there is (supposed to be)
4439 * a 1st, expression. We keep demanding expressions for each
4442 if (is_it_end_of_statement ())
4444 c
= 0; /* Skip loop. */
4445 ++input_line_pointer
; /* Compensate for end of loop. */
4449 c
= ','; /* Do loop. */
4451 while (c
== ',' || c
== '<' || c
== '"')
4454 switch (*input_line_pointer
)
4457 ++input_line_pointer
; /*->1st char of string. */
4458 start
= input_line_pointer
;
4459 while (is_a_char (c
= next_char_of_string ()))
4461 FRAG_APPEND_1_CHAR (c
);
4465 FRAG_APPEND_1_CHAR (0);
4467 know (input_line_pointer
[-1] == '\"');
4471 /* In ELF, when gcc is emitting DWARF 1 debugging output, it
4472 will emit .string with a filename in the .debug section
4473 after a sequence of constants. See the comment in
4474 emit_expr for the sequence. emit_expr will set
4475 dwarf_file_string to non-zero if this string might be a
4476 source file name. */
4477 if (strcmp (segment_name (now_seg
), ".debug") != 0)
4478 dwarf_file_string
= 0;
4479 else if (dwarf_file_string
)
4481 c
= input_line_pointer
[-1];
4482 input_line_pointer
[-1] = '\0';
4483 listing_source_file (start
);
4484 input_line_pointer
[-1] = c
;
4491 input_line_pointer
++;
4492 c
= get_single_number ();
4493 FRAG_APPEND_1_CHAR (c
);
4494 if (*input_line_pointer
!= '>')
4496 as_bad (_("Expected <nn>"));
4498 input_line_pointer
++;
4501 input_line_pointer
++;
4505 c
= *input_line_pointer
;
4508 demand_empty_rest_of_line ();
4511 /* FIXME-SOMEDAY: I had trouble here on characters with the
4512 high bits set. We'll probably also have trouble with
4513 multibyte chars, wide chars, etc. Also be careful about
4514 returning values bigger than 1 byte. xoxorich. */
4517 next_char_of_string ()
4519 register unsigned int c
;
4521 c
= *input_line_pointer
++ & CHAR_MASK
;
4529 as_warn (_("Unterminated string: Newline inserted."));
4530 bump_line_counters ();
4533 #ifndef NO_STRING_ESCAPES
4535 switch (c
= *input_line_pointer
++)
4563 break; /* As itself. */
4579 for (i
= 0, number
= 0; isdigit (c
) && i
< 3; c
= *input_line_pointer
++, i
++)
4581 number
= number
* 8 + c
- '0';
4585 --input_line_pointer
;
4594 c
= *input_line_pointer
++;
4595 while (isxdigit (c
))
4598 number
= number
* 16 + c
- '0';
4599 else if (isupper (c
))
4600 number
= number
* 16 + c
- 'A' + 10;
4602 number
= number
* 16 + c
- 'a' + 10;
4603 c
= *input_line_pointer
++;
4606 --input_line_pointer
;
4611 /* To be compatible with BSD 4.2 as: give the luser a linefeed!! */
4612 as_warn (_("Unterminated string: Newline inserted."));
4614 bump_line_counters ();
4619 #ifdef ONLY_STANDARD_ESCAPES
4620 as_bad (_("Bad escaped character in string, '?' assumed"));
4622 #endif /* ONLY_STANDARD_ESCAPES */
4625 } /* switch on escaped char */
4627 #endif /* ! defined (NO_STRING_ESCAPES) */
4631 } /* switch on char */
4633 } /* next_char_of_string() */
4636 get_segmented_expression (expP
)
4637 register expressionS
*expP
;
4639 register segT retval
;
4641 retval
= expression (expP
);
4642 if (expP
->X_op
== O_illegal
4643 || expP
->X_op
== O_absent
4644 || expP
->X_op
== O_big
)
4646 as_bad (_("expected address expression; zero assumed"));
4647 expP
->X_op
= O_constant
;
4648 expP
->X_add_number
= 0;
4649 retval
= absolute_section
;
4655 get_known_segmented_expression (expP
)
4656 register expressionS
*expP
;
4658 register segT retval
;
4660 if ((retval
= get_segmented_expression (expP
)) == undefined_section
)
4662 /* There is no easy way to extract the undefined symbol from the
4664 if (expP
->X_add_symbol
!= NULL
4665 && S_GET_SEGMENT (expP
->X_add_symbol
) != expr_section
)
4666 as_warn (_("symbol \"%s\" undefined; zero assumed"),
4667 S_GET_NAME (expP
->X_add_symbol
));
4669 as_warn (_("some symbol undefined; zero assumed"));
4670 retval
= absolute_section
;
4671 expP
->X_op
= O_constant
;
4672 expP
->X_add_number
= 0;
4674 know (retval
== absolute_section
|| SEG_NORMAL (retval
));
4676 } /* get_known_segmented_expression() */
4679 get_absolute_expression ()
4684 if (exp
.X_op
!= O_constant
)
4686 if (exp
.X_op
!= O_absent
)
4687 as_bad (_("bad or irreducible absolute expression; zero assumed"));
4688 exp
.X_add_number
= 0;
4690 return exp
.X_add_number
;
4693 char /* return terminator */
4694 get_absolute_expression_and_terminator (val_pointer
)
4695 long *val_pointer
; /* return value of expression */
4697 /* FIXME: val_pointer should probably be offsetT *. */
4698 *val_pointer
= (long) get_absolute_expression ();
4699 return (*input_line_pointer
++);
4703 * demand_copy_C_string()
4705 * Like demand_copy_string, but return NULL if the string contains any '\0's.
4706 * Give a warning if that happens.
4709 demand_copy_C_string (len_pointer
)
4714 if ((s
= demand_copy_string (len_pointer
)) != 0)
4718 for (len
= *len_pointer
; len
> 0; len
--)
4725 as_bad (_("This string may not contain \'\\0\'"));
4733 * demand_copy_string()
4735 * Demand string, but return a safe (=private) copy of the string.
4736 * Return NULL if we can't read a string here.
4739 demand_copy_string (lenP
)
4742 register unsigned int c
;
4748 if (*input_line_pointer
== '\"')
4750 input_line_pointer
++; /* Skip opening quote. */
4752 while (is_a_char (c
= next_char_of_string ()))
4754 obstack_1grow (¬es
, c
);
4757 /* JF this next line is so demand_copy_C_string will return a
4758 null terminated string. */
4759 obstack_1grow (¬es
, '\0');
4760 retval
= obstack_finish (¬es
);
4764 as_warn (_("Missing string"));
4766 ignore_rest_of_line ();
4770 } /* demand_copy_string() */
4773 * is_it_end_of_statement()
4775 * In: Input_line_pointer->next character.
4777 * Do: Skip input_line_pointer over all whitespace.
4779 * Out: 1 if input_line_pointer->end-of-line.
4782 is_it_end_of_statement ()
4785 return (is_end_of_line
[(unsigned char) *input_line_pointer
]);
4786 } /* is_it_end_of_statement() */
4789 equals (sym_name
, reassign
)
4793 register symbolS
*symbolP
; /* symbol we are working with */
4797 input_line_pointer
++;
4798 if (*input_line_pointer
== '=')
4799 input_line_pointer
++;
4801 while (*input_line_pointer
== ' ' || *input_line_pointer
== '\t')
4802 input_line_pointer
++;
4805 stop
= mri_comment_field (&stopc
);
4807 if (sym_name
[0] == '.' && sym_name
[1] == '\0')
4809 /* Turn '. = mumble' into a .org mumble */
4810 register segT segment
;
4813 segment
= get_known_segmented_expression (&exp
);
4815 do_org (segment
, &exp
, 0);
4819 symbolP
= symbol_find_or_make (sym_name
);
4820 /* Permit register names to be redefined. */
4822 && S_IS_DEFINED (symbolP
)
4823 && S_GET_SEGMENT (symbolP
) != reg_section
)
4824 as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP
));
4825 pseudo_set (symbolP
);
4830 ignore_rest_of_line (); /* check garbage after the expression */
4831 mri_comment_end (stop
, stopc
);
4835 /* .include -- include a file at this point. */
4848 if (! flag_m68k_mri
)
4850 filename
= demand_copy_string (&i
);
4851 if (filename
== NULL
)
4853 /* demand_copy_string has already printed an error and
4854 called ignore_rest_of_line. */
4862 while (! is_end_of_line
[(unsigned char) *input_line_pointer
]
4863 && *input_line_pointer
!= ' '
4864 && *input_line_pointer
!= '\t')
4866 obstack_1grow (¬es
, *input_line_pointer
);
4867 ++input_line_pointer
;
4870 obstack_1grow (¬es
, '\0');
4871 filename
= obstack_finish (¬es
);
4872 while (! is_end_of_line
[(unsigned char) *input_line_pointer
])
4873 ++input_line_pointer
;
4875 demand_empty_rest_of_line ();
4876 path
= xmalloc ((unsigned long) i
+ include_dir_maxlen
+ 5 /* slop */ );
4877 for (i
= 0; i
< include_dir_count
; i
++)
4879 strcpy (path
, include_dirs
[i
]);
4881 strcat (path
, filename
);
4882 if (0 != (try = fopen (path
, "r")))
4891 /* malloc Storage leak when file is found on path. FIXME-SOMEDAY. */
4892 register_dependency (path
);
4893 newbuf
= input_scrub_include_file (path
, input_line_pointer
);
4894 buffer_limit
= input_scrub_next_buffer (&input_line_pointer
);
4898 add_include_dir (path
)
4903 if (include_dir_count
== 0)
4905 include_dirs
= (char **) xmalloc (2 * sizeof (*include_dirs
));
4906 include_dirs
[0] = "."; /* Current dir */
4907 include_dir_count
= 2;
4911 include_dir_count
++;
4912 include_dirs
= (char **) realloc (include_dirs
,
4913 include_dir_count
* sizeof (*include_dirs
));
4916 include_dirs
[include_dir_count
- 1] = path
; /* New one */
4919 if (i
> include_dir_maxlen
)
4920 include_dir_maxlen
= i
;
4921 } /* add_include_dir() */
4923 /* Output debugging information to denote the source file. */
4926 generate_file_debug ()
4928 if (debug_type
== DEBUG_STABS
)
4929 stabs_generate_asm_file ();
4932 /* Output line number debugging information for the current source line. */
4935 generate_lineno_debug ()
4937 #ifdef ECOFF_DEBUGGING
4938 /* ECOFF assemblers automatically generate debugging information.
4939 FIXME: This should probably be handled elsewhere. */
4940 if (debug_type
== DEBUG_UNSPECIFIED
)
4942 if (ECOFF_DEBUGGING
&& ecoff_no_current_file ())
4943 debug_type
= DEBUG_ECOFF
;
4945 debug_type
= DEBUG_NONE
;
4951 case DEBUG_UNSPECIFIED
:
4955 stabs_generate_asm_lineno ();
4958 ecoff_generate_asm_lineno ();
4967 /* Output debugging information to mark a function entry point or end point.
4968 END_P is zero for .func, and non-zero for .endfunc. */
4974 do_s_func (end_p
, NULL
);
4977 /* Subroutine of s_func so targets can choose a different default prefix.
4978 If DEFAULT_PREFIX is NULL, use the target's "leading char". */
4981 do_s_func (end_p
, default_prefix
)
4983 const char *default_prefix
;
4985 /* Record the current function so that we can issue an error message for
4986 misplaced .func,.endfunc, and also so that .endfunc needs no
4988 static char *current_name
;
4989 static char *current_label
;
4993 if (current_name
== NULL
)
4995 as_bad (_("missing .func"));
4996 ignore_rest_of_line ();
5000 if (debug_type
== DEBUG_STABS
)
5001 stabs_generate_asm_endfunc (current_name
, current_label
);
5003 current_name
= current_label
= NULL
;
5010 if (current_name
!= NULL
)
5012 as_bad (_(".endfunc missing for previous .func"));
5013 ignore_rest_of_line ();
5017 name
= input_line_pointer
;
5018 delim1
= get_symbol_end ();
5019 name
= xstrdup (name
);
5020 *input_line_pointer
= delim1
;
5022 if (*input_line_pointer
!= ',')
5025 asprintf (&label
, "%s%s", default_prefix
, name
);
5028 char leading_char
= 0;
5029 #ifdef BFD_ASSEMBLER
5030 leading_char
= bfd_get_symbol_leading_char (stdoutput
);
5032 /* Missing entry point, use function's name with the leading
5035 asprintf (&label
, "%c%s", leading_char
, name
);
5042 ++input_line_pointer
;
5044 label
= input_line_pointer
;
5045 delim2
= get_symbol_end ();
5046 label
= xstrdup (label
);
5047 *input_line_pointer
= delim2
;
5050 if (debug_type
== DEBUG_STABS
)
5051 stabs_generate_asm_func (name
, label
);
5053 current_name
= name
;
5054 current_label
= label
;
5057 demand_empty_rest_of_line ();
5064 while (!is_end_of_line
[(unsigned char) *input_line_pointer
])
5066 ++input_line_pointer
;
5068 ++input_line_pointer
;
5073 read_print_statistics (file
)
5076 hash_print_statistics (file
, "pseudo-op table", po_hash
);